From 1203c8b185e9071d0bc6222e7d9bf4f5cce9da6b Mon Sep 17 00:00:00 2001 From: Abner Chang Date: Fri, 13 Aug 2021 23:02:12 +0800 Subject: [PATCH] RedfishClientPkg/Converter: EDK2 Redfish JSON schema to C structure DXE drivers Total 7044 files that is unable to be reviewed. This is the edk2 JSON to C structure DXE driver generated by open source Redfish Schema C Structure Generator Python script. (https://github.com/DMTF/Redfish-Schema-C-Struct-Generator). Each edk2 DXE driver is generated base on the Redfish schema name space and resource type and linked with library under ConvertLib/edk2library (https://github.com/changab/edk2-staging/commit/8e8497a28947834fa68b62902584f2a1a1fa0205). Each DXE driver register itself through EFI_REST_JSON_STRUCTURE_PROTOCOL in order to providing the Redfish JSON to C Structure conversion and vise versa. New edk2 Redfish JSON schema to C structure DXE driver will be added when every time the new schema is introduced in the Redfish schema release. Signed-off-by: Abner Chang --- .../v1_0_0/AccelerationFunction_V1_0_0_Dxe.c | 427 ++++++++++++++++++ ...RedfishAccelerationFunction_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/AccelerationFunction_V1_0_1_Dxe.c | 427 ++++++++++++++++++ ...RedfishAccelerationFunction_V1_0_1_Dxe.inf | 55 +++ .../v1_0_2/AccelerationFunction_V1_0_2_Dxe.c | 427 ++++++++++++++++++ ...RedfishAccelerationFunction_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/AccelerationFunction_V1_0_3_Dxe.c | 427 ++++++++++++++++++ ...RedfishAccelerationFunction_V1_0_3_Dxe.inf | 55 +++ .../AccelerationFunctionCollection_Dxe.c | 427 ++++++++++++++++++ ...fishAccelerationFunctionCollection_Dxe.inf | 55 +++ .../v1_0_0/AccountService_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_0_0_Dxe.inf | 55 +++ .../v1_0_10/AccountService_V1_0_10_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_0_10_Dxe.inf | 55 +++ .../v1_0_11/AccountService_V1_0_11_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_0_11_Dxe.inf | 55 +++ .../v1_0_2/AccountService_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/AccountService_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/AccountService_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_0_4_Dxe.inf | 55 +++ .../v1_0_5/AccountService_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_0_5_Dxe.inf | 55 +++ .../v1_0_6/AccountService_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_0_6_Dxe.inf | 55 +++ .../v1_0_7/AccountService_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_0_7_Dxe.inf | 55 +++ .../v1_0_8/AccountService_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_0_8_Dxe.inf | 55 +++ .../v1_0_9/AccountService_V1_0_9_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_0_9_Dxe.inf | 55 +++ .../v1_1_0/AccountService_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/AccountService_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_1_1_Dxe.inf | 55 +++ .../v1_1_2/AccountService_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_1_2_Dxe.inf | 55 +++ .../v1_1_3/AccountService_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_1_3_Dxe.inf | 55 +++ .../v1_1_4/AccountService_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_1_4_Dxe.inf | 55 +++ .../v1_1_5/AccountService_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_1_5_Dxe.inf | 55 +++ .../v1_1_6/AccountService_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_1_6_Dxe.inf | 55 +++ .../v1_1_7/AccountService_V1_1_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_1_7_Dxe.inf | 55 +++ .../v1_1_8/AccountService_V1_1_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_1_8_Dxe.inf | 55 +++ .../v1_2_0/AccountService_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_2_0_Dxe.inf | 55 +++ .../v1_2_1/AccountService_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_2_1_Dxe.inf | 55 +++ .../v1_2_2/AccountService_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_2_2_Dxe.inf | 55 +++ .../v1_2_3/AccountService_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_2_3_Dxe.inf | 55 +++ .../v1_2_4/AccountService_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_2_4_Dxe.inf | 55 +++ .../v1_2_5/AccountService_V1_2_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_2_5_Dxe.inf | 55 +++ .../v1_2_6/AccountService_V1_2_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_2_6_Dxe.inf | 55 +++ .../v1_2_7/AccountService_V1_2_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_2_7_Dxe.inf | 55 +++ .../v1_2_8/AccountService_V1_2_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_2_8_Dxe.inf | 55 +++ .../v1_3_0/AccountService_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_3_0_Dxe.inf | 55 +++ .../v1_3_1/AccountService_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_3_1_Dxe.inf | 55 +++ .../v1_3_2/AccountService_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_3_2_Dxe.inf | 55 +++ .../v1_3_3/AccountService_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_3_3_Dxe.inf | 55 +++ .../v1_3_4/AccountService_V1_3_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_3_4_Dxe.inf | 55 +++ .../v1_3_5/AccountService_V1_3_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_3_5_Dxe.inf | 55 +++ .../v1_3_6/AccountService_V1_3_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_3_6_Dxe.inf | 55 +++ .../v1_3_7/AccountService_V1_3_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_3_7_Dxe.inf | 55 +++ .../v1_4_0/AccountService_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_4_0_Dxe.inf | 55 +++ .../v1_4_1/AccountService_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_4_1_Dxe.inf | 55 +++ .../v1_4_2/AccountService_V1_4_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_4_2_Dxe.inf | 55 +++ .../v1_4_3/AccountService_V1_4_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_4_3_Dxe.inf | 55 +++ .../v1_4_4/AccountService_V1_4_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_4_4_Dxe.inf | 55 +++ .../v1_4_5/AccountService_V1_4_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_4_5_Dxe.inf | 55 +++ .../v1_5_0/AccountService_V1_5_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_5_0_Dxe.inf | 55 +++ .../v1_5_1/AccountService_V1_5_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_5_1_Dxe.inf | 55 +++ .../v1_5_2/AccountService_V1_5_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_5_2_Dxe.inf | 55 +++ .../v1_5_3/AccountService_V1_5_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_5_3_Dxe.inf | 55 +++ .../v1_5_4/AccountService_V1_5_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_5_4_Dxe.inf | 55 +++ .../v1_6_0/AccountService_V1_6_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_6_0_Dxe.inf | 55 +++ .../v1_6_1/AccountService_V1_6_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_6_1_Dxe.inf | 55 +++ .../v1_6_2/AccountService_V1_6_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_6_2_Dxe.inf | 55 +++ .../v1_6_3/AccountService_V1_6_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_6_3_Dxe.inf | 55 +++ .../v1_7_0/AccountService_V1_7_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_7_0_Dxe.inf | 55 +++ .../v1_7_1/AccountService_V1_7_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_7_1_Dxe.inf | 55 +++ .../v1_7_2/AccountService_V1_7_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_7_2_Dxe.inf | 55 +++ .../v1_7_3/AccountService_V1_7_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_7_3_Dxe.inf | 55 +++ .../v1_8_0/AccountService_V1_8_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishAccountService_V1_8_0_Dxe.inf | 55 +++ .../ActionInfo/v1_0_0/ActionInfo_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishActionInfo_V1_0_0_Dxe.inf | 55 +++ .../ActionInfo/v1_0_1/ActionInfo_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishActionInfo_V1_0_1_Dxe.inf | 55 +++ .../ActionInfo/v1_0_2/ActionInfo_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishActionInfo_V1_0_2_Dxe.inf | 55 +++ .../ActionInfo/v1_0_3/ActionInfo_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishActionInfo_V1_0_3_Dxe.inf | 55 +++ .../ActionInfo/v1_0_4/ActionInfo_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishActionInfo_V1_0_4_Dxe.inf | 55 +++ .../ActionInfo/v1_0_5/ActionInfo_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishActionInfo_V1_0_5_Dxe.inf | 55 +++ .../ActionInfo/v1_0_6/ActionInfo_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../v1_0_6/RedfishActionInfo_V1_0_6_Dxe.inf | 55 +++ .../ActionInfo/v1_1_0/ActionInfo_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishActionInfo_V1_1_0_Dxe.inf | 55 +++ .../ActionInfo/v1_1_1/ActionInfo_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishActionInfo_V1_1_1_Dxe.inf | 55 +++ .../ActionInfo/v1_1_2/ActionInfo_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishActionInfo_V1_1_2_Dxe.inf | 55 +++ .../v1_0_0/AddressPool_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishAddressPool_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/AddressPool_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishAddressPool_V1_0_1_Dxe.inf | 55 +++ .../v1_0_2/AddressPool_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishAddressPool_V1_0_2_Dxe.inf | 55 +++ .../v1_1_0/AddressPool_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishAddressPool_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/AddressPool_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishAddressPool_V1_1_1_Dxe.inf | 55 +++ .../AddressPoolCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishAddressPoolCollection_Dxe.inf | 55 +++ .../Aggregate/v1_0_0/Aggregate_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishAggregate_V1_0_0_Dxe.inf | 55 +++ .../Aggregate/v1_0_1/Aggregate_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishAggregate_V1_0_1_Dxe.inf | 55 +++ .../AggregateCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishAggregateCollection_Dxe.inf | 55 +++ .../v1_0_0/AggregationService_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishAggregationService_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/AggregationService_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishAggregationService_V1_0_1_Dxe.inf | 55 +++ .../v1_0_0/AggregationSource_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishAggregationSource_V1_0_0_Dxe.inf | 55 +++ .../v1_1_0/AggregationSource_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishAggregationSource_V1_1_0_Dxe.inf | 55 +++ .../AggregationSourceCollection_Dxe.c | 427 ++++++++++++++++++ ...RedfishAggregationSourceCollection_Dxe.inf | 55 +++ .../Assembly/v1_0_0/Assembly_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishAssembly_V1_0_0_Dxe.inf | 55 +++ .../Assembly/v1_0_1/Assembly_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishAssembly_V1_0_1_Dxe.inf | 55 +++ .../Assembly/v1_0_2/Assembly_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishAssembly_V1_0_2_Dxe.inf | 55 +++ .../Assembly/v1_0_3/Assembly_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishAssembly_V1_0_3_Dxe.inf | 55 +++ .../Assembly/v1_0_4/Assembly_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishAssembly_V1_0_4_Dxe.inf | 55 +++ .../Assembly/v1_1_0/Assembly_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishAssembly_V1_1_0_Dxe.inf | 55 +++ .../Assembly/v1_1_1/Assembly_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishAssembly_V1_1_1_Dxe.inf | 55 +++ .../Assembly/v1_1_2/Assembly_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishAssembly_V1_1_2_Dxe.inf | 55 +++ .../Assembly/v1_1_3/Assembly_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../v1_1_3/RedfishAssembly_V1_1_3_Dxe.inf | 55 +++ .../Assembly/v1_1_4/Assembly_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../v1_1_4/RedfishAssembly_V1_1_4_Dxe.inf | 55 +++ .../Assembly/v1_2_0/Assembly_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishAssembly_V1_2_0_Dxe.inf | 55 +++ .../Assembly/v1_2_1/Assembly_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../v1_2_1/RedfishAssembly_V1_2_1_Dxe.inf | 55 +++ .../Assembly/v1_2_2/Assembly_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../v1_2_2/RedfishAssembly_V1_2_2_Dxe.inf | 55 +++ .../Assembly/v1_2_3/Assembly_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../v1_2_3/RedfishAssembly_V1_2_3_Dxe.inf | 55 +++ .../Assembly/v1_3_0/Assembly_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../v1_3_0/RedfishAssembly_V1_3_0_Dxe.inf | 55 +++ .../v1_0_0/AttributeRegistry_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/AttributeRegistry_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_0_1_Dxe.inf | 55 +++ .../v1_0_10/AttributeRegistry_V1_0_10_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_0_10_Dxe.inf | 55 +++ .../v1_0_2/AttributeRegistry_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/AttributeRegistry_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/AttributeRegistry_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_0_4_Dxe.inf | 55 +++ .../v1_0_5/AttributeRegistry_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_0_5_Dxe.inf | 55 +++ .../v1_0_6/AttributeRegistry_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_0_6_Dxe.inf | 55 +++ .../v1_0_7/AttributeRegistry_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_0_7_Dxe.inf | 55 +++ .../v1_0_8/AttributeRegistry_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_0_8_Dxe.inf | 55 +++ .../v1_0_9/AttributeRegistry_V1_0_9_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_0_9_Dxe.inf | 55 +++ .../v1_1_0/AttributeRegistry_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/AttributeRegistry_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_1_1_Dxe.inf | 55 +++ .../v1_1_2/AttributeRegistry_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_1_2_Dxe.inf | 55 +++ .../v1_1_3/AttributeRegistry_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_1_3_Dxe.inf | 55 +++ .../v1_1_4/AttributeRegistry_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_1_4_Dxe.inf | 55 +++ .../v1_1_5/AttributeRegistry_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_1_5_Dxe.inf | 55 +++ .../v1_1_6/AttributeRegistry_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_1_6_Dxe.inf | 55 +++ .../v1_1_7/AttributeRegistry_V1_1_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_1_7_Dxe.inf | 55 +++ .../v1_1_8/AttributeRegistry_V1_1_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_1_8_Dxe.inf | 55 +++ .../v1_1_9/AttributeRegistry_V1_1_9_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_1_9_Dxe.inf | 55 +++ .../v1_2_0/AttributeRegistry_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_2_0_Dxe.inf | 55 +++ .../v1_2_1/AttributeRegistry_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_2_1_Dxe.inf | 55 +++ .../v1_2_2/AttributeRegistry_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_2_2_Dxe.inf | 55 +++ .../v1_2_3/AttributeRegistry_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_2_3_Dxe.inf | 55 +++ .../v1_2_4/AttributeRegistry_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_2_4_Dxe.inf | 55 +++ .../v1_2_5/AttributeRegistry_V1_2_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_2_5_Dxe.inf | 55 +++ .../v1_2_6/AttributeRegistry_V1_2_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_2_6_Dxe.inf | 55 +++ .../v1_2_7/AttributeRegistry_V1_2_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_2_7_Dxe.inf | 55 +++ .../v1_3_0/AttributeRegistry_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_3_0_Dxe.inf | 55 +++ .../v1_3_1/AttributeRegistry_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_3_1_Dxe.inf | 55 +++ .../v1_3_2/AttributeRegistry_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_3_2_Dxe.inf | 55 +++ .../v1_3_3/AttributeRegistry_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_3_3_Dxe.inf | 55 +++ .../v1_3_4/AttributeRegistry_V1_3_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_3_4_Dxe.inf | 55 +++ .../v1_3_5/AttributeRegistry_V1_3_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishAttributeRegistry_V1_3_5_Dxe.inf | 55 +++ .../Converter/Bios/v1_0_0/Bios_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../Bios/v1_0_0/RedfishBios_V1_0_0_Dxe.inf | 55 +++ .../Converter/Bios/v1_0_1/Bios_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../Bios/v1_0_1/RedfishBios_V1_0_1_Dxe.inf | 55 +++ .../Converter/Bios/v1_0_2/Bios_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../Bios/v1_0_2/RedfishBios_V1_0_2_Dxe.inf | 55 +++ .../Converter/Bios/v1_0_3/Bios_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../Bios/v1_0_3/RedfishBios_V1_0_3_Dxe.inf | 55 +++ .../Converter/Bios/v1_0_4/Bios_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../Bios/v1_0_4/RedfishBios_V1_0_4_Dxe.inf | 55 +++ .../Converter/Bios/v1_0_5/Bios_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../Bios/v1_0_5/RedfishBios_V1_0_5_Dxe.inf | 55 +++ .../Converter/Bios/v1_0_6/Bios_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../Bios/v1_0_6/RedfishBios_V1_0_6_Dxe.inf | 55 +++ .../Converter/Bios/v1_0_7/Bios_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../Bios/v1_0_7/RedfishBios_V1_0_7_Dxe.inf | 55 +++ .../Converter/Bios/v1_0_8/Bios_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../Bios/v1_0_8/RedfishBios_V1_0_8_Dxe.inf | 55 +++ .../Converter/Bios/v1_1_0/Bios_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../Bios/v1_1_0/RedfishBios_V1_1_0_Dxe.inf | 55 +++ .../Converter/Bios/v1_1_1/Bios_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../Bios/v1_1_1/RedfishBios_V1_1_1_Dxe.inf | 55 +++ .../BootOption/v1_0_0/BootOption_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishBootOption_V1_0_0_Dxe.inf | 55 +++ .../BootOption/v1_0_1/BootOption_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishBootOption_V1_0_1_Dxe.inf | 55 +++ .../BootOption/v1_0_2/BootOption_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishBootOption_V1_0_2_Dxe.inf | 55 +++ .../BootOption/v1_0_3/BootOption_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishBootOption_V1_0_3_Dxe.inf | 55 +++ .../BootOption/v1_0_4/BootOption_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishBootOption_V1_0_4_Dxe.inf | 55 +++ .../BootOptionCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishBootOptionCollection_Dxe.inf | 55 +++ .../v1_0_0/Certificate_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishCertificate_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/Certificate_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishCertificate_V1_0_1_Dxe.inf | 55 +++ .../v1_0_2/Certificate_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishCertificate_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/Certificate_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishCertificate_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/Certificate_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishCertificate_V1_0_4_Dxe.inf | 55 +++ .../v1_1_0/Certificate_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishCertificate_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/Certificate_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishCertificate_V1_1_1_Dxe.inf | 55 +++ .../v1_1_2/Certificate_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishCertificate_V1_1_2_Dxe.inf | 55 +++ .../v1_1_3/Certificate_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../v1_1_3/RedfishCertificate_V1_1_3_Dxe.inf | 55 +++ .../v1_2_0/Certificate_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishCertificate_V1_2_0_Dxe.inf | 55 +++ .../v1_2_1/Certificate_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../v1_2_1/RedfishCertificate_V1_2_1_Dxe.inf | 55 +++ .../v1_2_2/Certificate_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../v1_2_2/RedfishCertificate_V1_2_2_Dxe.inf | 55 +++ .../CertificateCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishCertificateCollection_Dxe.inf | 55 +++ .../v1_0_0/CertificateLocations_V1_0_0_Dxe.c | 427 ++++++++++++++++++ ...RedfishCertificateLocations_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/CertificateLocations_V1_0_1_Dxe.c | 427 ++++++++++++++++++ ...RedfishCertificateLocations_V1_0_1_Dxe.inf | 55 +++ .../v1_0_2/CertificateLocations_V1_0_2_Dxe.c | 427 ++++++++++++++++++ ...RedfishCertificateLocations_V1_0_2_Dxe.inf | 55 +++ .../v1_0_0/CertificateService_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishCertificateService_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/CertificateService_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishCertificateService_V1_0_1_Dxe.inf | 55 +++ .../v1_0_2/CertificateService_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishCertificateService_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/CertificateService_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishCertificateService_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/CertificateService_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishCertificateService_V1_0_4_Dxe.inf | 55 +++ .../Chassis/v1_0_0/Chassis_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishChassis_V1_0_0_Dxe.inf | 55 +++ .../Chassis/v1_0_1/Chassis_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishChassis_V1_0_1_Dxe.inf | 55 +++ .../Chassis/v1_0_10/Chassis_V1_0_10_Dxe.c | 427 ++++++++++++++++++ .../v1_0_10/RedfishChassis_V1_0_10_Dxe.inf | 55 +++ .../Chassis/v1_0_11/Chassis_V1_0_11_Dxe.c | 427 ++++++++++++++++++ .../v1_0_11/RedfishChassis_V1_0_11_Dxe.inf | 55 +++ .../Chassis/v1_0_12/Chassis_V1_0_12_Dxe.c | 427 ++++++++++++++++++ .../v1_0_12/RedfishChassis_V1_0_12_Dxe.inf | 55 +++ .../Chassis/v1_0_13/Chassis_V1_0_13_Dxe.c | 427 ++++++++++++++++++ .../v1_0_13/RedfishChassis_V1_0_13_Dxe.inf | 55 +++ .../Chassis/v1_0_2/Chassis_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishChassis_V1_0_2_Dxe.inf | 55 +++ .../Chassis/v1_0_3/Chassis_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishChassis_V1_0_3_Dxe.inf | 55 +++ .../Chassis/v1_0_4/Chassis_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishChassis_V1_0_4_Dxe.inf | 55 +++ .../Chassis/v1_0_5/Chassis_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishChassis_V1_0_5_Dxe.inf | 55 +++ .../Chassis/v1_0_6/Chassis_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../v1_0_6/RedfishChassis_V1_0_6_Dxe.inf | 55 +++ .../Chassis/v1_0_7/Chassis_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../v1_0_7/RedfishChassis_V1_0_7_Dxe.inf | 55 +++ .../Chassis/v1_0_8/Chassis_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../v1_0_8/RedfishChassis_V1_0_8_Dxe.inf | 55 +++ .../Chassis/v1_0_9/Chassis_V1_0_9_Dxe.c | 427 ++++++++++++++++++ .../v1_0_9/RedfishChassis_V1_0_9_Dxe.inf | 55 +++ .../Chassis/v1_10_0/Chassis_V1_10_0_Dxe.c | 427 ++++++++++++++++++ .../v1_10_0/RedfishChassis_V1_10_0_Dxe.inf | 55 +++ .../Chassis/v1_10_1/Chassis_V1_10_1_Dxe.c | 427 ++++++++++++++++++ .../v1_10_1/RedfishChassis_V1_10_1_Dxe.inf | 55 +++ .../Chassis/v1_10_2/Chassis_V1_10_2_Dxe.c | 427 ++++++++++++++++++ .../v1_10_2/RedfishChassis_V1_10_2_Dxe.inf | 55 +++ .../Chassis/v1_10_3/Chassis_V1_10_3_Dxe.c | 427 ++++++++++++++++++ .../v1_10_3/RedfishChassis_V1_10_3_Dxe.inf | 55 +++ .../Chassis/v1_11_0/Chassis_V1_11_0_Dxe.c | 427 ++++++++++++++++++ .../v1_11_0/RedfishChassis_V1_11_0_Dxe.inf | 55 +++ .../Chassis/v1_11_1/Chassis_V1_11_1_Dxe.c | 427 ++++++++++++++++++ .../v1_11_1/RedfishChassis_V1_11_1_Dxe.inf | 55 +++ .../Chassis/v1_11_2/Chassis_V1_11_2_Dxe.c | 427 ++++++++++++++++++ .../v1_11_2/RedfishChassis_V1_11_2_Dxe.inf | 55 +++ .../Chassis/v1_11_3/Chassis_V1_11_3_Dxe.c | 427 ++++++++++++++++++ .../v1_11_3/RedfishChassis_V1_11_3_Dxe.inf | 55 +++ .../Chassis/v1_12_0/Chassis_V1_12_0_Dxe.c | 427 ++++++++++++++++++ .../v1_12_0/RedfishChassis_V1_12_0_Dxe.inf | 55 +++ .../Chassis/v1_12_1/Chassis_V1_12_1_Dxe.c | 427 ++++++++++++++++++ .../v1_12_1/RedfishChassis_V1_12_1_Dxe.inf | 55 +++ .../Chassis/v1_12_2/Chassis_V1_12_2_Dxe.c | 427 ++++++++++++++++++ .../v1_12_2/RedfishChassis_V1_12_2_Dxe.inf | 55 +++ .../Chassis/v1_13_0/Chassis_V1_13_0_Dxe.c | 427 ++++++++++++++++++ .../v1_13_0/RedfishChassis_V1_13_0_Dxe.inf | 55 +++ .../Chassis/v1_13_1/Chassis_V1_13_1_Dxe.c | 427 ++++++++++++++++++ .../v1_13_1/RedfishChassis_V1_13_1_Dxe.inf | 55 +++ .../Chassis/v1_14_0/Chassis_V1_14_0_Dxe.c | 427 ++++++++++++++++++ .../v1_14_0/RedfishChassis_V1_14_0_Dxe.inf | 55 +++ .../Chassis/v1_15_0/Chassis_V1_15_0_Dxe.c | 427 ++++++++++++++++++ .../v1_15_0/RedfishChassis_V1_15_0_Dxe.inf | 55 +++ .../Chassis/v1_1_0/Chassis_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishChassis_V1_1_0_Dxe.inf | 55 +++ .../Chassis/v1_1_10/Chassis_V1_1_10_Dxe.c | 427 ++++++++++++++++++ .../v1_1_10/RedfishChassis_V1_1_10_Dxe.inf | 55 +++ .../Chassis/v1_1_11/Chassis_V1_1_11_Dxe.c | 427 ++++++++++++++++++ .../v1_1_11/RedfishChassis_V1_1_11_Dxe.inf | 55 +++ .../Chassis/v1_1_12/Chassis_V1_1_12_Dxe.c | 427 ++++++++++++++++++ .../v1_1_12/RedfishChassis_V1_1_12_Dxe.inf | 55 +++ .../Chassis/v1_1_13/Chassis_V1_1_13_Dxe.c | 427 ++++++++++++++++++ .../v1_1_13/RedfishChassis_V1_1_13_Dxe.inf | 55 +++ .../Chassis/v1_1_2/Chassis_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishChassis_V1_1_2_Dxe.inf | 55 +++ .../Chassis/v1_1_3/Chassis_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../v1_1_3/RedfishChassis_V1_1_3_Dxe.inf | 55 +++ .../Chassis/v1_1_4/Chassis_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../v1_1_4/RedfishChassis_V1_1_4_Dxe.inf | 55 +++ .../Chassis/v1_1_5/Chassis_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../v1_1_5/RedfishChassis_V1_1_5_Dxe.inf | 55 +++ .../Chassis/v1_1_6/Chassis_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../v1_1_6/RedfishChassis_V1_1_6_Dxe.inf | 55 +++ .../Chassis/v1_1_7/Chassis_V1_1_7_Dxe.c | 427 ++++++++++++++++++ .../v1_1_7/RedfishChassis_V1_1_7_Dxe.inf | 55 +++ .../Chassis/v1_1_8/Chassis_V1_1_8_Dxe.c | 427 ++++++++++++++++++ .../v1_1_8/RedfishChassis_V1_1_8_Dxe.inf | 55 +++ .../Chassis/v1_1_9/Chassis_V1_1_9_Dxe.c | 427 ++++++++++++++++++ .../v1_1_9/RedfishChassis_V1_1_9_Dxe.inf | 55 +++ .../Chassis/v1_2_0/Chassis_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishChassis_V1_2_0_Dxe.inf | 55 +++ .../Chassis/v1_2_1/Chassis_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../v1_2_1/RedfishChassis_V1_2_1_Dxe.inf | 55 +++ .../Chassis/v1_2_10/Chassis_V1_2_10_Dxe.c | 427 ++++++++++++++++++ .../v1_2_10/RedfishChassis_V1_2_10_Dxe.inf | 55 +++ .../Chassis/v1_2_11/Chassis_V1_2_11_Dxe.c | 427 ++++++++++++++++++ .../v1_2_11/RedfishChassis_V1_2_11_Dxe.inf | 55 +++ .../Chassis/v1_2_2/Chassis_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../v1_2_2/RedfishChassis_V1_2_2_Dxe.inf | 55 +++ .../Chassis/v1_2_3/Chassis_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../v1_2_3/RedfishChassis_V1_2_3_Dxe.inf | 55 +++ .../Chassis/v1_2_4/Chassis_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../v1_2_4/RedfishChassis_V1_2_4_Dxe.inf | 55 +++ .../Chassis/v1_2_5/Chassis_V1_2_5_Dxe.c | 427 ++++++++++++++++++ .../v1_2_5/RedfishChassis_V1_2_5_Dxe.inf | 55 +++ .../Chassis/v1_2_6/Chassis_V1_2_6_Dxe.c | 427 ++++++++++++++++++ .../v1_2_6/RedfishChassis_V1_2_6_Dxe.inf | 55 +++ .../Chassis/v1_2_7/Chassis_V1_2_7_Dxe.c | 427 ++++++++++++++++++ .../v1_2_7/RedfishChassis_V1_2_7_Dxe.inf | 55 +++ .../Chassis/v1_2_8/Chassis_V1_2_8_Dxe.c | 427 ++++++++++++++++++ .../v1_2_8/RedfishChassis_V1_2_8_Dxe.inf | 55 +++ .../Chassis/v1_2_9/Chassis_V1_2_9_Dxe.c | 427 ++++++++++++++++++ .../v1_2_9/RedfishChassis_V1_2_9_Dxe.inf | 55 +++ .../Chassis/v1_3_0/Chassis_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../v1_3_0/RedfishChassis_V1_3_0_Dxe.inf | 55 +++ .../Chassis/v1_3_1/Chassis_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../v1_3_1/RedfishChassis_V1_3_1_Dxe.inf | 55 +++ .../Chassis/v1_3_10/Chassis_V1_3_10_Dxe.c | 427 ++++++++++++++++++ .../v1_3_10/RedfishChassis_V1_3_10_Dxe.inf | 55 +++ .../Chassis/v1_3_11/Chassis_V1_3_11_Dxe.c | 427 ++++++++++++++++++ .../v1_3_11/RedfishChassis_V1_3_11_Dxe.inf | 55 +++ .../Chassis/v1_3_2/Chassis_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../v1_3_2/RedfishChassis_V1_3_2_Dxe.inf | 55 +++ .../Chassis/v1_3_3/Chassis_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../v1_3_3/RedfishChassis_V1_3_3_Dxe.inf | 55 +++ .../Chassis/v1_3_4/Chassis_V1_3_4_Dxe.c | 427 ++++++++++++++++++ .../v1_3_4/RedfishChassis_V1_3_4_Dxe.inf | 55 +++ .../Chassis/v1_3_5/Chassis_V1_3_5_Dxe.c | 427 ++++++++++++++++++ .../v1_3_5/RedfishChassis_V1_3_5_Dxe.inf | 55 +++ .../Chassis/v1_3_6/Chassis_V1_3_6_Dxe.c | 427 ++++++++++++++++++ .../v1_3_6/RedfishChassis_V1_3_6_Dxe.inf | 55 +++ .../Chassis/v1_3_7/Chassis_V1_3_7_Dxe.c | 427 ++++++++++++++++++ .../v1_3_7/RedfishChassis_V1_3_7_Dxe.inf | 55 +++ .../Chassis/v1_3_8/Chassis_V1_3_8_Dxe.c | 427 ++++++++++++++++++ .../v1_3_8/RedfishChassis_V1_3_8_Dxe.inf | 55 +++ .../Chassis/v1_3_9/Chassis_V1_3_9_Dxe.c | 427 ++++++++++++++++++ .../v1_3_9/RedfishChassis_V1_3_9_Dxe.inf | 55 +++ .../Chassis/v1_4_0/Chassis_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../v1_4_0/RedfishChassis_V1_4_0_Dxe.inf | 55 +++ .../Chassis/v1_4_1/Chassis_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../v1_4_1/RedfishChassis_V1_4_1_Dxe.inf | 55 +++ .../Chassis/v1_4_10/Chassis_V1_4_10_Dxe.c | 427 ++++++++++++++++++ .../v1_4_10/RedfishChassis_V1_4_10_Dxe.inf | 55 +++ .../Chassis/v1_4_2/Chassis_V1_4_2_Dxe.c | 427 ++++++++++++++++++ .../v1_4_2/RedfishChassis_V1_4_2_Dxe.inf | 55 +++ .../Chassis/v1_4_3/Chassis_V1_4_3_Dxe.c | 427 ++++++++++++++++++ .../v1_4_3/RedfishChassis_V1_4_3_Dxe.inf | 55 +++ .../Chassis/v1_4_4/Chassis_V1_4_4_Dxe.c | 427 ++++++++++++++++++ .../v1_4_4/RedfishChassis_V1_4_4_Dxe.inf | 55 +++ .../Chassis/v1_4_5/Chassis_V1_4_5_Dxe.c | 427 ++++++++++++++++++ .../v1_4_5/RedfishChassis_V1_4_5_Dxe.inf | 55 +++ .../Chassis/v1_4_6/Chassis_V1_4_6_Dxe.c | 427 ++++++++++++++++++ .../v1_4_6/RedfishChassis_V1_4_6_Dxe.inf | 55 +++ .../Chassis/v1_4_7/Chassis_V1_4_7_Dxe.c | 427 ++++++++++++++++++ .../v1_4_7/RedfishChassis_V1_4_7_Dxe.inf | 55 +++ .../Chassis/v1_4_8/Chassis_V1_4_8_Dxe.c | 427 ++++++++++++++++++ .../v1_4_8/RedfishChassis_V1_4_8_Dxe.inf | 55 +++ .../Chassis/v1_4_9/Chassis_V1_4_9_Dxe.c | 427 ++++++++++++++++++ .../v1_4_9/RedfishChassis_V1_4_9_Dxe.inf | 55 +++ .../Chassis/v1_5_0/Chassis_V1_5_0_Dxe.c | 427 ++++++++++++++++++ .../v1_5_0/RedfishChassis_V1_5_0_Dxe.inf | 55 +++ .../Chassis/v1_5_1/Chassis_V1_5_1_Dxe.c | 427 ++++++++++++++++++ .../v1_5_1/RedfishChassis_V1_5_1_Dxe.inf | 55 +++ .../Chassis/v1_5_2/Chassis_V1_5_2_Dxe.c | 427 ++++++++++++++++++ .../v1_5_2/RedfishChassis_V1_5_2_Dxe.inf | 55 +++ .../Chassis/v1_5_3/Chassis_V1_5_3_Dxe.c | 427 ++++++++++++++++++ .../v1_5_3/RedfishChassis_V1_5_3_Dxe.inf | 55 +++ .../Chassis/v1_5_4/Chassis_V1_5_4_Dxe.c | 427 ++++++++++++++++++ .../v1_5_4/RedfishChassis_V1_5_4_Dxe.inf | 55 +++ .../Chassis/v1_5_5/Chassis_V1_5_5_Dxe.c | 427 ++++++++++++++++++ .../v1_5_5/RedfishChassis_V1_5_5_Dxe.inf | 55 +++ .../Chassis/v1_5_6/Chassis_V1_5_6_Dxe.c | 427 ++++++++++++++++++ .../v1_5_6/RedfishChassis_V1_5_6_Dxe.inf | 55 +++ .../Chassis/v1_5_7/Chassis_V1_5_7_Dxe.c | 427 ++++++++++++++++++ .../v1_5_7/RedfishChassis_V1_5_7_Dxe.inf | 55 +++ .../Chassis/v1_5_8/Chassis_V1_5_8_Dxe.c | 427 ++++++++++++++++++ .../v1_5_8/RedfishChassis_V1_5_8_Dxe.inf | 55 +++ .../Chassis/v1_5_9/Chassis_V1_5_9_Dxe.c | 427 ++++++++++++++++++ .../v1_5_9/RedfishChassis_V1_5_9_Dxe.inf | 55 +++ .../Chassis/v1_6_0/Chassis_V1_6_0_Dxe.c | 427 ++++++++++++++++++ .../v1_6_0/RedfishChassis_V1_6_0_Dxe.inf | 55 +++ .../Chassis/v1_6_1/Chassis_V1_6_1_Dxe.c | 427 ++++++++++++++++++ .../v1_6_1/RedfishChassis_V1_6_1_Dxe.inf | 55 +++ .../Chassis/v1_6_2/Chassis_V1_6_2_Dxe.c | 427 ++++++++++++++++++ .../v1_6_2/RedfishChassis_V1_6_2_Dxe.inf | 55 +++ .../Chassis/v1_6_3/Chassis_V1_6_3_Dxe.c | 427 ++++++++++++++++++ .../v1_6_3/RedfishChassis_V1_6_3_Dxe.inf | 55 +++ .../Chassis/v1_6_4/Chassis_V1_6_4_Dxe.c | 427 ++++++++++++++++++ .../v1_6_4/RedfishChassis_V1_6_4_Dxe.inf | 55 +++ .../Chassis/v1_6_5/Chassis_V1_6_5_Dxe.c | 427 ++++++++++++++++++ .../v1_6_5/RedfishChassis_V1_6_5_Dxe.inf | 55 +++ .../Chassis/v1_6_6/Chassis_V1_6_6_Dxe.c | 427 ++++++++++++++++++ .../v1_6_6/RedfishChassis_V1_6_6_Dxe.inf | 55 +++ .../Chassis/v1_6_7/Chassis_V1_6_7_Dxe.c | 427 ++++++++++++++++++ .../v1_6_7/RedfishChassis_V1_6_7_Dxe.inf | 55 +++ .../Chassis/v1_7_0/Chassis_V1_7_0_Dxe.c | 427 ++++++++++++++++++ .../v1_7_0/RedfishChassis_V1_7_0_Dxe.inf | 55 +++ .../Chassis/v1_7_1/Chassis_V1_7_1_Dxe.c | 427 ++++++++++++++++++ .../v1_7_1/RedfishChassis_V1_7_1_Dxe.inf | 55 +++ .../Chassis/v1_7_2/Chassis_V1_7_2_Dxe.c | 427 ++++++++++++++++++ .../v1_7_2/RedfishChassis_V1_7_2_Dxe.inf | 55 +++ .../Chassis/v1_7_3/Chassis_V1_7_3_Dxe.c | 427 ++++++++++++++++++ .../v1_7_3/RedfishChassis_V1_7_3_Dxe.inf | 55 +++ .../Chassis/v1_7_4/Chassis_V1_7_4_Dxe.c | 427 ++++++++++++++++++ .../v1_7_4/RedfishChassis_V1_7_4_Dxe.inf | 55 +++ .../Chassis/v1_7_5/Chassis_V1_7_5_Dxe.c | 427 ++++++++++++++++++ .../v1_7_5/RedfishChassis_V1_7_5_Dxe.inf | 55 +++ .../Chassis/v1_7_6/Chassis_V1_7_6_Dxe.c | 427 ++++++++++++++++++ .../v1_7_6/RedfishChassis_V1_7_6_Dxe.inf | 55 +++ .../Chassis/v1_7_7/Chassis_V1_7_7_Dxe.c | 427 ++++++++++++++++++ .../v1_7_7/RedfishChassis_V1_7_7_Dxe.inf | 55 +++ .../Chassis/v1_8_0/Chassis_V1_8_0_Dxe.c | 427 ++++++++++++++++++ .../v1_8_0/RedfishChassis_V1_8_0_Dxe.inf | 55 +++ .../Chassis/v1_8_1/Chassis_V1_8_1_Dxe.c | 427 ++++++++++++++++++ .../v1_8_1/RedfishChassis_V1_8_1_Dxe.inf | 55 +++ .../Chassis/v1_8_2/Chassis_V1_8_2_Dxe.c | 427 ++++++++++++++++++ .../v1_8_2/RedfishChassis_V1_8_2_Dxe.inf | 55 +++ .../Chassis/v1_8_3/Chassis_V1_8_3_Dxe.c | 427 ++++++++++++++++++ .../v1_8_3/RedfishChassis_V1_8_3_Dxe.inf | 55 +++ .../Chassis/v1_8_4/Chassis_V1_8_4_Dxe.c | 427 ++++++++++++++++++ .../v1_8_4/RedfishChassis_V1_8_4_Dxe.inf | 55 +++ .../Chassis/v1_8_5/Chassis_V1_8_5_Dxe.c | 427 ++++++++++++++++++ .../v1_8_5/RedfishChassis_V1_8_5_Dxe.inf | 55 +++ .../Chassis/v1_8_6/Chassis_V1_8_6_Dxe.c | 427 ++++++++++++++++++ .../v1_8_6/RedfishChassis_V1_8_6_Dxe.inf | 55 +++ .../Chassis/v1_9_0/Chassis_V1_9_0_Dxe.c | 427 ++++++++++++++++++ .../v1_9_0/RedfishChassis_V1_9_0_Dxe.inf | 55 +++ .../Chassis/v1_9_1/Chassis_V1_9_1_Dxe.c | 427 ++++++++++++++++++ .../v1_9_1/RedfishChassis_V1_9_1_Dxe.inf | 55 +++ .../Chassis/v1_9_2/Chassis_V1_9_2_Dxe.c | 427 ++++++++++++++++++ .../v1_9_2/RedfishChassis_V1_9_2_Dxe.inf | 55 +++ .../Chassis/v1_9_3/Chassis_V1_9_3_Dxe.c | 427 ++++++++++++++++++ .../v1_9_3/RedfishChassis_V1_9_3_Dxe.inf | 55 +++ .../Chassis/v1_9_4/Chassis_V1_9_4_Dxe.c | 427 ++++++++++++++++++ .../v1_9_4/RedfishChassis_V1_9_4_Dxe.inf | 55 +++ .../Chassis/v1_9_5/Chassis_V1_9_5_Dxe.c | 427 ++++++++++++++++++ .../v1_9_5/RedfishChassis_V1_9_5_Dxe.inf | 55 +++ .../ChassisCollection/ChassisCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishChassisCollection_Dxe.inf | 55 +++ .../Circuit/v1_0_0/Circuit_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishCircuit_V1_0_0_Dxe.inf | 55 +++ .../Circuit/v1_0_1/Circuit_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishCircuit_V1_0_1_Dxe.inf | 55 +++ .../Circuit/v1_0_2/Circuit_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishCircuit_V1_0_2_Dxe.inf | 55 +++ .../Circuit/v1_1_0/Circuit_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishCircuit_V1_1_0_Dxe.inf | 55 +++ .../Circuit/v1_1_1/Circuit_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishCircuit_V1_1_1_Dxe.inf | 55 +++ .../Circuit/v1_2_0/Circuit_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishCircuit_V1_2_0_Dxe.inf | 55 +++ .../CircuitCollection/CircuitCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishCircuitCollection_Dxe.inf | 55 +++ .../v1_0_0/CompositionService_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishCompositionService_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/CompositionService_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishCompositionService_V1_0_1_Dxe.inf | 55 +++ .../v1_0_2/CompositionService_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishCompositionService_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/CompositionService_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishCompositionService_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/CompositionService_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishCompositionService_V1_0_4_Dxe.inf | 55 +++ .../v1_1_0/CompositionService_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishCompositionService_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/CompositionService_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishCompositionService_V1_1_1_Dxe.inf | 55 +++ .../v1_1_2/CompositionService_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishCompositionService_V1_1_2_Dxe.inf | 55 +++ .../v1_0_0/ComputerSystem_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/ComputerSystem_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_0_1_Dxe.inf | 55 +++ .../v1_0_10/ComputerSystem_V1_0_10_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_0_10_Dxe.inf | 55 +++ .../v1_0_11/ComputerSystem_V1_0_11_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_0_11_Dxe.inf | 55 +++ .../v1_0_12/ComputerSystem_V1_0_12_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_0_12_Dxe.inf | 55 +++ .../v1_0_13/ComputerSystem_V1_0_13_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_0_13_Dxe.inf | 55 +++ .../v1_0_14/ComputerSystem_V1_0_14_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_0_14_Dxe.inf | 55 +++ .../v1_0_15/ComputerSystem_V1_0_15_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_0_15_Dxe.inf | 55 +++ .../v1_0_16/ComputerSystem_V1_0_16_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_0_16_Dxe.inf | 55 +++ .../v1_0_2/ComputerSystem_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/ComputerSystem_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/ComputerSystem_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_0_4_Dxe.inf | 55 +++ .../v1_0_5/ComputerSystem_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_0_5_Dxe.inf | 55 +++ .../v1_0_6/ComputerSystem_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_0_6_Dxe.inf | 55 +++ .../v1_0_7/ComputerSystem_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_0_7_Dxe.inf | 55 +++ .../v1_0_8/ComputerSystem_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_0_8_Dxe.inf | 55 +++ .../v1_0_9/ComputerSystem_V1_0_9_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_0_9_Dxe.inf | 55 +++ .../v1_10_0/ComputerSystem_V1_10_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_10_0_Dxe.inf | 55 +++ .../v1_10_1/ComputerSystem_V1_10_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_10_1_Dxe.inf | 55 +++ .../v1_10_2/ComputerSystem_V1_10_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_10_2_Dxe.inf | 55 +++ .../v1_10_3/ComputerSystem_V1_10_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_10_3_Dxe.inf | 55 +++ .../v1_10_4/ComputerSystem_V1_10_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_10_4_Dxe.inf | 55 +++ .../v1_11_0/ComputerSystem_V1_11_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_11_0_Dxe.inf | 55 +++ .../v1_11_1/ComputerSystem_V1_11_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_11_1_Dxe.inf | 55 +++ .../v1_11_2/ComputerSystem_V1_11_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_11_2_Dxe.inf | 55 +++ .../v1_11_3/ComputerSystem_V1_11_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_11_3_Dxe.inf | 55 +++ .../v1_12_0/ComputerSystem_V1_12_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_12_0_Dxe.inf | 55 +++ .../v1_12_1/ComputerSystem_V1_12_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_12_1_Dxe.inf | 55 +++ .../v1_12_2/ComputerSystem_V1_12_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_12_2_Dxe.inf | 55 +++ .../v1_13_0/ComputerSystem_V1_13_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_13_0_Dxe.inf | 55 +++ .../v1_13_1/ComputerSystem_V1_13_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_13_1_Dxe.inf | 55 +++ .../v1_14_0/ComputerSystem_V1_14_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_14_0_Dxe.inf | 55 +++ .../v1_1_0/ComputerSystem_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/ComputerSystem_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_1_1_Dxe.inf | 55 +++ .../v1_1_10/ComputerSystem_V1_1_10_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_1_10_Dxe.inf | 55 +++ .../v1_1_11/ComputerSystem_V1_1_11_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_1_11_Dxe.inf | 55 +++ .../v1_1_12/ComputerSystem_V1_1_12_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_1_12_Dxe.inf | 55 +++ .../v1_1_13/ComputerSystem_V1_1_13_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_1_13_Dxe.inf | 55 +++ .../v1_1_14/ComputerSystem_V1_1_14_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_1_14_Dxe.inf | 55 +++ .../v1_1_2/ComputerSystem_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_1_2_Dxe.inf | 55 +++ .../v1_1_3/ComputerSystem_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_1_3_Dxe.inf | 55 +++ .../v1_1_4/ComputerSystem_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_1_4_Dxe.inf | 55 +++ .../v1_1_5/ComputerSystem_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_1_5_Dxe.inf | 55 +++ .../v1_1_6/ComputerSystem_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_1_6_Dxe.inf | 55 +++ .../v1_1_7/ComputerSystem_V1_1_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_1_7_Dxe.inf | 55 +++ .../v1_1_8/ComputerSystem_V1_1_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_1_8_Dxe.inf | 55 +++ .../v1_1_9/ComputerSystem_V1_1_9_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_1_9_Dxe.inf | 55 +++ .../v1_2_0/ComputerSystem_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_2_0_Dxe.inf | 55 +++ .../v1_2_1/ComputerSystem_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_2_1_Dxe.inf | 55 +++ .../v1_2_10/ComputerSystem_V1_2_10_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_2_10_Dxe.inf | 55 +++ .../v1_2_11/ComputerSystem_V1_2_11_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_2_11_Dxe.inf | 55 +++ .../v1_2_12/ComputerSystem_V1_2_12_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_2_12_Dxe.inf | 55 +++ .../v1_2_13/ComputerSystem_V1_2_13_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_2_13_Dxe.inf | 55 +++ .../v1_2_2/ComputerSystem_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_2_2_Dxe.inf | 55 +++ .../v1_2_3/ComputerSystem_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_2_3_Dxe.inf | 55 +++ .../v1_2_4/ComputerSystem_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_2_4_Dxe.inf | 55 +++ .../v1_2_5/ComputerSystem_V1_2_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_2_5_Dxe.inf | 55 +++ .../v1_2_6/ComputerSystem_V1_2_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_2_6_Dxe.inf | 55 +++ .../v1_2_7/ComputerSystem_V1_2_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_2_7_Dxe.inf | 55 +++ .../v1_2_8/ComputerSystem_V1_2_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_2_8_Dxe.inf | 55 +++ .../v1_2_9/ComputerSystem_V1_2_9_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_2_9_Dxe.inf | 55 +++ .../v1_3_0/ComputerSystem_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_3_0_Dxe.inf | 55 +++ .../v1_3_1/ComputerSystem_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_3_1_Dxe.inf | 55 +++ .../v1_3_10/ComputerSystem_V1_3_10_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_3_10_Dxe.inf | 55 +++ .../v1_3_11/ComputerSystem_V1_3_11_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_3_11_Dxe.inf | 55 +++ .../v1_3_12/ComputerSystem_V1_3_12_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_3_12_Dxe.inf | 55 +++ .../v1_3_2/ComputerSystem_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_3_2_Dxe.inf | 55 +++ .../v1_3_3/ComputerSystem_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_3_3_Dxe.inf | 55 +++ .../v1_3_4/ComputerSystem_V1_3_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_3_4_Dxe.inf | 55 +++ .../v1_3_5/ComputerSystem_V1_3_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_3_5_Dxe.inf | 55 +++ .../v1_3_6/ComputerSystem_V1_3_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_3_6_Dxe.inf | 55 +++ .../v1_3_7/ComputerSystem_V1_3_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_3_7_Dxe.inf | 55 +++ .../v1_3_8/ComputerSystem_V1_3_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_3_8_Dxe.inf | 55 +++ .../v1_3_9/ComputerSystem_V1_3_9_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_3_9_Dxe.inf | 55 +++ .../v1_4_0/ComputerSystem_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_4_0_Dxe.inf | 55 +++ .../v1_4_1/ComputerSystem_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_4_1_Dxe.inf | 55 +++ .../v1_4_10/ComputerSystem_V1_4_10_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_4_10_Dxe.inf | 55 +++ .../v1_4_11/ComputerSystem_V1_4_11_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_4_11_Dxe.inf | 55 +++ .../v1_4_2/ComputerSystem_V1_4_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_4_2_Dxe.inf | 55 +++ .../v1_4_3/ComputerSystem_V1_4_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_4_3_Dxe.inf | 55 +++ .../v1_4_4/ComputerSystem_V1_4_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_4_4_Dxe.inf | 55 +++ .../v1_4_5/ComputerSystem_V1_4_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_4_5_Dxe.inf | 55 +++ .../v1_4_6/ComputerSystem_V1_4_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_4_6_Dxe.inf | 55 +++ .../v1_4_7/ComputerSystem_V1_4_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_4_7_Dxe.inf | 55 +++ .../v1_4_8/ComputerSystem_V1_4_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_4_8_Dxe.inf | 55 +++ .../v1_4_9/ComputerSystem_V1_4_9_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_4_9_Dxe.inf | 55 +++ .../v1_5_0/ComputerSystem_V1_5_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_5_0_Dxe.inf | 55 +++ .../v1_5_1/ComputerSystem_V1_5_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_5_1_Dxe.inf | 55 +++ .../v1_5_2/ComputerSystem_V1_5_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_5_2_Dxe.inf | 55 +++ .../v1_5_3/ComputerSystem_V1_5_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_5_3_Dxe.inf | 55 +++ .../v1_5_4/ComputerSystem_V1_5_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_5_4_Dxe.inf | 55 +++ .../v1_5_5/ComputerSystem_V1_5_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_5_5_Dxe.inf | 55 +++ .../v1_5_6/ComputerSystem_V1_5_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_5_6_Dxe.inf | 55 +++ .../v1_5_7/ComputerSystem_V1_5_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_5_7_Dxe.inf | 55 +++ .../v1_5_8/ComputerSystem_V1_5_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_5_8_Dxe.inf | 55 +++ .../v1_5_9/ComputerSystem_V1_5_9_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_5_9_Dxe.inf | 55 +++ .../v1_6_0/ComputerSystem_V1_6_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_6_0_Dxe.inf | 55 +++ .../v1_6_1/ComputerSystem_V1_6_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_6_1_Dxe.inf | 55 +++ .../v1_6_2/ComputerSystem_V1_6_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_6_2_Dxe.inf | 55 +++ .../v1_6_3/ComputerSystem_V1_6_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_6_3_Dxe.inf | 55 +++ .../v1_6_4/ComputerSystem_V1_6_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_6_4_Dxe.inf | 55 +++ .../v1_6_5/ComputerSystem_V1_6_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_6_5_Dxe.inf | 55 +++ .../v1_6_6/ComputerSystem_V1_6_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_6_6_Dxe.inf | 55 +++ .../v1_6_7/ComputerSystem_V1_6_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_6_7_Dxe.inf | 55 +++ .../v1_7_0/ComputerSystem_V1_7_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_7_0_Dxe.inf | 55 +++ .../v1_7_1/ComputerSystem_V1_7_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_7_1_Dxe.inf | 55 +++ .../v1_7_2/ComputerSystem_V1_7_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_7_2_Dxe.inf | 55 +++ .../v1_7_3/ComputerSystem_V1_7_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_7_3_Dxe.inf | 55 +++ .../v1_7_4/ComputerSystem_V1_7_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_7_4_Dxe.inf | 55 +++ .../v1_7_5/ComputerSystem_V1_7_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_7_5_Dxe.inf | 55 +++ .../v1_7_6/ComputerSystem_V1_7_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_7_6_Dxe.inf | 55 +++ .../v1_8_0/ComputerSystem_V1_8_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_8_0_Dxe.inf | 55 +++ .../v1_8_1/ComputerSystem_V1_8_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_8_1_Dxe.inf | 55 +++ .../v1_8_2/ComputerSystem_V1_8_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_8_2_Dxe.inf | 55 +++ .../v1_8_3/ComputerSystem_V1_8_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_8_3_Dxe.inf | 55 +++ .../v1_8_4/ComputerSystem_V1_8_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_8_4_Dxe.inf | 55 +++ .../v1_8_5/ComputerSystem_V1_8_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_8_5_Dxe.inf | 55 +++ .../v1_9_0/ComputerSystem_V1_9_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_9_0_Dxe.inf | 55 +++ .../v1_9_1/ComputerSystem_V1_9_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_9_1_Dxe.inf | 55 +++ .../v1_9_2/ComputerSystem_V1_9_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_9_2_Dxe.inf | 55 +++ .../v1_9_3/ComputerSystem_V1_9_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_9_3_Dxe.inf | 55 +++ .../v1_9_4/ComputerSystem_V1_9_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_9_4_Dxe.inf | 55 +++ .../v1_9_5/ComputerSystem_V1_9_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystem_V1_9_5_Dxe.inf | 55 +++ .../ComputerSystemCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishComputerSystemCollection_Dxe.inf | 55 +++ .../Connection/v1_0_0/Connection_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishConnection_V1_0_0_Dxe.inf | 55 +++ .../ConnectionCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishConnectionCollection_Dxe.inf | 55 +++ .../v1_0_0/ConnectionMethod_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishConnectionMethod_V1_0_0_Dxe.inf | 55 +++ .../ConnectionMethodCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishConnectionMethodCollection_Dxe.inf | 55 +++ .../Converter/Drive/v1_0_0/Drive_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_0_0/RedfishDrive_V1_0_0_Dxe.inf | 55 +++ .../Converter/Drive/v1_0_1/Drive_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_0_1/RedfishDrive_V1_0_1_Dxe.inf | 55 +++ .../Drive/v1_0_10/Drive_V1_0_10_Dxe.c | 427 ++++++++++++++++++ .../v1_0_10/RedfishDrive_V1_0_10_Dxe.inf | 55 +++ .../Drive/v1_0_11/Drive_V1_0_11_Dxe.c | 427 ++++++++++++++++++ .../v1_0_11/RedfishDrive_V1_0_11_Dxe.inf | 55 +++ .../Converter/Drive/v1_0_2/Drive_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_0_2/RedfishDrive_V1_0_2_Dxe.inf | 55 +++ .../Converter/Drive/v1_0_3/Drive_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_0_3/RedfishDrive_V1_0_3_Dxe.inf | 55 +++ .../Converter/Drive/v1_0_4/Drive_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_0_4/RedfishDrive_V1_0_4_Dxe.inf | 55 +++ .../Converter/Drive/v1_0_5/Drive_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_0_5/RedfishDrive_V1_0_5_Dxe.inf | 55 +++ .../Converter/Drive/v1_0_6/Drive_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_0_6/RedfishDrive_V1_0_6_Dxe.inf | 55 +++ .../Converter/Drive/v1_0_7/Drive_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_0_7/RedfishDrive_V1_0_7_Dxe.inf | 55 +++ .../Converter/Drive/v1_0_8/Drive_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_0_8/RedfishDrive_V1_0_8_Dxe.inf | 55 +++ .../Converter/Drive/v1_0_9/Drive_V1_0_9_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_0_9/RedfishDrive_V1_0_9_Dxe.inf | 55 +++ .../Drive/v1_10_0/Drive_V1_10_0_Dxe.c | 427 ++++++++++++++++++ .../v1_10_0/RedfishDrive_V1_10_0_Dxe.inf | 55 +++ .../Drive/v1_10_1/Drive_V1_10_1_Dxe.c | 427 ++++++++++++++++++ .../v1_10_1/RedfishDrive_V1_10_1_Dxe.inf | 55 +++ .../Drive/v1_11_0/Drive_V1_11_0_Dxe.c | 427 ++++++++++++++++++ .../v1_11_0/RedfishDrive_V1_11_0_Dxe.inf | 55 +++ .../Drive/v1_11_1/Drive_V1_11_1_Dxe.c | 427 ++++++++++++++++++ .../v1_11_1/RedfishDrive_V1_11_1_Dxe.inf | 55 +++ .../Drive/v1_12_0/Drive_V1_12_0_Dxe.c | 427 ++++++++++++++++++ .../v1_12_0/RedfishDrive_V1_12_0_Dxe.inf | 55 +++ .../Converter/Drive/v1_1_0/Drive_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_1_0/RedfishDrive_V1_1_0_Dxe.inf | 55 +++ .../Converter/Drive/v1_1_1/Drive_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_1_1/RedfishDrive_V1_1_1_Dxe.inf | 55 +++ .../Drive/v1_1_10/Drive_V1_1_10_Dxe.c | 427 ++++++++++++++++++ .../v1_1_10/RedfishDrive_V1_1_10_Dxe.inf | 55 +++ .../Converter/Drive/v1_1_2/Drive_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_1_2/RedfishDrive_V1_1_2_Dxe.inf | 55 +++ .../Converter/Drive/v1_1_3/Drive_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_1_3/RedfishDrive_V1_1_3_Dxe.inf | 55 +++ .../Converter/Drive/v1_1_4/Drive_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_1_4/RedfishDrive_V1_1_4_Dxe.inf | 55 +++ .../Converter/Drive/v1_1_5/Drive_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_1_5/RedfishDrive_V1_1_5_Dxe.inf | 55 +++ .../Converter/Drive/v1_1_6/Drive_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_1_6/RedfishDrive_V1_1_6_Dxe.inf | 55 +++ .../Converter/Drive/v1_1_7/Drive_V1_1_7_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_1_7/RedfishDrive_V1_1_7_Dxe.inf | 55 +++ .../Converter/Drive/v1_1_8/Drive_V1_1_8_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_1_8/RedfishDrive_V1_1_8_Dxe.inf | 55 +++ .../Converter/Drive/v1_1_9/Drive_V1_1_9_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_1_9/RedfishDrive_V1_1_9_Dxe.inf | 55 +++ .../Converter/Drive/v1_2_0/Drive_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_2_0/RedfishDrive_V1_2_0_Dxe.inf | 55 +++ .../Converter/Drive/v1_2_1/Drive_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_2_1/RedfishDrive_V1_2_1_Dxe.inf | 55 +++ .../Converter/Drive/v1_2_2/Drive_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_2_2/RedfishDrive_V1_2_2_Dxe.inf | 55 +++ .../Converter/Drive/v1_2_3/Drive_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_2_3/RedfishDrive_V1_2_3_Dxe.inf | 55 +++ .../Converter/Drive/v1_2_4/Drive_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_2_4/RedfishDrive_V1_2_4_Dxe.inf | 55 +++ .../Converter/Drive/v1_2_5/Drive_V1_2_5_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_2_5/RedfishDrive_V1_2_5_Dxe.inf | 55 +++ .../Converter/Drive/v1_2_6/Drive_V1_2_6_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_2_6/RedfishDrive_V1_2_6_Dxe.inf | 55 +++ .../Converter/Drive/v1_2_7/Drive_V1_2_7_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_2_7/RedfishDrive_V1_2_7_Dxe.inf | 55 +++ .../Converter/Drive/v1_2_8/Drive_V1_2_8_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_2_8/RedfishDrive_V1_2_8_Dxe.inf | 55 +++ .../Converter/Drive/v1_3_0/Drive_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_3_0/RedfishDrive_V1_3_0_Dxe.inf | 55 +++ .../Converter/Drive/v1_3_1/Drive_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_3_1/RedfishDrive_V1_3_1_Dxe.inf | 55 +++ .../Converter/Drive/v1_3_2/Drive_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_3_2/RedfishDrive_V1_3_2_Dxe.inf | 55 +++ .../Converter/Drive/v1_3_3/Drive_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_3_3/RedfishDrive_V1_3_3_Dxe.inf | 55 +++ .../Converter/Drive/v1_3_4/Drive_V1_3_4_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_3_4/RedfishDrive_V1_3_4_Dxe.inf | 55 +++ .../Converter/Drive/v1_3_5/Drive_V1_3_5_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_3_5/RedfishDrive_V1_3_5_Dxe.inf | 55 +++ .../Converter/Drive/v1_3_6/Drive_V1_3_6_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_3_6/RedfishDrive_V1_3_6_Dxe.inf | 55 +++ .../Converter/Drive/v1_3_7/Drive_V1_3_7_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_3_7/RedfishDrive_V1_3_7_Dxe.inf | 55 +++ .../Converter/Drive/v1_4_0/Drive_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_4_0/RedfishDrive_V1_4_0_Dxe.inf | 55 +++ .../Converter/Drive/v1_4_1/Drive_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_4_1/RedfishDrive_V1_4_1_Dxe.inf | 55 +++ .../Converter/Drive/v1_4_2/Drive_V1_4_2_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_4_2/RedfishDrive_V1_4_2_Dxe.inf | 55 +++ .../Converter/Drive/v1_4_3/Drive_V1_4_3_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_4_3/RedfishDrive_V1_4_3_Dxe.inf | 55 +++ .../Converter/Drive/v1_4_4/Drive_V1_4_4_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_4_4/RedfishDrive_V1_4_4_Dxe.inf | 55 +++ .../Converter/Drive/v1_4_5/Drive_V1_4_5_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_4_5/RedfishDrive_V1_4_5_Dxe.inf | 55 +++ .../Converter/Drive/v1_4_6/Drive_V1_4_6_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_4_6/RedfishDrive_V1_4_6_Dxe.inf | 55 +++ .../Converter/Drive/v1_4_7/Drive_V1_4_7_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_4_7/RedfishDrive_V1_4_7_Dxe.inf | 55 +++ .../Converter/Drive/v1_5_0/Drive_V1_5_0_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_5_0/RedfishDrive_V1_5_0_Dxe.inf | 55 +++ .../Converter/Drive/v1_5_1/Drive_V1_5_1_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_5_1/RedfishDrive_V1_5_1_Dxe.inf | 55 +++ .../Converter/Drive/v1_5_2/Drive_V1_5_2_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_5_2/RedfishDrive_V1_5_2_Dxe.inf | 55 +++ .../Converter/Drive/v1_5_3/Drive_V1_5_3_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_5_3/RedfishDrive_V1_5_3_Dxe.inf | 55 +++ .../Converter/Drive/v1_5_4/Drive_V1_5_4_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_5_4/RedfishDrive_V1_5_4_Dxe.inf | 55 +++ .../Converter/Drive/v1_5_5/Drive_V1_5_5_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_5_5/RedfishDrive_V1_5_5_Dxe.inf | 55 +++ .../Converter/Drive/v1_5_6/Drive_V1_5_6_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_5_6/RedfishDrive_V1_5_6_Dxe.inf | 55 +++ .../Converter/Drive/v1_6_0/Drive_V1_6_0_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_6_0/RedfishDrive_V1_6_0_Dxe.inf | 55 +++ .../Converter/Drive/v1_6_1/Drive_V1_6_1_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_6_1/RedfishDrive_V1_6_1_Dxe.inf | 55 +++ .../Converter/Drive/v1_6_2/Drive_V1_6_2_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_6_2/RedfishDrive_V1_6_2_Dxe.inf | 55 +++ .../Converter/Drive/v1_6_3/Drive_V1_6_3_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_6_3/RedfishDrive_V1_6_3_Dxe.inf | 55 +++ .../Converter/Drive/v1_6_4/Drive_V1_6_4_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_6_4/RedfishDrive_V1_6_4_Dxe.inf | 55 +++ .../Converter/Drive/v1_7_0/Drive_V1_7_0_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_7_0/RedfishDrive_V1_7_0_Dxe.inf | 55 +++ .../Converter/Drive/v1_7_1/Drive_V1_7_1_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_7_1/RedfishDrive_V1_7_1_Dxe.inf | 55 +++ .../Converter/Drive/v1_7_2/Drive_V1_7_2_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_7_2/RedfishDrive_V1_7_2_Dxe.inf | 55 +++ .../Converter/Drive/v1_7_3/Drive_V1_7_3_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_7_3/RedfishDrive_V1_7_3_Dxe.inf | 55 +++ .../Converter/Drive/v1_8_0/Drive_V1_8_0_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_8_0/RedfishDrive_V1_8_0_Dxe.inf | 55 +++ .../Converter/Drive/v1_8_1/Drive_V1_8_1_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_8_1/RedfishDrive_V1_8_1_Dxe.inf | 55 +++ .../Converter/Drive/v1_8_2/Drive_V1_8_2_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_8_2/RedfishDrive_V1_8_2_Dxe.inf | 55 +++ .../Converter/Drive/v1_8_3/Drive_V1_8_3_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_8_3/RedfishDrive_V1_8_3_Dxe.inf | 55 +++ .../Converter/Drive/v1_9_0/Drive_V1_9_0_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_9_0/RedfishDrive_V1_9_0_Dxe.inf | 55 +++ .../Converter/Drive/v1_9_1/Drive_V1_9_1_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_9_1/RedfishDrive_V1_9_1_Dxe.inf | 55 +++ .../Converter/Drive/v1_9_2/Drive_V1_9_2_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_9_2/RedfishDrive_V1_9_2_Dxe.inf | 55 +++ .../Converter/Drive/v1_9_3/Drive_V1_9_3_Dxe.c | 427 ++++++++++++++++++ .../Drive/v1_9_3/RedfishDrive_V1_9_3_Dxe.inf | 55 +++ .../DriveCollection/DriveCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishDriveCollection_Dxe.inf | 55 +++ .../Endpoint/v1_0_0/Endpoint_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishEndpoint_V1_0_0_Dxe.inf | 55 +++ .../Endpoint/v1_0_1/Endpoint_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishEndpoint_V1_0_1_Dxe.inf | 55 +++ .../Endpoint/v1_0_10/Endpoint_V1_0_10_Dxe.c | 427 ++++++++++++++++++ .../v1_0_10/RedfishEndpoint_V1_0_10_Dxe.inf | 55 +++ .../Endpoint/v1_0_2/Endpoint_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishEndpoint_V1_0_2_Dxe.inf | 55 +++ .../Endpoint/v1_0_3/Endpoint_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishEndpoint_V1_0_3_Dxe.inf | 55 +++ .../Endpoint/v1_0_4/Endpoint_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishEndpoint_V1_0_4_Dxe.inf | 55 +++ .../Endpoint/v1_0_5/Endpoint_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishEndpoint_V1_0_5_Dxe.inf | 55 +++ .../Endpoint/v1_0_6/Endpoint_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../v1_0_6/RedfishEndpoint_V1_0_6_Dxe.inf | 55 +++ .../Endpoint/v1_0_7/Endpoint_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../v1_0_7/RedfishEndpoint_V1_0_7_Dxe.inf | 55 +++ .../Endpoint/v1_0_8/Endpoint_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../v1_0_8/RedfishEndpoint_V1_0_8_Dxe.inf | 55 +++ .../Endpoint/v1_0_9/Endpoint_V1_0_9_Dxe.c | 427 ++++++++++++++++++ .../v1_0_9/RedfishEndpoint_V1_0_9_Dxe.inf | 55 +++ .../Endpoint/v1_1_0/Endpoint_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishEndpoint_V1_1_0_Dxe.inf | 55 +++ .../Endpoint/v1_1_1/Endpoint_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishEndpoint_V1_1_1_Dxe.inf | 55 +++ .../Endpoint/v1_1_2/Endpoint_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishEndpoint_V1_1_2_Dxe.inf | 55 +++ .../Endpoint/v1_1_3/Endpoint_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../v1_1_3/RedfishEndpoint_V1_1_3_Dxe.inf | 55 +++ .../Endpoint/v1_1_4/Endpoint_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../v1_1_4/RedfishEndpoint_V1_1_4_Dxe.inf | 55 +++ .../Endpoint/v1_1_5/Endpoint_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../v1_1_5/RedfishEndpoint_V1_1_5_Dxe.inf | 55 +++ .../Endpoint/v1_1_6/Endpoint_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../v1_1_6/RedfishEndpoint_V1_1_6_Dxe.inf | 55 +++ .../Endpoint/v1_1_7/Endpoint_V1_1_7_Dxe.c | 427 ++++++++++++++++++ .../v1_1_7/RedfishEndpoint_V1_1_7_Dxe.inf | 55 +++ .../Endpoint/v1_2_0/Endpoint_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishEndpoint_V1_2_0_Dxe.inf | 55 +++ .../Endpoint/v1_2_1/Endpoint_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../v1_2_1/RedfishEndpoint_V1_2_1_Dxe.inf | 55 +++ .../Endpoint/v1_2_2/Endpoint_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../v1_2_2/RedfishEndpoint_V1_2_2_Dxe.inf | 55 +++ .../Endpoint/v1_2_3/Endpoint_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../v1_2_3/RedfishEndpoint_V1_2_3_Dxe.inf | 55 +++ .../Endpoint/v1_2_4/Endpoint_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../v1_2_4/RedfishEndpoint_V1_2_4_Dxe.inf | 55 +++ .../Endpoint/v1_2_5/Endpoint_V1_2_5_Dxe.c | 427 ++++++++++++++++++ .../v1_2_5/RedfishEndpoint_V1_2_5_Dxe.inf | 55 +++ .../Endpoint/v1_2_6/Endpoint_V1_2_6_Dxe.c | 427 ++++++++++++++++++ .../v1_2_6/RedfishEndpoint_V1_2_6_Dxe.inf | 55 +++ .../Endpoint/v1_3_0/Endpoint_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../v1_3_0/RedfishEndpoint_V1_3_0_Dxe.inf | 55 +++ .../Endpoint/v1_3_1/Endpoint_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../v1_3_1/RedfishEndpoint_V1_3_1_Dxe.inf | 55 +++ .../Endpoint/v1_3_2/Endpoint_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../v1_3_2/RedfishEndpoint_V1_3_2_Dxe.inf | 55 +++ .../Endpoint/v1_3_3/Endpoint_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../v1_3_3/RedfishEndpoint_V1_3_3_Dxe.inf | 55 +++ .../Endpoint/v1_3_4/Endpoint_V1_3_4_Dxe.c | 427 ++++++++++++++++++ .../v1_3_4/RedfishEndpoint_V1_3_4_Dxe.inf | 55 +++ .../Endpoint/v1_3_5/Endpoint_V1_3_5_Dxe.c | 427 ++++++++++++++++++ .../v1_3_5/RedfishEndpoint_V1_3_5_Dxe.inf | 55 +++ .../Endpoint/v1_4_0/Endpoint_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../v1_4_0/RedfishEndpoint_V1_4_0_Dxe.inf | 55 +++ .../Endpoint/v1_4_1/Endpoint_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../v1_4_1/RedfishEndpoint_V1_4_1_Dxe.inf | 55 +++ .../Endpoint/v1_4_2/Endpoint_V1_4_2_Dxe.c | 427 ++++++++++++++++++ .../v1_4_2/RedfishEndpoint_V1_4_2_Dxe.inf | 55 +++ .../Endpoint/v1_4_3/Endpoint_V1_4_3_Dxe.c | 427 ++++++++++++++++++ .../v1_4_3/RedfishEndpoint_V1_4_3_Dxe.inf | 55 +++ .../Endpoint/v1_5_0/Endpoint_V1_5_0_Dxe.c | 427 ++++++++++++++++++ .../v1_5_0/RedfishEndpoint_V1_5_0_Dxe.inf | 55 +++ .../Endpoint/v1_5_1/Endpoint_V1_5_1_Dxe.c | 427 ++++++++++++++++++ .../v1_5_1/RedfishEndpoint_V1_5_1_Dxe.inf | 55 +++ .../EndpointCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishEndpointCollection_Dxe.inf | 55 +++ .../v1_0_0/EndpointGroup_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishEndpointGroup_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/EndpointGroup_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishEndpointGroup_V1_0_1_Dxe.inf | 55 +++ .../v1_0_2/EndpointGroup_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishEndpointGroup_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/EndpointGroup_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishEndpointGroup_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/EndpointGroup_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishEndpointGroup_V1_0_4_Dxe.inf | 55 +++ .../v1_1_0/EndpointGroup_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishEndpointGroup_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/EndpointGroup_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishEndpointGroup_V1_1_1_Dxe.inf | 55 +++ .../v1_1_2/EndpointGroup_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishEndpointGroup_V1_1_2_Dxe.inf | 55 +++ .../v1_1_3/EndpointGroup_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishEndpointGroup_V1_1_3_Dxe.inf | 55 +++ .../v1_1_4/EndpointGroup_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishEndpointGroup_V1_1_4_Dxe.inf | 55 +++ .../v1_1_5/EndpointGroup_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishEndpointGroup_V1_1_5_Dxe.inf | 55 +++ .../v1_2_0/EndpointGroup_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishEndpointGroup_V1_2_0_Dxe.inf | 55 +++ .../v1_2_1/EndpointGroup_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishEndpointGroup_V1_2_1_Dxe.inf | 55 +++ .../v1_2_2/EndpointGroup_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishEndpointGroup_V1_2_2_Dxe.inf | 55 +++ .../v1_2_3/EndpointGroup_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishEndpointGroup_V1_2_3_Dxe.inf | 55 +++ .../v1_3_0/EndpointGroup_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishEndpointGroup_V1_3_0_Dxe.inf | 55 +++ .../v1_3_1/EndpointGroup_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishEndpointGroup_V1_3_1_Dxe.inf | 55 +++ .../EndpointGroupCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishEndpointGroupCollection_Dxe.inf | 55 +++ .../v1_0_0/EnvironmentMetrics_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishEnvironmentMetrics_V1_0_0_Dxe.inf | 55 +++ .../v1_0_0/EthernetInterface_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_0_0_Dxe.inf | 55 +++ .../v1_0_10/EthernetInterface_V1_0_10_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_0_10_Dxe.inf | 55 +++ .../v1_0_11/EthernetInterface_V1_0_11_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_0_11_Dxe.inf | 55 +++ .../v1_0_12/EthernetInterface_V1_0_12_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_0_12_Dxe.inf | 55 +++ .../v1_0_2/EthernetInterface_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/EthernetInterface_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/EthernetInterface_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_0_4_Dxe.inf | 55 +++ .../v1_0_5/EthernetInterface_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_0_5_Dxe.inf | 55 +++ .../v1_0_6/EthernetInterface_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_0_6_Dxe.inf | 55 +++ .../v1_0_7/EthernetInterface_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_0_7_Dxe.inf | 55 +++ .../v1_0_8/EthernetInterface_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_0_8_Dxe.inf | 55 +++ .../v1_0_9/EthernetInterface_V1_0_9_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_0_9_Dxe.inf | 55 +++ .../v1_1_0/EthernetInterface_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/EthernetInterface_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_1_1_Dxe.inf | 55 +++ .../v1_1_10/EthernetInterface_V1_1_10_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_1_10_Dxe.inf | 55 +++ .../v1_1_2/EthernetInterface_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_1_2_Dxe.inf | 55 +++ .../v1_1_3/EthernetInterface_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_1_3_Dxe.inf | 55 +++ .../v1_1_4/EthernetInterface_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_1_4_Dxe.inf | 55 +++ .../v1_1_5/EthernetInterface_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_1_5_Dxe.inf | 55 +++ .../v1_1_6/EthernetInterface_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_1_6_Dxe.inf | 55 +++ .../v1_1_7/EthernetInterface_V1_1_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_1_7_Dxe.inf | 55 +++ .../v1_1_8/EthernetInterface_V1_1_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_1_8_Dxe.inf | 55 +++ .../v1_1_9/EthernetInterface_V1_1_9_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_1_9_Dxe.inf | 55 +++ .../v1_2_0/EthernetInterface_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_2_0_Dxe.inf | 55 +++ .../v1_2_1/EthernetInterface_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_2_1_Dxe.inf | 55 +++ .../v1_2_2/EthernetInterface_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_2_2_Dxe.inf | 55 +++ .../v1_2_3/EthernetInterface_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_2_3_Dxe.inf | 55 +++ .../v1_2_4/EthernetInterface_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_2_4_Dxe.inf | 55 +++ .../v1_2_5/EthernetInterface_V1_2_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_2_5_Dxe.inf | 55 +++ .../v1_2_6/EthernetInterface_V1_2_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_2_6_Dxe.inf | 55 +++ .../v1_2_7/EthernetInterface_V1_2_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_2_7_Dxe.inf | 55 +++ .../v1_2_8/EthernetInterface_V1_2_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_2_8_Dxe.inf | 55 +++ .../v1_2_9/EthernetInterface_V1_2_9_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_2_9_Dxe.inf | 55 +++ .../v1_3_0/EthernetInterface_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_3_0_Dxe.inf | 55 +++ .../v1_3_1/EthernetInterface_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_3_1_Dxe.inf | 55 +++ .../v1_3_2/EthernetInterface_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_3_2_Dxe.inf | 55 +++ .../v1_3_3/EthernetInterface_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_3_3_Dxe.inf | 55 +++ .../v1_3_4/EthernetInterface_V1_3_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_3_4_Dxe.inf | 55 +++ .../v1_3_5/EthernetInterface_V1_3_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_3_5_Dxe.inf | 55 +++ .../v1_3_6/EthernetInterface_V1_3_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_3_6_Dxe.inf | 55 +++ .../v1_3_7/EthernetInterface_V1_3_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_3_7_Dxe.inf | 55 +++ .../v1_3_8/EthernetInterface_V1_3_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_3_8_Dxe.inf | 55 +++ .../v1_4_0/EthernetInterface_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_4_0_Dxe.inf | 55 +++ .../v1_4_1/EthernetInterface_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_4_1_Dxe.inf | 55 +++ .../v1_4_2/EthernetInterface_V1_4_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_4_2_Dxe.inf | 55 +++ .../v1_4_3/EthernetInterface_V1_4_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_4_3_Dxe.inf | 55 +++ .../v1_4_4/EthernetInterface_V1_4_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_4_4_Dxe.inf | 55 +++ .../v1_4_5/EthernetInterface_V1_4_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_4_5_Dxe.inf | 55 +++ .../v1_4_6/EthernetInterface_V1_4_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_4_6_Dxe.inf | 55 +++ .../v1_4_7/EthernetInterface_V1_4_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_4_7_Dxe.inf | 55 +++ .../v1_5_0/EthernetInterface_V1_5_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_5_0_Dxe.inf | 55 +++ .../v1_5_1/EthernetInterface_V1_5_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_5_1_Dxe.inf | 55 +++ .../v1_5_2/EthernetInterface_V1_5_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_5_2_Dxe.inf | 55 +++ .../v1_5_3/EthernetInterface_V1_5_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_5_3_Dxe.inf | 55 +++ .../v1_5_4/EthernetInterface_V1_5_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_5_4_Dxe.inf | 55 +++ .../v1_5_5/EthernetInterface_V1_5_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_5_5_Dxe.inf | 55 +++ .../v1_6_0/EthernetInterface_V1_6_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_6_0_Dxe.inf | 55 +++ .../v1_6_1/EthernetInterface_V1_6_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_6_1_Dxe.inf | 55 +++ .../v1_6_2/EthernetInterface_V1_6_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_6_2_Dxe.inf | 55 +++ .../v1_6_3/EthernetInterface_V1_6_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishEthernetInterface_V1_6_3_Dxe.inf | 55 +++ .../EthernetInterfaceCollection_Dxe.c | 427 ++++++++++++++++++ ...RedfishEthernetInterfaceCollection_Dxe.inf | 55 +++ .../Converter/Event/v1_0_0/Event_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_0_0/RedfishEvent_V1_0_0_Dxe.inf | 55 +++ .../Event/v1_0_10/Event_V1_0_10_Dxe.c | 427 ++++++++++++++++++ .../v1_0_10/RedfishEvent_V1_0_10_Dxe.inf | 55 +++ .../Event/v1_0_11/Event_V1_0_11_Dxe.c | 427 ++++++++++++++++++ .../v1_0_11/RedfishEvent_V1_0_11_Dxe.inf | 55 +++ .../Event/v1_0_12/Event_V1_0_12_Dxe.c | 427 ++++++++++++++++++ .../v1_0_12/RedfishEvent_V1_0_12_Dxe.inf | 55 +++ .../Event/v1_0_13/Event_V1_0_13_Dxe.c | 427 ++++++++++++++++++ .../v1_0_13/RedfishEvent_V1_0_13_Dxe.inf | 55 +++ .../Converter/Event/v1_0_2/Event_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_0_2/RedfishEvent_V1_0_2_Dxe.inf | 55 +++ .../Converter/Event/v1_0_3/Event_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_0_3/RedfishEvent_V1_0_3_Dxe.inf | 55 +++ .../Converter/Event/v1_0_4/Event_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_0_4/RedfishEvent_V1_0_4_Dxe.inf | 55 +++ .../Converter/Event/v1_0_5/Event_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_0_5/RedfishEvent_V1_0_5_Dxe.inf | 55 +++ .../Converter/Event/v1_0_6/Event_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_0_6/RedfishEvent_V1_0_6_Dxe.inf | 55 +++ .../Converter/Event/v1_0_7/Event_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_0_7/RedfishEvent_V1_0_7_Dxe.inf | 55 +++ .../Converter/Event/v1_0_8/Event_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_0_8/RedfishEvent_V1_0_8_Dxe.inf | 55 +++ .../Converter/Event/v1_0_9/Event_V1_0_9_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_0_9/RedfishEvent_V1_0_9_Dxe.inf | 55 +++ .../Converter/Event/v1_1_0/Event_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_1_0/RedfishEvent_V1_1_0_Dxe.inf | 55 +++ .../Converter/Event/v1_1_1/Event_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_1_1/RedfishEvent_V1_1_1_Dxe.inf | 55 +++ .../Event/v1_1_10/Event_V1_1_10_Dxe.c | 427 ++++++++++++++++++ .../v1_1_10/RedfishEvent_V1_1_10_Dxe.inf | 55 +++ .../Event/v1_1_11/Event_V1_1_11_Dxe.c | 427 ++++++++++++++++++ .../v1_1_11/RedfishEvent_V1_1_11_Dxe.inf | 55 +++ .../Converter/Event/v1_1_2/Event_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_1_2/RedfishEvent_V1_1_2_Dxe.inf | 55 +++ .../Converter/Event/v1_1_3/Event_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_1_3/RedfishEvent_V1_1_3_Dxe.inf | 55 +++ .../Converter/Event/v1_1_4/Event_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_1_4/RedfishEvent_V1_1_4_Dxe.inf | 55 +++ .../Converter/Event/v1_1_5/Event_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_1_5/RedfishEvent_V1_1_5_Dxe.inf | 55 +++ .../Converter/Event/v1_1_6/Event_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_1_6/RedfishEvent_V1_1_6_Dxe.inf | 55 +++ .../Converter/Event/v1_1_7/Event_V1_1_7_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_1_7/RedfishEvent_V1_1_7_Dxe.inf | 55 +++ .../Converter/Event/v1_1_8/Event_V1_1_8_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_1_8/RedfishEvent_V1_1_8_Dxe.inf | 55 +++ .../Converter/Event/v1_1_9/Event_V1_1_9_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_1_9/RedfishEvent_V1_1_9_Dxe.inf | 55 +++ .../Converter/Event/v1_2_0/Event_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_2_0/RedfishEvent_V1_2_0_Dxe.inf | 55 +++ .../Converter/Event/v1_2_1/Event_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_2_1/RedfishEvent_V1_2_1_Dxe.inf | 55 +++ .../Converter/Event/v1_2_2/Event_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_2_2/RedfishEvent_V1_2_2_Dxe.inf | 55 +++ .../Converter/Event/v1_2_3/Event_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_2_3/RedfishEvent_V1_2_3_Dxe.inf | 55 +++ .../Converter/Event/v1_2_4/Event_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_2_4/RedfishEvent_V1_2_4_Dxe.inf | 55 +++ .../Converter/Event/v1_2_5/Event_V1_2_5_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_2_5/RedfishEvent_V1_2_5_Dxe.inf | 55 +++ .../Converter/Event/v1_2_6/Event_V1_2_6_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_2_6/RedfishEvent_V1_2_6_Dxe.inf | 55 +++ .../Converter/Event/v1_2_7/Event_V1_2_7_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_2_7/RedfishEvent_V1_2_7_Dxe.inf | 55 +++ .../Converter/Event/v1_2_8/Event_V1_2_8_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_2_8/RedfishEvent_V1_2_8_Dxe.inf | 55 +++ .../Converter/Event/v1_3_0/Event_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_3_0/RedfishEvent_V1_3_0_Dxe.inf | 55 +++ .../Converter/Event/v1_3_1/Event_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_3_1/RedfishEvent_V1_3_1_Dxe.inf | 55 +++ .../Converter/Event/v1_3_2/Event_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_3_2/RedfishEvent_V1_3_2_Dxe.inf | 55 +++ .../Converter/Event/v1_3_3/Event_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_3_3/RedfishEvent_V1_3_3_Dxe.inf | 55 +++ .../Converter/Event/v1_3_4/Event_V1_3_4_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_3_4/RedfishEvent_V1_3_4_Dxe.inf | 55 +++ .../Converter/Event/v1_3_5/Event_V1_3_5_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_3_5/RedfishEvent_V1_3_5_Dxe.inf | 55 +++ .../Converter/Event/v1_3_6/Event_V1_3_6_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_3_6/RedfishEvent_V1_3_6_Dxe.inf | 55 +++ .../Converter/Event/v1_4_0/Event_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_4_0/RedfishEvent_V1_4_0_Dxe.inf | 55 +++ .../Converter/Event/v1_4_1/Event_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_4_1/RedfishEvent_V1_4_1_Dxe.inf | 55 +++ .../Converter/Event/v1_4_2/Event_V1_4_2_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_4_2/RedfishEvent_V1_4_2_Dxe.inf | 55 +++ .../Converter/Event/v1_4_3/Event_V1_4_3_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_4_3/RedfishEvent_V1_4_3_Dxe.inf | 55 +++ .../Converter/Event/v1_4_4/Event_V1_4_4_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_4_4/RedfishEvent_V1_4_4_Dxe.inf | 55 +++ .../Converter/Event/v1_5_0/Event_V1_5_0_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_5_0/RedfishEvent_V1_5_0_Dxe.inf | 55 +++ .../Converter/Event/v1_5_1/Event_V1_5_1_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_5_1/RedfishEvent_V1_5_1_Dxe.inf | 55 +++ .../Converter/Event/v1_5_2/Event_V1_5_2_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_5_2/RedfishEvent_V1_5_2_Dxe.inf | 55 +++ .../Converter/Event/v1_6_0/Event_V1_6_0_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_6_0/RedfishEvent_V1_6_0_Dxe.inf | 55 +++ .../Converter/Event/v1_6_1/Event_V1_6_1_Dxe.c | 427 ++++++++++++++++++ .../Event/v1_6_1/RedfishEvent_V1_6_1_Dxe.inf | 55 +++ .../v1_0_0/EventDestination_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_0_0_Dxe.inf | 55 +++ .../v1_0_2/EventDestination_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/EventDestination_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/EventDestination_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_0_4_Dxe.inf | 55 +++ .../v1_0_5/EventDestination_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_0_5_Dxe.inf | 55 +++ .../v1_0_6/EventDestination_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_0_6_Dxe.inf | 55 +++ .../v1_0_7/EventDestination_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_0_7_Dxe.inf | 55 +++ .../v1_0_8/EventDestination_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_0_8_Dxe.inf | 55 +++ .../v1_0_9/EventDestination_V1_0_9_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_0_9_Dxe.inf | 55 +++ .../v1_10_0/EventDestination_V1_10_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_10_0_Dxe.inf | 55 +++ .../v1_1_0/EventDestination_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/EventDestination_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_1_1_Dxe.inf | 55 +++ .../v1_1_2/EventDestination_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_1_2_Dxe.inf | 55 +++ .../v1_1_3/EventDestination_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_1_3_Dxe.inf | 55 +++ .../v1_1_4/EventDestination_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_1_4_Dxe.inf | 55 +++ .../v1_1_5/EventDestination_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_1_5_Dxe.inf | 55 +++ .../v1_1_6/EventDestination_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_1_6_Dxe.inf | 55 +++ .../v1_1_7/EventDestination_V1_1_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_1_7_Dxe.inf | 55 +++ .../v1_1_8/EventDestination_V1_1_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_1_8_Dxe.inf | 55 +++ .../v1_2_0/EventDestination_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_2_0_Dxe.inf | 55 +++ .../v1_2_1/EventDestination_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_2_1_Dxe.inf | 55 +++ .../v1_2_2/EventDestination_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_2_2_Dxe.inf | 55 +++ .../v1_2_3/EventDestination_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_2_3_Dxe.inf | 55 +++ .../v1_2_4/EventDestination_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_2_4_Dxe.inf | 55 +++ .../v1_2_5/EventDestination_V1_2_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_2_5_Dxe.inf | 55 +++ .../v1_2_6/EventDestination_V1_2_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_2_6_Dxe.inf | 55 +++ .../v1_3_0/EventDestination_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_3_0_Dxe.inf | 55 +++ .../v1_3_1/EventDestination_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_3_1_Dxe.inf | 55 +++ .../v1_3_2/EventDestination_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_3_2_Dxe.inf | 55 +++ .../v1_3_3/EventDestination_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_3_3_Dxe.inf | 55 +++ .../v1_3_4/EventDestination_V1_3_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_3_4_Dxe.inf | 55 +++ .../v1_4_0/EventDestination_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_4_0_Dxe.inf | 55 +++ .../v1_4_1/EventDestination_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_4_1_Dxe.inf | 55 +++ .../v1_4_2/EventDestination_V1_4_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_4_2_Dxe.inf | 55 +++ .../v1_4_3/EventDestination_V1_4_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_4_3_Dxe.inf | 55 +++ .../v1_5_0/EventDestination_V1_5_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_5_0_Dxe.inf | 55 +++ .../v1_5_1/EventDestination_V1_5_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_5_1_Dxe.inf | 55 +++ .../v1_5_2/EventDestination_V1_5_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_5_2_Dxe.inf | 55 +++ .../v1_6_0/EventDestination_V1_6_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_6_0_Dxe.inf | 55 +++ .../v1_6_1/EventDestination_V1_6_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_6_1_Dxe.inf | 55 +++ .../v1_6_2/EventDestination_V1_6_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_6_2_Dxe.inf | 55 +++ .../v1_7_0/EventDestination_V1_7_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_7_0_Dxe.inf | 55 +++ .../v1_7_1/EventDestination_V1_7_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_7_1_Dxe.inf | 55 +++ .../v1_7_2/EventDestination_V1_7_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_7_2_Dxe.inf | 55 +++ .../v1_8_0/EventDestination_V1_8_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_8_0_Dxe.inf | 55 +++ .../v1_8_1/EventDestination_V1_8_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_8_1_Dxe.inf | 55 +++ .../v1_8_2/EventDestination_V1_8_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_8_2_Dxe.inf | 55 +++ .../v1_9_0/EventDestination_V1_9_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_9_0_Dxe.inf | 55 +++ .../v1_9_1/EventDestination_V1_9_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestination_V1_9_1_Dxe.inf | 55 +++ .../EventDestinationCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventDestinationCollection_Dxe.inf | 55 +++ .../v1_0_0/EventService_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishEventService_V1_0_0_Dxe.inf | 55 +++ .../v1_0_10/EventService_V1_0_10_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventService_V1_0_10_Dxe.inf | 55 +++ .../v1_0_11/EventService_V1_0_11_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventService_V1_0_11_Dxe.inf | 55 +++ .../v1_0_12/EventService_V1_0_12_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventService_V1_0_12_Dxe.inf | 55 +++ .../v1_0_13/EventService_V1_0_13_Dxe.c | 427 ++++++++++++++++++ .../RedfishEventService_V1_0_13_Dxe.inf | 55 +++ .../v1_0_2/EventService_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishEventService_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/EventService_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishEventService_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/EventService_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishEventService_V1_0_4_Dxe.inf | 55 +++ .../v1_0_5/EventService_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishEventService_V1_0_5_Dxe.inf | 55 +++ .../v1_0_6/EventService_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../v1_0_6/RedfishEventService_V1_0_6_Dxe.inf | 55 +++ .../v1_0_7/EventService_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../v1_0_7/RedfishEventService_V1_0_7_Dxe.inf | 55 +++ .../v1_0_8/EventService_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../v1_0_8/RedfishEventService_V1_0_8_Dxe.inf | 55 +++ .../v1_0_9/EventService_V1_0_9_Dxe.c | 427 ++++++++++++++++++ .../v1_0_9/RedfishEventService_V1_0_9_Dxe.inf | 55 +++ .../v1_1_0/EventService_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishEventService_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/EventService_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishEventService_V1_1_1_Dxe.inf | 55 +++ .../v1_1_2/EventService_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishEventService_V1_1_2_Dxe.inf | 55 +++ .../v1_1_3/EventService_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../v1_1_3/RedfishEventService_V1_1_3_Dxe.inf | 55 +++ .../v1_1_4/EventService_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../v1_1_4/RedfishEventService_V1_1_4_Dxe.inf | 55 +++ .../v1_1_5/EventService_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../v1_1_5/RedfishEventService_V1_1_5_Dxe.inf | 55 +++ .../v1_1_6/EventService_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../v1_1_6/RedfishEventService_V1_1_6_Dxe.inf | 55 +++ .../v1_2_0/EventService_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishEventService_V1_2_0_Dxe.inf | 55 +++ .../v1_2_1/EventService_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../v1_2_1/RedfishEventService_V1_2_1_Dxe.inf | 55 +++ .../v1_2_2/EventService_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../v1_2_2/RedfishEventService_V1_2_2_Dxe.inf | 55 +++ .../v1_2_3/EventService_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../v1_2_3/RedfishEventService_V1_2_3_Dxe.inf | 55 +++ .../v1_2_4/EventService_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../v1_2_4/RedfishEventService_V1_2_4_Dxe.inf | 55 +++ .../v1_2_5/EventService_V1_2_5_Dxe.c | 427 ++++++++++++++++++ .../v1_2_5/RedfishEventService_V1_2_5_Dxe.inf | 55 +++ .../v1_3_0/EventService_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../v1_3_0/RedfishEventService_V1_3_0_Dxe.inf | 55 +++ .../v1_3_1/EventService_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../v1_3_1/RedfishEventService_V1_3_1_Dxe.inf | 55 +++ .../v1_3_2/EventService_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../v1_3_2/RedfishEventService_V1_3_2_Dxe.inf | 55 +++ .../v1_3_3/EventService_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../v1_3_3/RedfishEventService_V1_3_3_Dxe.inf | 55 +++ .../v1_3_4/EventService_V1_3_4_Dxe.c | 427 ++++++++++++++++++ .../v1_3_4/RedfishEventService_V1_3_4_Dxe.inf | 55 +++ .../v1_4_0/EventService_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../v1_4_0/RedfishEventService_V1_4_0_Dxe.inf | 55 +++ .../v1_4_1/EventService_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../v1_4_1/RedfishEventService_V1_4_1_Dxe.inf | 55 +++ .../v1_4_2/EventService_V1_4_2_Dxe.c | 427 ++++++++++++++++++ .../v1_4_2/RedfishEventService_V1_4_2_Dxe.inf | 55 +++ .../v1_4_3/EventService_V1_4_3_Dxe.c | 427 ++++++++++++++++++ .../v1_4_3/RedfishEventService_V1_4_3_Dxe.inf | 55 +++ .../v1_5_0/EventService_V1_5_0_Dxe.c | 427 ++++++++++++++++++ .../v1_5_0/RedfishEventService_V1_5_0_Dxe.inf | 55 +++ .../v1_5_1/EventService_V1_5_1_Dxe.c | 427 ++++++++++++++++++ .../v1_5_1/RedfishEventService_V1_5_1_Dxe.inf | 55 +++ .../v1_5_2/EventService_V1_5_2_Dxe.c | 427 ++++++++++++++++++ .../v1_5_2/RedfishEventService_V1_5_2_Dxe.inf | 55 +++ .../v1_5_3/EventService_V1_5_3_Dxe.c | 427 ++++++++++++++++++ .../v1_5_3/RedfishEventService_V1_5_3_Dxe.inf | 55 +++ .../v1_6_0/EventService_V1_6_0_Dxe.c | 427 ++++++++++++++++++ .../v1_6_0/RedfishEventService_V1_6_0_Dxe.inf | 55 +++ .../v1_6_1/EventService_V1_6_1_Dxe.c | 427 ++++++++++++++++++ .../v1_6_1/RedfishEventService_V1_6_1_Dxe.inf | 55 +++ .../v1_6_2/EventService_V1_6_2_Dxe.c | 427 ++++++++++++++++++ .../v1_6_2/RedfishEventService_V1_6_2_Dxe.inf | 55 +++ .../v1_7_0/EventService_V1_7_0_Dxe.c | 427 ++++++++++++++++++ .../v1_7_0/RedfishEventService_V1_7_0_Dxe.inf | 55 +++ .../v1_7_1/EventService_V1_7_1_Dxe.c | 427 ++++++++++++++++++ .../v1_7_1/RedfishEventService_V1_7_1_Dxe.inf | 55 +++ .../ExternalAccountProvider_V1_0_0_Dxe.c | 427 ++++++++++++++++++ ...fishExternalAccountProvider_V1_0_0_Dxe.inf | 55 +++ .../ExternalAccountProvider_V1_0_1_Dxe.c | 427 ++++++++++++++++++ ...fishExternalAccountProvider_V1_0_1_Dxe.inf | 55 +++ .../ExternalAccountProvider_V1_0_2_Dxe.c | 427 ++++++++++++++++++ ...fishExternalAccountProvider_V1_0_2_Dxe.inf | 55 +++ .../ExternalAccountProvider_V1_0_3_Dxe.c | 427 ++++++++++++++++++ ...fishExternalAccountProvider_V1_0_3_Dxe.inf | 55 +++ .../ExternalAccountProvider_V1_0_4_Dxe.c | 427 ++++++++++++++++++ ...fishExternalAccountProvider_V1_0_4_Dxe.inf | 55 +++ .../ExternalAccountProvider_V1_0_5_Dxe.c | 427 ++++++++++++++++++ ...fishExternalAccountProvider_V1_0_5_Dxe.inf | 55 +++ .../ExternalAccountProvider_V1_1_0_Dxe.c | 427 ++++++++++++++++++ ...fishExternalAccountProvider_V1_1_0_Dxe.inf | 55 +++ .../ExternalAccountProvider_V1_1_1_Dxe.c | 427 ++++++++++++++++++ ...fishExternalAccountProvider_V1_1_1_Dxe.inf | 55 +++ .../ExternalAccountProvider_V1_1_2_Dxe.c | 427 ++++++++++++++++++ ...fishExternalAccountProvider_V1_1_2_Dxe.inf | 55 +++ .../ExternalAccountProvider_V1_1_3_Dxe.c | 427 ++++++++++++++++++ ...fishExternalAccountProvider_V1_1_3_Dxe.inf | 55 +++ .../ExternalAccountProvider_V1_1_4_Dxe.c | 427 ++++++++++++++++++ ...fishExternalAccountProvider_V1_1_4_Dxe.inf | 55 +++ .../ExternalAccountProvider_V1_2_0_Dxe.c | 427 ++++++++++++++++++ ...fishExternalAccountProvider_V1_2_0_Dxe.inf | 55 +++ .../ExternalAccountProviderCollection_Dxe.c | 427 ++++++++++++++++++ ...hExternalAccountProviderCollection_Dxe.inf | 55 +++ .../Fabric/v1_0_0/Fabric_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishFabric_V1_0_0_Dxe.inf | 55 +++ .../Fabric/v1_0_1/Fabric_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishFabric_V1_0_1_Dxe.inf | 55 +++ .../Fabric/v1_0_2/Fabric_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishFabric_V1_0_2_Dxe.inf | 55 +++ .../Fabric/v1_0_3/Fabric_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishFabric_V1_0_3_Dxe.inf | 55 +++ .../Fabric/v1_0_4/Fabric_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishFabric_V1_0_4_Dxe.inf | 55 +++ .../Fabric/v1_0_5/Fabric_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishFabric_V1_0_5_Dxe.inf | 55 +++ .../Fabric/v1_0_6/Fabric_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../v1_0_6/RedfishFabric_V1_0_6_Dxe.inf | 55 +++ .../Fabric/v1_0_7/Fabric_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../v1_0_7/RedfishFabric_V1_0_7_Dxe.inf | 55 +++ .../Fabric/v1_0_8/Fabric_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../v1_0_8/RedfishFabric_V1_0_8_Dxe.inf | 55 +++ .../Fabric/v1_1_0/Fabric_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishFabric_V1_1_0_Dxe.inf | 55 +++ .../Fabric/v1_1_1/Fabric_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishFabric_V1_1_1_Dxe.inf | 55 +++ .../Fabric/v1_1_2/Fabric_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishFabric_V1_1_2_Dxe.inf | 55 +++ .../Fabric/v1_2_0/Fabric_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishFabric_V1_2_0_Dxe.inf | 55 +++ .../Fabric/v1_2_1/Fabric_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../v1_2_1/RedfishFabric_V1_2_1_Dxe.inf | 55 +++ .../v1_0_0/FabricAdapter_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishFabricAdapter_V1_0_0_Dxe.inf | 55 +++ .../FabricAdapterCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishFabricAdapterCollection_Dxe.inf | 55 +++ .../FabricCollection/FabricCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishFabricCollection_Dxe.inf | 55 +++ .../Facility/v1_0_0/Facility_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishFacility_V1_0_0_Dxe.inf | 55 +++ .../Facility/v1_0_1/Facility_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishFacility_V1_0_1_Dxe.inf | 55 +++ .../Facility/v1_1_0/Facility_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishFacility_V1_1_0_Dxe.inf | 55 +++ .../FacilityCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishFacilityCollection_Dxe.inf | 55 +++ .../Converter/Fan/v1_0_0/Fan_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../Fan/v1_0_0/RedfishFan_V1_0_0_Dxe.inf | 55 +++ .../FanCollection/FanCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishFanCollection_Dxe.inf | 55 +++ .../v1_0_0/HostInterface_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishHostInterface_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/HostInterface_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishHostInterface_V1_0_1_Dxe.inf | 55 +++ .../v1_0_2/HostInterface_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishHostInterface_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/HostInterface_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishHostInterface_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/HostInterface_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishHostInterface_V1_0_4_Dxe.inf | 55 +++ .../v1_0_5/HostInterface_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishHostInterface_V1_0_5_Dxe.inf | 55 +++ .../v1_1_0/HostInterface_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishHostInterface_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/HostInterface_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishHostInterface_V1_1_1_Dxe.inf | 55 +++ .../v1_1_2/HostInterface_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishHostInterface_V1_1_2_Dxe.inf | 55 +++ .../v1_1_3/HostInterface_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishHostInterface_V1_1_3_Dxe.inf | 55 +++ .../v1_1_4/HostInterface_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishHostInterface_V1_1_4_Dxe.inf | 55 +++ .../v1_1_5/HostInterface_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishHostInterface_V1_1_5_Dxe.inf | 55 +++ .../v1_2_0/HostInterface_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishHostInterface_V1_2_0_Dxe.inf | 55 +++ .../v1_2_1/HostInterface_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishHostInterface_V1_2_1_Dxe.inf | 55 +++ .../v1_2_2/HostInterface_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishHostInterface_V1_2_2_Dxe.inf | 55 +++ .../v1_3_0/HostInterface_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishHostInterface_V1_3_0_Dxe.inf | 55 +++ .../HostInterfaceCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishHostInterfaceCollection_Dxe.inf | 55 +++ .../Converter/Job/v1_0_0/Job_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../Job/v1_0_0/RedfishJob_V1_0_0_Dxe.inf | 55 +++ .../Converter/Job/v1_0_1/Job_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../Job/v1_0_1/RedfishJob_V1_0_1_Dxe.inf | 55 +++ .../Converter/Job/v1_0_2/Job_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../Job/v1_0_2/RedfishJob_V1_0_2_Dxe.inf | 55 +++ .../Converter/Job/v1_0_3/Job_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../Job/v1_0_3/RedfishJob_V1_0_3_Dxe.inf | 55 +++ .../Converter/Job/v1_0_4/Job_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../Job/v1_0_4/RedfishJob_V1_0_4_Dxe.inf | 55 +++ .../Converter/Job/v1_0_5/Job_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../Job/v1_0_5/RedfishJob_V1_0_5_Dxe.inf | 55 +++ .../Converter/Job/v1_0_6/Job_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../Job/v1_0_6/RedfishJob_V1_0_6_Dxe.inf | 55 +++ .../JobCollection/JobCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishJobCollection_Dxe.inf | 55 +++ .../JobService/v1_0_0/JobService_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishJobService_V1_0_0_Dxe.inf | 55 +++ .../JobService/v1_0_1/JobService_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishJobService_V1_0_1_Dxe.inf | 55 +++ .../JobService/v1_0_2/JobService_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishJobService_V1_0_2_Dxe.inf | 55 +++ .../JobService/v1_0_3/JobService_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishJobService_V1_0_3_Dxe.inf | 55 +++ .../JobService/v1_0_4/JobService_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishJobService_V1_0_4_Dxe.inf | 55 +++ .../v1_0_0/JsonSchemaFile_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishJsonSchemaFile_V1_0_0_Dxe.inf | 55 +++ .../v1_0_2/JsonSchemaFile_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishJsonSchemaFile_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/JsonSchemaFile_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishJsonSchemaFile_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/JsonSchemaFile_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishJsonSchemaFile_V1_0_4_Dxe.inf | 55 +++ .../v1_0_5/JsonSchemaFile_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishJsonSchemaFile_V1_0_5_Dxe.inf | 55 +++ .../v1_0_6/JsonSchemaFile_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishJsonSchemaFile_V1_0_6_Dxe.inf | 55 +++ .../v1_0_7/JsonSchemaFile_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishJsonSchemaFile_V1_0_7_Dxe.inf | 55 +++ .../v1_0_8/JsonSchemaFile_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishJsonSchemaFile_V1_0_8_Dxe.inf | 55 +++ .../v1_1_0/JsonSchemaFile_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishJsonSchemaFile_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/JsonSchemaFile_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishJsonSchemaFile_V1_1_1_Dxe.inf | 55 +++ .../v1_1_2/JsonSchemaFile_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishJsonSchemaFile_V1_1_2_Dxe.inf | 55 +++ .../v1_1_3/JsonSchemaFile_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishJsonSchemaFile_V1_1_3_Dxe.inf | 55 +++ .../v1_1_4/JsonSchemaFile_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishJsonSchemaFile_V1_1_4_Dxe.inf | 55 +++ .../JsonSchemaFileCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishJsonSchemaFileCollection_Dxe.inf | 55 +++ .../LogEntry/v1_0_0/LogEntry_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishLogEntry_V1_0_0_Dxe.inf | 55 +++ .../LogEntry/v1_0_10/LogEntry_V1_0_10_Dxe.c | 427 ++++++++++++++++++ .../v1_0_10/RedfishLogEntry_V1_0_10_Dxe.inf | 55 +++ .../LogEntry/v1_0_11/LogEntry_V1_0_11_Dxe.c | 427 ++++++++++++++++++ .../v1_0_11/RedfishLogEntry_V1_0_11_Dxe.inf | 55 +++ .../LogEntry/v1_0_12/LogEntry_V1_0_12_Dxe.c | 427 ++++++++++++++++++ .../v1_0_12/RedfishLogEntry_V1_0_12_Dxe.inf | 55 +++ .../LogEntry/v1_0_13/LogEntry_V1_0_13_Dxe.c | 427 ++++++++++++++++++ .../v1_0_13/RedfishLogEntry_V1_0_13_Dxe.inf | 55 +++ .../LogEntry/v1_0_14/LogEntry_V1_0_14_Dxe.c | 427 ++++++++++++++++++ .../v1_0_14/RedfishLogEntry_V1_0_14_Dxe.inf | 55 +++ .../LogEntry/v1_0_2/LogEntry_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishLogEntry_V1_0_2_Dxe.inf | 55 +++ .../LogEntry/v1_0_3/LogEntry_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishLogEntry_V1_0_3_Dxe.inf | 55 +++ .../LogEntry/v1_0_4/LogEntry_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishLogEntry_V1_0_4_Dxe.inf | 55 +++ .../LogEntry/v1_0_5/LogEntry_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishLogEntry_V1_0_5_Dxe.inf | 55 +++ .../LogEntry/v1_0_6/LogEntry_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../v1_0_6/RedfishLogEntry_V1_0_6_Dxe.inf | 55 +++ .../LogEntry/v1_0_7/LogEntry_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../v1_0_7/RedfishLogEntry_V1_0_7_Dxe.inf | 55 +++ .../LogEntry/v1_0_8/LogEntry_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../v1_0_8/RedfishLogEntry_V1_0_8_Dxe.inf | 55 +++ .../LogEntry/v1_0_9/LogEntry_V1_0_9_Dxe.c | 427 ++++++++++++++++++ .../v1_0_9/RedfishLogEntry_V1_0_9_Dxe.inf | 55 +++ .../LogEntry/v1_1_0/LogEntry_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishLogEntry_V1_1_0_Dxe.inf | 55 +++ .../LogEntry/v1_1_1/LogEntry_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishLogEntry_V1_1_1_Dxe.inf | 55 +++ .../LogEntry/v1_1_10/LogEntry_V1_1_10_Dxe.c | 427 ++++++++++++++++++ .../v1_1_10/RedfishLogEntry_V1_1_10_Dxe.inf | 55 +++ .../LogEntry/v1_1_11/LogEntry_V1_1_11_Dxe.c | 427 ++++++++++++++++++ .../v1_1_11/RedfishLogEntry_V1_1_11_Dxe.inf | 55 +++ .../LogEntry/v1_1_12/LogEntry_V1_1_12_Dxe.c | 427 ++++++++++++++++++ .../v1_1_12/RedfishLogEntry_V1_1_12_Dxe.inf | 55 +++ .../LogEntry/v1_1_2/LogEntry_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishLogEntry_V1_1_2_Dxe.inf | 55 +++ .../LogEntry/v1_1_3/LogEntry_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../v1_1_3/RedfishLogEntry_V1_1_3_Dxe.inf | 55 +++ .../LogEntry/v1_1_4/LogEntry_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../v1_1_4/RedfishLogEntry_V1_1_4_Dxe.inf | 55 +++ .../LogEntry/v1_1_5/LogEntry_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../v1_1_5/RedfishLogEntry_V1_1_5_Dxe.inf | 55 +++ .../LogEntry/v1_1_6/LogEntry_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../v1_1_6/RedfishLogEntry_V1_1_6_Dxe.inf | 55 +++ .../LogEntry/v1_1_7/LogEntry_V1_1_7_Dxe.c | 427 ++++++++++++++++++ .../v1_1_7/RedfishLogEntry_V1_1_7_Dxe.inf | 55 +++ .../LogEntry/v1_1_8/LogEntry_V1_1_8_Dxe.c | 427 ++++++++++++++++++ .../v1_1_8/RedfishLogEntry_V1_1_8_Dxe.inf | 55 +++ .../LogEntry/v1_1_9/LogEntry_V1_1_9_Dxe.c | 427 ++++++++++++++++++ .../v1_1_9/RedfishLogEntry_V1_1_9_Dxe.inf | 55 +++ .../LogEntry/v1_2_0/LogEntry_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishLogEntry_V1_2_0_Dxe.inf | 55 +++ .../LogEntry/v1_2_1/LogEntry_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../v1_2_1/RedfishLogEntry_V1_2_1_Dxe.inf | 55 +++ .../LogEntry/v1_2_10/LogEntry_V1_2_10_Dxe.c | 427 ++++++++++++++++++ .../v1_2_10/RedfishLogEntry_V1_2_10_Dxe.inf | 55 +++ .../LogEntry/v1_2_2/LogEntry_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../v1_2_2/RedfishLogEntry_V1_2_2_Dxe.inf | 55 +++ .../LogEntry/v1_2_3/LogEntry_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../v1_2_3/RedfishLogEntry_V1_2_3_Dxe.inf | 55 +++ .../LogEntry/v1_2_4/LogEntry_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../v1_2_4/RedfishLogEntry_V1_2_4_Dxe.inf | 55 +++ .../LogEntry/v1_2_5/LogEntry_V1_2_5_Dxe.c | 427 ++++++++++++++++++ .../v1_2_5/RedfishLogEntry_V1_2_5_Dxe.inf | 55 +++ .../LogEntry/v1_2_6/LogEntry_V1_2_6_Dxe.c | 427 ++++++++++++++++++ .../v1_2_6/RedfishLogEntry_V1_2_6_Dxe.inf | 55 +++ .../LogEntry/v1_2_7/LogEntry_V1_2_7_Dxe.c | 427 ++++++++++++++++++ .../v1_2_7/RedfishLogEntry_V1_2_7_Dxe.inf | 55 +++ .../LogEntry/v1_2_8/LogEntry_V1_2_8_Dxe.c | 427 ++++++++++++++++++ .../v1_2_8/RedfishLogEntry_V1_2_8_Dxe.inf | 55 +++ .../LogEntry/v1_2_9/LogEntry_V1_2_9_Dxe.c | 427 ++++++++++++++++++ .../v1_2_9/RedfishLogEntry_V1_2_9_Dxe.inf | 55 +++ .../LogEntry/v1_3_0/LogEntry_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../v1_3_0/RedfishLogEntry_V1_3_0_Dxe.inf | 55 +++ .../LogEntry/v1_3_1/LogEntry_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../v1_3_1/RedfishLogEntry_V1_3_1_Dxe.inf | 55 +++ .../LogEntry/v1_3_2/LogEntry_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../v1_3_2/RedfishLogEntry_V1_3_2_Dxe.inf | 55 +++ .../LogEntry/v1_3_3/LogEntry_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../v1_3_3/RedfishLogEntry_V1_3_3_Dxe.inf | 55 +++ .../LogEntry/v1_3_4/LogEntry_V1_3_4_Dxe.c | 427 ++++++++++++++++++ .../v1_3_4/RedfishLogEntry_V1_3_4_Dxe.inf | 55 +++ .../LogEntry/v1_3_5/LogEntry_V1_3_5_Dxe.c | 427 ++++++++++++++++++ .../v1_3_5/RedfishLogEntry_V1_3_5_Dxe.inf | 55 +++ .../LogEntry/v1_3_6/LogEntry_V1_3_6_Dxe.c | 427 ++++++++++++++++++ .../v1_3_6/RedfishLogEntry_V1_3_6_Dxe.inf | 55 +++ .../LogEntry/v1_3_7/LogEntry_V1_3_7_Dxe.c | 427 ++++++++++++++++++ .../v1_3_7/RedfishLogEntry_V1_3_7_Dxe.inf | 55 +++ .../LogEntry/v1_3_8/LogEntry_V1_3_8_Dxe.c | 427 ++++++++++++++++++ .../v1_3_8/RedfishLogEntry_V1_3_8_Dxe.inf | 55 +++ .../LogEntry/v1_3_9/LogEntry_V1_3_9_Dxe.c | 427 ++++++++++++++++++ .../v1_3_9/RedfishLogEntry_V1_3_9_Dxe.inf | 55 +++ .../LogEntry/v1_4_0/LogEntry_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../v1_4_0/RedfishLogEntry_V1_4_0_Dxe.inf | 55 +++ .../LogEntry/v1_4_1/LogEntry_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../v1_4_1/RedfishLogEntry_V1_4_1_Dxe.inf | 55 +++ .../LogEntry/v1_4_2/LogEntry_V1_4_2_Dxe.c | 427 ++++++++++++++++++ .../v1_4_2/RedfishLogEntry_V1_4_2_Dxe.inf | 55 +++ .../LogEntry/v1_4_3/LogEntry_V1_4_3_Dxe.c | 427 ++++++++++++++++++ .../v1_4_3/RedfishLogEntry_V1_4_3_Dxe.inf | 55 +++ .../LogEntry/v1_4_4/LogEntry_V1_4_4_Dxe.c | 427 ++++++++++++++++++ .../v1_4_4/RedfishLogEntry_V1_4_4_Dxe.inf | 55 +++ .../LogEntry/v1_4_5/LogEntry_V1_4_5_Dxe.c | 427 ++++++++++++++++++ .../v1_4_5/RedfishLogEntry_V1_4_5_Dxe.inf | 55 +++ .../LogEntry/v1_4_6/LogEntry_V1_4_6_Dxe.c | 427 ++++++++++++++++++ .../v1_4_6/RedfishLogEntry_V1_4_6_Dxe.inf | 55 +++ .../LogEntry/v1_4_7/LogEntry_V1_4_7_Dxe.c | 427 ++++++++++++++++++ .../v1_4_7/RedfishLogEntry_V1_4_7_Dxe.inf | 55 +++ .../LogEntry/v1_4_8/LogEntry_V1_4_8_Dxe.c | 427 ++++++++++++++++++ .../v1_4_8/RedfishLogEntry_V1_4_8_Dxe.inf | 55 +++ .../LogEntry/v1_5_0/LogEntry_V1_5_0_Dxe.c | 427 ++++++++++++++++++ .../v1_5_0/RedfishLogEntry_V1_5_0_Dxe.inf | 55 +++ .../LogEntry/v1_5_1/LogEntry_V1_5_1_Dxe.c | 427 ++++++++++++++++++ .../v1_5_1/RedfishLogEntry_V1_5_1_Dxe.inf | 55 +++ .../LogEntry/v1_5_2/LogEntry_V1_5_2_Dxe.c | 427 ++++++++++++++++++ .../v1_5_2/RedfishLogEntry_V1_5_2_Dxe.inf | 55 +++ .../LogEntry/v1_5_3/LogEntry_V1_5_3_Dxe.c | 427 ++++++++++++++++++ .../v1_5_3/RedfishLogEntry_V1_5_3_Dxe.inf | 55 +++ .../LogEntry/v1_5_4/LogEntry_V1_5_4_Dxe.c | 427 ++++++++++++++++++ .../v1_5_4/RedfishLogEntry_V1_5_4_Dxe.inf | 55 +++ .../LogEntry/v1_6_0/LogEntry_V1_6_0_Dxe.c | 427 ++++++++++++++++++ .../v1_6_0/RedfishLogEntry_V1_6_0_Dxe.inf | 55 +++ .../LogEntry/v1_6_1/LogEntry_V1_6_1_Dxe.c | 427 ++++++++++++++++++ .../v1_6_1/RedfishLogEntry_V1_6_1_Dxe.inf | 55 +++ .../LogEntry/v1_6_2/LogEntry_V1_6_2_Dxe.c | 427 ++++++++++++++++++ .../v1_6_2/RedfishLogEntry_V1_6_2_Dxe.inf | 55 +++ .../LogEntry/v1_6_3/LogEntry_V1_6_3_Dxe.c | 427 ++++++++++++++++++ .../v1_6_3/RedfishLogEntry_V1_6_3_Dxe.inf | 55 +++ .../LogEntry/v1_7_0/LogEntry_V1_7_0_Dxe.c | 427 ++++++++++++++++++ .../v1_7_0/RedfishLogEntry_V1_7_0_Dxe.inf | 55 +++ .../LogEntry/v1_7_1/LogEntry_V1_7_1_Dxe.c | 427 ++++++++++++++++++ .../v1_7_1/RedfishLogEntry_V1_7_1_Dxe.inf | 55 +++ .../LogEntry/v1_8_0/LogEntry_V1_8_0_Dxe.c | 427 ++++++++++++++++++ .../v1_8_0/RedfishLogEntry_V1_8_0_Dxe.inf | 55 +++ .../LogEntryCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishLogEntryCollection_Dxe.inf | 55 +++ .../LogService/v1_0_0/LogService_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishLogService_V1_0_0_Dxe.inf | 55 +++ .../LogService/v1_0_2/LogService_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishLogService_V1_0_2_Dxe.inf | 55 +++ .../LogService/v1_0_3/LogService_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishLogService_V1_0_3_Dxe.inf | 55 +++ .../LogService/v1_0_4/LogService_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishLogService_V1_0_4_Dxe.inf | 55 +++ .../LogService/v1_0_5/LogService_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishLogService_V1_0_5_Dxe.inf | 55 +++ .../LogService/v1_0_6/LogService_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../v1_0_6/RedfishLogService_V1_0_6_Dxe.inf | 55 +++ .../LogService/v1_0_7/LogService_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../v1_0_7/RedfishLogService_V1_0_7_Dxe.inf | 55 +++ .../LogService/v1_0_8/LogService_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../v1_0_8/RedfishLogService_V1_0_8_Dxe.inf | 55 +++ .../LogService/v1_1_0/LogService_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishLogService_V1_1_0_Dxe.inf | 55 +++ .../LogService/v1_1_1/LogService_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishLogService_V1_1_1_Dxe.inf | 55 +++ .../LogService/v1_1_2/LogService_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishLogService_V1_1_2_Dxe.inf | 55 +++ .../LogService/v1_1_3/LogService_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../v1_1_3/RedfishLogService_V1_1_3_Dxe.inf | 55 +++ .../LogService/v1_2_0/LogService_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishLogService_V1_2_0_Dxe.inf | 55 +++ .../LogServiceCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishLogServiceCollection_Dxe.inf | 55 +++ .../Manager/v1_0_0/Manager_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishManager_V1_0_0_Dxe.inf | 55 +++ .../Manager/v1_0_1/Manager_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishManager_V1_0_1_Dxe.inf | 55 +++ .../Manager/v1_0_10/Manager_V1_0_10_Dxe.c | 427 ++++++++++++++++++ .../v1_0_10/RedfishManager_V1_0_10_Dxe.inf | 55 +++ .../Manager/v1_0_11/Manager_V1_0_11_Dxe.c | 427 ++++++++++++++++++ .../v1_0_11/RedfishManager_V1_0_11_Dxe.inf | 55 +++ .../Manager/v1_0_12/Manager_V1_0_12_Dxe.c | 427 ++++++++++++++++++ .../v1_0_12/RedfishManager_V1_0_12_Dxe.inf | 55 +++ .../Manager/v1_0_13/Manager_V1_0_13_Dxe.c | 427 ++++++++++++++++++ .../v1_0_13/RedfishManager_V1_0_13_Dxe.inf | 55 +++ .../Manager/v1_0_14/Manager_V1_0_14_Dxe.c | 427 ++++++++++++++++++ .../v1_0_14/RedfishManager_V1_0_14_Dxe.inf | 55 +++ .../Manager/v1_0_2/Manager_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishManager_V1_0_2_Dxe.inf | 55 +++ .../Manager/v1_0_3/Manager_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishManager_V1_0_3_Dxe.inf | 55 +++ .../Manager/v1_0_4/Manager_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishManager_V1_0_4_Dxe.inf | 55 +++ .../Manager/v1_0_5/Manager_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishManager_V1_0_5_Dxe.inf | 55 +++ .../Manager/v1_0_6/Manager_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../v1_0_6/RedfishManager_V1_0_6_Dxe.inf | 55 +++ .../Manager/v1_0_7/Manager_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../v1_0_7/RedfishManager_V1_0_7_Dxe.inf | 55 +++ .../Manager/v1_0_8/Manager_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../v1_0_8/RedfishManager_V1_0_8_Dxe.inf | 55 +++ .../Manager/v1_0_9/Manager_V1_0_9_Dxe.c | 427 ++++++++++++++++++ .../v1_0_9/RedfishManager_V1_0_9_Dxe.inf | 55 +++ .../Manager/v1_10_0/Manager_V1_10_0_Dxe.c | 427 ++++++++++++++++++ .../v1_10_0/RedfishManager_V1_10_0_Dxe.inf | 55 +++ .../Manager/v1_10_1/Manager_V1_10_1_Dxe.c | 427 ++++++++++++++++++ .../v1_10_1/RedfishManager_V1_10_1_Dxe.inf | 55 +++ .../Manager/v1_11_0/Manager_V1_11_0_Dxe.c | 427 ++++++++++++++++++ .../v1_11_0/RedfishManager_V1_11_0_Dxe.inf | 55 +++ .../Manager/v1_1_0/Manager_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishManager_V1_1_0_Dxe.inf | 55 +++ .../Manager/v1_1_1/Manager_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishManager_V1_1_1_Dxe.inf | 55 +++ .../Manager/v1_1_10/Manager_V1_1_10_Dxe.c | 427 ++++++++++++++++++ .../v1_1_10/RedfishManager_V1_1_10_Dxe.inf | 55 +++ .../Manager/v1_1_11/Manager_V1_1_11_Dxe.c | 427 ++++++++++++++++++ .../v1_1_11/RedfishManager_V1_1_11_Dxe.inf | 55 +++ .../Manager/v1_1_12/Manager_V1_1_12_Dxe.c | 427 ++++++++++++++++++ .../v1_1_12/RedfishManager_V1_1_12_Dxe.inf | 55 +++ .../Manager/v1_1_2/Manager_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishManager_V1_1_2_Dxe.inf | 55 +++ .../Manager/v1_1_3/Manager_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../v1_1_3/RedfishManager_V1_1_3_Dxe.inf | 55 +++ .../Manager/v1_1_4/Manager_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../v1_1_4/RedfishManager_V1_1_4_Dxe.inf | 55 +++ .../Manager/v1_1_5/Manager_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../v1_1_5/RedfishManager_V1_1_5_Dxe.inf | 55 +++ .../Manager/v1_1_6/Manager_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../v1_1_6/RedfishManager_V1_1_6_Dxe.inf | 55 +++ .../Manager/v1_1_7/Manager_V1_1_7_Dxe.c | 427 ++++++++++++++++++ .../v1_1_7/RedfishManager_V1_1_7_Dxe.inf | 55 +++ .../Manager/v1_1_8/Manager_V1_1_8_Dxe.c | 427 ++++++++++++++++++ .../v1_1_8/RedfishManager_V1_1_8_Dxe.inf | 55 +++ .../Manager/v1_1_9/Manager_V1_1_9_Dxe.c | 427 ++++++++++++++++++ .../v1_1_9/RedfishManager_V1_1_9_Dxe.inf | 55 +++ .../Manager/v1_2_0/Manager_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishManager_V1_2_0_Dxe.inf | 55 +++ .../Manager/v1_2_1/Manager_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../v1_2_1/RedfishManager_V1_2_1_Dxe.inf | 55 +++ .../Manager/v1_2_10/Manager_V1_2_10_Dxe.c | 427 ++++++++++++++++++ .../v1_2_10/RedfishManager_V1_2_10_Dxe.inf | 55 +++ .../Manager/v1_2_11/Manager_V1_2_11_Dxe.c | 427 ++++++++++++++++++ .../v1_2_11/RedfishManager_V1_2_11_Dxe.inf | 55 +++ .../Manager/v1_2_12/Manager_V1_2_12_Dxe.c | 427 ++++++++++++++++++ .../v1_2_12/RedfishManager_V1_2_12_Dxe.inf | 55 +++ .../Manager/v1_2_2/Manager_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../v1_2_2/RedfishManager_V1_2_2_Dxe.inf | 55 +++ .../Manager/v1_2_3/Manager_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../v1_2_3/RedfishManager_V1_2_3_Dxe.inf | 55 +++ .../Manager/v1_2_4/Manager_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../v1_2_4/RedfishManager_V1_2_4_Dxe.inf | 55 +++ .../Manager/v1_2_5/Manager_V1_2_5_Dxe.c | 427 ++++++++++++++++++ .../v1_2_5/RedfishManager_V1_2_5_Dxe.inf | 55 +++ .../Manager/v1_2_6/Manager_V1_2_6_Dxe.c | 427 ++++++++++++++++++ .../v1_2_6/RedfishManager_V1_2_6_Dxe.inf | 55 +++ .../Manager/v1_2_7/Manager_V1_2_7_Dxe.c | 427 ++++++++++++++++++ .../v1_2_7/RedfishManager_V1_2_7_Dxe.inf | 55 +++ .../Manager/v1_2_8/Manager_V1_2_8_Dxe.c | 427 ++++++++++++++++++ .../v1_2_8/RedfishManager_V1_2_8_Dxe.inf | 55 +++ .../Manager/v1_2_9/Manager_V1_2_9_Dxe.c | 427 ++++++++++++++++++ .../v1_2_9/RedfishManager_V1_2_9_Dxe.inf | 55 +++ .../Manager/v1_3_0/Manager_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../v1_3_0/RedfishManager_V1_3_0_Dxe.inf | 55 +++ .../Manager/v1_3_1/Manager_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../v1_3_1/RedfishManager_V1_3_1_Dxe.inf | 55 +++ .../Manager/v1_3_10/Manager_V1_3_10_Dxe.c | 427 ++++++++++++++++++ .../v1_3_10/RedfishManager_V1_3_10_Dxe.inf | 55 +++ .../Manager/v1_3_11/Manager_V1_3_11_Dxe.c | 427 ++++++++++++++++++ .../v1_3_11/RedfishManager_V1_3_11_Dxe.inf | 55 +++ .../Manager/v1_3_2/Manager_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../v1_3_2/RedfishManager_V1_3_2_Dxe.inf | 55 +++ .../Manager/v1_3_3/Manager_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../v1_3_3/RedfishManager_V1_3_3_Dxe.inf | 55 +++ .../Manager/v1_3_4/Manager_V1_3_4_Dxe.c | 427 ++++++++++++++++++ .../v1_3_4/RedfishManager_V1_3_4_Dxe.inf | 55 +++ .../Manager/v1_3_5/Manager_V1_3_5_Dxe.c | 427 ++++++++++++++++++ .../v1_3_5/RedfishManager_V1_3_5_Dxe.inf | 55 +++ .../Manager/v1_3_6/Manager_V1_3_6_Dxe.c | 427 ++++++++++++++++++ .../v1_3_6/RedfishManager_V1_3_6_Dxe.inf | 55 +++ .../Manager/v1_3_7/Manager_V1_3_7_Dxe.c | 427 ++++++++++++++++++ .../v1_3_7/RedfishManager_V1_3_7_Dxe.inf | 55 +++ .../Manager/v1_3_8/Manager_V1_3_8_Dxe.c | 427 ++++++++++++++++++ .../v1_3_8/RedfishManager_V1_3_8_Dxe.inf | 55 +++ .../Manager/v1_3_9/Manager_V1_3_9_Dxe.c | 427 ++++++++++++++++++ .../v1_3_9/RedfishManager_V1_3_9_Dxe.inf | 55 +++ .../Manager/v1_4_0/Manager_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../v1_4_0/RedfishManager_V1_4_0_Dxe.inf | 55 +++ .../Manager/v1_4_1/Manager_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../v1_4_1/RedfishManager_V1_4_1_Dxe.inf | 55 +++ .../Manager/v1_4_2/Manager_V1_4_2_Dxe.c | 427 ++++++++++++++++++ .../v1_4_2/RedfishManager_V1_4_2_Dxe.inf | 55 +++ .../Manager/v1_4_3/Manager_V1_4_3_Dxe.c | 427 ++++++++++++++++++ .../v1_4_3/RedfishManager_V1_4_3_Dxe.inf | 55 +++ .../Manager/v1_4_4/Manager_V1_4_4_Dxe.c | 427 ++++++++++++++++++ .../v1_4_4/RedfishManager_V1_4_4_Dxe.inf | 55 +++ .../Manager/v1_4_5/Manager_V1_4_5_Dxe.c | 427 ++++++++++++++++++ .../v1_4_5/RedfishManager_V1_4_5_Dxe.inf | 55 +++ .../Manager/v1_4_6/Manager_V1_4_6_Dxe.c | 427 ++++++++++++++++++ .../v1_4_6/RedfishManager_V1_4_6_Dxe.inf | 55 +++ .../Manager/v1_4_7/Manager_V1_4_7_Dxe.c | 427 ++++++++++++++++++ .../v1_4_7/RedfishManager_V1_4_7_Dxe.inf | 55 +++ .../Manager/v1_4_8/Manager_V1_4_8_Dxe.c | 427 ++++++++++++++++++ .../v1_4_8/RedfishManager_V1_4_8_Dxe.inf | 55 +++ .../Manager/v1_5_0/Manager_V1_5_0_Dxe.c | 427 ++++++++++++++++++ .../v1_5_0/RedfishManager_V1_5_0_Dxe.inf | 55 +++ .../Manager/v1_5_1/Manager_V1_5_1_Dxe.c | 427 ++++++++++++++++++ .../v1_5_1/RedfishManager_V1_5_1_Dxe.inf | 55 +++ .../Manager/v1_5_2/Manager_V1_5_2_Dxe.c | 427 ++++++++++++++++++ .../v1_5_2/RedfishManager_V1_5_2_Dxe.inf | 55 +++ .../Manager/v1_5_3/Manager_V1_5_3_Dxe.c | 427 ++++++++++++++++++ .../v1_5_3/RedfishManager_V1_5_3_Dxe.inf | 55 +++ .../Manager/v1_5_4/Manager_V1_5_4_Dxe.c | 427 ++++++++++++++++++ .../v1_5_4/RedfishManager_V1_5_4_Dxe.inf | 55 +++ .../Manager/v1_5_5/Manager_V1_5_5_Dxe.c | 427 ++++++++++++++++++ .../v1_5_5/RedfishManager_V1_5_5_Dxe.inf | 55 +++ .../Manager/v1_5_6/Manager_V1_5_6_Dxe.c | 427 ++++++++++++++++++ .../v1_5_6/RedfishManager_V1_5_6_Dxe.inf | 55 +++ .../Manager/v1_5_7/Manager_V1_5_7_Dxe.c | 427 ++++++++++++++++++ .../v1_5_7/RedfishManager_V1_5_7_Dxe.inf | 55 +++ .../Manager/v1_6_0/Manager_V1_6_0_Dxe.c | 427 ++++++++++++++++++ .../v1_6_0/RedfishManager_V1_6_0_Dxe.inf | 55 +++ .../Manager/v1_6_1/Manager_V1_6_1_Dxe.c | 427 ++++++++++++++++++ .../v1_6_1/RedfishManager_V1_6_1_Dxe.inf | 55 +++ .../Manager/v1_6_2/Manager_V1_6_2_Dxe.c | 427 ++++++++++++++++++ .../v1_6_2/RedfishManager_V1_6_2_Dxe.inf | 55 +++ .../Manager/v1_6_3/Manager_V1_6_3_Dxe.c | 427 ++++++++++++++++++ .../v1_6_3/RedfishManager_V1_6_3_Dxe.inf | 55 +++ .../Manager/v1_6_4/Manager_V1_6_4_Dxe.c | 427 ++++++++++++++++++ .../v1_6_4/RedfishManager_V1_6_4_Dxe.inf | 55 +++ .../Manager/v1_7_0/Manager_V1_7_0_Dxe.c | 427 ++++++++++++++++++ .../v1_7_0/RedfishManager_V1_7_0_Dxe.inf | 55 +++ .../Manager/v1_7_1/Manager_V1_7_1_Dxe.c | 427 ++++++++++++++++++ .../v1_7_1/RedfishManager_V1_7_1_Dxe.inf | 55 +++ .../Manager/v1_7_2/Manager_V1_7_2_Dxe.c | 427 ++++++++++++++++++ .../v1_7_2/RedfishManager_V1_7_2_Dxe.inf | 55 +++ .../Manager/v1_7_3/Manager_V1_7_3_Dxe.c | 427 ++++++++++++++++++ .../v1_7_3/RedfishManager_V1_7_3_Dxe.inf | 55 +++ .../Manager/v1_7_4/Manager_V1_7_4_Dxe.c | 427 ++++++++++++++++++ .../v1_7_4/RedfishManager_V1_7_4_Dxe.inf | 55 +++ .../Manager/v1_8_0/Manager_V1_8_0_Dxe.c | 427 ++++++++++++++++++ .../v1_8_0/RedfishManager_V1_8_0_Dxe.inf | 55 +++ .../Manager/v1_8_1/Manager_V1_8_1_Dxe.c | 427 ++++++++++++++++++ .../v1_8_1/RedfishManager_V1_8_1_Dxe.inf | 55 +++ .../Manager/v1_8_2/Manager_V1_8_2_Dxe.c | 427 ++++++++++++++++++ .../v1_8_2/RedfishManager_V1_8_2_Dxe.inf | 55 +++ .../Manager/v1_8_3/Manager_V1_8_3_Dxe.c | 427 ++++++++++++++++++ .../v1_8_3/RedfishManager_V1_8_3_Dxe.inf | 55 +++ .../Manager/v1_9_0/Manager_V1_9_0_Dxe.c | 427 ++++++++++++++++++ .../v1_9_0/RedfishManager_V1_9_0_Dxe.inf | 55 +++ .../Manager/v1_9_1/Manager_V1_9_1_Dxe.c | 427 ++++++++++++++++++ .../v1_9_1/RedfishManager_V1_9_1_Dxe.inf | 55 +++ .../Manager/v1_9_2/Manager_V1_9_2_Dxe.c | 427 ++++++++++++++++++ .../v1_9_2/RedfishManager_V1_9_2_Dxe.inf | 55 +++ .../v1_0_0/ManagerAccount_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_0_0_Dxe.inf | 55 +++ .../v1_0_10/ManagerAccount_V1_0_10_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_0_10_Dxe.inf | 55 +++ .../v1_0_11/ManagerAccount_V1_0_11_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_0_11_Dxe.inf | 55 +++ .../v1_0_2/ManagerAccount_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/ManagerAccount_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/ManagerAccount_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_0_4_Dxe.inf | 55 +++ .../v1_0_5/ManagerAccount_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_0_5_Dxe.inf | 55 +++ .../v1_0_6/ManagerAccount_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_0_6_Dxe.inf | 55 +++ .../v1_0_7/ManagerAccount_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_0_7_Dxe.inf | 55 +++ .../v1_0_8/ManagerAccount_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_0_8_Dxe.inf | 55 +++ .../v1_0_9/ManagerAccount_V1_0_9_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_0_9_Dxe.inf | 55 +++ .../v1_1_0/ManagerAccount_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/ManagerAccount_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_1_1_Dxe.inf | 55 +++ .../v1_1_2/ManagerAccount_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_1_2_Dxe.inf | 55 +++ .../v1_1_3/ManagerAccount_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_1_3_Dxe.inf | 55 +++ .../v1_1_4/ManagerAccount_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_1_4_Dxe.inf | 55 +++ .../v1_1_5/ManagerAccount_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_1_5_Dxe.inf | 55 +++ .../v1_1_6/ManagerAccount_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_1_6_Dxe.inf | 55 +++ .../v1_1_7/ManagerAccount_V1_1_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_1_7_Dxe.inf | 55 +++ .../v1_2_0/ManagerAccount_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_2_0_Dxe.inf | 55 +++ .../v1_2_1/ManagerAccount_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_2_1_Dxe.inf | 55 +++ .../v1_2_2/ManagerAccount_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_2_2_Dxe.inf | 55 +++ .../v1_2_3/ManagerAccount_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_2_3_Dxe.inf | 55 +++ .../v1_2_4/ManagerAccount_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_2_4_Dxe.inf | 55 +++ .../v1_3_0/ManagerAccount_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_3_0_Dxe.inf | 55 +++ .../v1_3_1/ManagerAccount_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_3_1_Dxe.inf | 55 +++ .../v1_3_2/ManagerAccount_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_3_2_Dxe.inf | 55 +++ .../v1_3_3/ManagerAccount_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_3_3_Dxe.inf | 55 +++ .../v1_4_0/ManagerAccount_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_4_0_Dxe.inf | 55 +++ .../v1_4_1/ManagerAccount_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_4_1_Dxe.inf | 55 +++ .../v1_4_2/ManagerAccount_V1_4_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_4_2_Dxe.inf | 55 +++ .../v1_4_3/ManagerAccount_V1_4_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_4_3_Dxe.inf | 55 +++ .../v1_4_4/ManagerAccount_V1_4_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_4_4_Dxe.inf | 55 +++ .../v1_5_0/ManagerAccount_V1_5_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_5_0_Dxe.inf | 55 +++ .../v1_5_1/ManagerAccount_V1_5_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_5_1_Dxe.inf | 55 +++ .../v1_5_2/ManagerAccount_V1_5_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_5_2_Dxe.inf | 55 +++ .../v1_5_3/ManagerAccount_V1_5_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_5_3_Dxe.inf | 55 +++ .../v1_6_0/ManagerAccount_V1_6_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_6_0_Dxe.inf | 55 +++ .../v1_6_1/ManagerAccount_V1_6_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_6_1_Dxe.inf | 55 +++ .../v1_6_2/ManagerAccount_V1_6_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_6_2_Dxe.inf | 55 +++ .../v1_7_0/ManagerAccount_V1_7_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccount_V1_7_0_Dxe.inf | 55 +++ .../ManagerAccountCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerAccountCollection_Dxe.inf | 55 +++ .../ManagerCollection/ManagerCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishManagerCollection_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_0_0_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_0_0_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_0_2_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_0_2_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_0_3_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_0_3_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_0_4_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_0_4_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_0_5_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_0_5_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_0_6_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_0_6_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_0_7_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_0_7_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_0_8_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_0_8_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_0_9_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_0_9_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_1_0_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_1_0_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_1_1_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_1_1_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_1_2_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_1_2_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_1_3_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_1_3_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_1_4_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_1_4_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_1_5_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_1_5_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_1_6_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_1_6_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_2_0_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_2_0_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_2_1_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_2_1_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_2_2_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_2_2_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_2_3_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_2_3_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_2_4_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_2_4_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_2_5_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_2_5_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_3_0_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_3_0_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_3_1_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_3_1_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_3_2_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_3_2_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_3_3_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_3_3_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_3_4_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_3_4_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_4_0_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_4_0_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_4_1_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_4_1_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_4_2_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_4_2_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_4_3_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_4_3_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_4_4_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_4_4_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_5_0_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_5_0_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_5_1_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_5_1_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_5_2_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_5_2_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_5_3_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_5_3_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_6_0_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_6_0_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_6_1_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_6_1_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_6_2_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_6_2_Dxe.inf | 55 +++ .../ManagerNetworkProtocol_V1_7_0_Dxe.c | 427 ++++++++++++++++++ ...dfishManagerNetworkProtocol_V1_7_0_Dxe.inf | 55 +++ .../v1_0_0/MediaController_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishMediaController_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/MediaController_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishMediaController_V1_0_1_Dxe.inf | 55 +++ .../v1_1_0/MediaController_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishMediaController_V1_1_0_Dxe.inf | 55 +++ .../MediaControllerCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishMediaControllerCollection_Dxe.inf | 55 +++ .../Memory/v1_0_0/Memory_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishMemory_V1_0_0_Dxe.inf | 55 +++ .../Memory/v1_0_1/Memory_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishMemory_V1_0_1_Dxe.inf | 55 +++ .../Memory/v1_0_10/Memory_V1_0_10_Dxe.c | 427 ++++++++++++++++++ .../v1_0_10/RedfishMemory_V1_0_10_Dxe.inf | 55 +++ .../Memory/v1_0_11/Memory_V1_0_11_Dxe.c | 427 ++++++++++++++++++ .../v1_0_11/RedfishMemory_V1_0_11_Dxe.inf | 55 +++ .../Memory/v1_0_2/Memory_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishMemory_V1_0_2_Dxe.inf | 55 +++ .../Memory/v1_0_3/Memory_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishMemory_V1_0_3_Dxe.inf | 55 +++ .../Memory/v1_0_4/Memory_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishMemory_V1_0_4_Dxe.inf | 55 +++ .../Memory/v1_0_5/Memory_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishMemory_V1_0_5_Dxe.inf | 55 +++ .../Memory/v1_0_6/Memory_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../v1_0_6/RedfishMemory_V1_0_6_Dxe.inf | 55 +++ .../Memory/v1_0_7/Memory_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../v1_0_7/RedfishMemory_V1_0_7_Dxe.inf | 55 +++ .../Memory/v1_0_8/Memory_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../v1_0_8/RedfishMemory_V1_0_8_Dxe.inf | 55 +++ .../Memory/v1_0_9/Memory_V1_0_9_Dxe.c | 427 ++++++++++++++++++ .../v1_0_9/RedfishMemory_V1_0_9_Dxe.inf | 55 +++ .../Memory/v1_10_0/Memory_V1_10_0_Dxe.c | 427 ++++++++++++++++++ .../v1_10_0/RedfishMemory_V1_10_0_Dxe.inf | 55 +++ .../Memory/v1_10_1/Memory_V1_10_1_Dxe.c | 427 ++++++++++++++++++ .../v1_10_1/RedfishMemory_V1_10_1_Dxe.inf | 55 +++ .../Memory/v1_11_0/Memory_V1_11_0_Dxe.c | 427 ++++++++++++++++++ .../v1_11_0/RedfishMemory_V1_11_0_Dxe.inf | 55 +++ .../Memory/v1_1_0/Memory_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishMemory_V1_1_0_Dxe.inf | 55 +++ .../Memory/v1_1_1/Memory_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishMemory_V1_1_1_Dxe.inf | 55 +++ .../Memory/v1_1_10/Memory_V1_1_10_Dxe.c | 427 ++++++++++++++++++ .../v1_1_10/RedfishMemory_V1_1_10_Dxe.inf | 55 +++ .../Memory/v1_1_2/Memory_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishMemory_V1_1_2_Dxe.inf | 55 +++ .../Memory/v1_1_3/Memory_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../v1_1_3/RedfishMemory_V1_1_3_Dxe.inf | 55 +++ .../Memory/v1_1_4/Memory_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../v1_1_4/RedfishMemory_V1_1_4_Dxe.inf | 55 +++ .../Memory/v1_1_5/Memory_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../v1_1_5/RedfishMemory_V1_1_5_Dxe.inf | 55 +++ .../Memory/v1_1_6/Memory_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../v1_1_6/RedfishMemory_V1_1_6_Dxe.inf | 55 +++ .../Memory/v1_1_7/Memory_V1_1_7_Dxe.c | 427 ++++++++++++++++++ .../v1_1_7/RedfishMemory_V1_1_7_Dxe.inf | 55 +++ .../Memory/v1_1_8/Memory_V1_1_8_Dxe.c | 427 ++++++++++++++++++ .../v1_1_8/RedfishMemory_V1_1_8_Dxe.inf | 55 +++ .../Memory/v1_1_9/Memory_V1_1_9_Dxe.c | 427 ++++++++++++++++++ .../v1_1_9/RedfishMemory_V1_1_9_Dxe.inf | 55 +++ .../Memory/v1_2_0/Memory_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishMemory_V1_2_0_Dxe.inf | 55 +++ .../Memory/v1_2_1/Memory_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../v1_2_1/RedfishMemory_V1_2_1_Dxe.inf | 55 +++ .../Memory/v1_2_2/Memory_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../v1_2_2/RedfishMemory_V1_2_2_Dxe.inf | 55 +++ .../Memory/v1_2_3/Memory_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../v1_2_3/RedfishMemory_V1_2_3_Dxe.inf | 55 +++ .../Memory/v1_2_4/Memory_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../v1_2_4/RedfishMemory_V1_2_4_Dxe.inf | 55 +++ .../Memory/v1_2_5/Memory_V1_2_5_Dxe.c | 427 ++++++++++++++++++ .../v1_2_5/RedfishMemory_V1_2_5_Dxe.inf | 55 +++ .../Memory/v1_2_6/Memory_V1_2_6_Dxe.c | 427 ++++++++++++++++++ .../v1_2_6/RedfishMemory_V1_2_6_Dxe.inf | 55 +++ .../Memory/v1_2_7/Memory_V1_2_7_Dxe.c | 427 ++++++++++++++++++ .../v1_2_7/RedfishMemory_V1_2_7_Dxe.inf | 55 +++ .../Memory/v1_2_8/Memory_V1_2_8_Dxe.c | 427 ++++++++++++++++++ .../v1_2_8/RedfishMemory_V1_2_8_Dxe.inf | 55 +++ .../Memory/v1_2_9/Memory_V1_2_9_Dxe.c | 427 ++++++++++++++++++ .../v1_2_9/RedfishMemory_V1_2_9_Dxe.inf | 55 +++ .../Memory/v1_3_0/Memory_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../v1_3_0/RedfishMemory_V1_3_0_Dxe.inf | 55 +++ .../Memory/v1_3_1/Memory_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../v1_3_1/RedfishMemory_V1_3_1_Dxe.inf | 55 +++ .../Memory/v1_3_2/Memory_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../v1_3_2/RedfishMemory_V1_3_2_Dxe.inf | 55 +++ .../Memory/v1_3_3/Memory_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../v1_3_3/RedfishMemory_V1_3_3_Dxe.inf | 55 +++ .../Memory/v1_3_4/Memory_V1_3_4_Dxe.c | 427 ++++++++++++++++++ .../v1_3_4/RedfishMemory_V1_3_4_Dxe.inf | 55 +++ .../Memory/v1_3_5/Memory_V1_3_5_Dxe.c | 427 ++++++++++++++++++ .../v1_3_5/RedfishMemory_V1_3_5_Dxe.inf | 55 +++ .../Memory/v1_3_6/Memory_V1_3_6_Dxe.c | 427 ++++++++++++++++++ .../v1_3_6/RedfishMemory_V1_3_6_Dxe.inf | 55 +++ .../Memory/v1_3_7/Memory_V1_3_7_Dxe.c | 427 ++++++++++++++++++ .../v1_3_7/RedfishMemory_V1_3_7_Dxe.inf | 55 +++ .../Memory/v1_3_8/Memory_V1_3_8_Dxe.c | 427 ++++++++++++++++++ .../v1_3_8/RedfishMemory_V1_3_8_Dxe.inf | 55 +++ .../Memory/v1_3_9/Memory_V1_3_9_Dxe.c | 427 ++++++++++++++++++ .../v1_3_9/RedfishMemory_V1_3_9_Dxe.inf | 55 +++ .../Memory/v1_4_0/Memory_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../v1_4_0/RedfishMemory_V1_4_0_Dxe.inf | 55 +++ .../Memory/v1_4_1/Memory_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../v1_4_1/RedfishMemory_V1_4_1_Dxe.inf | 55 +++ .../Memory/v1_4_2/Memory_V1_4_2_Dxe.c | 427 ++++++++++++++++++ .../v1_4_2/RedfishMemory_V1_4_2_Dxe.inf | 55 +++ .../Memory/v1_4_3/Memory_V1_4_3_Dxe.c | 427 ++++++++++++++++++ .../v1_4_3/RedfishMemory_V1_4_3_Dxe.inf | 55 +++ .../Memory/v1_4_4/Memory_V1_4_4_Dxe.c | 427 ++++++++++++++++++ .../v1_4_4/RedfishMemory_V1_4_4_Dxe.inf | 55 +++ .../Memory/v1_4_5/Memory_V1_4_5_Dxe.c | 427 ++++++++++++++++++ .../v1_4_5/RedfishMemory_V1_4_5_Dxe.inf | 55 +++ .../Memory/v1_4_6/Memory_V1_4_6_Dxe.c | 427 ++++++++++++++++++ .../v1_4_6/RedfishMemory_V1_4_6_Dxe.inf | 55 +++ .../Memory/v1_4_7/Memory_V1_4_7_Dxe.c | 427 ++++++++++++++++++ .../v1_4_7/RedfishMemory_V1_4_7_Dxe.inf | 55 +++ .../Memory/v1_4_8/Memory_V1_4_8_Dxe.c | 427 ++++++++++++++++++ .../v1_4_8/RedfishMemory_V1_4_8_Dxe.inf | 55 +++ .../Memory/v1_4_9/Memory_V1_4_9_Dxe.c | 427 ++++++++++++++++++ .../v1_4_9/RedfishMemory_V1_4_9_Dxe.inf | 55 +++ .../Memory/v1_5_0/Memory_V1_5_0_Dxe.c | 427 ++++++++++++++++++ .../v1_5_0/RedfishMemory_V1_5_0_Dxe.inf | 55 +++ .../Memory/v1_5_1/Memory_V1_5_1_Dxe.c | 427 ++++++++++++++++++ .../v1_5_1/RedfishMemory_V1_5_1_Dxe.inf | 55 +++ .../Memory/v1_5_2/Memory_V1_5_2_Dxe.c | 427 ++++++++++++++++++ .../v1_5_2/RedfishMemory_V1_5_2_Dxe.inf | 55 +++ .../Memory/v1_5_3/Memory_V1_5_3_Dxe.c | 427 ++++++++++++++++++ .../v1_5_3/RedfishMemory_V1_5_3_Dxe.inf | 55 +++ .../Memory/v1_5_4/Memory_V1_5_4_Dxe.c | 427 ++++++++++++++++++ .../v1_5_4/RedfishMemory_V1_5_4_Dxe.inf | 55 +++ .../Memory/v1_5_5/Memory_V1_5_5_Dxe.c | 427 ++++++++++++++++++ .../v1_5_5/RedfishMemory_V1_5_5_Dxe.inf | 55 +++ .../Memory/v1_5_6/Memory_V1_5_6_Dxe.c | 427 ++++++++++++++++++ .../v1_5_6/RedfishMemory_V1_5_6_Dxe.inf | 55 +++ .../Memory/v1_5_7/Memory_V1_5_7_Dxe.c | 427 ++++++++++++++++++ .../v1_5_7/RedfishMemory_V1_5_7_Dxe.inf | 55 +++ .../Memory/v1_5_8/Memory_V1_5_8_Dxe.c | 427 ++++++++++++++++++ .../v1_5_8/RedfishMemory_V1_5_8_Dxe.inf | 55 +++ .../Memory/v1_6_0/Memory_V1_6_0_Dxe.c | 427 ++++++++++++++++++ .../v1_6_0/RedfishMemory_V1_6_0_Dxe.inf | 55 +++ .../Memory/v1_6_1/Memory_V1_6_1_Dxe.c | 427 ++++++++++++++++++ .../v1_6_1/RedfishMemory_V1_6_1_Dxe.inf | 55 +++ .../Memory/v1_6_2/Memory_V1_6_2_Dxe.c | 427 ++++++++++++++++++ .../v1_6_2/RedfishMemory_V1_6_2_Dxe.inf | 55 +++ .../Memory/v1_6_3/Memory_V1_6_3_Dxe.c | 427 ++++++++++++++++++ .../v1_6_3/RedfishMemory_V1_6_3_Dxe.inf | 55 +++ .../Memory/v1_6_4/Memory_V1_6_4_Dxe.c | 427 ++++++++++++++++++ .../v1_6_4/RedfishMemory_V1_6_4_Dxe.inf | 55 +++ .../Memory/v1_6_5/Memory_V1_6_5_Dxe.c | 427 ++++++++++++++++++ .../v1_6_5/RedfishMemory_V1_6_5_Dxe.inf | 55 +++ .../Memory/v1_6_6/Memory_V1_6_6_Dxe.c | 427 ++++++++++++++++++ .../v1_6_6/RedfishMemory_V1_6_6_Dxe.inf | 55 +++ .../Memory/v1_6_7/Memory_V1_6_7_Dxe.c | 427 ++++++++++++++++++ .../v1_6_7/RedfishMemory_V1_6_7_Dxe.inf | 55 +++ .../Memory/v1_7_0/Memory_V1_7_0_Dxe.c | 427 ++++++++++++++++++ .../v1_7_0/RedfishMemory_V1_7_0_Dxe.inf | 55 +++ .../Memory/v1_7_1/Memory_V1_7_1_Dxe.c | 427 ++++++++++++++++++ .../v1_7_1/RedfishMemory_V1_7_1_Dxe.inf | 55 +++ .../Memory/v1_7_2/Memory_V1_7_2_Dxe.c | 427 ++++++++++++++++++ .../v1_7_2/RedfishMemory_V1_7_2_Dxe.inf | 55 +++ .../Memory/v1_7_3/Memory_V1_7_3_Dxe.c | 427 ++++++++++++++++++ .../v1_7_3/RedfishMemory_V1_7_3_Dxe.inf | 55 +++ .../Memory/v1_7_4/Memory_V1_7_4_Dxe.c | 427 ++++++++++++++++++ .../v1_7_4/RedfishMemory_V1_7_4_Dxe.inf | 55 +++ .../Memory/v1_7_5/Memory_V1_7_5_Dxe.c | 427 ++++++++++++++++++ .../v1_7_5/RedfishMemory_V1_7_5_Dxe.inf | 55 +++ .../Memory/v1_7_6/Memory_V1_7_6_Dxe.c | 427 ++++++++++++++++++ .../v1_7_6/RedfishMemory_V1_7_6_Dxe.inf | 55 +++ .../Memory/v1_8_0/Memory_V1_8_0_Dxe.c | 427 ++++++++++++++++++ .../v1_8_0/RedfishMemory_V1_8_0_Dxe.inf | 55 +++ .../Memory/v1_8_1/Memory_V1_8_1_Dxe.c | 427 ++++++++++++++++++ .../v1_8_1/RedfishMemory_V1_8_1_Dxe.inf | 55 +++ .../Memory/v1_8_2/Memory_V1_8_2_Dxe.c | 427 ++++++++++++++++++ .../v1_8_2/RedfishMemory_V1_8_2_Dxe.inf | 55 +++ .../Memory/v1_8_3/Memory_V1_8_3_Dxe.c | 427 ++++++++++++++++++ .../v1_8_3/RedfishMemory_V1_8_3_Dxe.inf | 55 +++ .../Memory/v1_8_4/Memory_V1_8_4_Dxe.c | 427 ++++++++++++++++++ .../v1_8_4/RedfishMemory_V1_8_4_Dxe.inf | 55 +++ .../Memory/v1_9_0/Memory_V1_9_0_Dxe.c | 427 ++++++++++++++++++ .../v1_9_0/RedfishMemory_V1_9_0_Dxe.inf | 55 +++ .../Memory/v1_9_1/Memory_V1_9_1_Dxe.c | 427 ++++++++++++++++++ .../v1_9_1/RedfishMemory_V1_9_1_Dxe.inf | 55 +++ .../Memory/v1_9_2/Memory_V1_9_2_Dxe.c | 427 ++++++++++++++++++ .../v1_9_2/RedfishMemory_V1_9_2_Dxe.inf | 55 +++ .../Memory/v1_9_3/Memory_V1_9_3_Dxe.c | 427 ++++++++++++++++++ .../v1_9_3/RedfishMemory_V1_9_3_Dxe.inf | 55 +++ .../Memory/v1_9_4/Memory_V1_9_4_Dxe.c | 427 ++++++++++++++++++ .../v1_9_4/RedfishMemory_V1_9_4_Dxe.inf | 55 +++ .../v1_0_0/MemoryChunks_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishMemoryChunks_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/MemoryChunks_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishMemoryChunks_V1_0_1_Dxe.inf | 55 +++ .../v1_0_2/MemoryChunks_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishMemoryChunks_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/MemoryChunks_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishMemoryChunks_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/MemoryChunks_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishMemoryChunks_V1_0_4_Dxe.inf | 55 +++ .../v1_0_5/MemoryChunks_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishMemoryChunks_V1_0_5_Dxe.inf | 55 +++ .../v1_0_6/MemoryChunks_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../v1_0_6/RedfishMemoryChunks_V1_0_6_Dxe.inf | 55 +++ .../v1_0_7/MemoryChunks_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../v1_0_7/RedfishMemoryChunks_V1_0_7_Dxe.inf | 55 +++ .../v1_1_0/MemoryChunks_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishMemoryChunks_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/MemoryChunks_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishMemoryChunks_V1_1_1_Dxe.inf | 55 +++ .../v1_1_2/MemoryChunks_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishMemoryChunks_V1_1_2_Dxe.inf | 55 +++ .../v1_1_3/MemoryChunks_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../v1_1_3/RedfishMemoryChunks_V1_1_3_Dxe.inf | 55 +++ .../v1_1_4/MemoryChunks_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../v1_1_4/RedfishMemoryChunks_V1_1_4_Dxe.inf | 55 +++ .../v1_1_5/MemoryChunks_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../v1_1_5/RedfishMemoryChunks_V1_1_5_Dxe.inf | 55 +++ .../v1_2_0/MemoryChunks_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishMemoryChunks_V1_2_0_Dxe.inf | 55 +++ .../v1_2_1/MemoryChunks_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../v1_2_1/RedfishMemoryChunks_V1_2_1_Dxe.inf | 55 +++ .../v1_2_2/MemoryChunks_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../v1_2_2/RedfishMemoryChunks_V1_2_2_Dxe.inf | 55 +++ .../v1_2_3/MemoryChunks_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../v1_2_3/RedfishMemoryChunks_V1_2_3_Dxe.inf | 55 +++ .../v1_2_4/MemoryChunks_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../v1_2_4/RedfishMemoryChunks_V1_2_4_Dxe.inf | 55 +++ .../v1_2_5/MemoryChunks_V1_2_5_Dxe.c | 427 ++++++++++++++++++ .../v1_2_5/RedfishMemoryChunks_V1_2_5_Dxe.inf | 55 +++ .../v1_2_6/MemoryChunks_V1_2_6_Dxe.c | 427 ++++++++++++++++++ .../v1_2_6/RedfishMemoryChunks_V1_2_6_Dxe.inf | 55 +++ .../v1_3_0/MemoryChunks_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../v1_3_0/RedfishMemoryChunks_V1_3_0_Dxe.inf | 55 +++ .../v1_3_1/MemoryChunks_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../v1_3_1/RedfishMemoryChunks_V1_3_1_Dxe.inf | 55 +++ .../v1_3_2/MemoryChunks_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../v1_3_2/RedfishMemoryChunks_V1_3_2_Dxe.inf | 55 +++ .../v1_4_0/MemoryChunks_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../v1_4_0/RedfishMemoryChunks_V1_4_0_Dxe.inf | 55 +++ .../v1_4_1/MemoryChunks_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../v1_4_1/RedfishMemoryChunks_V1_4_1_Dxe.inf | 55 +++ .../MemoryChunksCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryChunksCollection_Dxe.inf | 55 +++ .../MemoryCollection/MemoryCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryCollection_Dxe.inf | 55 +++ .../v1_0_0/MemoryDomain_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishMemoryDomain_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/MemoryDomain_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishMemoryDomain_V1_0_1_Dxe.inf | 55 +++ .../v1_0_2/MemoryDomain_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishMemoryDomain_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/MemoryDomain_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishMemoryDomain_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/MemoryDomain_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishMemoryDomain_V1_0_4_Dxe.inf | 55 +++ .../v1_0_5/MemoryDomain_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishMemoryDomain_V1_0_5_Dxe.inf | 55 +++ .../v1_1_0/MemoryDomain_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishMemoryDomain_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/MemoryDomain_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishMemoryDomain_V1_1_1_Dxe.inf | 55 +++ .../v1_1_2/MemoryDomain_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishMemoryDomain_V1_1_2_Dxe.inf | 55 +++ .../v1_1_3/MemoryDomain_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../v1_1_3/RedfishMemoryDomain_V1_1_3_Dxe.inf | 55 +++ .../v1_1_4/MemoryDomain_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../v1_1_4/RedfishMemoryDomain_V1_1_4_Dxe.inf | 55 +++ .../v1_2_0/MemoryDomain_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishMemoryDomain_V1_2_0_Dxe.inf | 55 +++ .../v1_2_1/MemoryDomain_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../v1_2_1/RedfishMemoryDomain_V1_2_1_Dxe.inf | 55 +++ .../v1_2_2/MemoryDomain_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../v1_2_2/RedfishMemoryDomain_V1_2_2_Dxe.inf | 55 +++ .../v1_2_3/MemoryDomain_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../v1_2_3/RedfishMemoryDomain_V1_2_3_Dxe.inf | 55 +++ .../v1_3_0/MemoryDomain_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../v1_3_0/RedfishMemoryDomain_V1_3_0_Dxe.inf | 55 +++ .../MemoryDomainCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryDomainCollection_Dxe.inf | 55 +++ .../v1_0_0/MemoryMetrics_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryMetrics_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/MemoryMetrics_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryMetrics_V1_0_1_Dxe.inf | 55 +++ .../v1_0_2/MemoryMetrics_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryMetrics_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/MemoryMetrics_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryMetrics_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/MemoryMetrics_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryMetrics_V1_0_4_Dxe.inf | 55 +++ .../v1_0_5/MemoryMetrics_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryMetrics_V1_0_5_Dxe.inf | 55 +++ .../v1_0_6/MemoryMetrics_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryMetrics_V1_0_6_Dxe.inf | 55 +++ .../v1_0_7/MemoryMetrics_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryMetrics_V1_0_7_Dxe.inf | 55 +++ .../v1_0_8/MemoryMetrics_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryMetrics_V1_0_8_Dxe.inf | 55 +++ .../v1_1_1/MemoryMetrics_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryMetrics_V1_1_1_Dxe.inf | 55 +++ .../v1_1_2/MemoryMetrics_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryMetrics_V1_1_2_Dxe.inf | 55 +++ .../v1_1_3/MemoryMetrics_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryMetrics_V1_1_3_Dxe.inf | 55 +++ .../v1_1_4/MemoryMetrics_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryMetrics_V1_1_4_Dxe.inf | 55 +++ .../v1_1_5/MemoryMetrics_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryMetrics_V1_1_5_Dxe.inf | 55 +++ .../v1_1_6/MemoryMetrics_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryMetrics_V1_1_6_Dxe.inf | 55 +++ .../v1_1_7/MemoryMetrics_V1_1_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryMetrics_V1_1_7_Dxe.inf | 55 +++ .../v1_1_8/MemoryMetrics_V1_1_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryMetrics_V1_1_8_Dxe.inf | 55 +++ .../v1_2_0/MemoryMetrics_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryMetrics_V1_2_0_Dxe.inf | 55 +++ .../v1_2_1/MemoryMetrics_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryMetrics_V1_2_1_Dxe.inf | 55 +++ .../v1_2_2/MemoryMetrics_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryMetrics_V1_2_2_Dxe.inf | 55 +++ .../v1_3_0/MemoryMetrics_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryMetrics_V1_3_0_Dxe.inf | 55 +++ .../v1_3_1/MemoryMetrics_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryMetrics_V1_3_1_Dxe.inf | 55 +++ .../v1_4_0/MemoryMetrics_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryMetrics_V1_4_0_Dxe.inf | 55 +++ .../v1_4_1/MemoryMetrics_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishMemoryMetrics_V1_4_1_Dxe.inf | 55 +++ .../v1_0_0/MessageRegistry_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_0_0_Dxe.inf | 55 +++ .../v1_0_10/MessageRegistry_V1_0_10_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_0_10_Dxe.inf | 55 +++ .../v1_0_2/MessageRegistry_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/MessageRegistry_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/MessageRegistry_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_0_4_Dxe.inf | 55 +++ .../v1_0_5/MessageRegistry_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_0_5_Dxe.inf | 55 +++ .../v1_0_6/MessageRegistry_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_0_6_Dxe.inf | 55 +++ .../v1_0_7/MessageRegistry_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_0_7_Dxe.inf | 55 +++ .../v1_0_8/MessageRegistry_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_0_8_Dxe.inf | 55 +++ .../v1_0_9/MessageRegistry_V1_0_9_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_0_9_Dxe.inf | 55 +++ .../v1_1_0/MessageRegistry_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/MessageRegistry_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_1_1_Dxe.inf | 55 +++ .../v1_1_2/MessageRegistry_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_1_2_Dxe.inf | 55 +++ .../v1_1_3/MessageRegistry_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_1_3_Dxe.inf | 55 +++ .../v1_1_4/MessageRegistry_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_1_4_Dxe.inf | 55 +++ .../v1_1_5/MessageRegistry_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_1_5_Dxe.inf | 55 +++ .../v1_1_6/MessageRegistry_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_1_6_Dxe.inf | 55 +++ .../v1_2_0/MessageRegistry_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_2_0_Dxe.inf | 55 +++ .../v1_2_1/MessageRegistry_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_2_1_Dxe.inf | 55 +++ .../v1_2_2/MessageRegistry_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_2_2_Dxe.inf | 55 +++ .../v1_2_3/MessageRegistry_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_2_3_Dxe.inf | 55 +++ .../v1_2_4/MessageRegistry_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_2_4_Dxe.inf | 55 +++ .../v1_3_0/MessageRegistry_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_3_0_Dxe.inf | 55 +++ .../v1_3_1/MessageRegistry_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_3_1_Dxe.inf | 55 +++ .../v1_3_2/MessageRegistry_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_3_2_Dxe.inf | 55 +++ .../v1_3_3/MessageRegistry_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_3_3_Dxe.inf | 55 +++ .../v1_4_0/MessageRegistry_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_4_0_Dxe.inf | 55 +++ .../v1_4_1/MessageRegistry_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_4_1_Dxe.inf | 55 +++ .../v1_4_2/MessageRegistry_V1_4_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistry_V1_4_2_Dxe.inf | 55 +++ .../MessageRegistryCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistryCollection_Dxe.inf | 55 +++ .../v1_0_0/MessageRegistryFile_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistryFile_V1_0_0_Dxe.inf | 55 +++ .../v1_0_2/MessageRegistryFile_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistryFile_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/MessageRegistryFile_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistryFile_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/MessageRegistryFile_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistryFile_V1_0_4_Dxe.inf | 55 +++ .../v1_0_5/MessageRegistryFile_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistryFile_V1_0_5_Dxe.inf | 55 +++ .../v1_0_6/MessageRegistryFile_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistryFile_V1_0_6_Dxe.inf | 55 +++ .../v1_0_7/MessageRegistryFile_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistryFile_V1_0_7_Dxe.inf | 55 +++ .../v1_1_0/MessageRegistryFile_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistryFile_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/MessageRegistryFile_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistryFile_V1_1_1_Dxe.inf | 55 +++ .../v1_1_2/MessageRegistryFile_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistryFile_V1_1_2_Dxe.inf | 55 +++ .../v1_1_3/MessageRegistryFile_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishMessageRegistryFile_V1_1_3_Dxe.inf | 55 +++ .../MessageRegistryFileCollection_Dxe.c | 427 ++++++++++++++++++ ...dfishMessageRegistryFileCollection_Dxe.inf | 55 +++ .../v1_0_0/MetricDefinition_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishMetricDefinition_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/MetricDefinition_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishMetricDefinition_V1_0_1_Dxe.inf | 55 +++ .../v1_0_2/MetricDefinition_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishMetricDefinition_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/MetricDefinition_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishMetricDefinition_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/MetricDefinition_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishMetricDefinition_V1_0_4_Dxe.inf | 55 +++ .../v1_0_5/MetricDefinition_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishMetricDefinition_V1_0_5_Dxe.inf | 55 +++ .../v1_0_6/MetricDefinition_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishMetricDefinition_V1_0_6_Dxe.inf | 55 +++ .../v1_1_0/MetricDefinition_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishMetricDefinition_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/MetricDefinition_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishMetricDefinition_V1_1_1_Dxe.inf | 55 +++ .../MetricDefinitionCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishMetricDefinitionCollection_Dxe.inf | 55 +++ .../v1_0_0/MetricReport_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishMetricReport_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/MetricReport_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishMetricReport_V1_0_1_Dxe.inf | 55 +++ .../v1_0_2/MetricReport_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishMetricReport_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/MetricReport_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishMetricReport_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/MetricReport_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishMetricReport_V1_0_4_Dxe.inf | 55 +++ .../v1_0_5/MetricReport_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishMetricReport_V1_0_5_Dxe.inf | 55 +++ .../v1_0_6/MetricReport_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../v1_0_6/RedfishMetricReport_V1_0_6_Dxe.inf | 55 +++ .../v1_1_0/MetricReport_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishMetricReport_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/MetricReport_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishMetricReport_V1_1_1_Dxe.inf | 55 +++ .../v1_1_2/MetricReport_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishMetricReport_V1_1_2_Dxe.inf | 55 +++ .../v1_1_3/MetricReport_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../v1_1_3/RedfishMetricReport_V1_1_3_Dxe.inf | 55 +++ .../v1_1_4/MetricReport_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../v1_1_4/RedfishMetricReport_V1_1_4_Dxe.inf | 55 +++ .../v1_1_5/MetricReport_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../v1_1_5/RedfishMetricReport_V1_1_5_Dxe.inf | 55 +++ .../v1_2_0/MetricReport_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishMetricReport_V1_2_0_Dxe.inf | 55 +++ .../v1_2_1/MetricReport_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../v1_2_1/RedfishMetricReport_V1_2_1_Dxe.inf | 55 +++ .../v1_2_2/MetricReport_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../v1_2_2/RedfishMetricReport_V1_2_2_Dxe.inf | 55 +++ .../v1_2_3/MetricReport_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../v1_2_3/RedfishMetricReport_V1_2_3_Dxe.inf | 55 +++ .../v1_3_0/MetricReport_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../v1_3_0/RedfishMetricReport_V1_3_0_Dxe.inf | 55 +++ .../v1_3_1/MetricReport_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../v1_3_1/RedfishMetricReport_V1_3_1_Dxe.inf | 55 +++ .../v1_3_2/MetricReport_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../v1_3_2/RedfishMetricReport_V1_3_2_Dxe.inf | 55 +++ .../v1_4_0/MetricReport_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../v1_4_0/RedfishMetricReport_V1_4_0_Dxe.inf | 55 +++ .../v1_4_1/MetricReport_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../v1_4_1/RedfishMetricReport_V1_4_1_Dxe.inf | 55 +++ .../MetricReportCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishMetricReportCollection_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_0_0_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_0_0_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_0_1_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_0_1_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_0_2_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_0_2_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_0_3_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_0_3_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_0_4_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_0_4_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_0_5_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_0_5_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_0_6_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_0_6_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_0_7_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_0_7_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_1_0_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_1_0_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_1_1_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_1_1_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_1_2_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_1_2_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_1_3_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_1_3_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_1_4_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_1_4_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_1_5_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_1_5_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_1_6_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_1_6_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_2_0_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_2_0_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_2_1_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_2_1_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_2_2_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_2_2_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_2_3_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_2_3_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_2_4_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_2_4_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_2_5_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_2_5_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_3_0_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_3_0_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_3_1_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_3_1_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_3_2_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_3_2_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_3_3_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_3_3_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_3_4_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_3_4_Dxe.inf | 55 +++ .../MetricReportDefinition_V1_4_0_Dxe.c | 427 ++++++++++++++++++ ...dfishMetricReportDefinition_V1_4_0_Dxe.inf | 55 +++ .../MetricReportDefinitionCollection_Dxe.c | 427 ++++++++++++++++++ ...shMetricReportDefinitionCollection_Dxe.inf | 55 +++ .../v1_0_0/NetworkAdapter_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/NetworkAdapter_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_0_1_Dxe.inf | 55 +++ .../v1_0_2/NetworkAdapter_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/NetworkAdapter_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/NetworkAdapter_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_0_4_Dxe.inf | 55 +++ .../v1_0_5/NetworkAdapter_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_0_5_Dxe.inf | 55 +++ .../v1_0_6/NetworkAdapter_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_0_6_Dxe.inf | 55 +++ .../v1_0_7/NetworkAdapter_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_0_7_Dxe.inf | 55 +++ .../v1_1_0/NetworkAdapter_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/NetworkAdapter_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_1_1_Dxe.inf | 55 +++ .../v1_1_2/NetworkAdapter_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_1_2_Dxe.inf | 55 +++ .../v1_1_3/NetworkAdapter_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_1_3_Dxe.inf | 55 +++ .../v1_1_4/NetworkAdapter_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_1_4_Dxe.inf | 55 +++ .../v1_1_5/NetworkAdapter_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_1_5_Dxe.inf | 55 +++ .../v1_1_6/NetworkAdapter_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_1_6_Dxe.inf | 55 +++ .../v1_2_0/NetworkAdapter_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_2_0_Dxe.inf | 55 +++ .../v1_2_1/NetworkAdapter_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_2_1_Dxe.inf | 55 +++ .../v1_2_2/NetworkAdapter_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_2_2_Dxe.inf | 55 +++ .../v1_2_3/NetworkAdapter_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_2_3_Dxe.inf | 55 +++ .../v1_2_4/NetworkAdapter_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_2_4_Dxe.inf | 55 +++ .../v1_2_5/NetworkAdapter_V1_2_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_2_5_Dxe.inf | 55 +++ .../v1_3_0/NetworkAdapter_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_3_0_Dxe.inf | 55 +++ .../v1_3_1/NetworkAdapter_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_3_1_Dxe.inf | 55 +++ .../v1_3_2/NetworkAdapter_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_3_2_Dxe.inf | 55 +++ .../v1_3_3/NetworkAdapter_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_3_3_Dxe.inf | 55 +++ .../v1_3_4/NetworkAdapter_V1_3_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_3_4_Dxe.inf | 55 +++ .../v1_4_0/NetworkAdapter_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_4_0_Dxe.inf | 55 +++ .../v1_4_1/NetworkAdapter_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_4_1_Dxe.inf | 55 +++ .../v1_5_0/NetworkAdapter_V1_5_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_5_0_Dxe.inf | 55 +++ .../v1_5_1/NetworkAdapter_V1_5_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_5_1_Dxe.inf | 55 +++ .../v1_6_0/NetworkAdapter_V1_6_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapter_V1_6_0_Dxe.inf | 55 +++ .../NetworkAdapterCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkAdapterCollection_Dxe.inf | 55 +++ .../v1_0_0/NetworkDeviceFunction_V1_0_0_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/NetworkDeviceFunction_V1_0_1_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_0_1_Dxe.inf | 55 +++ .../v1_0_2/NetworkDeviceFunction_V1_0_2_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/NetworkDeviceFunction_V1_0_3_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/NetworkDeviceFunction_V1_0_4_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_0_4_Dxe.inf | 55 +++ .../v1_0_5/NetworkDeviceFunction_V1_0_5_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_0_5_Dxe.inf | 55 +++ .../v1_0_6/NetworkDeviceFunction_V1_0_6_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_0_6_Dxe.inf | 55 +++ .../v1_0_7/NetworkDeviceFunction_V1_0_7_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_0_7_Dxe.inf | 55 +++ .../v1_0_8/NetworkDeviceFunction_V1_0_8_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_0_8_Dxe.inf | 55 +++ .../v1_1_0/NetworkDeviceFunction_V1_1_0_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/NetworkDeviceFunction_V1_1_1_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_1_1_Dxe.inf | 55 +++ .../v1_1_2/NetworkDeviceFunction_V1_1_2_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_1_2_Dxe.inf | 55 +++ .../v1_1_3/NetworkDeviceFunction_V1_1_3_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_1_3_Dxe.inf | 55 +++ .../v1_1_4/NetworkDeviceFunction_V1_1_4_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_1_4_Dxe.inf | 55 +++ .../v1_1_5/NetworkDeviceFunction_V1_1_5_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_1_5_Dxe.inf | 55 +++ .../v1_1_6/NetworkDeviceFunction_V1_1_6_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_1_6_Dxe.inf | 55 +++ .../v1_1_7/NetworkDeviceFunction_V1_1_7_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_1_7_Dxe.inf | 55 +++ .../v1_2_0/NetworkDeviceFunction_V1_2_0_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_2_0_Dxe.inf | 55 +++ .../v1_2_1/NetworkDeviceFunction_V1_2_1_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_2_1_Dxe.inf | 55 +++ .../v1_2_2/NetworkDeviceFunction_V1_2_2_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_2_2_Dxe.inf | 55 +++ .../v1_2_3/NetworkDeviceFunction_V1_2_3_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_2_3_Dxe.inf | 55 +++ .../v1_2_4/NetworkDeviceFunction_V1_2_4_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_2_4_Dxe.inf | 55 +++ .../v1_2_5/NetworkDeviceFunction_V1_2_5_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_2_5_Dxe.inf | 55 +++ .../v1_2_6/NetworkDeviceFunction_V1_2_6_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_2_6_Dxe.inf | 55 +++ .../v1_2_7/NetworkDeviceFunction_V1_2_7_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_2_7_Dxe.inf | 55 +++ .../v1_3_0/NetworkDeviceFunction_V1_3_0_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_3_0_Dxe.inf | 55 +++ .../v1_3_1/NetworkDeviceFunction_V1_3_1_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_3_1_Dxe.inf | 55 +++ .../v1_3_2/NetworkDeviceFunction_V1_3_2_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_3_2_Dxe.inf | 55 +++ .../v1_3_3/NetworkDeviceFunction_V1_3_3_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_3_3_Dxe.inf | 55 +++ .../v1_3_4/NetworkDeviceFunction_V1_3_4_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_3_4_Dxe.inf | 55 +++ .../v1_3_5/NetworkDeviceFunction_V1_3_5_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_3_5_Dxe.inf | 55 +++ .../v1_4_0/NetworkDeviceFunction_V1_4_0_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_4_0_Dxe.inf | 55 +++ .../v1_4_1/NetworkDeviceFunction_V1_4_1_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_4_1_Dxe.inf | 55 +++ .../v1_4_2/NetworkDeviceFunction_V1_4_2_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_4_2_Dxe.inf | 55 +++ .../v1_5_0/NetworkDeviceFunction_V1_5_0_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_5_0_Dxe.inf | 55 +++ .../v1_5_1/NetworkDeviceFunction_V1_5_1_Dxe.c | 427 ++++++++++++++++++ ...edfishNetworkDeviceFunction_V1_5_1_Dxe.inf | 55 +++ .../NetworkDeviceFunctionCollection_Dxe.c | 427 ++++++++++++++++++ ...ishNetworkDeviceFunctionCollection_Dxe.inf | 55 +++ .../v1_0_0/NetworkInterface_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkInterface_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/NetworkInterface_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkInterface_V1_0_1_Dxe.inf | 55 +++ .../v1_0_2/NetworkInterface_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkInterface_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/NetworkInterface_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkInterface_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/NetworkInterface_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkInterface_V1_0_4_Dxe.inf | 55 +++ .../v1_0_5/NetworkInterface_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkInterface_V1_0_5_Dxe.inf | 55 +++ .../v1_0_6/NetworkInterface_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkInterface_V1_0_6_Dxe.inf | 55 +++ .../v1_1_0/NetworkInterface_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkInterface_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/NetworkInterface_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkInterface_V1_1_1_Dxe.inf | 55 +++ .../v1_1_2/NetworkInterface_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkInterface_V1_1_2_Dxe.inf | 55 +++ .../v1_1_3/NetworkInterface_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkInterface_V1_1_3_Dxe.inf | 55 +++ .../v1_1_4/NetworkInterface_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkInterface_V1_1_4_Dxe.inf | 55 +++ .../v1_1_5/NetworkInterface_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkInterface_V1_1_5_Dxe.inf | 55 +++ .../v1_2_0/NetworkInterface_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkInterface_V1_2_0_Dxe.inf | 55 +++ .../v1_2_1/NetworkInterface_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkInterface_V1_2_1_Dxe.inf | 55 +++ .../NetworkInterfaceCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkInterfaceCollection_Dxe.inf | 55 +++ .../v1_0_0/NetworkPort_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishNetworkPort_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/NetworkPort_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishNetworkPort_V1_0_1_Dxe.inf | 55 +++ .../v1_0_2/NetworkPort_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishNetworkPort_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/NetworkPort_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishNetworkPort_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/NetworkPort_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishNetworkPort_V1_0_4_Dxe.inf | 55 +++ .../v1_0_5/NetworkPort_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishNetworkPort_V1_0_5_Dxe.inf | 55 +++ .../v1_0_6/NetworkPort_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../v1_0_6/RedfishNetworkPort_V1_0_6_Dxe.inf | 55 +++ .../v1_0_7/NetworkPort_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../v1_0_7/RedfishNetworkPort_V1_0_7_Dxe.inf | 55 +++ .../v1_0_8/NetworkPort_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../v1_0_8/RedfishNetworkPort_V1_0_8_Dxe.inf | 55 +++ .../v1_1_0/NetworkPort_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishNetworkPort_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/NetworkPort_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishNetworkPort_V1_1_1_Dxe.inf | 55 +++ .../v1_1_2/NetworkPort_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishNetworkPort_V1_1_2_Dxe.inf | 55 +++ .../v1_1_3/NetworkPort_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../v1_1_3/RedfishNetworkPort_V1_1_3_Dxe.inf | 55 +++ .../v1_1_4/NetworkPort_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../v1_1_4/RedfishNetworkPort_V1_1_4_Dxe.inf | 55 +++ .../v1_1_5/NetworkPort_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../v1_1_5/RedfishNetworkPort_V1_1_5_Dxe.inf | 55 +++ .../v1_1_6/NetworkPort_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../v1_1_6/RedfishNetworkPort_V1_1_6_Dxe.inf | 55 +++ .../v1_1_7/NetworkPort_V1_1_7_Dxe.c | 427 ++++++++++++++++++ .../v1_1_7/RedfishNetworkPort_V1_1_7_Dxe.inf | 55 +++ .../v1_2_0/NetworkPort_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishNetworkPort_V1_2_0_Dxe.inf | 55 +++ .../v1_2_1/NetworkPort_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../v1_2_1/RedfishNetworkPort_V1_2_1_Dxe.inf | 55 +++ .../v1_2_2/NetworkPort_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../v1_2_2/RedfishNetworkPort_V1_2_2_Dxe.inf | 55 +++ .../v1_2_3/NetworkPort_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../v1_2_3/RedfishNetworkPort_V1_2_3_Dxe.inf | 55 +++ .../v1_2_4/NetworkPort_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../v1_2_4/RedfishNetworkPort_V1_2_4_Dxe.inf | 55 +++ .../v1_2_5/NetworkPort_V1_2_5_Dxe.c | 427 ++++++++++++++++++ .../v1_2_5/RedfishNetworkPort_V1_2_5_Dxe.inf | 55 +++ .../v1_2_6/NetworkPort_V1_2_6_Dxe.c | 427 ++++++++++++++++++ .../v1_2_6/RedfishNetworkPort_V1_2_6_Dxe.inf | 55 +++ .../v1_3_0/NetworkPort_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../v1_3_0/RedfishNetworkPort_V1_3_0_Dxe.inf | 55 +++ .../v1_3_1/NetworkPort_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../v1_3_1/RedfishNetworkPort_V1_3_1_Dxe.inf | 55 +++ .../v1_4_0/NetworkPort_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../v1_4_0/RedfishNetworkPort_V1_4_0_Dxe.inf | 55 +++ .../NetworkPortCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishNetworkPortCollection_Dxe.inf | 55 +++ .../v1_0_0/OperatingConfig_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishOperatingConfig_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/OperatingConfig_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishOperatingConfig_V1_0_1_Dxe.inf | 55 +++ .../v1_0_2/OperatingConfig_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishOperatingConfig_V1_0_2_Dxe.inf | 55 +++ .../OperatingConfigCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishOperatingConfigCollection_Dxe.inf | 55 +++ .../Outlet/v1_0_0/Outlet_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishOutlet_V1_0_0_Dxe.inf | 55 +++ .../Outlet/v1_0_1/Outlet_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishOutlet_V1_0_1_Dxe.inf | 55 +++ .../Outlet/v1_0_2/Outlet_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishOutlet_V1_0_2_Dxe.inf | 55 +++ .../Outlet/v1_1_0/Outlet_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishOutlet_V1_1_0_Dxe.inf | 55 +++ .../Outlet/v1_1_1/Outlet_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishOutlet_V1_1_1_Dxe.inf | 55 +++ .../OutletCollection/OutletCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishOutletCollection_Dxe.inf | 55 +++ .../v1_0_0/OutletGroup_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishOutletGroup_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/OutletGroup_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishOutletGroup_V1_0_1_Dxe.inf | 55 +++ .../OutletGroupCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishOutletGroupCollection_Dxe.inf | 55 +++ .../PCIeDevice/v1_0_0/PCIeDevice_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishPCIeDevice_V1_0_0_Dxe.inf | 55 +++ .../PCIeDevice/v1_0_1/PCIeDevice_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishPCIeDevice_V1_0_1_Dxe.inf | 55 +++ .../PCIeDevice/v1_0_2/PCIeDevice_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishPCIeDevice_V1_0_2_Dxe.inf | 55 +++ .../PCIeDevice/v1_0_3/PCIeDevice_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishPCIeDevice_V1_0_3_Dxe.inf | 55 +++ .../PCIeDevice/v1_0_4/PCIeDevice_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishPCIeDevice_V1_0_4_Dxe.inf | 55 +++ .../PCIeDevice/v1_0_5/PCIeDevice_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishPCIeDevice_V1_0_5_Dxe.inf | 55 +++ .../PCIeDevice/v1_1_0/PCIeDevice_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishPCIeDevice_V1_1_0_Dxe.inf | 55 +++ .../PCIeDevice/v1_1_1/PCIeDevice_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishPCIeDevice_V1_1_1_Dxe.inf | 55 +++ .../PCIeDevice/v1_1_2/PCIeDevice_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishPCIeDevice_V1_1_2_Dxe.inf | 55 +++ .../PCIeDevice/v1_1_3/PCIeDevice_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../v1_1_3/RedfishPCIeDevice_V1_1_3_Dxe.inf | 55 +++ .../PCIeDevice/v1_2_0/PCIeDevice_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishPCIeDevice_V1_2_0_Dxe.inf | 55 +++ .../PCIeDevice/v1_2_1/PCIeDevice_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../v1_2_1/RedfishPCIeDevice_V1_2_1_Dxe.inf | 55 +++ .../PCIeDevice/v1_2_2/PCIeDevice_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../v1_2_2/RedfishPCIeDevice_V1_2_2_Dxe.inf | 55 +++ .../PCIeDevice/v1_2_3/PCIeDevice_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../v1_2_3/RedfishPCIeDevice_V1_2_3_Dxe.inf | 55 +++ .../PCIeDevice/v1_3_0/PCIeDevice_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../v1_3_0/RedfishPCIeDevice_V1_3_0_Dxe.inf | 55 +++ .../PCIeDevice/v1_3_1/PCIeDevice_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../v1_3_1/RedfishPCIeDevice_V1_3_1_Dxe.inf | 55 +++ .../PCIeDevice/v1_3_2/PCIeDevice_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../v1_3_2/RedfishPCIeDevice_V1_3_2_Dxe.inf | 55 +++ .../PCIeDevice/v1_4_0/PCIeDevice_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../v1_4_0/RedfishPCIeDevice_V1_4_0_Dxe.inf | 55 +++ .../PCIeDevice/v1_5_0/PCIeDevice_V1_5_0_Dxe.c | 427 ++++++++++++++++++ .../v1_5_0/RedfishPCIeDevice_V1_5_0_Dxe.inf | 55 +++ .../PCIeDevice/v1_6_0/PCIeDevice_V1_6_0_Dxe.c | 427 ++++++++++++++++++ .../v1_6_0/RedfishPCIeDevice_V1_6_0_Dxe.inf | 55 +++ .../PCIeDeviceCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishPCIeDeviceCollection_Dxe.inf | 55 +++ .../v1_0_0/PCIeFunction_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishPCIeFunction_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/PCIeFunction_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishPCIeFunction_V1_0_1_Dxe.inf | 55 +++ .../v1_0_2/PCIeFunction_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishPCIeFunction_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/PCIeFunction_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishPCIeFunction_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/PCIeFunction_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishPCIeFunction_V1_0_4_Dxe.inf | 55 +++ .../v1_0_5/PCIeFunction_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishPCIeFunction_V1_0_5_Dxe.inf | 55 +++ .../v1_0_6/PCIeFunction_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../v1_0_6/RedfishPCIeFunction_V1_0_6_Dxe.inf | 55 +++ .../v1_1_0/PCIeFunction_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishPCIeFunction_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/PCIeFunction_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishPCIeFunction_V1_1_1_Dxe.inf | 55 +++ .../v1_1_2/PCIeFunction_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishPCIeFunction_V1_1_2_Dxe.inf | 55 +++ .../v1_1_3/PCIeFunction_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../v1_1_3/RedfishPCIeFunction_V1_1_3_Dxe.inf | 55 +++ .../v1_1_4/PCIeFunction_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../v1_1_4/RedfishPCIeFunction_V1_1_4_Dxe.inf | 55 +++ .../v1_2_0/PCIeFunction_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishPCIeFunction_V1_2_0_Dxe.inf | 55 +++ .../v1_2_1/PCIeFunction_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../v1_2_1/RedfishPCIeFunction_V1_2_1_Dxe.inf | 55 +++ .../v1_2_2/PCIeFunction_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../v1_2_2/RedfishPCIeFunction_V1_2_2_Dxe.inf | 55 +++ .../v1_2_3/PCIeFunction_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../v1_2_3/RedfishPCIeFunction_V1_2_3_Dxe.inf | 55 +++ .../PCIeFunctionCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishPCIeFunctionCollection_Dxe.inf | 55 +++ .../PCIeSlots/v1_0_0/PCIeSlots_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishPCIeSlots_V1_0_0_Dxe.inf | 55 +++ .../PCIeSlots/v1_0_1/PCIeSlots_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishPCIeSlots_V1_0_1_Dxe.inf | 55 +++ .../PCIeSlots/v1_0_2/PCIeSlots_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishPCIeSlots_V1_0_2_Dxe.inf | 55 +++ .../PCIeSlots/v1_0_3/PCIeSlots_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishPCIeSlots_V1_0_3_Dxe.inf | 55 +++ .../PCIeSlots/v1_1_0/PCIeSlots_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishPCIeSlots_V1_1_0_Dxe.inf | 55 +++ .../PCIeSlots/v1_1_1/PCIeSlots_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishPCIeSlots_V1_1_1_Dxe.inf | 55 +++ .../PCIeSlots/v1_1_2/PCIeSlots_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishPCIeSlots_V1_1_2_Dxe.inf | 55 +++ .../PCIeSlots/v1_2_0/PCIeSlots_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishPCIeSlots_V1_2_0_Dxe.inf | 55 +++ .../PCIeSlots/v1_3_0/PCIeSlots_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../v1_3_0/RedfishPCIeSlots_V1_3_0_Dxe.inf | 55 +++ .../PCIeSlots/v1_4_0/PCIeSlots_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../v1_4_0/RedfishPCIeSlots_V1_4_0_Dxe.inf | 55 +++ .../PCIeSlots/v1_4_1/PCIeSlots_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../v1_4_1/RedfishPCIeSlots_V1_4_1_Dxe.inf | 55 +++ .../Converter/Port/v1_0_0/Port_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../Port/v1_0_0/RedfishPort_V1_0_0_Dxe.inf | 55 +++ .../Converter/Port/v1_0_1/Port_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../Port/v1_0_1/RedfishPort_V1_0_1_Dxe.inf | 55 +++ .../Converter/Port/v1_0_2/Port_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../Port/v1_0_2/RedfishPort_V1_0_2_Dxe.inf | 55 +++ .../Converter/Port/v1_0_3/Port_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../Port/v1_0_3/RedfishPort_V1_0_3_Dxe.inf | 55 +++ .../Converter/Port/v1_0_4/Port_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../Port/v1_0_4/RedfishPort_V1_0_4_Dxe.inf | 55 +++ .../Converter/Port/v1_0_5/Port_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../Port/v1_0_5/RedfishPort_V1_0_5_Dxe.inf | 55 +++ .../Converter/Port/v1_0_6/Port_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../Port/v1_0_6/RedfishPort_V1_0_6_Dxe.inf | 55 +++ .../Converter/Port/v1_0_7/Port_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../Port/v1_0_7/RedfishPort_V1_0_7_Dxe.inf | 55 +++ .../Converter/Port/v1_0_8/Port_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../Port/v1_0_8/RedfishPort_V1_0_8_Dxe.inf | 55 +++ .../Converter/Port/v1_1_0/Port_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../Port/v1_1_0/RedfishPort_V1_1_0_Dxe.inf | 55 +++ .../Converter/Port/v1_1_1/Port_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../Port/v1_1_1/RedfishPort_V1_1_1_Dxe.inf | 55 +++ .../Converter/Port/v1_1_2/Port_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../Port/v1_1_2/RedfishPort_V1_1_2_Dxe.inf | 55 +++ .../Converter/Port/v1_1_3/Port_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../Port/v1_1_3/RedfishPort_V1_1_3_Dxe.inf | 55 +++ .../Converter/Port/v1_1_4/Port_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../Port/v1_1_4/RedfishPort_V1_1_4_Dxe.inf | 55 +++ .../Converter/Port/v1_1_5/Port_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../Port/v1_1_5/RedfishPort_V1_1_5_Dxe.inf | 55 +++ .../Converter/Port/v1_2_0/Port_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../Port/v1_2_0/RedfishPort_V1_2_0_Dxe.inf | 55 +++ .../Converter/Port/v1_2_1/Port_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../Port/v1_2_1/RedfishPort_V1_2_1_Dxe.inf | 55 +++ .../Converter/Port/v1_2_2/Port_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../Port/v1_2_2/RedfishPort_V1_2_2_Dxe.inf | 55 +++ .../Converter/Port/v1_2_3/Port_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../Port/v1_2_3/RedfishPort_V1_2_3_Dxe.inf | 55 +++ .../Converter/Port/v1_3_0/Port_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../Port/v1_3_0/RedfishPort_V1_3_0_Dxe.inf | 55 +++ .../Converter/Port/v1_3_1/Port_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../Port/v1_3_1/RedfishPort_V1_3_1_Dxe.inf | 55 +++ .../PortCollection/PortCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishPortCollection_Dxe.inf | 55 +++ .../v1_0_0/PortMetrics_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishPortMetrics_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/PortMetrics_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishPortMetrics_V1_0_1_Dxe.inf | 55 +++ .../Converter/Power/v1_0_0/Power_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_0_0/RedfishPower_V1_0_0_Dxe.inf | 55 +++ .../Converter/Power/v1_0_1/Power_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_0_1/RedfishPower_V1_0_1_Dxe.inf | 55 +++ .../Power/v1_0_10/Power_V1_0_10_Dxe.c | 427 ++++++++++++++++++ .../v1_0_10/RedfishPower_V1_0_10_Dxe.inf | 55 +++ .../Power/v1_0_11/Power_V1_0_11_Dxe.c | 427 ++++++++++++++++++ .../v1_0_11/RedfishPower_V1_0_11_Dxe.inf | 55 +++ .../Power/v1_0_12/Power_V1_0_12_Dxe.c | 427 ++++++++++++++++++ .../v1_0_12/RedfishPower_V1_0_12_Dxe.inf | 55 +++ .../Converter/Power/v1_0_2/Power_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_0_2/RedfishPower_V1_0_2_Dxe.inf | 55 +++ .../Converter/Power/v1_0_3/Power_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_0_3/RedfishPower_V1_0_3_Dxe.inf | 55 +++ .../Converter/Power/v1_0_4/Power_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_0_4/RedfishPower_V1_0_4_Dxe.inf | 55 +++ .../Converter/Power/v1_0_5/Power_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_0_5/RedfishPower_V1_0_5_Dxe.inf | 55 +++ .../Converter/Power/v1_0_6/Power_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_0_6/RedfishPower_V1_0_6_Dxe.inf | 55 +++ .../Converter/Power/v1_0_7/Power_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_0_7/RedfishPower_V1_0_7_Dxe.inf | 55 +++ .../Converter/Power/v1_0_8/Power_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_0_8/RedfishPower_V1_0_8_Dxe.inf | 55 +++ .../Converter/Power/v1_0_9/Power_V1_0_9_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_0_9/RedfishPower_V1_0_9_Dxe.inf | 55 +++ .../Converter/Power/v1_1_0/Power_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_1_0/RedfishPower_V1_1_0_Dxe.inf | 55 +++ .../Converter/Power/v1_1_1/Power_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_1_1/RedfishPower_V1_1_1_Dxe.inf | 55 +++ .../Power/v1_1_10/Power_V1_1_10_Dxe.c | 427 ++++++++++++++++++ .../v1_1_10/RedfishPower_V1_1_10_Dxe.inf | 55 +++ .../Converter/Power/v1_1_2/Power_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_1_2/RedfishPower_V1_1_2_Dxe.inf | 55 +++ .../Converter/Power/v1_1_3/Power_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_1_3/RedfishPower_V1_1_3_Dxe.inf | 55 +++ .../Converter/Power/v1_1_4/Power_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_1_4/RedfishPower_V1_1_4_Dxe.inf | 55 +++ .../Converter/Power/v1_1_5/Power_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_1_5/RedfishPower_V1_1_5_Dxe.inf | 55 +++ .../Converter/Power/v1_1_6/Power_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_1_6/RedfishPower_V1_1_6_Dxe.inf | 55 +++ .../Converter/Power/v1_1_7/Power_V1_1_7_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_1_7/RedfishPower_V1_1_7_Dxe.inf | 55 +++ .../Converter/Power/v1_1_8/Power_V1_1_8_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_1_8/RedfishPower_V1_1_8_Dxe.inf | 55 +++ .../Converter/Power/v1_1_9/Power_V1_1_9_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_1_9/RedfishPower_V1_1_9_Dxe.inf | 55 +++ .../Converter/Power/v1_2_0/Power_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_2_0/RedfishPower_V1_2_0_Dxe.inf | 55 +++ .../Converter/Power/v1_2_1/Power_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_2_1/RedfishPower_V1_2_1_Dxe.inf | 55 +++ .../Power/v1_2_10/Power_V1_2_10_Dxe.c | 427 ++++++++++++++++++ .../v1_2_10/RedfishPower_V1_2_10_Dxe.inf | 55 +++ .../Converter/Power/v1_2_2/Power_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_2_2/RedfishPower_V1_2_2_Dxe.inf | 55 +++ .../Converter/Power/v1_2_3/Power_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_2_3/RedfishPower_V1_2_3_Dxe.inf | 55 +++ .../Converter/Power/v1_2_4/Power_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_2_4/RedfishPower_V1_2_4_Dxe.inf | 55 +++ .../Converter/Power/v1_2_5/Power_V1_2_5_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_2_5/RedfishPower_V1_2_5_Dxe.inf | 55 +++ .../Converter/Power/v1_2_6/Power_V1_2_6_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_2_6/RedfishPower_V1_2_6_Dxe.inf | 55 +++ .../Converter/Power/v1_2_7/Power_V1_2_7_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_2_7/RedfishPower_V1_2_7_Dxe.inf | 55 +++ .../Converter/Power/v1_2_8/Power_V1_2_8_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_2_8/RedfishPower_V1_2_8_Dxe.inf | 55 +++ .../Converter/Power/v1_2_9/Power_V1_2_9_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_2_9/RedfishPower_V1_2_9_Dxe.inf | 55 +++ .../Converter/Power/v1_3_0/Power_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_3_0/RedfishPower_V1_3_0_Dxe.inf | 55 +++ .../Converter/Power/v1_3_1/Power_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_3_1/RedfishPower_V1_3_1_Dxe.inf | 55 +++ .../Converter/Power/v1_3_2/Power_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_3_2/RedfishPower_V1_3_2_Dxe.inf | 55 +++ .../Converter/Power/v1_3_3/Power_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_3_3/RedfishPower_V1_3_3_Dxe.inf | 55 +++ .../Converter/Power/v1_3_4/Power_V1_3_4_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_3_4/RedfishPower_V1_3_4_Dxe.inf | 55 +++ .../Converter/Power/v1_3_5/Power_V1_3_5_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_3_5/RedfishPower_V1_3_5_Dxe.inf | 55 +++ .../Converter/Power/v1_3_6/Power_V1_3_6_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_3_6/RedfishPower_V1_3_6_Dxe.inf | 55 +++ .../Converter/Power/v1_3_7/Power_V1_3_7_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_3_7/RedfishPower_V1_3_7_Dxe.inf | 55 +++ .../Converter/Power/v1_3_8/Power_V1_3_8_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_3_8/RedfishPower_V1_3_8_Dxe.inf | 55 +++ .../Converter/Power/v1_4_0/Power_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_4_0/RedfishPower_V1_4_0_Dxe.inf | 55 +++ .../Converter/Power/v1_4_1/Power_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_4_1/RedfishPower_V1_4_1_Dxe.inf | 55 +++ .../Converter/Power/v1_4_2/Power_V1_4_2_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_4_2/RedfishPower_V1_4_2_Dxe.inf | 55 +++ .../Converter/Power/v1_4_3/Power_V1_4_3_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_4_3/RedfishPower_V1_4_3_Dxe.inf | 55 +++ .../Converter/Power/v1_4_4/Power_V1_4_4_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_4_4/RedfishPower_V1_4_4_Dxe.inf | 55 +++ .../Converter/Power/v1_4_5/Power_V1_4_5_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_4_5/RedfishPower_V1_4_5_Dxe.inf | 55 +++ .../Converter/Power/v1_4_6/Power_V1_4_6_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_4_6/RedfishPower_V1_4_6_Dxe.inf | 55 +++ .../Converter/Power/v1_4_7/Power_V1_4_7_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_4_7/RedfishPower_V1_4_7_Dxe.inf | 55 +++ .../Converter/Power/v1_5_0/Power_V1_5_0_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_5_0/RedfishPower_V1_5_0_Dxe.inf | 55 +++ .../Converter/Power/v1_5_1/Power_V1_5_1_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_5_1/RedfishPower_V1_5_1_Dxe.inf | 55 +++ .../Converter/Power/v1_5_2/Power_V1_5_2_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_5_2/RedfishPower_V1_5_2_Dxe.inf | 55 +++ .../Converter/Power/v1_5_3/Power_V1_5_3_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_5_3/RedfishPower_V1_5_3_Dxe.inf | 55 +++ .../Converter/Power/v1_5_4/Power_V1_5_4_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_5_4/RedfishPower_V1_5_4_Dxe.inf | 55 +++ .../Converter/Power/v1_5_5/Power_V1_5_5_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_5_5/RedfishPower_V1_5_5_Dxe.inf | 55 +++ .../Converter/Power/v1_5_6/Power_V1_5_6_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_5_6/RedfishPower_V1_5_6_Dxe.inf | 55 +++ .../Converter/Power/v1_6_0/Power_V1_6_0_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_6_0/RedfishPower_V1_6_0_Dxe.inf | 55 +++ .../Converter/Power/v1_6_1/Power_V1_6_1_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_6_1/RedfishPower_V1_6_1_Dxe.inf | 55 +++ .../Converter/Power/v1_6_2/Power_V1_6_2_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_6_2/RedfishPower_V1_6_2_Dxe.inf | 55 +++ .../Converter/Power/v1_7_0/Power_V1_7_0_Dxe.c | 427 ++++++++++++++++++ .../Power/v1_7_0/RedfishPower_V1_7_0_Dxe.inf | 55 +++ .../v1_0_0/PowerDistribution_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishPowerDistribution_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/PowerDistribution_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishPowerDistribution_V1_0_1_Dxe.inf | 55 +++ .../v1_0_2/PowerDistribution_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishPowerDistribution_V1_0_2_Dxe.inf | 55 +++ .../PowerDistributionCollection_Dxe.c | 427 ++++++++++++++++++ ...RedfishPowerDistributionCollection_Dxe.inf | 55 +++ .../PowerDistributionMetrics_V1_0_0_Dxe.c | 427 ++++++++++++++++++ ...ishPowerDistributionMetrics_V1_0_0_Dxe.inf | 55 +++ .../v1_0_0/PowerDomain_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishPowerDomain_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/PowerDomain_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishPowerDomain_V1_0_1_Dxe.inf | 55 +++ .../PowerDomainCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishPowerDomainCollection_Dxe.inf | 55 +++ .../v1_0_0/PowerEquipment_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishPowerEquipment_V1_0_0_Dxe.inf | 55 +++ .../v1_0_0/PowerSubsystem_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishPowerSubsystem_V1_0_0_Dxe.inf | 55 +++ .../v1_0_0/PowerSupply_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishPowerSupply_V1_0_0_Dxe.inf | 55 +++ .../PowerSupplyCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishPowerSupplyCollection_Dxe.inf | 55 +++ .../v1_0_0/PowerSupplyMetrics_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishPowerSupplyMetrics_V1_0_0_Dxe.inf | 55 +++ .../v1_0_0/PrivilegeRegistry_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishPrivilegeRegistry_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/PrivilegeRegistry_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishPrivilegeRegistry_V1_0_1_Dxe.inf | 55 +++ .../v1_0_2/PrivilegeRegistry_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishPrivilegeRegistry_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/PrivilegeRegistry_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishPrivilegeRegistry_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/PrivilegeRegistry_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishPrivilegeRegistry_V1_0_4_Dxe.inf | 55 +++ .../v1_0_5/PrivilegeRegistry_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishPrivilegeRegistry_V1_0_5_Dxe.inf | 55 +++ .../v1_1_0/PrivilegeRegistry_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishPrivilegeRegistry_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/PrivilegeRegistry_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishPrivilegeRegistry_V1_1_1_Dxe.inf | 55 +++ .../v1_1_2/PrivilegeRegistry_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishPrivilegeRegistry_V1_1_2_Dxe.inf | 55 +++ .../v1_1_3/PrivilegeRegistry_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishPrivilegeRegistry_V1_1_3_Dxe.inf | 55 +++ .../v1_1_4/PrivilegeRegistry_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishPrivilegeRegistry_V1_1_4_Dxe.inf | 55 +++ .../Processor/v1_0_0/Processor_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishProcessor_V1_0_0_Dxe.inf | 55 +++ .../Processor/v1_0_10/Processor_V1_0_10_Dxe.c | 427 ++++++++++++++++++ .../v1_0_10/RedfishProcessor_V1_0_10_Dxe.inf | 55 +++ .../Processor/v1_0_11/Processor_V1_0_11_Dxe.c | 427 ++++++++++++++++++ .../v1_0_11/RedfishProcessor_V1_0_11_Dxe.inf | 55 +++ .../Processor/v1_0_12/Processor_V1_0_12_Dxe.c | 427 ++++++++++++++++++ .../v1_0_12/RedfishProcessor_V1_0_12_Dxe.inf | 55 +++ .../Processor/v1_0_2/Processor_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishProcessor_V1_0_2_Dxe.inf | 55 +++ .../Processor/v1_0_3/Processor_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishProcessor_V1_0_3_Dxe.inf | 55 +++ .../Processor/v1_0_4/Processor_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishProcessor_V1_0_4_Dxe.inf | 55 +++ .../Processor/v1_0_5/Processor_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishProcessor_V1_0_5_Dxe.inf | 55 +++ .../Processor/v1_0_6/Processor_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../v1_0_6/RedfishProcessor_V1_0_6_Dxe.inf | 55 +++ .../Processor/v1_0_7/Processor_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../v1_0_7/RedfishProcessor_V1_0_7_Dxe.inf | 55 +++ .../Processor/v1_0_8/Processor_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../v1_0_8/RedfishProcessor_V1_0_8_Dxe.inf | 55 +++ .../Processor/v1_0_9/Processor_V1_0_9_Dxe.c | 427 ++++++++++++++++++ .../v1_0_9/RedfishProcessor_V1_0_9_Dxe.inf | 55 +++ .../Processor/v1_10_0/Processor_V1_10_0_Dxe.c | 427 ++++++++++++++++++ .../v1_10_0/RedfishProcessor_V1_10_0_Dxe.inf | 55 +++ .../Processor/v1_10_1/Processor_V1_10_1_Dxe.c | 427 ++++++++++++++++++ .../v1_10_1/RedfishProcessor_V1_10_1_Dxe.inf | 55 +++ .../Processor/v1_11_0/Processor_V1_11_0_Dxe.c | 427 ++++++++++++++++++ .../v1_11_0/RedfishProcessor_V1_11_0_Dxe.inf | 55 +++ .../Processor/v1_1_0/Processor_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishProcessor_V1_1_0_Dxe.inf | 55 +++ .../Processor/v1_1_1/Processor_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishProcessor_V1_1_1_Dxe.inf | 55 +++ .../Processor/v1_1_2/Processor_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishProcessor_V1_1_2_Dxe.inf | 55 +++ .../Processor/v1_1_3/Processor_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../v1_1_3/RedfishProcessor_V1_1_3_Dxe.inf | 55 +++ .../Processor/v1_1_4/Processor_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../v1_1_4/RedfishProcessor_V1_1_4_Dxe.inf | 55 +++ .../Processor/v1_1_5/Processor_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../v1_1_5/RedfishProcessor_V1_1_5_Dxe.inf | 55 +++ .../Processor/v1_1_6/Processor_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../v1_1_6/RedfishProcessor_V1_1_6_Dxe.inf | 55 +++ .../Processor/v1_1_7/Processor_V1_1_7_Dxe.c | 427 ++++++++++++++++++ .../v1_1_7/RedfishProcessor_V1_1_7_Dxe.inf | 55 +++ .../Processor/v1_1_8/Processor_V1_1_8_Dxe.c | 427 ++++++++++++++++++ .../v1_1_8/RedfishProcessor_V1_1_8_Dxe.inf | 55 +++ .../Processor/v1_2_0/Processor_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishProcessor_V1_2_0_Dxe.inf | 55 +++ .../Processor/v1_2_1/Processor_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../v1_2_1/RedfishProcessor_V1_2_1_Dxe.inf | 55 +++ .../Processor/v1_2_2/Processor_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../v1_2_2/RedfishProcessor_V1_2_2_Dxe.inf | 55 +++ .../Processor/v1_2_3/Processor_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../v1_2_3/RedfishProcessor_V1_2_3_Dxe.inf | 55 +++ .../Processor/v1_2_4/Processor_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../v1_2_4/RedfishProcessor_V1_2_4_Dxe.inf | 55 +++ .../Processor/v1_2_5/Processor_V1_2_5_Dxe.c | 427 ++++++++++++++++++ .../v1_2_5/RedfishProcessor_V1_2_5_Dxe.inf | 55 +++ .../Processor/v1_2_6/Processor_V1_2_6_Dxe.c | 427 ++++++++++++++++++ .../v1_2_6/RedfishProcessor_V1_2_6_Dxe.inf | 55 +++ .../Processor/v1_2_7/Processor_V1_2_7_Dxe.c | 427 ++++++++++++++++++ .../v1_2_7/RedfishProcessor_V1_2_7_Dxe.inf | 55 +++ .../Processor/v1_2_8/Processor_V1_2_8_Dxe.c | 427 ++++++++++++++++++ .../v1_2_8/RedfishProcessor_V1_2_8_Dxe.inf | 55 +++ .../Processor/v1_3_0/Processor_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../v1_3_0/RedfishProcessor_V1_3_0_Dxe.inf | 55 +++ .../Processor/v1_3_1/Processor_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../v1_3_1/RedfishProcessor_V1_3_1_Dxe.inf | 55 +++ .../Processor/v1_3_2/Processor_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../v1_3_2/RedfishProcessor_V1_3_2_Dxe.inf | 55 +++ .../Processor/v1_3_3/Processor_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../v1_3_3/RedfishProcessor_V1_3_3_Dxe.inf | 55 +++ .../Processor/v1_3_4/Processor_V1_3_4_Dxe.c | 427 ++++++++++++++++++ .../v1_3_4/RedfishProcessor_V1_3_4_Dxe.inf | 55 +++ .../Processor/v1_3_5/Processor_V1_3_5_Dxe.c | 427 ++++++++++++++++++ .../v1_3_5/RedfishProcessor_V1_3_5_Dxe.inf | 55 +++ .../Processor/v1_3_6/Processor_V1_3_6_Dxe.c | 427 ++++++++++++++++++ .../v1_3_6/RedfishProcessor_V1_3_6_Dxe.inf | 55 +++ .../Processor/v1_3_7/Processor_V1_3_7_Dxe.c | 427 ++++++++++++++++++ .../v1_3_7/RedfishProcessor_V1_3_7_Dxe.inf | 55 +++ .../Processor/v1_3_8/Processor_V1_3_8_Dxe.c | 427 ++++++++++++++++++ .../v1_3_8/RedfishProcessor_V1_3_8_Dxe.inf | 55 +++ .../Processor/v1_4_0/Processor_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../v1_4_0/RedfishProcessor_V1_4_0_Dxe.inf | 55 +++ .../Processor/v1_4_1/Processor_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../v1_4_1/RedfishProcessor_V1_4_1_Dxe.inf | 55 +++ .../Processor/v1_4_2/Processor_V1_4_2_Dxe.c | 427 ++++++++++++++++++ .../v1_4_2/RedfishProcessor_V1_4_2_Dxe.inf | 55 +++ .../Processor/v1_4_3/Processor_V1_4_3_Dxe.c | 427 ++++++++++++++++++ .../v1_4_3/RedfishProcessor_V1_4_3_Dxe.inf | 55 +++ .../Processor/v1_4_4/Processor_V1_4_4_Dxe.c | 427 ++++++++++++++++++ .../v1_4_4/RedfishProcessor_V1_4_4_Dxe.inf | 55 +++ .../Processor/v1_4_5/Processor_V1_4_5_Dxe.c | 427 ++++++++++++++++++ .../v1_4_5/RedfishProcessor_V1_4_5_Dxe.inf | 55 +++ .../Processor/v1_4_6/Processor_V1_4_6_Dxe.c | 427 ++++++++++++++++++ .../v1_4_6/RedfishProcessor_V1_4_6_Dxe.inf | 55 +++ .../Processor/v1_4_7/Processor_V1_4_7_Dxe.c | 427 ++++++++++++++++++ .../v1_4_7/RedfishProcessor_V1_4_7_Dxe.inf | 55 +++ .../Processor/v1_5_0/Processor_V1_5_0_Dxe.c | 427 ++++++++++++++++++ .../v1_5_0/RedfishProcessor_V1_5_0_Dxe.inf | 55 +++ .../Processor/v1_5_1/Processor_V1_5_1_Dxe.c | 427 ++++++++++++++++++ .../v1_5_1/RedfishProcessor_V1_5_1_Dxe.inf | 55 +++ .../Processor/v1_5_2/Processor_V1_5_2_Dxe.c | 427 ++++++++++++++++++ .../v1_5_2/RedfishProcessor_V1_5_2_Dxe.inf | 55 +++ .../Processor/v1_5_3/Processor_V1_5_3_Dxe.c | 427 ++++++++++++++++++ .../v1_5_3/RedfishProcessor_V1_5_3_Dxe.inf | 55 +++ .../Processor/v1_5_4/Processor_V1_5_4_Dxe.c | 427 ++++++++++++++++++ .../v1_5_4/RedfishProcessor_V1_5_4_Dxe.inf | 55 +++ .../Processor/v1_5_5/Processor_V1_5_5_Dxe.c | 427 ++++++++++++++++++ .../v1_5_5/RedfishProcessor_V1_5_5_Dxe.inf | 55 +++ .../Processor/v1_5_6/Processor_V1_5_6_Dxe.c | 427 ++++++++++++++++++ .../v1_5_6/RedfishProcessor_V1_5_6_Dxe.inf | 55 +++ .../Processor/v1_6_0/Processor_V1_6_0_Dxe.c | 427 ++++++++++++++++++ .../v1_6_0/RedfishProcessor_V1_6_0_Dxe.inf | 55 +++ .../Processor/v1_6_1/Processor_V1_6_1_Dxe.c | 427 ++++++++++++++++++ .../v1_6_1/RedfishProcessor_V1_6_1_Dxe.inf | 55 +++ .../Processor/v1_6_2/Processor_V1_6_2_Dxe.c | 427 ++++++++++++++++++ .../v1_6_2/RedfishProcessor_V1_6_2_Dxe.inf | 55 +++ .../Processor/v1_6_3/Processor_V1_6_3_Dxe.c | 427 ++++++++++++++++++ .../v1_6_3/RedfishProcessor_V1_6_3_Dxe.inf | 55 +++ .../Processor/v1_6_4/Processor_V1_6_4_Dxe.c | 427 ++++++++++++++++++ .../v1_6_4/RedfishProcessor_V1_6_4_Dxe.inf | 55 +++ .../Processor/v1_7_0/Processor_V1_7_0_Dxe.c | 427 ++++++++++++++++++ .../v1_7_0/RedfishProcessor_V1_7_0_Dxe.inf | 55 +++ .../Processor/v1_7_1/Processor_V1_7_1_Dxe.c | 427 ++++++++++++++++++ .../v1_7_1/RedfishProcessor_V1_7_1_Dxe.inf | 55 +++ .../Processor/v1_7_2/Processor_V1_7_2_Dxe.c | 427 ++++++++++++++++++ .../v1_7_2/RedfishProcessor_V1_7_2_Dxe.inf | 55 +++ .../Processor/v1_7_3/Processor_V1_7_3_Dxe.c | 427 ++++++++++++++++++ .../v1_7_3/RedfishProcessor_V1_7_3_Dxe.inf | 55 +++ .../Processor/v1_8_0/Processor_V1_8_0_Dxe.c | 427 ++++++++++++++++++ .../v1_8_0/RedfishProcessor_V1_8_0_Dxe.inf | 55 +++ .../Processor/v1_8_1/Processor_V1_8_1_Dxe.c | 427 ++++++++++++++++++ .../v1_8_1/RedfishProcessor_V1_8_1_Dxe.inf | 55 +++ .../Processor/v1_8_2/Processor_V1_8_2_Dxe.c | 427 ++++++++++++++++++ .../v1_8_2/RedfishProcessor_V1_8_2_Dxe.inf | 55 +++ .../Processor/v1_9_0/Processor_V1_9_0_Dxe.c | 427 ++++++++++++++++++ .../v1_9_0/RedfishProcessor_V1_9_0_Dxe.inf | 55 +++ .../Processor/v1_9_1/Processor_V1_9_1_Dxe.c | 427 ++++++++++++++++++ .../v1_9_1/RedfishProcessor_V1_9_1_Dxe.inf | 55 +++ .../ProcessorCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishProcessorCollection_Dxe.inf | 55 +++ .../v1_0_0/ProcessorMetrics_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishProcessorMetrics_V1_0_0_Dxe.inf | 55 +++ .../v1_0_1/ProcessorMetrics_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishProcessorMetrics_V1_0_1_Dxe.inf | 55 +++ .../v1_0_2/ProcessorMetrics_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishProcessorMetrics_V1_0_2_Dxe.inf | 55 +++ .../v1_0_3/ProcessorMetrics_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishProcessorMetrics_V1_0_3_Dxe.inf | 55 +++ .../v1_0_4/ProcessorMetrics_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishProcessorMetrics_V1_0_4_Dxe.inf | 55 +++ .../v1_1_0/ProcessorMetrics_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishProcessorMetrics_V1_1_0_Dxe.inf | 55 +++ .../v1_1_1/ProcessorMetrics_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishProcessorMetrics_V1_1_1_Dxe.inf | 55 +++ .../v1_1_2/ProcessorMetrics_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishProcessorMetrics_V1_1_2_Dxe.inf | 55 +++ .../v1_2_0/ProcessorMetrics_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishProcessorMetrics_V1_2_0_Dxe.inf | 55 +++ .../RedfishResourceBlock_V1_0_0_Dxe.inf | 55 +++ .../v1_0_0/ResourceBlock_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishResourceBlock_V1_0_1_Dxe.inf | 55 +++ .../v1_0_1/ResourceBlock_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishResourceBlock_V1_0_2_Dxe.inf | 55 +++ .../v1_0_2/ResourceBlock_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishResourceBlock_V1_0_3_Dxe.inf | 55 +++ .../v1_0_3/ResourceBlock_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishResourceBlock_V1_0_4_Dxe.inf | 55 +++ .../v1_0_4/ResourceBlock_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishResourceBlock_V1_0_5_Dxe.inf | 55 +++ .../v1_0_5/ResourceBlock_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishResourceBlock_V1_0_6_Dxe.inf | 55 +++ .../v1_0_6/ResourceBlock_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishResourceBlock_V1_1_0_Dxe.inf | 55 +++ .../v1_1_0/ResourceBlock_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishResourceBlock_V1_1_1_Dxe.inf | 55 +++ .../v1_1_1/ResourceBlock_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishResourceBlock_V1_1_2_Dxe.inf | 55 +++ .../v1_1_2/ResourceBlock_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishResourceBlock_V1_1_3_Dxe.inf | 55 +++ .../v1_1_3/ResourceBlock_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishResourceBlock_V1_1_4_Dxe.inf | 55 +++ .../v1_1_4/ResourceBlock_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishResourceBlock_V1_1_5_Dxe.inf | 55 +++ .../v1_1_5/ResourceBlock_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishResourceBlock_V1_1_6_Dxe.inf | 55 +++ .../v1_1_6/ResourceBlock_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishResourceBlock_V1_2_0_Dxe.inf | 55 +++ .../v1_2_0/ResourceBlock_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishResourceBlock_V1_2_1_Dxe.inf | 55 +++ .../v1_2_1/ResourceBlock_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishResourceBlock_V1_2_2_Dxe.inf | 55 +++ .../v1_2_2/ResourceBlock_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishResourceBlock_V1_2_3_Dxe.inf | 55 +++ .../v1_2_3/ResourceBlock_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishResourceBlock_V1_2_4_Dxe.inf | 55 +++ .../v1_2_4/ResourceBlock_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishResourceBlock_V1_2_5_Dxe.inf | 55 +++ .../v1_2_5/ResourceBlock_V1_2_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishResourceBlock_V1_3_0_Dxe.inf | 55 +++ .../v1_3_0/ResourceBlock_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishResourceBlock_V1_3_1_Dxe.inf | 55 +++ .../v1_3_1/ResourceBlock_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishResourceBlock_V1_3_2_Dxe.inf | 55 +++ .../v1_3_2/ResourceBlock_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishResourceBlock_V1_3_3_Dxe.inf | 55 +++ .../v1_3_3/ResourceBlock_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishResourceBlock_V1_3_4_Dxe.inf | 55 +++ .../v1_3_4/ResourceBlock_V1_3_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishResourceBlockCollection_Dxe.inf | 55 +++ .../ResourceBlockCollection_Dxe.c | 427 ++++++++++++++++++ .../Role/v1_0_0/RedfishRole_V1_0_0_Dxe.inf | 55 +++ .../Converter/Role/v1_0_0/Role_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../Role/v1_0_2/RedfishRole_V1_0_2_Dxe.inf | 55 +++ .../Converter/Role/v1_0_2/Role_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../Role/v1_0_3/RedfishRole_V1_0_3_Dxe.inf | 55 +++ .../Converter/Role/v1_0_3/Role_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../Role/v1_0_4/RedfishRole_V1_0_4_Dxe.inf | 55 +++ .../Converter/Role/v1_0_4/Role_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../Role/v1_0_5/RedfishRole_V1_0_5_Dxe.inf | 55 +++ .../Converter/Role/v1_0_5/Role_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../Role/v1_0_6/RedfishRole_V1_0_6_Dxe.inf | 55 +++ .../Converter/Role/v1_0_6/Role_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../Role/v1_0_7/RedfishRole_V1_0_7_Dxe.inf | 55 +++ .../Converter/Role/v1_0_7/Role_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../Role/v1_1_0/RedfishRole_V1_1_0_Dxe.inf | 55 +++ .../Converter/Role/v1_1_0/Role_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../Role/v1_1_1/RedfishRole_V1_1_1_Dxe.inf | 55 +++ .../Converter/Role/v1_1_1/Role_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../Role/v1_1_2/RedfishRole_V1_1_2_Dxe.inf | 55 +++ .../Converter/Role/v1_1_2/Role_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../Role/v1_1_3/RedfishRole_V1_1_3_Dxe.inf | 55 +++ .../Converter/Role/v1_1_3/Role_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../Role/v1_1_4/RedfishRole_V1_1_4_Dxe.inf | 55 +++ .../Converter/Role/v1_1_4/Role_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../Role/v1_1_5/RedfishRole_V1_1_5_Dxe.inf | 55 +++ .../Converter/Role/v1_1_5/Role_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../Role/v1_2_0/RedfishRole_V1_2_0_Dxe.inf | 55 +++ .../Converter/Role/v1_2_0/Role_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../Role/v1_2_1/RedfishRole_V1_2_1_Dxe.inf | 55 +++ .../Converter/Role/v1_2_1/Role_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../Role/v1_2_2/RedfishRole_V1_2_2_Dxe.inf | 55 +++ .../Converter/Role/v1_2_2/Role_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../Role/v1_2_3/RedfishRole_V1_2_3_Dxe.inf | 55 +++ .../Converter/Role/v1_2_3/Role_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../Role/v1_2_4/RedfishRole_V1_2_4_Dxe.inf | 55 +++ .../Converter/Role/v1_2_4/Role_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../Role/v1_2_5/RedfishRole_V1_2_5_Dxe.inf | 55 +++ .../Converter/Role/v1_2_5/Role_V1_2_5_Dxe.c | 427 ++++++++++++++++++ .../Role/v1_3_0/RedfishRole_V1_3_0_Dxe.inf | 55 +++ .../Converter/Role/v1_3_0/Role_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishRoleCollection_Dxe.inf | 55 +++ .../RoleCollection/RoleCollection_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishRouteEntry_V1_0_0_Dxe.inf | 55 +++ .../RouteEntry/v1_0_0/RouteEntry_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishRouteEntry_V1_0_1_Dxe.inf | 55 +++ .../RouteEntry/v1_0_1/RouteEntry_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishRouteEntryCollection_Dxe.inf | 55 +++ .../RouteEntryCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishRouteSetEntry_V1_0_0_Dxe.inf | 55 +++ .../v1_0_0/RouteSetEntry_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishRouteSetEntry_V1_0_1_Dxe.inf | 55 +++ .../v1_0_1/RouteSetEntry_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishRouteSetEntryCollection_Dxe.inf | 55 +++ .../RouteSetEntryCollection_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishSecureBoot_V1_0_0_Dxe.inf | 55 +++ .../SecureBoot/v1_0_0/SecureBoot_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishSecureBoot_V1_0_1_Dxe.inf | 55 +++ .../SecureBoot/v1_0_1/SecureBoot_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishSecureBoot_V1_0_2_Dxe.inf | 55 +++ .../SecureBoot/v1_0_2/SecureBoot_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishSecureBoot_V1_0_3_Dxe.inf | 55 +++ .../SecureBoot/v1_0_3/SecureBoot_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishSecureBoot_V1_0_4_Dxe.inf | 55 +++ .../SecureBoot/v1_0_4/SecureBoot_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishSecureBoot_V1_0_5_Dxe.inf | 55 +++ .../SecureBoot/v1_0_5/SecureBoot_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_0_6/RedfishSecureBoot_V1_0_6_Dxe.inf | 55 +++ .../SecureBoot/v1_0_6/SecureBoot_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../v1_0_7/RedfishSecureBoot_V1_0_7_Dxe.inf | 55 +++ .../SecureBoot/v1_0_7/SecureBoot_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishSecureBoot_V1_1_0_Dxe.inf | 55 +++ .../SecureBoot/v1_1_0/SecureBoot_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishSecureBootDatabase_V1_0_0_Dxe.inf | 55 +++ .../v1_0_0/SecureBootDatabase_V1_0_0_Dxe.c | 427 ++++++++++++++++++ ...edfishSecureBootDatabaseCollection_Dxe.inf | 55 +++ .../SecureBootDatabaseCollection_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishSensor_V1_0_0_Dxe.inf | 55 +++ .../Sensor/v1_0_0/Sensor_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishSensor_V1_0_1_Dxe.inf | 55 +++ .../Sensor/v1_0_1/Sensor_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishSensor_V1_0_2_Dxe.inf | 55 +++ .../Sensor/v1_0_2/Sensor_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishSensor_V1_0_3_Dxe.inf | 55 +++ .../Sensor/v1_0_3/Sensor_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishSensor_V1_0_4_Dxe.inf | 55 +++ .../Sensor/v1_0_4/Sensor_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishSensor_V1_0_5_Dxe.inf | 55 +++ .../Sensor/v1_0_5/Sensor_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_0_6/RedfishSensor_V1_0_6_Dxe.inf | 55 +++ .../Sensor/v1_0_6/Sensor_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishSensor_V1_1_0_Dxe.inf | 55 +++ .../Sensor/v1_1_0/Sensor_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishSensor_V1_1_1_Dxe.inf | 55 +++ .../Sensor/v1_1_1/Sensor_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishSensor_V1_1_2_Dxe.inf | 55 +++ .../Sensor/v1_1_2/Sensor_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishSensor_V1_2_0_Dxe.inf | 55 +++ .../Sensor/v1_2_0/Sensor_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishSensorCollection_Dxe.inf | 55 +++ .../SensorCollection/SensorCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishSerialInterface_V1_0_0_Dxe.inf | 55 +++ .../v1_0_0/SerialInterface_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishSerialInterface_V1_0_10_Dxe.inf | 55 +++ .../v1_0_10/SerialInterface_V1_0_10_Dxe.c | 427 ++++++++++++++++++ .../RedfishSerialInterface_V1_0_2_Dxe.inf | 55 +++ .../v1_0_2/SerialInterface_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishSerialInterface_V1_0_3_Dxe.inf | 55 +++ .../v1_0_3/SerialInterface_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishSerialInterface_V1_0_4_Dxe.inf | 55 +++ .../v1_0_4/SerialInterface_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishSerialInterface_V1_0_5_Dxe.inf | 55 +++ .../v1_0_5/SerialInterface_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishSerialInterface_V1_0_6_Dxe.inf | 55 +++ .../v1_0_6/SerialInterface_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishSerialInterface_V1_0_7_Dxe.inf | 55 +++ .../v1_0_7/SerialInterface_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishSerialInterface_V1_0_8_Dxe.inf | 55 +++ .../v1_0_8/SerialInterface_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishSerialInterface_V1_0_9_Dxe.inf | 55 +++ .../v1_0_9/SerialInterface_V1_0_9_Dxe.c | 427 ++++++++++++++++++ .../RedfishSerialInterface_V1_1_0_Dxe.inf | 55 +++ .../v1_1_0/SerialInterface_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishSerialInterface_V1_1_1_Dxe.inf | 55 +++ .../v1_1_1/SerialInterface_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishSerialInterface_V1_1_2_Dxe.inf | 55 +++ .../v1_1_2/SerialInterface_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishSerialInterface_V1_1_3_Dxe.inf | 55 +++ .../v1_1_3/SerialInterface_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishSerialInterface_V1_1_4_Dxe.inf | 55 +++ .../v1_1_4/SerialInterface_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishSerialInterface_V1_1_5_Dxe.inf | 55 +++ .../v1_1_5/SerialInterface_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishSerialInterface_V1_1_6_Dxe.inf | 55 +++ .../v1_1_6/SerialInterface_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishSerialInterface_V1_1_7_Dxe.inf | 55 +++ .../v1_1_7/SerialInterface_V1_1_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishSerialInterfaceCollection_Dxe.inf | 55 +++ .../SerialInterfaceCollection_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishServiceRoot_V1_0_0_Dxe.inf | 55 +++ .../v1_0_0/ServiceRoot_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishServiceRoot_V1_0_2_Dxe.inf | 55 +++ .../v1_0_2/ServiceRoot_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishServiceRoot_V1_0_3_Dxe.inf | 55 +++ .../v1_0_3/ServiceRoot_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishServiceRoot_V1_0_4_Dxe.inf | 55 +++ .../v1_0_4/ServiceRoot_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishServiceRoot_V1_0_5_Dxe.inf | 55 +++ .../v1_0_5/ServiceRoot_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_0_6/RedfishServiceRoot_V1_0_6_Dxe.inf | 55 +++ .../v1_0_6/ServiceRoot_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../v1_0_7/RedfishServiceRoot_V1_0_7_Dxe.inf | 55 +++ .../v1_0_7/ServiceRoot_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../v1_0_8/RedfishServiceRoot_V1_0_8_Dxe.inf | 55 +++ .../v1_0_8/ServiceRoot_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../v1_0_9/RedfishServiceRoot_V1_0_9_Dxe.inf | 55 +++ .../v1_0_9/ServiceRoot_V1_0_9_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishServiceRoot_V1_1_0_Dxe.inf | 55 +++ .../v1_1_0/ServiceRoot_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishServiceRoot_V1_1_1_Dxe.inf | 55 +++ .../v1_1_1/ServiceRoot_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishServiceRoot_V1_1_2_Dxe.inf | 55 +++ .../v1_1_2/ServiceRoot_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_3/RedfishServiceRoot_V1_1_3_Dxe.inf | 55 +++ .../v1_1_3/ServiceRoot_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../v1_1_4/RedfishServiceRoot_V1_1_4_Dxe.inf | 55 +++ .../v1_1_4/ServiceRoot_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../v1_1_5/RedfishServiceRoot_V1_1_5_Dxe.inf | 55 +++ .../v1_1_5/ServiceRoot_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../v1_1_6/RedfishServiceRoot_V1_1_6_Dxe.inf | 55 +++ .../v1_1_6/ServiceRoot_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishServiceRoot_V1_2_0_Dxe.inf | 55 +++ .../v1_2_0/ServiceRoot_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_1/RedfishServiceRoot_V1_2_1_Dxe.inf | 55 +++ .../v1_2_1/ServiceRoot_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../v1_2_2/RedfishServiceRoot_V1_2_2_Dxe.inf | 55 +++ .../v1_2_2/ServiceRoot_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../v1_2_3/RedfishServiceRoot_V1_2_3_Dxe.inf | 55 +++ .../v1_2_3/ServiceRoot_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../v1_2_4/RedfishServiceRoot_V1_2_4_Dxe.inf | 55 +++ .../v1_2_4/ServiceRoot_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../v1_3_0/RedfishServiceRoot_V1_3_0_Dxe.inf | 55 +++ .../v1_3_0/ServiceRoot_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../v1_3_1/RedfishServiceRoot_V1_3_1_Dxe.inf | 55 +++ .../v1_3_1/ServiceRoot_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../v1_3_2/RedfishServiceRoot_V1_3_2_Dxe.inf | 55 +++ .../v1_3_2/ServiceRoot_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../v1_3_3/RedfishServiceRoot_V1_3_3_Dxe.inf | 55 +++ .../v1_3_3/ServiceRoot_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../v1_3_4/RedfishServiceRoot_V1_3_4_Dxe.inf | 55 +++ .../v1_3_4/ServiceRoot_V1_3_4_Dxe.c | 427 ++++++++++++++++++ .../v1_3_5/RedfishServiceRoot_V1_3_5_Dxe.inf | 55 +++ .../v1_3_5/ServiceRoot_V1_3_5_Dxe.c | 427 ++++++++++++++++++ .../v1_4_0/RedfishServiceRoot_V1_4_0_Dxe.inf | 55 +++ .../v1_4_0/ServiceRoot_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../v1_4_1/RedfishServiceRoot_V1_4_1_Dxe.inf | 55 +++ .../v1_4_1/ServiceRoot_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../v1_4_2/RedfishServiceRoot_V1_4_2_Dxe.inf | 55 +++ .../v1_4_2/ServiceRoot_V1_4_2_Dxe.c | 427 ++++++++++++++++++ .../v1_4_3/RedfishServiceRoot_V1_4_3_Dxe.inf | 55 +++ .../v1_4_3/ServiceRoot_V1_4_3_Dxe.c | 427 ++++++++++++++++++ .../v1_5_0/RedfishServiceRoot_V1_5_0_Dxe.inf | 55 +++ .../v1_5_0/ServiceRoot_V1_5_0_Dxe.c | 427 ++++++++++++++++++ .../v1_5_1/RedfishServiceRoot_V1_5_1_Dxe.inf | 55 +++ .../v1_5_1/ServiceRoot_V1_5_1_Dxe.c | 427 ++++++++++++++++++ .../v1_5_2/RedfishServiceRoot_V1_5_2_Dxe.inf | 55 +++ .../v1_5_2/ServiceRoot_V1_5_2_Dxe.c | 427 ++++++++++++++++++ .../v1_6_0/RedfishServiceRoot_V1_6_0_Dxe.inf | 55 +++ .../v1_6_0/ServiceRoot_V1_6_0_Dxe.c | 427 ++++++++++++++++++ .../v1_7_0/RedfishServiceRoot_V1_7_0_Dxe.inf | 55 +++ .../v1_7_0/ServiceRoot_V1_7_0_Dxe.c | 427 ++++++++++++++++++ .../v1_8_0/RedfishServiceRoot_V1_8_0_Dxe.inf | 55 +++ .../v1_8_0/ServiceRoot_V1_8_0_Dxe.c | 427 ++++++++++++++++++ .../v1_9_0/RedfishServiceRoot_V1_9_0_Dxe.inf | 55 +++ .../v1_9_0/ServiceRoot_V1_9_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishSession_V1_0_0_Dxe.inf | 55 +++ .../Session/v1_0_0/Session_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishSession_V1_0_2_Dxe.inf | 55 +++ .../Session/v1_0_2/Session_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishSession_V1_0_3_Dxe.inf | 55 +++ .../Session/v1_0_3/Session_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishSession_V1_0_4_Dxe.inf | 55 +++ .../Session/v1_0_4/Session_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishSession_V1_0_5_Dxe.inf | 55 +++ .../Session/v1_0_5/Session_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_0_6/RedfishSession_V1_0_6_Dxe.inf | 55 +++ .../Session/v1_0_6/Session_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishSession_V1_1_0_Dxe.inf | 55 +++ .../Session/v1_1_0/Session_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishSession_V1_1_1_Dxe.inf | 55 +++ .../Session/v1_1_1/Session_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishSession_V1_1_2_Dxe.inf | 55 +++ .../Session/v1_1_2/Session_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_3/RedfishSession_V1_1_3_Dxe.inf | 55 +++ .../Session/v1_1_3/Session_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishSession_V1_2_0_Dxe.inf | 55 +++ .../Session/v1_2_0/Session_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_1/RedfishSession_V1_2_1_Dxe.inf | 55 +++ .../Session/v1_2_1/Session_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../v1_3_0/RedfishSession_V1_3_0_Dxe.inf | 55 +++ .../Session/v1_3_0/Session_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishSessionCollection_Dxe.inf | 55 +++ .../SessionCollection/SessionCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishSessionService_V1_0_0_Dxe.inf | 55 +++ .../v1_0_0/SessionService_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishSessionService_V1_0_2_Dxe.inf | 55 +++ .../v1_0_2/SessionService_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishSessionService_V1_0_3_Dxe.inf | 55 +++ .../v1_0_3/SessionService_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishSessionService_V1_0_4_Dxe.inf | 55 +++ .../v1_0_4/SessionService_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishSessionService_V1_0_5_Dxe.inf | 55 +++ .../v1_0_5/SessionService_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishSessionService_V1_0_6_Dxe.inf | 55 +++ .../v1_0_6/SessionService_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishSessionService_V1_0_7_Dxe.inf | 55 +++ .../v1_0_7/SessionService_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishSessionService_V1_0_8_Dxe.inf | 55 +++ .../v1_0_8/SessionService_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishSessionService_V1_0_9_Dxe.inf | 55 +++ .../v1_0_9/SessionService_V1_0_9_Dxe.c | 427 ++++++++++++++++++ .../RedfishSessionService_V1_1_0_Dxe.inf | 55 +++ .../v1_1_0/SessionService_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishSessionService_V1_1_1_Dxe.inf | 55 +++ .../v1_1_1/SessionService_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishSessionService_V1_1_2_Dxe.inf | 55 +++ .../v1_1_2/SessionService_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishSessionService_V1_1_3_Dxe.inf | 55 +++ .../v1_1_3/SessionService_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishSessionService_V1_1_4_Dxe.inf | 55 +++ .../v1_1_4/SessionService_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishSessionService_V1_1_5_Dxe.inf | 55 +++ .../v1_1_5/SessionService_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishSessionService_V1_1_6_Dxe.inf | 55 +++ .../v1_1_6/SessionService_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishSessionService_V1_1_7_Dxe.inf | 55 +++ .../v1_1_7/SessionService_V1_1_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishSessionService_V1_1_8_Dxe.inf | 55 +++ .../v1_1_8/SessionService_V1_1_8_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishSignature_V1_0_0_Dxe.inf | 55 +++ .../Signature/v1_0_0/Signature_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishSignature_V1_0_1_Dxe.inf | 55 +++ .../Signature/v1_0_1/Signature_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishSignature_V1_0_2_Dxe.inf | 55 +++ .../Signature/v1_0_2/Signature_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishSignatureCollection_Dxe.inf | 55 +++ .../SignatureCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishSimpleStorage_V1_0_0_Dxe.inf | 55 +++ .../v1_0_0/SimpleStorage_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishSimpleStorage_V1_0_2_Dxe.inf | 55 +++ .../v1_0_2/SimpleStorage_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishSimpleStorage_V1_0_3_Dxe.inf | 55 +++ .../v1_0_3/SimpleStorage_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishSimpleStorage_V1_0_4_Dxe.inf | 55 +++ .../v1_0_4/SimpleStorage_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishSimpleStorage_V1_0_5_Dxe.inf | 55 +++ .../v1_0_5/SimpleStorage_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishSimpleStorage_V1_0_6_Dxe.inf | 55 +++ .../v1_0_6/SimpleStorage_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishSimpleStorage_V1_0_7_Dxe.inf | 55 +++ .../v1_0_7/SimpleStorage_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishSimpleStorage_V1_0_8_Dxe.inf | 55 +++ .../v1_0_8/SimpleStorage_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishSimpleStorage_V1_1_0_Dxe.inf | 55 +++ .../v1_1_0/SimpleStorage_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishSimpleStorage_V1_1_1_Dxe.inf | 55 +++ .../v1_1_1/SimpleStorage_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishSimpleStorage_V1_1_2_Dxe.inf | 55 +++ .../v1_1_2/SimpleStorage_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishSimpleStorage_V1_1_3_Dxe.inf | 55 +++ .../v1_1_3/SimpleStorage_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishSimpleStorage_V1_1_4_Dxe.inf | 55 +++ .../v1_1_4/SimpleStorage_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishSimpleStorage_V1_1_5_Dxe.inf | 55 +++ .../v1_1_5/SimpleStorage_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishSimpleStorage_V1_1_6_Dxe.inf | 55 +++ .../v1_1_6/SimpleStorage_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishSimpleStorage_V1_2_0_Dxe.inf | 55 +++ .../v1_2_0/SimpleStorage_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishSimpleStorage_V1_2_1_Dxe.inf | 55 +++ .../v1_2_1/SimpleStorage_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishSimpleStorage_V1_2_2_Dxe.inf | 55 +++ .../v1_2_2/SimpleStorage_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishSimpleStorage_V1_2_3_Dxe.inf | 55 +++ .../v1_2_3/SimpleStorage_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishSimpleStorage_V1_2_4_Dxe.inf | 55 +++ .../v1_2_4/SimpleStorage_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishSimpleStorage_V1_3_0_Dxe.inf | 55 +++ .../v1_3_0/SimpleStorage_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishSimpleStorage_V1_3_1_Dxe.inf | 55 +++ .../v1_3_1/SimpleStorage_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishSimpleStorageCollection_Dxe.inf | 55 +++ .../SimpleStorageCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishSoftwareInventory_V1_0_0_Dxe.inf | 55 +++ .../v1_0_0/SoftwareInventory_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishSoftwareInventory_V1_0_1_Dxe.inf | 55 +++ .../v1_0_1/SoftwareInventory_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishSoftwareInventory_V1_0_2_Dxe.inf | 55 +++ .../v1_0_2/SoftwareInventory_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishSoftwareInventory_V1_0_3_Dxe.inf | 55 +++ .../v1_0_3/SoftwareInventory_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishSoftwareInventory_V1_0_4_Dxe.inf | 55 +++ .../v1_0_4/SoftwareInventory_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishSoftwareInventory_V1_0_5_Dxe.inf | 55 +++ .../v1_0_5/SoftwareInventory_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishSoftwareInventory_V1_1_0_Dxe.inf | 55 +++ .../v1_1_0/SoftwareInventory_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishSoftwareInventory_V1_1_1_Dxe.inf | 55 +++ .../v1_1_1/SoftwareInventory_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishSoftwareInventory_V1_1_2_Dxe.inf | 55 +++ .../v1_1_2/SoftwareInventory_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishSoftwareInventory_V1_1_3_Dxe.inf | 55 +++ .../v1_1_3/SoftwareInventory_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishSoftwareInventory_V1_1_4_Dxe.inf | 55 +++ .../v1_1_4/SoftwareInventory_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishSoftwareInventory_V1_2_0_Dxe.inf | 55 +++ .../v1_2_0/SoftwareInventory_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishSoftwareInventory_V1_2_1_Dxe.inf | 55 +++ .../v1_2_1/SoftwareInventory_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishSoftwareInventory_V1_2_2_Dxe.inf | 55 +++ .../v1_2_2/SoftwareInventory_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishSoftwareInventory_V1_2_3_Dxe.inf | 55 +++ .../v1_2_3/SoftwareInventory_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishSoftwareInventory_V1_3_0_Dxe.inf | 55 +++ .../v1_3_0/SoftwareInventory_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishSoftwareInventory_V1_4_0_Dxe.inf | 55 +++ .../v1_4_0/SoftwareInventory_V1_4_0_Dxe.c | 427 ++++++++++++++++++ ...RedfishSoftwareInventoryCollection_Dxe.inf | 55 +++ .../SoftwareInventoryCollection_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishStorage_V1_0_1_Dxe.inf | 55 +++ .../Storage/v1_0_1/Storage_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_10/RedfishStorage_V1_0_10_Dxe.inf | 55 +++ .../Storage/v1_0_10/Storage_V1_0_10_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishStorage_V1_0_2_Dxe.inf | 55 +++ .../Storage/v1_0_2/Storage_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishStorage_V1_0_3_Dxe.inf | 55 +++ .../Storage/v1_0_3/Storage_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishStorage_V1_0_4_Dxe.inf | 55 +++ .../Storage/v1_0_4/Storage_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishStorage_V1_0_5_Dxe.inf | 55 +++ .../Storage/v1_0_5/Storage_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_0_6/RedfishStorage_V1_0_6_Dxe.inf | 55 +++ .../Storage/v1_0_6/Storage_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../v1_0_7/RedfishStorage_V1_0_7_Dxe.inf | 55 +++ .../Storage/v1_0_7/Storage_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../v1_0_8/RedfishStorage_V1_0_8_Dxe.inf | 55 +++ .../Storage/v1_0_8/Storage_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../v1_0_9/RedfishStorage_V1_0_9_Dxe.inf | 55 +++ .../Storage/v1_0_9/Storage_V1_0_9_Dxe.c | 427 ++++++++++++++++++ .../v1_10_0/RedfishStorage_V1_10_0_Dxe.inf | 55 +++ .../Storage/v1_10_0/Storage_V1_10_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishStorage_V1_1_1_Dxe.inf | 55 +++ .../Storage/v1_1_1/Storage_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishStorage_V1_1_2_Dxe.inf | 55 +++ .../Storage/v1_1_2/Storage_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_3/RedfishStorage_V1_1_3_Dxe.inf | 55 +++ .../Storage/v1_1_3/Storage_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../v1_1_4/RedfishStorage_V1_1_4_Dxe.inf | 55 +++ .../Storage/v1_1_4/Storage_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../v1_1_5/RedfishStorage_V1_1_5_Dxe.inf | 55 +++ .../Storage/v1_1_5/Storage_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../v1_1_6/RedfishStorage_V1_1_6_Dxe.inf | 55 +++ .../Storage/v1_1_6/Storage_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../v1_1_7/RedfishStorage_V1_1_7_Dxe.inf | 55 +++ .../Storage/v1_1_7/Storage_V1_1_7_Dxe.c | 427 ++++++++++++++++++ .../v1_1_8/RedfishStorage_V1_1_8_Dxe.inf | 55 +++ .../Storage/v1_1_8/Storage_V1_1_8_Dxe.c | 427 ++++++++++++++++++ .../v1_1_9/RedfishStorage_V1_1_9_Dxe.inf | 55 +++ .../Storage/v1_1_9/Storage_V1_1_9_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishStorage_V1_2_0_Dxe.inf | 55 +++ .../Storage/v1_2_0/Storage_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_1/RedfishStorage_V1_2_1_Dxe.inf | 55 +++ .../Storage/v1_2_1/Storage_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../v1_2_2/RedfishStorage_V1_2_2_Dxe.inf | 55 +++ .../Storage/v1_2_2/Storage_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../v1_2_3/RedfishStorage_V1_2_3_Dxe.inf | 55 +++ .../Storage/v1_2_3/Storage_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../v1_2_4/RedfishStorage_V1_2_4_Dxe.inf | 55 +++ .../Storage/v1_2_4/Storage_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../v1_2_5/RedfishStorage_V1_2_5_Dxe.inf | 55 +++ .../Storage/v1_2_5/Storage_V1_2_5_Dxe.c | 427 ++++++++++++++++++ .../v1_2_6/RedfishStorage_V1_2_6_Dxe.inf | 55 +++ .../Storage/v1_2_6/Storage_V1_2_6_Dxe.c | 427 ++++++++++++++++++ .../v1_2_7/RedfishStorage_V1_2_7_Dxe.inf | 55 +++ .../Storage/v1_2_7/Storage_V1_2_7_Dxe.c | 427 ++++++++++++++++++ .../v1_3_0/RedfishStorage_V1_3_0_Dxe.inf | 55 +++ .../Storage/v1_3_0/Storage_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../v1_3_1/RedfishStorage_V1_3_1_Dxe.inf | 55 +++ .../Storage/v1_3_1/Storage_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../v1_3_2/RedfishStorage_V1_3_2_Dxe.inf | 55 +++ .../Storage/v1_3_2/Storage_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../v1_3_3/RedfishStorage_V1_3_3_Dxe.inf | 55 +++ .../Storage/v1_3_3/Storage_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../v1_3_4/RedfishStorage_V1_3_4_Dxe.inf | 55 +++ .../Storage/v1_3_4/Storage_V1_3_4_Dxe.c | 427 ++++++++++++++++++ .../v1_3_5/RedfishStorage_V1_3_5_Dxe.inf | 55 +++ .../Storage/v1_3_5/Storage_V1_3_5_Dxe.c | 427 ++++++++++++++++++ .../v1_3_6/RedfishStorage_V1_3_6_Dxe.inf | 55 +++ .../Storage/v1_3_6/Storage_V1_3_6_Dxe.c | 427 ++++++++++++++++++ .../v1_3_7/RedfishStorage_V1_3_7_Dxe.inf | 55 +++ .../Storage/v1_3_7/Storage_V1_3_7_Dxe.c | 427 ++++++++++++++++++ .../v1_4_0/RedfishStorage_V1_4_0_Dxe.inf | 55 +++ .../Storage/v1_4_0/Storage_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../v1_4_1/RedfishStorage_V1_4_1_Dxe.inf | 55 +++ .../Storage/v1_4_1/Storage_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../v1_4_2/RedfishStorage_V1_4_2_Dxe.inf | 55 +++ .../Storage/v1_4_2/Storage_V1_4_2_Dxe.c | 427 ++++++++++++++++++ .../v1_4_3/RedfishStorage_V1_4_3_Dxe.inf | 55 +++ .../Storage/v1_4_3/Storage_V1_4_3_Dxe.c | 427 ++++++++++++++++++ .../v1_4_4/RedfishStorage_V1_4_4_Dxe.inf | 55 +++ .../Storage/v1_4_4/Storage_V1_4_4_Dxe.c | 427 ++++++++++++++++++ .../v1_4_5/RedfishStorage_V1_4_5_Dxe.inf | 55 +++ .../Storage/v1_4_5/Storage_V1_4_5_Dxe.c | 427 ++++++++++++++++++ .../v1_4_6/RedfishStorage_V1_4_6_Dxe.inf | 55 +++ .../Storage/v1_4_6/Storage_V1_4_6_Dxe.c | 427 ++++++++++++++++++ .../v1_5_0/RedfishStorage_V1_5_0_Dxe.inf | 55 +++ .../Storage/v1_5_0/Storage_V1_5_0_Dxe.c | 427 ++++++++++++++++++ .../v1_5_1/RedfishStorage_V1_5_1_Dxe.inf | 55 +++ .../Storage/v1_5_1/Storage_V1_5_1_Dxe.c | 427 ++++++++++++++++++ .../v1_5_2/RedfishStorage_V1_5_2_Dxe.inf | 55 +++ .../Storage/v1_5_2/Storage_V1_5_2_Dxe.c | 427 ++++++++++++++++++ .../v1_5_3/RedfishStorage_V1_5_3_Dxe.inf | 55 +++ .../Storage/v1_5_3/Storage_V1_5_3_Dxe.c | 427 ++++++++++++++++++ .../v1_5_4/RedfishStorage_V1_5_4_Dxe.inf | 55 +++ .../Storage/v1_5_4/Storage_V1_5_4_Dxe.c | 427 ++++++++++++++++++ .../v1_5_5/RedfishStorage_V1_5_5_Dxe.inf | 55 +++ .../Storage/v1_5_5/Storage_V1_5_5_Dxe.c | 427 ++++++++++++++++++ .../v1_6_0/RedfishStorage_V1_6_0_Dxe.inf | 55 +++ .../Storage/v1_6_0/Storage_V1_6_0_Dxe.c | 427 ++++++++++++++++++ .../v1_6_1/RedfishStorage_V1_6_1_Dxe.inf | 55 +++ .../Storage/v1_6_1/Storage_V1_6_1_Dxe.c | 427 ++++++++++++++++++ .../v1_6_2/RedfishStorage_V1_6_2_Dxe.inf | 55 +++ .../Storage/v1_6_2/Storage_V1_6_2_Dxe.c | 427 ++++++++++++++++++ .../v1_6_3/RedfishStorage_V1_6_3_Dxe.inf | 55 +++ .../Storage/v1_6_3/Storage_V1_6_3_Dxe.c | 427 ++++++++++++++++++ .../v1_6_4/RedfishStorage_V1_6_4_Dxe.inf | 55 +++ .../Storage/v1_6_4/Storage_V1_6_4_Dxe.c | 427 ++++++++++++++++++ .../v1_7_0/RedfishStorage_V1_7_0_Dxe.inf | 55 +++ .../Storage/v1_7_0/Storage_V1_7_0_Dxe.c | 427 ++++++++++++++++++ .../v1_7_1/RedfishStorage_V1_7_1_Dxe.inf | 55 +++ .../Storage/v1_7_1/Storage_V1_7_1_Dxe.c | 427 ++++++++++++++++++ .../v1_7_2/RedfishStorage_V1_7_2_Dxe.inf | 55 +++ .../Storage/v1_7_2/Storage_V1_7_2_Dxe.c | 427 ++++++++++++++++++ .../v1_7_3/RedfishStorage_V1_7_3_Dxe.inf | 55 +++ .../Storage/v1_7_3/Storage_V1_7_3_Dxe.c | 427 ++++++++++++++++++ .../v1_8_0/RedfishStorage_V1_8_0_Dxe.inf | 55 +++ .../Storage/v1_8_0/Storage_V1_8_0_Dxe.c | 427 ++++++++++++++++++ .../v1_8_1/RedfishStorage_V1_8_1_Dxe.inf | 55 +++ .../Storage/v1_8_1/Storage_V1_8_1_Dxe.c | 427 ++++++++++++++++++ .../v1_8_2/RedfishStorage_V1_8_2_Dxe.inf | 55 +++ .../Storage/v1_8_2/Storage_V1_8_2_Dxe.c | 427 ++++++++++++++++++ .../v1_9_0/RedfishStorage_V1_9_0_Dxe.inf | 55 +++ .../Storage/v1_9_0/Storage_V1_9_0_Dxe.c | 427 ++++++++++++++++++ .../v1_9_1/RedfishStorage_V1_9_1_Dxe.inf | 55 +++ .../Storage/v1_9_1/Storage_V1_9_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishStorageCollection_Dxe.inf | 55 +++ .../StorageCollection/StorageCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishStorageController_V1_0_0_Dxe.inf | 55 +++ .../v1_0_0/StorageController_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishStorageController_V1_0_1_Dxe.inf | 55 +++ .../v1_0_1/StorageController_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishStorageController_V1_1_0_Dxe.inf | 55 +++ .../v1_1_0/StorageController_V1_1_0_Dxe.c | 427 ++++++++++++++++++ ...RedfishStorageControllerCollection_Dxe.inf | 55 +++ .../StorageControllerCollection_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishSwitch_V1_0_0_Dxe.inf | 55 +++ .../Switch/v1_0_0/Switch_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishSwitch_V1_0_1_Dxe.inf | 55 +++ .../Switch/v1_0_1/Switch_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishSwitch_V1_0_2_Dxe.inf | 55 +++ .../Switch/v1_0_2/Switch_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishSwitch_V1_0_3_Dxe.inf | 55 +++ .../Switch/v1_0_3/Switch_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishSwitch_V1_0_4_Dxe.inf | 55 +++ .../Switch/v1_0_4/Switch_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishSwitch_V1_0_5_Dxe.inf | 55 +++ .../Switch/v1_0_5/Switch_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_0_6/RedfishSwitch_V1_0_6_Dxe.inf | 55 +++ .../Switch/v1_0_6/Switch_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../v1_0_7/RedfishSwitch_V1_0_7_Dxe.inf | 55 +++ .../Switch/v1_0_7/Switch_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../v1_0_8/RedfishSwitch_V1_0_8_Dxe.inf | 55 +++ .../Switch/v1_0_8/Switch_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishSwitch_V1_1_0_Dxe.inf | 55 +++ .../Switch/v1_1_0/Switch_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishSwitch_V1_1_1_Dxe.inf | 55 +++ .../Switch/v1_1_1/Switch_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishSwitch_V1_1_2_Dxe.inf | 55 +++ .../Switch/v1_1_2/Switch_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_3/RedfishSwitch_V1_1_3_Dxe.inf | 55 +++ .../Switch/v1_1_3/Switch_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../v1_1_4/RedfishSwitch_V1_1_4_Dxe.inf | 55 +++ .../Switch/v1_1_4/Switch_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../v1_1_5/RedfishSwitch_V1_1_5_Dxe.inf | 55 +++ .../Switch/v1_1_5/Switch_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishSwitch_V1_2_0_Dxe.inf | 55 +++ .../Switch/v1_2_0/Switch_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_1/RedfishSwitch_V1_2_1_Dxe.inf | 55 +++ .../Switch/v1_2_1/Switch_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../v1_2_2/RedfishSwitch_V1_2_2_Dxe.inf | 55 +++ .../Switch/v1_2_2/Switch_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../v1_3_0/RedfishSwitch_V1_3_0_Dxe.inf | 55 +++ .../Switch/v1_3_0/Switch_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../v1_3_1/RedfishSwitch_V1_3_1_Dxe.inf | 55 +++ .../Switch/v1_3_1/Switch_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../v1_3_2/RedfishSwitch_V1_3_2_Dxe.inf | 55 +++ .../Switch/v1_3_2/Switch_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../v1_4_0/RedfishSwitch_V1_4_0_Dxe.inf | 55 +++ .../Switch/v1_4_0/Switch_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../v1_4_1/RedfishSwitch_V1_4_1_Dxe.inf | 55 +++ .../Switch/v1_4_1/Switch_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../v1_5_0/RedfishSwitch_V1_5_0_Dxe.inf | 55 +++ .../Switch/v1_5_0/Switch_V1_5_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishSwitchCollection_Dxe.inf | 55 +++ .../SwitchCollection/SwitchCollection_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_0_0/RedfishTask_V1_0_0_Dxe.inf | 55 +++ .../Converter/Task/v1_0_0/Task_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_0_2/RedfishTask_V1_0_2_Dxe.inf | 55 +++ .../Converter/Task/v1_0_2/Task_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_0_3/RedfishTask_V1_0_3_Dxe.inf | 55 +++ .../Converter/Task/v1_0_3/Task_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_0_4/RedfishTask_V1_0_4_Dxe.inf | 55 +++ .../Converter/Task/v1_0_4/Task_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_0_5/RedfishTask_V1_0_5_Dxe.inf | 55 +++ .../Converter/Task/v1_0_5/Task_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_0_6/RedfishTask_V1_0_6_Dxe.inf | 55 +++ .../Converter/Task/v1_0_6/Task_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_0_7/RedfishTask_V1_0_7_Dxe.inf | 55 +++ .../Converter/Task/v1_0_7/Task_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_0_8/RedfishTask_V1_0_8_Dxe.inf | 55 +++ .../Converter/Task/v1_0_8/Task_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_0_9/RedfishTask_V1_0_9_Dxe.inf | 55 +++ .../Converter/Task/v1_0_9/Task_V1_0_9_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_1_0/RedfishTask_V1_1_0_Dxe.inf | 55 +++ .../Converter/Task/v1_1_0/Task_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_1_1/RedfishTask_V1_1_1_Dxe.inf | 55 +++ .../Converter/Task/v1_1_1/Task_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_1_2/RedfishTask_V1_1_2_Dxe.inf | 55 +++ .../Converter/Task/v1_1_2/Task_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_1_3/RedfishTask_V1_1_3_Dxe.inf | 55 +++ .../Converter/Task/v1_1_3/Task_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_1_4/RedfishTask_V1_1_4_Dxe.inf | 55 +++ .../Converter/Task/v1_1_4/Task_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_1_5/RedfishTask_V1_1_5_Dxe.inf | 55 +++ .../Converter/Task/v1_1_5/Task_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_1_6/RedfishTask_V1_1_6_Dxe.inf | 55 +++ .../Converter/Task/v1_1_6/Task_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_2_0/RedfishTask_V1_2_0_Dxe.inf | 55 +++ .../Converter/Task/v1_2_0/Task_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_2_1/RedfishTask_V1_2_1_Dxe.inf | 55 +++ .../Converter/Task/v1_2_1/Task_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_2_2/RedfishTask_V1_2_2_Dxe.inf | 55 +++ .../Converter/Task/v1_2_2/Task_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_2_3/RedfishTask_V1_2_3_Dxe.inf | 55 +++ .../Converter/Task/v1_2_3/Task_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_2_4/RedfishTask_V1_2_4_Dxe.inf | 55 +++ .../Converter/Task/v1_2_4/Task_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_2_5/RedfishTask_V1_2_5_Dxe.inf | 55 +++ .../Converter/Task/v1_2_5/Task_V1_2_5_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_3_0/RedfishTask_V1_3_0_Dxe.inf | 55 +++ .../Converter/Task/v1_3_0/Task_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_3_1/RedfishTask_V1_3_1_Dxe.inf | 55 +++ .../Converter/Task/v1_3_1/Task_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_3_2/RedfishTask_V1_3_2_Dxe.inf | 55 +++ .../Converter/Task/v1_3_2/Task_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_3_3/RedfishTask_V1_3_3_Dxe.inf | 55 +++ .../Converter/Task/v1_3_3/Task_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_3_4/RedfishTask_V1_3_4_Dxe.inf | 55 +++ .../Converter/Task/v1_3_4/Task_V1_3_4_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_3_5/RedfishTask_V1_3_5_Dxe.inf | 55 +++ .../Converter/Task/v1_3_5/Task_V1_3_5_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_4_0/RedfishTask_V1_4_0_Dxe.inf | 55 +++ .../Converter/Task/v1_4_0/Task_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_4_1/RedfishTask_V1_4_1_Dxe.inf | 55 +++ .../Converter/Task/v1_4_1/Task_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_4_2/RedfishTask_V1_4_2_Dxe.inf | 55 +++ .../Converter/Task/v1_4_2/Task_V1_4_2_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_4_3/RedfishTask_V1_4_3_Dxe.inf | 55 +++ .../Converter/Task/v1_4_3/Task_V1_4_3_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_4_4/RedfishTask_V1_4_4_Dxe.inf | 55 +++ .../Converter/Task/v1_4_4/Task_V1_4_4_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_5_0/RedfishTask_V1_5_0_Dxe.inf | 55 +++ .../Converter/Task/v1_5_0/Task_V1_5_0_Dxe.c | 427 ++++++++++++++++++ .../Task/v1_5_1/RedfishTask_V1_5_1_Dxe.inf | 55 +++ .../Converter/Task/v1_5_1/Task_V1_5_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishTaskCollection_Dxe.inf | 55 +++ .../TaskCollection/TaskCollection_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishTaskService_V1_0_0_Dxe.inf | 55 +++ .../v1_0_0/TaskService_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishTaskService_V1_0_2_Dxe.inf | 55 +++ .../v1_0_2/TaskService_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishTaskService_V1_0_3_Dxe.inf | 55 +++ .../v1_0_3/TaskService_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishTaskService_V1_0_4_Dxe.inf | 55 +++ .../v1_0_4/TaskService_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishTaskService_V1_0_5_Dxe.inf | 55 +++ .../v1_0_5/TaskService_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_0_6/RedfishTaskService_V1_0_6_Dxe.inf | 55 +++ .../v1_0_6/TaskService_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../v1_0_7/RedfishTaskService_V1_0_7_Dxe.inf | 55 +++ .../v1_0_7/TaskService_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../v1_0_8/RedfishTaskService_V1_0_8_Dxe.inf | 55 +++ .../v1_0_8/TaskService_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../v1_0_9/RedfishTaskService_V1_0_9_Dxe.inf | 55 +++ .../v1_0_9/TaskService_V1_0_9_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishTaskService_V1_1_0_Dxe.inf | 55 +++ .../v1_1_0/TaskService_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishTaskService_V1_1_1_Dxe.inf | 55 +++ .../v1_1_1/TaskService_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishTaskService_V1_1_2_Dxe.inf | 55 +++ .../v1_1_2/TaskService_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_3/RedfishTaskService_V1_1_3_Dxe.inf | 55 +++ .../v1_1_3/TaskService_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../v1_1_4/RedfishTaskService_V1_1_4_Dxe.inf | 55 +++ .../v1_1_4/TaskService_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../v1_1_5/RedfishTaskService_V1_1_5_Dxe.inf | 55 +++ .../v1_1_5/TaskService_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../v1_1_6/RedfishTaskService_V1_1_6_Dxe.inf | 55 +++ .../v1_1_6/TaskService_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishTelemetryService_V1_0_0_Dxe.inf | 55 +++ .../v1_0_0/TelemetryService_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishTelemetryService_V1_0_1_Dxe.inf | 55 +++ .../v1_0_1/TelemetryService_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishTelemetryService_V1_0_2_Dxe.inf | 55 +++ .../v1_0_2/TelemetryService_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishTelemetryService_V1_0_3_Dxe.inf | 55 +++ .../v1_0_3/TelemetryService_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishTelemetryService_V1_0_4_Dxe.inf | 55 +++ .../v1_0_4/TelemetryService_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishTelemetryService_V1_1_0_Dxe.inf | 55 +++ .../v1_1_0/TelemetryService_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishTelemetryService_V1_1_1_Dxe.inf | 55 +++ .../v1_1_1/TelemetryService_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishTelemetryService_V1_1_2_Dxe.inf | 55 +++ .../v1_1_2/TelemetryService_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishTelemetryService_V1_1_3_Dxe.inf | 55 +++ .../v1_1_3/TelemetryService_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishTelemetryService_V1_1_4_Dxe.inf | 55 +++ .../v1_1_4/TelemetryService_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishTelemetryService_V1_2_0_Dxe.inf | 55 +++ .../v1_2_0/TelemetryService_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishTelemetryService_V1_2_1_Dxe.inf | 55 +++ .../v1_2_1/TelemetryService_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishTelemetryService_V1_2_2_Dxe.inf | 55 +++ .../v1_2_2/TelemetryService_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishTelemetryService_V1_3_0_Dxe.inf | 55 +++ .../v1_3_0/TelemetryService_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishThermal_V1_0_0_Dxe.inf | 55 +++ .../Thermal/v1_0_0/Thermal_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishThermal_V1_0_1_Dxe.inf | 55 +++ .../Thermal/v1_0_1/Thermal_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_10/RedfishThermal_V1_0_10_Dxe.inf | 55 +++ .../Thermal/v1_0_10/Thermal_V1_0_10_Dxe.c | 427 ++++++++++++++++++ .../v1_0_11/RedfishThermal_V1_0_11_Dxe.inf | 55 +++ .../Thermal/v1_0_11/Thermal_V1_0_11_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishThermal_V1_0_2_Dxe.inf | 55 +++ .../Thermal/v1_0_2/Thermal_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishThermal_V1_0_3_Dxe.inf | 55 +++ .../Thermal/v1_0_3/Thermal_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishThermal_V1_0_4_Dxe.inf | 55 +++ .../Thermal/v1_0_4/Thermal_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishThermal_V1_0_5_Dxe.inf | 55 +++ .../Thermal/v1_0_5/Thermal_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_0_6/RedfishThermal_V1_0_6_Dxe.inf | 55 +++ .../Thermal/v1_0_6/Thermal_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../v1_0_7/RedfishThermal_V1_0_7_Dxe.inf | 55 +++ .../Thermal/v1_0_7/Thermal_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../v1_0_8/RedfishThermal_V1_0_8_Dxe.inf | 55 +++ .../Thermal/v1_0_8/Thermal_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../v1_0_9/RedfishThermal_V1_0_9_Dxe.inf | 55 +++ .../Thermal/v1_0_9/Thermal_V1_0_9_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishThermal_V1_1_0_Dxe.inf | 55 +++ .../Thermal/v1_1_0/Thermal_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishThermal_V1_1_1_Dxe.inf | 55 +++ .../Thermal/v1_1_1/Thermal_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishThermal_V1_1_2_Dxe.inf | 55 +++ .../Thermal/v1_1_2/Thermal_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_3/RedfishThermal_V1_1_3_Dxe.inf | 55 +++ .../Thermal/v1_1_3/Thermal_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../v1_1_4/RedfishThermal_V1_1_4_Dxe.inf | 55 +++ .../Thermal/v1_1_4/Thermal_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../v1_1_5/RedfishThermal_V1_1_5_Dxe.inf | 55 +++ .../Thermal/v1_1_5/Thermal_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../v1_1_6/RedfishThermal_V1_1_6_Dxe.inf | 55 +++ .../Thermal/v1_1_6/Thermal_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../v1_1_7/RedfishThermal_V1_1_7_Dxe.inf | 55 +++ .../Thermal/v1_1_7/Thermal_V1_1_7_Dxe.c | 427 ++++++++++++++++++ .../v1_1_8/RedfishThermal_V1_1_8_Dxe.inf | 55 +++ .../Thermal/v1_1_8/Thermal_V1_1_8_Dxe.c | 427 ++++++++++++++++++ .../v1_1_9/RedfishThermal_V1_1_9_Dxe.inf | 55 +++ .../Thermal/v1_1_9/Thermal_V1_1_9_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishThermal_V1_2_0_Dxe.inf | 55 +++ .../Thermal/v1_2_0/Thermal_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_1/RedfishThermal_V1_2_1_Dxe.inf | 55 +++ .../Thermal/v1_2_1/Thermal_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../v1_2_2/RedfishThermal_V1_2_2_Dxe.inf | 55 +++ .../Thermal/v1_2_2/Thermal_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../v1_2_3/RedfishThermal_V1_2_3_Dxe.inf | 55 +++ .../Thermal/v1_2_3/Thermal_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../v1_2_4/RedfishThermal_V1_2_4_Dxe.inf | 55 +++ .../Thermal/v1_2_4/Thermal_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../v1_2_5/RedfishThermal_V1_2_5_Dxe.inf | 55 +++ .../Thermal/v1_2_5/Thermal_V1_2_5_Dxe.c | 427 ++++++++++++++++++ .../v1_2_6/RedfishThermal_V1_2_6_Dxe.inf | 55 +++ .../Thermal/v1_2_6/Thermal_V1_2_6_Dxe.c | 427 ++++++++++++++++++ .../v1_2_7/RedfishThermal_V1_2_7_Dxe.inf | 55 +++ .../Thermal/v1_2_7/Thermal_V1_2_7_Dxe.c | 427 ++++++++++++++++++ .../v1_2_8/RedfishThermal_V1_2_8_Dxe.inf | 55 +++ .../Thermal/v1_2_8/Thermal_V1_2_8_Dxe.c | 427 ++++++++++++++++++ .../v1_3_0/RedfishThermal_V1_3_0_Dxe.inf | 55 +++ .../Thermal/v1_3_0/Thermal_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../v1_3_1/RedfishThermal_V1_3_1_Dxe.inf | 55 +++ .../Thermal/v1_3_1/Thermal_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../v1_3_2/RedfishThermal_V1_3_2_Dxe.inf | 55 +++ .../Thermal/v1_3_2/Thermal_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../v1_3_3/RedfishThermal_V1_3_3_Dxe.inf | 55 +++ .../Thermal/v1_3_3/Thermal_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../v1_3_4/RedfishThermal_V1_3_4_Dxe.inf | 55 +++ .../Thermal/v1_3_4/Thermal_V1_3_4_Dxe.c | 427 ++++++++++++++++++ .../v1_3_5/RedfishThermal_V1_3_5_Dxe.inf | 55 +++ .../Thermal/v1_3_5/Thermal_V1_3_5_Dxe.c | 427 ++++++++++++++++++ .../v1_3_6/RedfishThermal_V1_3_6_Dxe.inf | 55 +++ .../Thermal/v1_3_6/Thermal_V1_3_6_Dxe.c | 427 ++++++++++++++++++ .../v1_3_7/RedfishThermal_V1_3_7_Dxe.inf | 55 +++ .../Thermal/v1_3_7/Thermal_V1_3_7_Dxe.c | 427 ++++++++++++++++++ .../v1_4_0/RedfishThermal_V1_4_0_Dxe.inf | 55 +++ .../Thermal/v1_4_0/Thermal_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../v1_4_1/RedfishThermal_V1_4_1_Dxe.inf | 55 +++ .../Thermal/v1_4_1/Thermal_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../v1_4_2/RedfishThermal_V1_4_2_Dxe.inf | 55 +++ .../Thermal/v1_4_2/Thermal_V1_4_2_Dxe.c | 427 ++++++++++++++++++ .../v1_4_3/RedfishThermal_V1_4_3_Dxe.inf | 55 +++ .../Thermal/v1_4_3/Thermal_V1_4_3_Dxe.c | 427 ++++++++++++++++++ .../v1_4_4/RedfishThermal_V1_4_4_Dxe.inf | 55 +++ .../Thermal/v1_4_4/Thermal_V1_4_4_Dxe.c | 427 ++++++++++++++++++ .../v1_4_5/RedfishThermal_V1_4_5_Dxe.inf | 55 +++ .../Thermal/v1_4_5/Thermal_V1_4_5_Dxe.c | 427 ++++++++++++++++++ .../v1_4_6/RedfishThermal_V1_4_6_Dxe.inf | 55 +++ .../Thermal/v1_4_6/Thermal_V1_4_6_Dxe.c | 427 ++++++++++++++++++ .../v1_5_0/RedfishThermal_V1_5_0_Dxe.inf | 55 +++ .../Thermal/v1_5_0/Thermal_V1_5_0_Dxe.c | 427 ++++++++++++++++++ .../v1_5_1/RedfishThermal_V1_5_1_Dxe.inf | 55 +++ .../Thermal/v1_5_1/Thermal_V1_5_1_Dxe.c | 427 ++++++++++++++++++ .../v1_5_2/RedfishThermal_V1_5_2_Dxe.inf | 55 +++ .../Thermal/v1_5_2/Thermal_V1_5_2_Dxe.c | 427 ++++++++++++++++++ .../v1_5_3/RedfishThermal_V1_5_3_Dxe.inf | 55 +++ .../Thermal/v1_5_3/Thermal_V1_5_3_Dxe.c | 427 ++++++++++++++++++ .../v1_5_4/RedfishThermal_V1_5_4_Dxe.inf | 55 +++ .../Thermal/v1_5_4/Thermal_V1_5_4_Dxe.c | 427 ++++++++++++++++++ .../v1_5_5/RedfishThermal_V1_5_5_Dxe.inf | 55 +++ .../Thermal/v1_5_5/Thermal_V1_5_5_Dxe.c | 427 ++++++++++++++++++ .../v1_6_0/RedfishThermal_V1_6_0_Dxe.inf | 55 +++ .../Thermal/v1_6_0/Thermal_V1_6_0_Dxe.c | 427 ++++++++++++++++++ .../v1_6_1/RedfishThermal_V1_6_1_Dxe.inf | 55 +++ .../Thermal/v1_6_1/Thermal_V1_6_1_Dxe.c | 427 ++++++++++++++++++ .../v1_6_2/RedfishThermal_V1_6_2_Dxe.inf | 55 +++ .../Thermal/v1_6_2/Thermal_V1_6_2_Dxe.c | 427 ++++++++++++++++++ .../v1_7_0/RedfishThermal_V1_7_0_Dxe.inf | 55 +++ .../Thermal/v1_7_0/Thermal_V1_7_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishThermalMetrics_V1_0_0_Dxe.inf | 55 +++ .../v1_0_0/ThermalMetrics_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishThermalSubsystem_V1_0_0_Dxe.inf | 55 +++ .../v1_0_0/ThermalSubsystem_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishTriggers_V1_0_0_Dxe.inf | 55 +++ .../Triggers/v1_0_0/Triggers_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishTriggers_V1_0_1_Dxe.inf | 55 +++ .../Triggers/v1_0_1/Triggers_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishTriggers_V1_0_2_Dxe.inf | 55 +++ .../Triggers/v1_0_2/Triggers_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishTriggers_V1_0_3_Dxe.inf | 55 +++ .../Triggers/v1_0_3/Triggers_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishTriggers_V1_0_4_Dxe.inf | 55 +++ .../Triggers/v1_0_4/Triggers_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishTriggers_V1_0_5_Dxe.inf | 55 +++ .../Triggers/v1_0_5/Triggers_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishTriggers_V1_1_0_Dxe.inf | 55 +++ .../Triggers/v1_1_0/Triggers_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishTriggers_V1_1_1_Dxe.inf | 55 +++ .../Triggers/v1_1_1/Triggers_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishTriggers_V1_1_2_Dxe.inf | 55 +++ .../Triggers/v1_1_2/Triggers_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_3/RedfishTriggers_V1_1_3_Dxe.inf | 55 +++ .../Triggers/v1_1_3/Triggers_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishTriggersCollection_Dxe.inf | 55 +++ .../TriggersCollection_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_0_0_Dxe.inf | 55 +++ .../v1_0_0/UpdateService_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_0_1_Dxe.inf | 55 +++ .../v1_0_1/UpdateService_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_0_10_Dxe.inf | 55 +++ .../v1_0_10/UpdateService_V1_0_10_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_0_2_Dxe.inf | 55 +++ .../v1_0_2/UpdateService_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_0_3_Dxe.inf | 55 +++ .../v1_0_3/UpdateService_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_0_4_Dxe.inf | 55 +++ .../v1_0_4/UpdateService_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_0_5_Dxe.inf | 55 +++ .../v1_0_5/UpdateService_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_0_6_Dxe.inf | 55 +++ .../v1_0_6/UpdateService_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_0_7_Dxe.inf | 55 +++ .../v1_0_7/UpdateService_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_0_8_Dxe.inf | 55 +++ .../v1_0_8/UpdateService_V1_0_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_0_9_Dxe.inf | 55 +++ .../v1_0_9/UpdateService_V1_0_9_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_1_0_Dxe.inf | 55 +++ .../v1_1_0/UpdateService_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_1_1_Dxe.inf | 55 +++ .../v1_1_1/UpdateService_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_1_2_Dxe.inf | 55 +++ .../v1_1_2/UpdateService_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_1_3_Dxe.inf | 55 +++ .../v1_1_3/UpdateService_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_1_4_Dxe.inf | 55 +++ .../v1_1_4/UpdateService_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_1_5_Dxe.inf | 55 +++ .../v1_1_5/UpdateService_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_1_6_Dxe.inf | 55 +++ .../v1_1_6/UpdateService_V1_1_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_1_7_Dxe.inf | 55 +++ .../v1_1_7/UpdateService_V1_1_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_1_8_Dxe.inf | 55 +++ .../v1_1_8/UpdateService_V1_1_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_1_9_Dxe.inf | 55 +++ .../v1_1_9/UpdateService_V1_1_9_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_2_0_Dxe.inf | 55 +++ .../v1_2_0/UpdateService_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_2_1_Dxe.inf | 55 +++ .../v1_2_1/UpdateService_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_2_2_Dxe.inf | 55 +++ .../v1_2_2/UpdateService_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_2_3_Dxe.inf | 55 +++ .../v1_2_3/UpdateService_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_2_4_Dxe.inf | 55 +++ .../v1_2_4/UpdateService_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_2_5_Dxe.inf | 55 +++ .../v1_2_5/UpdateService_V1_2_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_2_6_Dxe.inf | 55 +++ .../v1_2_6/UpdateService_V1_2_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_2_7_Dxe.inf | 55 +++ .../v1_2_7/UpdateService_V1_2_7_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_2_8_Dxe.inf | 55 +++ .../v1_2_8/UpdateService_V1_2_8_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_3_0_Dxe.inf | 55 +++ .../v1_3_0/UpdateService_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_3_1_Dxe.inf | 55 +++ .../v1_3_1/UpdateService_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_3_2_Dxe.inf | 55 +++ .../v1_3_2/UpdateService_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_3_3_Dxe.inf | 55 +++ .../v1_3_3/UpdateService_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_3_4_Dxe.inf | 55 +++ .../v1_3_4/UpdateService_V1_3_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_3_5_Dxe.inf | 55 +++ .../v1_3_5/UpdateService_V1_3_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_3_6_Dxe.inf | 55 +++ .../v1_3_6/UpdateService_V1_3_6_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_4_0_Dxe.inf | 55 +++ .../v1_4_0/UpdateService_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_4_1_Dxe.inf | 55 +++ .../v1_4_1/UpdateService_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_4_2_Dxe.inf | 55 +++ .../v1_4_2/UpdateService_V1_4_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_4_3_Dxe.inf | 55 +++ .../v1_4_3/UpdateService_V1_4_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_4_4_Dxe.inf | 55 +++ .../v1_4_4/UpdateService_V1_4_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_4_5_Dxe.inf | 55 +++ .../v1_4_5/UpdateService_V1_4_5_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_5_0_Dxe.inf | 55 +++ .../v1_5_0/UpdateService_V1_5_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_5_1_Dxe.inf | 55 +++ .../v1_5_1/UpdateService_V1_5_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_5_2_Dxe.inf | 55 +++ .../v1_5_2/UpdateService_V1_5_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_5_3_Dxe.inf | 55 +++ .../v1_5_3/UpdateService_V1_5_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_5_4_Dxe.inf | 55 +++ .../v1_5_4/UpdateService_V1_5_4_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_6_0_Dxe.inf | 55 +++ .../v1_6_0/UpdateService_V1_6_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_6_1_Dxe.inf | 55 +++ .../v1_6_1/UpdateService_V1_6_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_6_2_Dxe.inf | 55 +++ .../v1_6_2/UpdateService_V1_6_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_6_3_Dxe.inf | 55 +++ .../v1_6_3/UpdateService_V1_6_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_7_0_Dxe.inf | 55 +++ .../v1_7_0/UpdateService_V1_7_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_7_1_Dxe.inf | 55 +++ .../v1_7_1/UpdateService_V1_7_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_7_2_Dxe.inf | 55 +++ .../v1_7_2/UpdateService_V1_7_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_7_3_Dxe.inf | 55 +++ .../v1_7_3/UpdateService_V1_7_3_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_8_0_Dxe.inf | 55 +++ .../v1_8_0/UpdateService_V1_8_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_8_1_Dxe.inf | 55 +++ .../v1_8_1/UpdateService_V1_8_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_8_2_Dxe.inf | 55 +++ .../v1_8_2/UpdateService_V1_8_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishUpdateService_V1_8_3_Dxe.inf | 55 +++ .../v1_8_3/UpdateService_V1_8_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishVCATEntry_V1_0_0_Dxe.inf | 55 +++ .../VCATEntry/v1_0_0/VCATEntry_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishVCATEntry_V1_0_1_Dxe.inf | 55 +++ .../VCATEntry/v1_0_1/VCATEntry_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishVCATEntryCollection_Dxe.inf | 55 +++ .../VCATEntryCollection_Dxe.c | 427 ++++++++++++++++++ ...RedfishVLanNetworkInterface_V1_0_0_Dxe.inf | 55 +++ .../v1_0_0/VLanNetworkInterface_V1_0_0_Dxe.c | 427 ++++++++++++++++++ ...RedfishVLanNetworkInterface_V1_0_1_Dxe.inf | 55 +++ .../v1_0_1/VLanNetworkInterface_V1_0_1_Dxe.c | 427 ++++++++++++++++++ ...RedfishVLanNetworkInterface_V1_0_2_Dxe.inf | 55 +++ .../v1_0_2/VLanNetworkInterface_V1_0_2_Dxe.c | 427 ++++++++++++++++++ ...RedfishVLanNetworkInterface_V1_0_3_Dxe.inf | 55 +++ .../v1_0_3/VLanNetworkInterface_V1_0_3_Dxe.c | 427 ++++++++++++++++++ ...RedfishVLanNetworkInterface_V1_0_4_Dxe.inf | 55 +++ .../v1_0_4/VLanNetworkInterface_V1_0_4_Dxe.c | 427 ++++++++++++++++++ ...RedfishVLanNetworkInterface_V1_0_5_Dxe.inf | 55 +++ .../v1_0_5/VLanNetworkInterface_V1_0_5_Dxe.c | 427 ++++++++++++++++++ ...RedfishVLanNetworkInterface_V1_0_6_Dxe.inf | 55 +++ .../v1_0_6/VLanNetworkInterface_V1_0_6_Dxe.c | 427 ++++++++++++++++++ ...RedfishVLanNetworkInterface_V1_0_7_Dxe.inf | 55 +++ .../v1_0_7/VLanNetworkInterface_V1_0_7_Dxe.c | 427 ++++++++++++++++++ ...RedfishVLanNetworkInterface_V1_0_8_Dxe.inf | 55 +++ .../v1_0_8/VLanNetworkInterface_V1_0_8_Dxe.c | 427 ++++++++++++++++++ ...RedfishVLanNetworkInterface_V1_0_9_Dxe.inf | 55 +++ .../v1_0_9/VLanNetworkInterface_V1_0_9_Dxe.c | 427 ++++++++++++++++++ ...RedfishVLanNetworkInterface_V1_1_0_Dxe.inf | 55 +++ .../v1_1_0/VLanNetworkInterface_V1_1_0_Dxe.c | 427 ++++++++++++++++++ ...RedfishVLanNetworkInterface_V1_1_1_Dxe.inf | 55 +++ .../v1_1_1/VLanNetworkInterface_V1_1_1_Dxe.c | 427 ++++++++++++++++++ ...RedfishVLanNetworkInterface_V1_1_2_Dxe.inf | 55 +++ .../v1_1_2/VLanNetworkInterface_V1_1_2_Dxe.c | 427 ++++++++++++++++++ ...RedfishVLanNetworkInterface_V1_1_3_Dxe.inf | 55 +++ .../v1_1_3/VLanNetworkInterface_V1_1_3_Dxe.c | 427 ++++++++++++++++++ ...RedfishVLanNetworkInterface_V1_1_4_Dxe.inf | 55 +++ .../v1_1_4/VLanNetworkInterface_V1_1_4_Dxe.c | 427 ++++++++++++++++++ ...RedfishVLanNetworkInterface_V1_1_5_Dxe.inf | 55 +++ .../v1_1_5/VLanNetworkInterface_V1_1_5_Dxe.c | 427 ++++++++++++++++++ ...RedfishVLanNetworkInterface_V1_2_0_Dxe.inf | 55 +++ .../v1_2_0/VLanNetworkInterface_V1_2_0_Dxe.c | 427 ++++++++++++++++++ ...fishVLanNetworkInterfaceCollection_Dxe.inf | 55 +++ .../VLanNetworkInterfaceCollection_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishVirtualMedia_V1_0_0_Dxe.inf | 55 +++ .../v1_0_0/VirtualMedia_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishVirtualMedia_V1_0_2_Dxe.inf | 55 +++ .../v1_0_2/VirtualMedia_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishVirtualMedia_V1_0_3_Dxe.inf | 55 +++ .../v1_0_3/VirtualMedia_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishVirtualMedia_V1_0_4_Dxe.inf | 55 +++ .../v1_0_4/VirtualMedia_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_0_5/RedfishVirtualMedia_V1_0_5_Dxe.inf | 55 +++ .../v1_0_5/VirtualMedia_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../v1_0_6/RedfishVirtualMedia_V1_0_6_Dxe.inf | 55 +++ .../v1_0_6/VirtualMedia_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../v1_0_7/RedfishVirtualMedia_V1_0_7_Dxe.inf | 55 +++ .../v1_0_7/VirtualMedia_V1_0_7_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishVirtualMedia_V1_1_0_Dxe.inf | 55 +++ .../v1_1_0/VirtualMedia_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishVirtualMedia_V1_1_1_Dxe.inf | 55 +++ .../v1_1_1/VirtualMedia_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishVirtualMedia_V1_1_2_Dxe.inf | 55 +++ .../v1_1_2/VirtualMedia_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_3/RedfishVirtualMedia_V1_1_3_Dxe.inf | 55 +++ .../v1_1_3/VirtualMedia_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../v1_1_4/RedfishVirtualMedia_V1_1_4_Dxe.inf | 55 +++ .../v1_1_4/VirtualMedia_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../v1_1_5/RedfishVirtualMedia_V1_1_5_Dxe.inf | 55 +++ .../v1_1_5/VirtualMedia_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishVirtualMedia_V1_2_0_Dxe.inf | 55 +++ .../v1_2_0/VirtualMedia_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_1/RedfishVirtualMedia_V1_2_1_Dxe.inf | 55 +++ .../v1_2_1/VirtualMedia_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../v1_2_2/RedfishVirtualMedia_V1_2_2_Dxe.inf | 55 +++ .../v1_2_2/VirtualMedia_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../v1_2_3/RedfishVirtualMedia_V1_2_3_Dxe.inf | 55 +++ .../v1_2_3/VirtualMedia_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../v1_2_4/RedfishVirtualMedia_V1_2_4_Dxe.inf | 55 +++ .../v1_2_4/VirtualMedia_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../v1_3_0/RedfishVirtualMedia_V1_3_0_Dxe.inf | 55 +++ .../v1_3_0/VirtualMedia_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../v1_3_1/RedfishVirtualMedia_V1_3_1_Dxe.inf | 55 +++ .../v1_3_1/VirtualMedia_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../v1_3_2/RedfishVirtualMedia_V1_3_2_Dxe.inf | 55 +++ .../v1_3_2/VirtualMedia_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../RedfishVirtualMediaCollection_Dxe.inf | 55 +++ .../VirtualMediaCollection_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/RedfishVolume_V1_0_0_Dxe.inf | 55 +++ .../Volume/v1_0_0/Volume_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/RedfishVolume_V1_0_1_Dxe.inf | 55 +++ .../Volume/v1_0_1/Volume_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_2/RedfishVolume_V1_0_2_Dxe.inf | 55 +++ .../Volume/v1_0_2/Volume_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../v1_0_3/RedfishVolume_V1_0_3_Dxe.inf | 55 +++ .../Volume/v1_0_3/Volume_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../v1_0_4/RedfishVolume_V1_0_4_Dxe.inf | 55 +++ .../Volume/v1_0_4/Volume_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../v1_1_0/RedfishVolume_V1_1_0_Dxe.inf | 55 +++ .../Volume/v1_1_0/Volume_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../v1_1_1/RedfishVolume_V1_1_1_Dxe.inf | 55 +++ .../Volume/v1_1_1/Volume_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../v1_1_2/RedfishVolume_V1_1_2_Dxe.inf | 55 +++ .../Volume/v1_1_2/Volume_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../v1_1_3/RedfishVolume_V1_1_3_Dxe.inf | 55 +++ .../Volume/v1_1_3/Volume_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../v1_1_4/RedfishVolume_V1_1_4_Dxe.inf | 55 +++ .../Volume/v1_1_4/Volume_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../v1_1_5/RedfishVolume_V1_1_5_Dxe.inf | 55 +++ .../Volume/v1_1_5/Volume_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../v1_2_0/RedfishVolume_V1_2_0_Dxe.inf | 55 +++ .../Volume/v1_2_0/Volume_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../v1_2_1/RedfishVolume_V1_2_1_Dxe.inf | 55 +++ .../Volume/v1_2_1/Volume_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../v1_2_2/RedfishVolume_V1_2_2_Dxe.inf | 55 +++ .../Volume/v1_2_2/Volume_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../v1_2_3/RedfishVolume_V1_2_3_Dxe.inf | 55 +++ .../Volume/v1_2_3/Volume_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../v1_2_4/RedfishVolume_V1_2_4_Dxe.inf | 55 +++ .../Volume/v1_2_4/Volume_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../v1_2_5/RedfishVolume_V1_2_5_Dxe.inf | 55 +++ .../Volume/v1_2_5/Volume_V1_2_5_Dxe.c | 427 ++++++++++++++++++ .../v1_3_0/RedfishVolume_V1_3_0_Dxe.inf | 55 +++ .../Volume/v1_3_0/Volume_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../v1_3_1/RedfishVolume_V1_3_1_Dxe.inf | 55 +++ .../Volume/v1_3_1/Volume_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../v1_3_2/RedfishVolume_V1_3_2_Dxe.inf | 55 +++ .../Volume/v1_3_2/Volume_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../v1_3_3/RedfishVolume_V1_3_3_Dxe.inf | 55 +++ .../Volume/v1_3_3/Volume_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../v1_3_4/RedfishVolume_V1_3_4_Dxe.inf | 55 +++ .../Volume/v1_3_4/Volume_V1_3_4_Dxe.c | 427 ++++++++++++++++++ .../v1_4_0/RedfishVolume_V1_4_0_Dxe.inf | 55 +++ .../Volume/v1_4_0/Volume_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../v1_4_1/RedfishVolume_V1_4_1_Dxe.inf | 55 +++ .../Volume/v1_4_1/Volume_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../v1_4_2/RedfishVolume_V1_4_2_Dxe.inf | 55 +++ .../Volume/v1_4_2/Volume_V1_4_2_Dxe.c | 427 ++++++++++++++++++ .../v1_4_3/RedfishVolume_V1_4_3_Dxe.inf | 55 +++ .../Volume/v1_4_3/Volume_V1_4_3_Dxe.c | 427 ++++++++++++++++++ .../v1_5_0/RedfishVolume_V1_5_0_Dxe.inf | 55 +++ .../Volume/v1_5_0/Volume_V1_5_0_Dxe.c | 427 ++++++++++++++++++ .../v1_5_1/RedfishVolume_V1_5_1_Dxe.inf | 55 +++ .../Volume/v1_5_1/Volume_V1_5_1_Dxe.c | 427 ++++++++++++++++++ .../v1_6_0/RedfishVolume_V1_6_0_Dxe.inf | 55 +++ .../Volume/v1_6_0/Volume_V1_6_0_Dxe.c | 427 ++++++++++++++++++ .../v1_6_1/RedfishVolume_V1_6_1_Dxe.inf | 55 +++ .../Volume/v1_6_1/Volume_V1_6_1_Dxe.c | 427 ++++++++++++++++++ .../RedfishVolumeCollection_Dxe.inf | 55 +++ .../VolumeCollection/VolumeCollection_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_0_0/RedfishZone_V1_0_0_Dxe.inf | 55 +++ .../Converter/Zone/v1_0_0/Zone_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_0_1/RedfishZone_V1_0_1_Dxe.inf | 55 +++ .../Converter/Zone/v1_0_1/Zone_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_0_2/RedfishZone_V1_0_2_Dxe.inf | 55 +++ .../Converter/Zone/v1_0_2/Zone_V1_0_2_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_0_3/RedfishZone_V1_0_3_Dxe.inf | 55 +++ .../Converter/Zone/v1_0_3/Zone_V1_0_3_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_0_4/RedfishZone_V1_0_4_Dxe.inf | 55 +++ .../Converter/Zone/v1_0_4/Zone_V1_0_4_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_0_5/RedfishZone_V1_0_5_Dxe.inf | 55 +++ .../Converter/Zone/v1_0_5/Zone_V1_0_5_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_0_6/RedfishZone_V1_0_6_Dxe.inf | 55 +++ .../Converter/Zone/v1_0_6/Zone_V1_0_6_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_1_0/RedfishZone_V1_1_0_Dxe.inf | 55 +++ .../Converter/Zone/v1_1_0/Zone_V1_1_0_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_1_1/RedfishZone_V1_1_1_Dxe.inf | 55 +++ .../Converter/Zone/v1_1_1/Zone_V1_1_1_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_1_2/RedfishZone_V1_1_2_Dxe.inf | 55 +++ .../Converter/Zone/v1_1_2/Zone_V1_1_2_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_1_3/RedfishZone_V1_1_3_Dxe.inf | 55 +++ .../Converter/Zone/v1_1_3/Zone_V1_1_3_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_1_4/RedfishZone_V1_1_4_Dxe.inf | 55 +++ .../Converter/Zone/v1_1_4/Zone_V1_1_4_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_1_5/RedfishZone_V1_1_5_Dxe.inf | 55 +++ .../Converter/Zone/v1_1_5/Zone_V1_1_5_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_2_0/RedfishZone_V1_2_0_Dxe.inf | 55 +++ .../Converter/Zone/v1_2_0/Zone_V1_2_0_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_2_1/RedfishZone_V1_2_1_Dxe.inf | 55 +++ .../Converter/Zone/v1_2_1/Zone_V1_2_1_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_2_2/RedfishZone_V1_2_2_Dxe.inf | 55 +++ .../Converter/Zone/v1_2_2/Zone_V1_2_2_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_2_3/RedfishZone_V1_2_3_Dxe.inf | 55 +++ .../Converter/Zone/v1_2_3/Zone_V1_2_3_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_2_4/RedfishZone_V1_2_4_Dxe.inf | 55 +++ .../Converter/Zone/v1_2_4/Zone_V1_2_4_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_3_0/RedfishZone_V1_3_0_Dxe.inf | 55 +++ .../Converter/Zone/v1_3_0/Zone_V1_3_0_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_3_1/RedfishZone_V1_3_1_Dxe.inf | 55 +++ .../Converter/Zone/v1_3_1/Zone_V1_3_1_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_3_2/RedfishZone_V1_3_2_Dxe.inf | 55 +++ .../Converter/Zone/v1_3_2/Zone_V1_3_2_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_3_3/RedfishZone_V1_3_3_Dxe.inf | 55 +++ .../Converter/Zone/v1_3_3/Zone_V1_3_3_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_4_0/RedfishZone_V1_4_0_Dxe.inf | 55 +++ .../Converter/Zone/v1_4_0/Zone_V1_4_0_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_4_1/RedfishZone_V1_4_1_Dxe.inf | 55 +++ .../Converter/Zone/v1_4_1/Zone_V1_4_1_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_4_2/RedfishZone_V1_4_2_Dxe.inf | 55 +++ .../Converter/Zone/v1_4_2/Zone_V1_4_2_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_5_0/RedfishZone_V1_5_0_Dxe.inf | 55 +++ .../Converter/Zone/v1_5_0/Zone_V1_5_0_Dxe.c | 427 ++++++++++++++++++ .../Zone/v1_6_0/RedfishZone_V1_6_0_Dxe.inf | 55 +++ .../Converter/Zone/v1_6_0/Zone_V1_6_0_Dxe.c | 427 ++++++++++++++++++ .../RedfishZoneCollection_Dxe.inf | 55 +++ .../ZoneCollection/ZoneCollection_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/Redfishredfisherror_V1_0_0_Dxe.inf | 55 +++ .../v1_0_0/redfisherror_V1_0_0_Dxe.c | 427 ++++++++++++++++++ .../v1_0_1/Redfishredfisherror_V1_0_1_Dxe.inf | 55 +++ .../v1_0_1/redfisherror_V1_0_1_Dxe.c | 427 ++++++++++++++++++ .../v1_0_0/EfiAccelerationFunctionV1_0_0.h | 30 ++ .../v1_0_1/EfiAccelerationFunctionV1_0_1.h | 30 ++ .../v1_0_2/EfiAccelerationFunctionV1_0_2.h | 30 ++ .../v1_0_3/EfiAccelerationFunctionV1_0_3.h | 30 ++ .../EfiAccelerationFunctionCollection.h | 30 ++ .../v1_0_0/EfiAccountServiceV1_0_0.h | 30 ++ .../v1_0_10/EfiAccountServiceV1_0_10.h | 30 ++ .../v1_0_11/EfiAccountServiceV1_0_11.h | 30 ++ .../v1_0_2/EfiAccountServiceV1_0_2.h | 30 ++ .../v1_0_3/EfiAccountServiceV1_0_3.h | 30 ++ .../v1_0_4/EfiAccountServiceV1_0_4.h | 30 ++ .../v1_0_5/EfiAccountServiceV1_0_5.h | 30 ++ .../v1_0_6/EfiAccountServiceV1_0_6.h | 30 ++ .../v1_0_7/EfiAccountServiceV1_0_7.h | 30 ++ .../v1_0_8/EfiAccountServiceV1_0_8.h | 30 ++ .../v1_0_9/EfiAccountServiceV1_0_9.h | 30 ++ .../v1_1_0/EfiAccountServiceV1_1_0.h | 30 ++ .../v1_1_1/EfiAccountServiceV1_1_1.h | 30 ++ .../v1_1_2/EfiAccountServiceV1_1_2.h | 30 ++ .../v1_1_3/EfiAccountServiceV1_1_3.h | 30 ++ .../v1_1_4/EfiAccountServiceV1_1_4.h | 30 ++ .../v1_1_5/EfiAccountServiceV1_1_5.h | 30 ++ .../v1_1_6/EfiAccountServiceV1_1_6.h | 30 ++ .../v1_1_7/EfiAccountServiceV1_1_7.h | 30 ++ .../v1_1_8/EfiAccountServiceV1_1_8.h | 30 ++ .../v1_2_0/EfiAccountServiceV1_2_0.h | 30 ++ .../v1_2_1/EfiAccountServiceV1_2_1.h | 30 ++ .../v1_2_2/EfiAccountServiceV1_2_2.h | 30 ++ .../v1_2_3/EfiAccountServiceV1_2_3.h | 30 ++ .../v1_2_4/EfiAccountServiceV1_2_4.h | 30 ++ .../v1_2_5/EfiAccountServiceV1_2_5.h | 30 ++ .../v1_2_6/EfiAccountServiceV1_2_6.h | 30 ++ .../v1_2_7/EfiAccountServiceV1_2_7.h | 30 ++ .../v1_2_8/EfiAccountServiceV1_2_8.h | 30 ++ .../v1_3_0/EfiAccountServiceV1_3_0.h | 30 ++ .../v1_3_1/EfiAccountServiceV1_3_1.h | 30 ++ .../v1_3_2/EfiAccountServiceV1_3_2.h | 30 ++ .../v1_3_3/EfiAccountServiceV1_3_3.h | 30 ++ .../v1_3_4/EfiAccountServiceV1_3_4.h | 30 ++ .../v1_3_5/EfiAccountServiceV1_3_5.h | 30 ++ .../v1_3_6/EfiAccountServiceV1_3_6.h | 30 ++ .../v1_3_7/EfiAccountServiceV1_3_7.h | 30 ++ .../v1_4_0/EfiAccountServiceV1_4_0.h | 30 ++ .../v1_4_1/EfiAccountServiceV1_4_1.h | 30 ++ .../v1_4_2/EfiAccountServiceV1_4_2.h | 30 ++ .../v1_4_3/EfiAccountServiceV1_4_3.h | 30 ++ .../v1_4_4/EfiAccountServiceV1_4_4.h | 30 ++ .../v1_4_5/EfiAccountServiceV1_4_5.h | 30 ++ .../v1_5_0/EfiAccountServiceV1_5_0.h | 30 ++ .../v1_5_1/EfiAccountServiceV1_5_1.h | 30 ++ .../v1_5_2/EfiAccountServiceV1_5_2.h | 30 ++ .../v1_5_3/EfiAccountServiceV1_5_3.h | 30 ++ .../v1_5_4/EfiAccountServiceV1_5_4.h | 30 ++ .../v1_6_0/EfiAccountServiceV1_6_0.h | 30 ++ .../v1_6_1/EfiAccountServiceV1_6_1.h | 30 ++ .../v1_6_2/EfiAccountServiceV1_6_2.h | 30 ++ .../v1_6_3/EfiAccountServiceV1_6_3.h | 30 ++ .../v1_7_0/EfiAccountServiceV1_7_0.h | 30 ++ .../v1_7_1/EfiAccountServiceV1_7_1.h | 30 ++ .../v1_7_2/EfiAccountServiceV1_7_2.h | 30 ++ .../v1_7_3/EfiAccountServiceV1_7_3.h | 30 ++ .../v1_8_0/EfiAccountServiceV1_8_0.h | 30 ++ .../ActionInfo/v1_0_0/EfiActionInfoV1_0_0.h | 30 ++ .../ActionInfo/v1_0_1/EfiActionInfoV1_0_1.h | 30 ++ .../ActionInfo/v1_0_2/EfiActionInfoV1_0_2.h | 30 ++ .../ActionInfo/v1_0_3/EfiActionInfoV1_0_3.h | 30 ++ .../ActionInfo/v1_0_4/EfiActionInfoV1_0_4.h | 30 ++ .../ActionInfo/v1_0_5/EfiActionInfoV1_0_5.h | 30 ++ .../ActionInfo/v1_0_6/EfiActionInfoV1_0_6.h | 30 ++ .../ActionInfo/v1_1_0/EfiActionInfoV1_1_0.h | 30 ++ .../ActionInfo/v1_1_1/EfiActionInfoV1_1_1.h | 30 ++ .../ActionInfo/v1_1_2/EfiActionInfoV1_1_2.h | 30 ++ .../AddressPool/v1_0_0/EfiAddressPoolV1_0_0.h | 30 ++ .../AddressPool/v1_0_1/EfiAddressPoolV1_0_1.h | 30 ++ .../AddressPool/v1_0_2/EfiAddressPoolV1_0_2.h | 30 ++ .../AddressPool/v1_1_0/EfiAddressPoolV1_1_0.h | 30 ++ .../AddressPool/v1_1_1/EfiAddressPoolV1_1_1.h | 30 ++ .../EfiAddressPoolCollection.h | 30 ++ .../Aggregate/v1_0_0/EfiAggregateV1_0_0.h | 30 ++ .../Aggregate/v1_0_1/EfiAggregateV1_0_1.h | 30 ++ .../EfiAggregateCollection.h | 30 ++ .../v1_0_0/EfiAggregationServiceV1_0_0.h | 30 ++ .../v1_0_1/EfiAggregationServiceV1_0_1.h | 30 ++ .../v1_0_0/EfiAggregationSourceV1_0_0.h | 30 ++ .../v1_1_0/EfiAggregationSourceV1_1_0.h | 30 ++ .../EfiAggregationSourceCollection.h | 30 ++ .../Assembly/v1_0_0/EfiAssemblyV1_0_0.h | 30 ++ .../Assembly/v1_0_1/EfiAssemblyV1_0_1.h | 30 ++ .../Assembly/v1_0_2/EfiAssemblyV1_0_2.h | 30 ++ .../Assembly/v1_0_3/EfiAssemblyV1_0_3.h | 30 ++ .../Assembly/v1_0_4/EfiAssemblyV1_0_4.h | 30 ++ .../Assembly/v1_1_0/EfiAssemblyV1_1_0.h | 30 ++ .../Assembly/v1_1_1/EfiAssemblyV1_1_1.h | 30 ++ .../Assembly/v1_1_2/EfiAssemblyV1_1_2.h | 30 ++ .../Assembly/v1_1_3/EfiAssemblyV1_1_3.h | 30 ++ .../Assembly/v1_1_4/EfiAssemblyV1_1_4.h | 30 ++ .../Assembly/v1_2_0/EfiAssemblyV1_2_0.h | 30 ++ .../Assembly/v1_2_1/EfiAssemblyV1_2_1.h | 30 ++ .../Assembly/v1_2_2/EfiAssemblyV1_2_2.h | 30 ++ .../Assembly/v1_2_3/EfiAssemblyV1_2_3.h | 30 ++ .../Assembly/v1_3_0/EfiAssemblyV1_3_0.h | 30 ++ .../v1_0_0/EfiAttributeRegistryV1_0_0.h | 30 ++ .../v1_0_1/EfiAttributeRegistryV1_0_1.h | 30 ++ .../v1_0_10/EfiAttributeRegistryV1_0_10.h | 30 ++ .../v1_0_2/EfiAttributeRegistryV1_0_2.h | 30 ++ .../v1_0_3/EfiAttributeRegistryV1_0_3.h | 30 ++ .../v1_0_4/EfiAttributeRegistryV1_0_4.h | 30 ++ .../v1_0_5/EfiAttributeRegistryV1_0_5.h | 30 ++ .../v1_0_6/EfiAttributeRegistryV1_0_6.h | 30 ++ .../v1_0_7/EfiAttributeRegistryV1_0_7.h | 30 ++ .../v1_0_8/EfiAttributeRegistryV1_0_8.h | 30 ++ .../v1_0_9/EfiAttributeRegistryV1_0_9.h | 30 ++ .../v1_1_0/EfiAttributeRegistryV1_1_0.h | 30 ++ .../v1_1_1/EfiAttributeRegistryV1_1_1.h | 30 ++ .../v1_1_2/EfiAttributeRegistryV1_1_2.h | 30 ++ .../v1_1_3/EfiAttributeRegistryV1_1_3.h | 30 ++ .../v1_1_4/EfiAttributeRegistryV1_1_4.h | 30 ++ .../v1_1_5/EfiAttributeRegistryV1_1_5.h | 30 ++ .../v1_1_6/EfiAttributeRegistryV1_1_6.h | 30 ++ .../v1_1_7/EfiAttributeRegistryV1_1_7.h | 30 ++ .../v1_1_8/EfiAttributeRegistryV1_1_8.h | 30 ++ .../v1_1_9/EfiAttributeRegistryV1_1_9.h | 30 ++ .../v1_2_0/EfiAttributeRegistryV1_2_0.h | 30 ++ .../v1_2_1/EfiAttributeRegistryV1_2_1.h | 30 ++ .../v1_2_2/EfiAttributeRegistryV1_2_2.h | 30 ++ .../v1_2_3/EfiAttributeRegistryV1_2_3.h | 30 ++ .../v1_2_4/EfiAttributeRegistryV1_2_4.h | 30 ++ .../v1_2_5/EfiAttributeRegistryV1_2_5.h | 30 ++ .../v1_2_6/EfiAttributeRegistryV1_2_6.h | 30 ++ .../v1_2_7/EfiAttributeRegistryV1_2_7.h | 30 ++ .../v1_3_0/EfiAttributeRegistryV1_3_0.h | 30 ++ .../v1_3_1/EfiAttributeRegistryV1_3_1.h | 30 ++ .../v1_3_2/EfiAttributeRegistryV1_3_2.h | 30 ++ .../v1_3_3/EfiAttributeRegistryV1_3_3.h | 30 ++ .../v1_3_4/EfiAttributeRegistryV1_3_4.h | 30 ++ .../v1_3_5/EfiAttributeRegistryV1_3_5.h | 30 ++ .../Bios/v1_0_0/EfiBiosV1_0_0.h | 30 ++ .../Bios/v1_0_1/EfiBiosV1_0_1.h | 30 ++ .../Bios/v1_0_2/EfiBiosV1_0_2.h | 30 ++ .../Bios/v1_0_3/EfiBiosV1_0_3.h | 30 ++ .../Bios/v1_0_4/EfiBiosV1_0_4.h | 30 ++ .../Bios/v1_0_5/EfiBiosV1_0_5.h | 30 ++ .../Bios/v1_0_6/EfiBiosV1_0_6.h | 30 ++ .../Bios/v1_0_7/EfiBiosV1_0_7.h | 30 ++ .../Bios/v1_0_8/EfiBiosV1_0_8.h | 30 ++ .../Bios/v1_1_0/EfiBiosV1_1_0.h | 30 ++ .../Bios/v1_1_1/EfiBiosV1_1_1.h | 30 ++ .../BootOption/v1_0_0/EfiBootOptionV1_0_0.h | 30 ++ .../BootOption/v1_0_1/EfiBootOptionV1_0_1.h | 30 ++ .../BootOption/v1_0_2/EfiBootOptionV1_0_2.h | 30 ++ .../BootOption/v1_0_3/EfiBootOptionV1_0_3.h | 30 ++ .../BootOption/v1_0_4/EfiBootOptionV1_0_4.h | 30 ++ .../EfiBootOptionCollection.h | 30 ++ .../Certificate/v1_0_0/EfiCertificateV1_0_0.h | 30 ++ .../Certificate/v1_0_1/EfiCertificateV1_0_1.h | 30 ++ .../Certificate/v1_0_2/EfiCertificateV1_0_2.h | 30 ++ .../Certificate/v1_0_3/EfiCertificateV1_0_3.h | 30 ++ .../Certificate/v1_0_4/EfiCertificateV1_0_4.h | 30 ++ .../Certificate/v1_1_0/EfiCertificateV1_1_0.h | 30 ++ .../Certificate/v1_1_1/EfiCertificateV1_1_1.h | 30 ++ .../Certificate/v1_1_2/EfiCertificateV1_1_2.h | 30 ++ .../Certificate/v1_1_3/EfiCertificateV1_1_3.h | 30 ++ .../Certificate/v1_2_0/EfiCertificateV1_2_0.h | 30 ++ .../Certificate/v1_2_1/EfiCertificateV1_2_1.h | 30 ++ .../Certificate/v1_2_2/EfiCertificateV1_2_2.h | 30 ++ .../EfiCertificateCollection.h | 30 ++ .../v1_0_0/EfiCertificateLocationsV1_0_0.h | 30 ++ .../v1_0_1/EfiCertificateLocationsV1_0_1.h | 30 ++ .../v1_0_2/EfiCertificateLocationsV1_0_2.h | 30 ++ .../v1_0_0/EfiCertificateServiceV1_0_0.h | 30 ++ .../v1_0_1/EfiCertificateServiceV1_0_1.h | 30 ++ .../v1_0_2/EfiCertificateServiceV1_0_2.h | 30 ++ .../v1_0_3/EfiCertificateServiceV1_0_3.h | 30 ++ .../v1_0_4/EfiCertificateServiceV1_0_4.h | 30 ++ .../Chassis/v1_0_0/EfiChassisV1_0_0.h | 30 ++ .../Chassis/v1_0_1/EfiChassisV1_0_1.h | 30 ++ .../Chassis/v1_0_10/EfiChassisV1_0_10.h | 30 ++ .../Chassis/v1_0_11/EfiChassisV1_0_11.h | 30 ++ .../Chassis/v1_0_12/EfiChassisV1_0_12.h | 30 ++ .../Chassis/v1_0_13/EfiChassisV1_0_13.h | 30 ++ .../Chassis/v1_0_2/EfiChassisV1_0_2.h | 30 ++ .../Chassis/v1_0_3/EfiChassisV1_0_3.h | 30 ++ .../Chassis/v1_0_4/EfiChassisV1_0_4.h | 30 ++ .../Chassis/v1_0_5/EfiChassisV1_0_5.h | 30 ++ .../Chassis/v1_0_6/EfiChassisV1_0_6.h | 30 ++ .../Chassis/v1_0_7/EfiChassisV1_0_7.h | 30 ++ .../Chassis/v1_0_8/EfiChassisV1_0_8.h | 30 ++ .../Chassis/v1_0_9/EfiChassisV1_0_9.h | 30 ++ .../Chassis/v1_10_0/EfiChassisV1_10_0.h | 30 ++ .../Chassis/v1_10_1/EfiChassisV1_10_1.h | 30 ++ .../Chassis/v1_10_2/EfiChassisV1_10_2.h | 30 ++ .../Chassis/v1_10_3/EfiChassisV1_10_3.h | 30 ++ .../Chassis/v1_11_0/EfiChassisV1_11_0.h | 30 ++ .../Chassis/v1_11_1/EfiChassisV1_11_1.h | 30 ++ .../Chassis/v1_11_2/EfiChassisV1_11_2.h | 30 ++ .../Chassis/v1_11_3/EfiChassisV1_11_3.h | 30 ++ .../Chassis/v1_12_0/EfiChassisV1_12_0.h | 30 ++ .../Chassis/v1_12_1/EfiChassisV1_12_1.h | 30 ++ .../Chassis/v1_12_2/EfiChassisV1_12_2.h | 30 ++ .../Chassis/v1_13_0/EfiChassisV1_13_0.h | 30 ++ .../Chassis/v1_13_1/EfiChassisV1_13_1.h | 30 ++ .../Chassis/v1_14_0/EfiChassisV1_14_0.h | 30 ++ .../Chassis/v1_15_0/EfiChassisV1_15_0.h | 30 ++ .../Chassis/v1_1_0/EfiChassisV1_1_0.h | 30 ++ .../Chassis/v1_1_10/EfiChassisV1_1_10.h | 30 ++ .../Chassis/v1_1_11/EfiChassisV1_1_11.h | 30 ++ .../Chassis/v1_1_12/EfiChassisV1_1_12.h | 30 ++ .../Chassis/v1_1_13/EfiChassisV1_1_13.h | 30 ++ .../Chassis/v1_1_2/EfiChassisV1_1_2.h | 30 ++ .../Chassis/v1_1_3/EfiChassisV1_1_3.h | 30 ++ .../Chassis/v1_1_4/EfiChassisV1_1_4.h | 30 ++ .../Chassis/v1_1_5/EfiChassisV1_1_5.h | 30 ++ .../Chassis/v1_1_6/EfiChassisV1_1_6.h | 30 ++ .../Chassis/v1_1_7/EfiChassisV1_1_7.h | 30 ++ .../Chassis/v1_1_8/EfiChassisV1_1_8.h | 30 ++ .../Chassis/v1_1_9/EfiChassisV1_1_9.h | 30 ++ .../Chassis/v1_2_0/EfiChassisV1_2_0.h | 30 ++ .../Chassis/v1_2_1/EfiChassisV1_2_1.h | 30 ++ .../Chassis/v1_2_10/EfiChassisV1_2_10.h | 30 ++ .../Chassis/v1_2_11/EfiChassisV1_2_11.h | 30 ++ .../Chassis/v1_2_2/EfiChassisV1_2_2.h | 30 ++ .../Chassis/v1_2_3/EfiChassisV1_2_3.h | 30 ++ .../Chassis/v1_2_4/EfiChassisV1_2_4.h | 30 ++ .../Chassis/v1_2_5/EfiChassisV1_2_5.h | 30 ++ .../Chassis/v1_2_6/EfiChassisV1_2_6.h | 30 ++ .../Chassis/v1_2_7/EfiChassisV1_2_7.h | 30 ++ .../Chassis/v1_2_8/EfiChassisV1_2_8.h | 30 ++ .../Chassis/v1_2_9/EfiChassisV1_2_9.h | 30 ++ .../Chassis/v1_3_0/EfiChassisV1_3_0.h | 30 ++ .../Chassis/v1_3_1/EfiChassisV1_3_1.h | 30 ++ .../Chassis/v1_3_10/EfiChassisV1_3_10.h | 30 ++ .../Chassis/v1_3_11/EfiChassisV1_3_11.h | 30 ++ .../Chassis/v1_3_2/EfiChassisV1_3_2.h | 30 ++ .../Chassis/v1_3_3/EfiChassisV1_3_3.h | 30 ++ .../Chassis/v1_3_4/EfiChassisV1_3_4.h | 30 ++ .../Chassis/v1_3_5/EfiChassisV1_3_5.h | 30 ++ .../Chassis/v1_3_6/EfiChassisV1_3_6.h | 30 ++ .../Chassis/v1_3_7/EfiChassisV1_3_7.h | 30 ++ .../Chassis/v1_3_8/EfiChassisV1_3_8.h | 30 ++ .../Chassis/v1_3_9/EfiChassisV1_3_9.h | 30 ++ .../Chassis/v1_4_0/EfiChassisV1_4_0.h | 30 ++ .../Chassis/v1_4_1/EfiChassisV1_4_1.h | 30 ++ .../Chassis/v1_4_10/EfiChassisV1_4_10.h | 30 ++ .../Chassis/v1_4_2/EfiChassisV1_4_2.h | 30 ++ .../Chassis/v1_4_3/EfiChassisV1_4_3.h | 30 ++ .../Chassis/v1_4_4/EfiChassisV1_4_4.h | 30 ++ .../Chassis/v1_4_5/EfiChassisV1_4_5.h | 30 ++ .../Chassis/v1_4_6/EfiChassisV1_4_6.h | 30 ++ .../Chassis/v1_4_7/EfiChassisV1_4_7.h | 30 ++ .../Chassis/v1_4_8/EfiChassisV1_4_8.h | 30 ++ .../Chassis/v1_4_9/EfiChassisV1_4_9.h | 30 ++ .../Chassis/v1_5_0/EfiChassisV1_5_0.h | 30 ++ .../Chassis/v1_5_1/EfiChassisV1_5_1.h | 30 ++ .../Chassis/v1_5_2/EfiChassisV1_5_2.h | 30 ++ .../Chassis/v1_5_3/EfiChassisV1_5_3.h | 30 ++ .../Chassis/v1_5_4/EfiChassisV1_5_4.h | 30 ++ .../Chassis/v1_5_5/EfiChassisV1_5_5.h | 30 ++ .../Chassis/v1_5_6/EfiChassisV1_5_6.h | 30 ++ .../Chassis/v1_5_7/EfiChassisV1_5_7.h | 30 ++ .../Chassis/v1_5_8/EfiChassisV1_5_8.h | 30 ++ .../Chassis/v1_5_9/EfiChassisV1_5_9.h | 30 ++ .../Chassis/v1_6_0/EfiChassisV1_6_0.h | 30 ++ .../Chassis/v1_6_1/EfiChassisV1_6_1.h | 30 ++ .../Chassis/v1_6_2/EfiChassisV1_6_2.h | 30 ++ .../Chassis/v1_6_3/EfiChassisV1_6_3.h | 30 ++ .../Chassis/v1_6_4/EfiChassisV1_6_4.h | 30 ++ .../Chassis/v1_6_5/EfiChassisV1_6_5.h | 30 ++ .../Chassis/v1_6_6/EfiChassisV1_6_6.h | 30 ++ .../Chassis/v1_6_7/EfiChassisV1_6_7.h | 30 ++ .../Chassis/v1_7_0/EfiChassisV1_7_0.h | 30 ++ .../Chassis/v1_7_1/EfiChassisV1_7_1.h | 30 ++ .../Chassis/v1_7_2/EfiChassisV1_7_2.h | 30 ++ .../Chassis/v1_7_3/EfiChassisV1_7_3.h | 30 ++ .../Chassis/v1_7_4/EfiChassisV1_7_4.h | 30 ++ .../Chassis/v1_7_5/EfiChassisV1_7_5.h | 30 ++ .../Chassis/v1_7_6/EfiChassisV1_7_6.h | 30 ++ .../Chassis/v1_7_7/EfiChassisV1_7_7.h | 30 ++ .../Chassis/v1_8_0/EfiChassisV1_8_0.h | 30 ++ .../Chassis/v1_8_1/EfiChassisV1_8_1.h | 30 ++ .../Chassis/v1_8_2/EfiChassisV1_8_2.h | 30 ++ .../Chassis/v1_8_3/EfiChassisV1_8_3.h | 30 ++ .../Chassis/v1_8_4/EfiChassisV1_8_4.h | 30 ++ .../Chassis/v1_8_5/EfiChassisV1_8_5.h | 30 ++ .../Chassis/v1_8_6/EfiChassisV1_8_6.h | 30 ++ .../Chassis/v1_9_0/EfiChassisV1_9_0.h | 30 ++ .../Chassis/v1_9_1/EfiChassisV1_9_1.h | 30 ++ .../Chassis/v1_9_2/EfiChassisV1_9_2.h | 30 ++ .../Chassis/v1_9_3/EfiChassisV1_9_3.h | 30 ++ .../Chassis/v1_9_4/EfiChassisV1_9_4.h | 30 ++ .../Chassis/v1_9_5/EfiChassisV1_9_5.h | 30 ++ .../ChassisCollection/EfiChassisCollection.h | 30 ++ .../Circuit/v1_0_0/EfiCircuitV1_0_0.h | 30 ++ .../Circuit/v1_0_1/EfiCircuitV1_0_1.h | 30 ++ .../Circuit/v1_0_2/EfiCircuitV1_0_2.h | 30 ++ .../Circuit/v1_1_0/EfiCircuitV1_1_0.h | 30 ++ .../Circuit/v1_1_1/EfiCircuitV1_1_1.h | 30 ++ .../Circuit/v1_2_0/EfiCircuitV1_2_0.h | 30 ++ .../CircuitCollection/EfiCircuitCollection.h | 30 ++ .../v1_0_0/EfiCompositionServiceV1_0_0.h | 30 ++ .../v1_0_1/EfiCompositionServiceV1_0_1.h | 30 ++ .../v1_0_2/EfiCompositionServiceV1_0_2.h | 30 ++ .../v1_0_3/EfiCompositionServiceV1_0_3.h | 30 ++ .../v1_0_4/EfiCompositionServiceV1_0_4.h | 30 ++ .../v1_1_0/EfiCompositionServiceV1_1_0.h | 30 ++ .../v1_1_1/EfiCompositionServiceV1_1_1.h | 30 ++ .../v1_1_2/EfiCompositionServiceV1_1_2.h | 30 ++ .../v1_0_0/EfiComputerSystemV1_0_0.h | 30 ++ .../v1_0_1/EfiComputerSystemV1_0_1.h | 30 ++ .../v1_0_10/EfiComputerSystemV1_0_10.h | 30 ++ .../v1_0_11/EfiComputerSystemV1_0_11.h | 30 ++ .../v1_0_12/EfiComputerSystemV1_0_12.h | 30 ++ .../v1_0_13/EfiComputerSystemV1_0_13.h | 30 ++ .../v1_0_14/EfiComputerSystemV1_0_14.h | 30 ++ .../v1_0_15/EfiComputerSystemV1_0_15.h | 30 ++ .../v1_0_16/EfiComputerSystemV1_0_16.h | 30 ++ .../v1_0_2/EfiComputerSystemV1_0_2.h | 30 ++ .../v1_0_3/EfiComputerSystemV1_0_3.h | 30 ++ .../v1_0_4/EfiComputerSystemV1_0_4.h | 30 ++ .../v1_0_5/EfiComputerSystemV1_0_5.h | 30 ++ .../v1_0_6/EfiComputerSystemV1_0_6.h | 30 ++ .../v1_0_7/EfiComputerSystemV1_0_7.h | 30 ++ .../v1_0_8/EfiComputerSystemV1_0_8.h | 30 ++ .../v1_0_9/EfiComputerSystemV1_0_9.h | 30 ++ .../v1_10_0/EfiComputerSystemV1_10_0.h | 30 ++ .../v1_10_1/EfiComputerSystemV1_10_1.h | 30 ++ .../v1_10_2/EfiComputerSystemV1_10_2.h | 30 ++ .../v1_10_3/EfiComputerSystemV1_10_3.h | 30 ++ .../v1_10_4/EfiComputerSystemV1_10_4.h | 30 ++ .../v1_11_0/EfiComputerSystemV1_11_0.h | 30 ++ .../v1_11_1/EfiComputerSystemV1_11_1.h | 30 ++ .../v1_11_2/EfiComputerSystemV1_11_2.h | 30 ++ .../v1_11_3/EfiComputerSystemV1_11_3.h | 30 ++ .../v1_12_0/EfiComputerSystemV1_12_0.h | 30 ++ .../v1_12_1/EfiComputerSystemV1_12_1.h | 30 ++ .../v1_12_2/EfiComputerSystemV1_12_2.h | 30 ++ .../v1_13_0/EfiComputerSystemV1_13_0.h | 30 ++ .../v1_13_1/EfiComputerSystemV1_13_1.h | 30 ++ .../v1_14_0/EfiComputerSystemV1_14_0.h | 30 ++ .../v1_1_0/EfiComputerSystemV1_1_0.h | 30 ++ .../v1_1_1/EfiComputerSystemV1_1_1.h | 30 ++ .../v1_1_10/EfiComputerSystemV1_1_10.h | 30 ++ .../v1_1_11/EfiComputerSystemV1_1_11.h | 30 ++ .../v1_1_12/EfiComputerSystemV1_1_12.h | 30 ++ .../v1_1_13/EfiComputerSystemV1_1_13.h | 30 ++ .../v1_1_14/EfiComputerSystemV1_1_14.h | 30 ++ .../v1_1_2/EfiComputerSystemV1_1_2.h | 30 ++ .../v1_1_3/EfiComputerSystemV1_1_3.h | 30 ++ .../v1_1_4/EfiComputerSystemV1_1_4.h | 30 ++ .../v1_1_5/EfiComputerSystemV1_1_5.h | 30 ++ .../v1_1_6/EfiComputerSystemV1_1_6.h | 30 ++ .../v1_1_7/EfiComputerSystemV1_1_7.h | 30 ++ .../v1_1_8/EfiComputerSystemV1_1_8.h | 30 ++ .../v1_1_9/EfiComputerSystemV1_1_9.h | 30 ++ .../v1_2_0/EfiComputerSystemV1_2_0.h | 30 ++ .../v1_2_1/EfiComputerSystemV1_2_1.h | 30 ++ .../v1_2_10/EfiComputerSystemV1_2_10.h | 30 ++ .../v1_2_11/EfiComputerSystemV1_2_11.h | 30 ++ .../v1_2_12/EfiComputerSystemV1_2_12.h | 30 ++ .../v1_2_13/EfiComputerSystemV1_2_13.h | 30 ++ .../v1_2_2/EfiComputerSystemV1_2_2.h | 30 ++ .../v1_2_3/EfiComputerSystemV1_2_3.h | 30 ++ .../v1_2_4/EfiComputerSystemV1_2_4.h | 30 ++ .../v1_2_5/EfiComputerSystemV1_2_5.h | 30 ++ .../v1_2_6/EfiComputerSystemV1_2_6.h | 30 ++ .../v1_2_7/EfiComputerSystemV1_2_7.h | 30 ++ .../v1_2_8/EfiComputerSystemV1_2_8.h | 30 ++ .../v1_2_9/EfiComputerSystemV1_2_9.h | 30 ++ .../v1_3_0/EfiComputerSystemV1_3_0.h | 30 ++ .../v1_3_1/EfiComputerSystemV1_3_1.h | 30 ++ .../v1_3_10/EfiComputerSystemV1_3_10.h | 30 ++ .../v1_3_11/EfiComputerSystemV1_3_11.h | 30 ++ .../v1_3_12/EfiComputerSystemV1_3_12.h | 30 ++ .../v1_3_2/EfiComputerSystemV1_3_2.h | 30 ++ .../v1_3_3/EfiComputerSystemV1_3_3.h | 30 ++ .../v1_3_4/EfiComputerSystemV1_3_4.h | 30 ++ .../v1_3_5/EfiComputerSystemV1_3_5.h | 30 ++ .../v1_3_6/EfiComputerSystemV1_3_6.h | 30 ++ .../v1_3_7/EfiComputerSystemV1_3_7.h | 30 ++ .../v1_3_8/EfiComputerSystemV1_3_8.h | 30 ++ .../v1_3_9/EfiComputerSystemV1_3_9.h | 30 ++ .../v1_4_0/EfiComputerSystemV1_4_0.h | 30 ++ .../v1_4_1/EfiComputerSystemV1_4_1.h | 30 ++ .../v1_4_10/EfiComputerSystemV1_4_10.h | 30 ++ .../v1_4_11/EfiComputerSystemV1_4_11.h | 30 ++ .../v1_4_2/EfiComputerSystemV1_4_2.h | 30 ++ .../v1_4_3/EfiComputerSystemV1_4_3.h | 30 ++ .../v1_4_4/EfiComputerSystemV1_4_4.h | 30 ++ .../v1_4_5/EfiComputerSystemV1_4_5.h | 30 ++ .../v1_4_6/EfiComputerSystemV1_4_6.h | 30 ++ .../v1_4_7/EfiComputerSystemV1_4_7.h | 30 ++ .../v1_4_8/EfiComputerSystemV1_4_8.h | 30 ++ .../v1_4_9/EfiComputerSystemV1_4_9.h | 30 ++ .../v1_5_0/EfiComputerSystemV1_5_0.h | 30 ++ .../v1_5_1/EfiComputerSystemV1_5_1.h | 30 ++ .../v1_5_2/EfiComputerSystemV1_5_2.h | 30 ++ .../v1_5_3/EfiComputerSystemV1_5_3.h | 30 ++ .../v1_5_4/EfiComputerSystemV1_5_4.h | 30 ++ .../v1_5_5/EfiComputerSystemV1_5_5.h | 30 ++ .../v1_5_6/EfiComputerSystemV1_5_6.h | 30 ++ .../v1_5_7/EfiComputerSystemV1_5_7.h | 30 ++ .../v1_5_8/EfiComputerSystemV1_5_8.h | 30 ++ .../v1_5_9/EfiComputerSystemV1_5_9.h | 30 ++ .../v1_6_0/EfiComputerSystemV1_6_0.h | 30 ++ .../v1_6_1/EfiComputerSystemV1_6_1.h | 30 ++ .../v1_6_2/EfiComputerSystemV1_6_2.h | 30 ++ .../v1_6_3/EfiComputerSystemV1_6_3.h | 30 ++ .../v1_6_4/EfiComputerSystemV1_6_4.h | 30 ++ .../v1_6_5/EfiComputerSystemV1_6_5.h | 30 ++ .../v1_6_6/EfiComputerSystemV1_6_6.h | 30 ++ .../v1_6_7/EfiComputerSystemV1_6_7.h | 30 ++ .../v1_7_0/EfiComputerSystemV1_7_0.h | 30 ++ .../v1_7_1/EfiComputerSystemV1_7_1.h | 30 ++ .../v1_7_2/EfiComputerSystemV1_7_2.h | 30 ++ .../v1_7_3/EfiComputerSystemV1_7_3.h | 30 ++ .../v1_7_4/EfiComputerSystemV1_7_4.h | 30 ++ .../v1_7_5/EfiComputerSystemV1_7_5.h | 30 ++ .../v1_7_6/EfiComputerSystemV1_7_6.h | 30 ++ .../v1_8_0/EfiComputerSystemV1_8_0.h | 30 ++ .../v1_8_1/EfiComputerSystemV1_8_1.h | 30 ++ .../v1_8_2/EfiComputerSystemV1_8_2.h | 30 ++ .../v1_8_3/EfiComputerSystemV1_8_3.h | 30 ++ .../v1_8_4/EfiComputerSystemV1_8_4.h | 30 ++ .../v1_8_5/EfiComputerSystemV1_8_5.h | 30 ++ .../v1_9_0/EfiComputerSystemV1_9_0.h | 30 ++ .../v1_9_1/EfiComputerSystemV1_9_1.h | 30 ++ .../v1_9_2/EfiComputerSystemV1_9_2.h | 30 ++ .../v1_9_3/EfiComputerSystemV1_9_3.h | 30 ++ .../v1_9_4/EfiComputerSystemV1_9_4.h | 30 ++ .../v1_9_5/EfiComputerSystemV1_9_5.h | 30 ++ .../EfiComputerSystemCollection.h | 30 ++ .../Connection/v1_0_0/EfiConnectionV1_0_0.h | 30 ++ .../EfiConnectionCollection.h | 30 ++ .../v1_0_0/EfiConnectionMethodV1_0_0.h | 30 ++ .../EfiConnectionMethodCollection.h | 30 ++ .../Drive/v1_0_0/EfiDriveV1_0_0.h | 30 ++ .../Drive/v1_0_1/EfiDriveV1_0_1.h | 30 ++ .../Drive/v1_0_10/EfiDriveV1_0_10.h | 30 ++ .../Drive/v1_0_11/EfiDriveV1_0_11.h | 30 ++ .../Drive/v1_0_2/EfiDriveV1_0_2.h | 30 ++ .../Drive/v1_0_3/EfiDriveV1_0_3.h | 30 ++ .../Drive/v1_0_4/EfiDriveV1_0_4.h | 30 ++ .../Drive/v1_0_5/EfiDriveV1_0_5.h | 30 ++ .../Drive/v1_0_6/EfiDriveV1_0_6.h | 30 ++ .../Drive/v1_0_7/EfiDriveV1_0_7.h | 30 ++ .../Drive/v1_0_8/EfiDriveV1_0_8.h | 30 ++ .../Drive/v1_0_9/EfiDriveV1_0_9.h | 30 ++ .../Drive/v1_10_0/EfiDriveV1_10_0.h | 30 ++ .../Drive/v1_10_1/EfiDriveV1_10_1.h | 30 ++ .../Drive/v1_11_0/EfiDriveV1_11_0.h | 30 ++ .../Drive/v1_11_1/EfiDriveV1_11_1.h | 30 ++ .../Drive/v1_12_0/EfiDriveV1_12_0.h | 30 ++ .../Drive/v1_1_0/EfiDriveV1_1_0.h | 30 ++ .../Drive/v1_1_1/EfiDriveV1_1_1.h | 30 ++ .../Drive/v1_1_10/EfiDriveV1_1_10.h | 30 ++ .../Drive/v1_1_2/EfiDriveV1_1_2.h | 30 ++ .../Drive/v1_1_3/EfiDriveV1_1_3.h | 30 ++ .../Drive/v1_1_4/EfiDriveV1_1_4.h | 30 ++ .../Drive/v1_1_5/EfiDriveV1_1_5.h | 30 ++ .../Drive/v1_1_6/EfiDriveV1_1_6.h | 30 ++ .../Drive/v1_1_7/EfiDriveV1_1_7.h | 30 ++ .../Drive/v1_1_8/EfiDriveV1_1_8.h | 30 ++ .../Drive/v1_1_9/EfiDriveV1_1_9.h | 30 ++ .../Drive/v1_2_0/EfiDriveV1_2_0.h | 30 ++ .../Drive/v1_2_1/EfiDriveV1_2_1.h | 30 ++ .../Drive/v1_2_2/EfiDriveV1_2_2.h | 30 ++ .../Drive/v1_2_3/EfiDriveV1_2_3.h | 30 ++ .../Drive/v1_2_4/EfiDriveV1_2_4.h | 30 ++ .../Drive/v1_2_5/EfiDriveV1_2_5.h | 30 ++ .../Drive/v1_2_6/EfiDriveV1_2_6.h | 30 ++ .../Drive/v1_2_7/EfiDriveV1_2_7.h | 30 ++ .../Drive/v1_2_8/EfiDriveV1_2_8.h | 30 ++ .../Drive/v1_3_0/EfiDriveV1_3_0.h | 30 ++ .../Drive/v1_3_1/EfiDriveV1_3_1.h | 30 ++ .../Drive/v1_3_2/EfiDriveV1_3_2.h | 30 ++ .../Drive/v1_3_3/EfiDriveV1_3_3.h | 30 ++ .../Drive/v1_3_4/EfiDriveV1_3_4.h | 30 ++ .../Drive/v1_3_5/EfiDriveV1_3_5.h | 30 ++ .../Drive/v1_3_6/EfiDriveV1_3_6.h | 30 ++ .../Drive/v1_3_7/EfiDriveV1_3_7.h | 30 ++ .../Drive/v1_4_0/EfiDriveV1_4_0.h | 30 ++ .../Drive/v1_4_1/EfiDriveV1_4_1.h | 30 ++ .../Drive/v1_4_2/EfiDriveV1_4_2.h | 30 ++ .../Drive/v1_4_3/EfiDriveV1_4_3.h | 30 ++ .../Drive/v1_4_4/EfiDriveV1_4_4.h | 30 ++ .../Drive/v1_4_5/EfiDriveV1_4_5.h | 30 ++ .../Drive/v1_4_6/EfiDriveV1_4_6.h | 30 ++ .../Drive/v1_4_7/EfiDriveV1_4_7.h | 30 ++ .../Drive/v1_5_0/EfiDriveV1_5_0.h | 30 ++ .../Drive/v1_5_1/EfiDriveV1_5_1.h | 30 ++ .../Drive/v1_5_2/EfiDriveV1_5_2.h | 30 ++ .../Drive/v1_5_3/EfiDriveV1_5_3.h | 30 ++ .../Drive/v1_5_4/EfiDriveV1_5_4.h | 30 ++ .../Drive/v1_5_5/EfiDriveV1_5_5.h | 30 ++ .../Drive/v1_5_6/EfiDriveV1_5_6.h | 30 ++ .../Drive/v1_6_0/EfiDriveV1_6_0.h | 30 ++ .../Drive/v1_6_1/EfiDriveV1_6_1.h | 30 ++ .../Drive/v1_6_2/EfiDriveV1_6_2.h | 30 ++ .../Drive/v1_6_3/EfiDriveV1_6_3.h | 30 ++ .../Drive/v1_6_4/EfiDriveV1_6_4.h | 30 ++ .../Drive/v1_7_0/EfiDriveV1_7_0.h | 30 ++ .../Drive/v1_7_1/EfiDriveV1_7_1.h | 30 ++ .../Drive/v1_7_2/EfiDriveV1_7_2.h | 30 ++ .../Drive/v1_7_3/EfiDriveV1_7_3.h | 30 ++ .../Drive/v1_8_0/EfiDriveV1_8_0.h | 30 ++ .../Drive/v1_8_1/EfiDriveV1_8_1.h | 30 ++ .../Drive/v1_8_2/EfiDriveV1_8_2.h | 30 ++ .../Drive/v1_8_3/EfiDriveV1_8_3.h | 30 ++ .../Drive/v1_9_0/EfiDriveV1_9_0.h | 30 ++ .../Drive/v1_9_1/EfiDriveV1_9_1.h | 30 ++ .../Drive/v1_9_2/EfiDriveV1_9_2.h | 30 ++ .../Drive/v1_9_3/EfiDriveV1_9_3.h | 30 ++ .../DriveCollection/EfiDriveCollection.h | 30 ++ .../Endpoint/v1_0_0/EfiEndpointV1_0_0.h | 30 ++ .../Endpoint/v1_0_1/EfiEndpointV1_0_1.h | 30 ++ .../Endpoint/v1_0_10/EfiEndpointV1_0_10.h | 30 ++ .../Endpoint/v1_0_2/EfiEndpointV1_0_2.h | 30 ++ .../Endpoint/v1_0_3/EfiEndpointV1_0_3.h | 30 ++ .../Endpoint/v1_0_4/EfiEndpointV1_0_4.h | 30 ++ .../Endpoint/v1_0_5/EfiEndpointV1_0_5.h | 30 ++ .../Endpoint/v1_0_6/EfiEndpointV1_0_6.h | 30 ++ .../Endpoint/v1_0_7/EfiEndpointV1_0_7.h | 30 ++ .../Endpoint/v1_0_8/EfiEndpointV1_0_8.h | 30 ++ .../Endpoint/v1_0_9/EfiEndpointV1_0_9.h | 30 ++ .../Endpoint/v1_1_0/EfiEndpointV1_1_0.h | 30 ++ .../Endpoint/v1_1_1/EfiEndpointV1_1_1.h | 30 ++ .../Endpoint/v1_1_2/EfiEndpointV1_1_2.h | 30 ++ .../Endpoint/v1_1_3/EfiEndpointV1_1_3.h | 30 ++ .../Endpoint/v1_1_4/EfiEndpointV1_1_4.h | 30 ++ .../Endpoint/v1_1_5/EfiEndpointV1_1_5.h | 30 ++ .../Endpoint/v1_1_6/EfiEndpointV1_1_6.h | 30 ++ .../Endpoint/v1_1_7/EfiEndpointV1_1_7.h | 30 ++ .../Endpoint/v1_2_0/EfiEndpointV1_2_0.h | 30 ++ .../Endpoint/v1_2_1/EfiEndpointV1_2_1.h | 30 ++ .../Endpoint/v1_2_2/EfiEndpointV1_2_2.h | 30 ++ .../Endpoint/v1_2_3/EfiEndpointV1_2_3.h | 30 ++ .../Endpoint/v1_2_4/EfiEndpointV1_2_4.h | 30 ++ .../Endpoint/v1_2_5/EfiEndpointV1_2_5.h | 30 ++ .../Endpoint/v1_2_6/EfiEndpointV1_2_6.h | 30 ++ .../Endpoint/v1_3_0/EfiEndpointV1_3_0.h | 30 ++ .../Endpoint/v1_3_1/EfiEndpointV1_3_1.h | 30 ++ .../Endpoint/v1_3_2/EfiEndpointV1_3_2.h | 30 ++ .../Endpoint/v1_3_3/EfiEndpointV1_3_3.h | 30 ++ .../Endpoint/v1_3_4/EfiEndpointV1_3_4.h | 30 ++ .../Endpoint/v1_3_5/EfiEndpointV1_3_5.h | 30 ++ .../Endpoint/v1_4_0/EfiEndpointV1_4_0.h | 30 ++ .../Endpoint/v1_4_1/EfiEndpointV1_4_1.h | 30 ++ .../Endpoint/v1_4_2/EfiEndpointV1_4_2.h | 30 ++ .../Endpoint/v1_4_3/EfiEndpointV1_4_3.h | 30 ++ .../Endpoint/v1_5_0/EfiEndpointV1_5_0.h | 30 ++ .../Endpoint/v1_5_1/EfiEndpointV1_5_1.h | 30 ++ .../EfiEndpointCollection.h | 30 ++ .../v1_0_0/EfiEndpointGroupV1_0_0.h | 30 ++ .../v1_0_1/EfiEndpointGroupV1_0_1.h | 30 ++ .../v1_0_2/EfiEndpointGroupV1_0_2.h | 30 ++ .../v1_0_3/EfiEndpointGroupV1_0_3.h | 30 ++ .../v1_0_4/EfiEndpointGroupV1_0_4.h | 30 ++ .../v1_1_0/EfiEndpointGroupV1_1_0.h | 30 ++ .../v1_1_1/EfiEndpointGroupV1_1_1.h | 30 ++ .../v1_1_2/EfiEndpointGroupV1_1_2.h | 30 ++ .../v1_1_3/EfiEndpointGroupV1_1_3.h | 30 ++ .../v1_1_4/EfiEndpointGroupV1_1_4.h | 30 ++ .../v1_1_5/EfiEndpointGroupV1_1_5.h | 30 ++ .../v1_2_0/EfiEndpointGroupV1_2_0.h | 30 ++ .../v1_2_1/EfiEndpointGroupV1_2_1.h | 30 ++ .../v1_2_2/EfiEndpointGroupV1_2_2.h | 30 ++ .../v1_2_3/EfiEndpointGroupV1_2_3.h | 30 ++ .../v1_3_0/EfiEndpointGroupV1_3_0.h | 30 ++ .../v1_3_1/EfiEndpointGroupV1_3_1.h | 30 ++ .../EfiEndpointGroupCollection.h | 30 ++ .../v1_0_0/EfiEnvironmentMetricsV1_0_0.h | 30 ++ .../v1_0_0/EfiEthernetInterfaceV1_0_0.h | 30 ++ .../v1_0_10/EfiEthernetInterfaceV1_0_10.h | 30 ++ .../v1_0_11/EfiEthernetInterfaceV1_0_11.h | 30 ++ .../v1_0_12/EfiEthernetInterfaceV1_0_12.h | 30 ++ .../v1_0_2/EfiEthernetInterfaceV1_0_2.h | 30 ++ .../v1_0_3/EfiEthernetInterfaceV1_0_3.h | 30 ++ .../v1_0_4/EfiEthernetInterfaceV1_0_4.h | 30 ++ .../v1_0_5/EfiEthernetInterfaceV1_0_5.h | 30 ++ .../v1_0_6/EfiEthernetInterfaceV1_0_6.h | 30 ++ .../v1_0_7/EfiEthernetInterfaceV1_0_7.h | 30 ++ .../v1_0_8/EfiEthernetInterfaceV1_0_8.h | 30 ++ .../v1_0_9/EfiEthernetInterfaceV1_0_9.h | 30 ++ .../v1_1_0/EfiEthernetInterfaceV1_1_0.h | 30 ++ .../v1_1_1/EfiEthernetInterfaceV1_1_1.h | 30 ++ .../v1_1_10/EfiEthernetInterfaceV1_1_10.h | 30 ++ .../v1_1_2/EfiEthernetInterfaceV1_1_2.h | 30 ++ .../v1_1_3/EfiEthernetInterfaceV1_1_3.h | 30 ++ .../v1_1_4/EfiEthernetInterfaceV1_1_4.h | 30 ++ .../v1_1_5/EfiEthernetInterfaceV1_1_5.h | 30 ++ .../v1_1_6/EfiEthernetInterfaceV1_1_6.h | 30 ++ .../v1_1_7/EfiEthernetInterfaceV1_1_7.h | 30 ++ .../v1_1_8/EfiEthernetInterfaceV1_1_8.h | 30 ++ .../v1_1_9/EfiEthernetInterfaceV1_1_9.h | 30 ++ .../v1_2_0/EfiEthernetInterfaceV1_2_0.h | 30 ++ .../v1_2_1/EfiEthernetInterfaceV1_2_1.h | 30 ++ .../v1_2_2/EfiEthernetInterfaceV1_2_2.h | 30 ++ .../v1_2_3/EfiEthernetInterfaceV1_2_3.h | 30 ++ .../v1_2_4/EfiEthernetInterfaceV1_2_4.h | 30 ++ .../v1_2_5/EfiEthernetInterfaceV1_2_5.h | 30 ++ .../v1_2_6/EfiEthernetInterfaceV1_2_6.h | 30 ++ .../v1_2_7/EfiEthernetInterfaceV1_2_7.h | 30 ++ .../v1_2_8/EfiEthernetInterfaceV1_2_8.h | 30 ++ .../v1_2_9/EfiEthernetInterfaceV1_2_9.h | 30 ++ .../v1_3_0/EfiEthernetInterfaceV1_3_0.h | 30 ++ .../v1_3_1/EfiEthernetInterfaceV1_3_1.h | 30 ++ .../v1_3_2/EfiEthernetInterfaceV1_3_2.h | 30 ++ .../v1_3_3/EfiEthernetInterfaceV1_3_3.h | 30 ++ .../v1_3_4/EfiEthernetInterfaceV1_3_4.h | 30 ++ .../v1_3_5/EfiEthernetInterfaceV1_3_5.h | 30 ++ .../v1_3_6/EfiEthernetInterfaceV1_3_6.h | 30 ++ .../v1_3_7/EfiEthernetInterfaceV1_3_7.h | 30 ++ .../v1_3_8/EfiEthernetInterfaceV1_3_8.h | 30 ++ .../v1_4_0/EfiEthernetInterfaceV1_4_0.h | 30 ++ .../v1_4_1/EfiEthernetInterfaceV1_4_1.h | 30 ++ .../v1_4_2/EfiEthernetInterfaceV1_4_2.h | 30 ++ .../v1_4_3/EfiEthernetInterfaceV1_4_3.h | 30 ++ .../v1_4_4/EfiEthernetInterfaceV1_4_4.h | 30 ++ .../v1_4_5/EfiEthernetInterfaceV1_4_5.h | 30 ++ .../v1_4_6/EfiEthernetInterfaceV1_4_6.h | 30 ++ .../v1_4_7/EfiEthernetInterfaceV1_4_7.h | 30 ++ .../v1_5_0/EfiEthernetInterfaceV1_5_0.h | 30 ++ .../v1_5_1/EfiEthernetInterfaceV1_5_1.h | 30 ++ .../v1_5_2/EfiEthernetInterfaceV1_5_2.h | 30 ++ .../v1_5_3/EfiEthernetInterfaceV1_5_3.h | 30 ++ .../v1_5_4/EfiEthernetInterfaceV1_5_4.h | 30 ++ .../v1_5_5/EfiEthernetInterfaceV1_5_5.h | 30 ++ .../v1_6_0/EfiEthernetInterfaceV1_6_0.h | 30 ++ .../v1_6_1/EfiEthernetInterfaceV1_6_1.h | 30 ++ .../v1_6_2/EfiEthernetInterfaceV1_6_2.h | 30 ++ .../v1_6_3/EfiEthernetInterfaceV1_6_3.h | 30 ++ .../EfiEthernetInterfaceCollection.h | 30 ++ .../Event/v1_0_0/EfiEventV1_0_0.h | 30 ++ .../Event/v1_0_10/EfiEventV1_0_10.h | 30 ++ .../Event/v1_0_11/EfiEventV1_0_11.h | 30 ++ .../Event/v1_0_12/EfiEventV1_0_12.h | 30 ++ .../Event/v1_0_13/EfiEventV1_0_13.h | 30 ++ .../Event/v1_0_2/EfiEventV1_0_2.h | 30 ++ .../Event/v1_0_3/EfiEventV1_0_3.h | 30 ++ .../Event/v1_0_4/EfiEventV1_0_4.h | 30 ++ .../Event/v1_0_5/EfiEventV1_0_5.h | 30 ++ .../Event/v1_0_6/EfiEventV1_0_6.h | 30 ++ .../Event/v1_0_7/EfiEventV1_0_7.h | 30 ++ .../Event/v1_0_8/EfiEventV1_0_8.h | 30 ++ .../Event/v1_0_9/EfiEventV1_0_9.h | 30 ++ .../Event/v1_1_0/EfiEventV1_1_0.h | 30 ++ .../Event/v1_1_1/EfiEventV1_1_1.h | 30 ++ .../Event/v1_1_10/EfiEventV1_1_10.h | 30 ++ .../Event/v1_1_11/EfiEventV1_1_11.h | 30 ++ .../Event/v1_1_2/EfiEventV1_1_2.h | 30 ++ .../Event/v1_1_3/EfiEventV1_1_3.h | 30 ++ .../Event/v1_1_4/EfiEventV1_1_4.h | 30 ++ .../Event/v1_1_5/EfiEventV1_1_5.h | 30 ++ .../Event/v1_1_6/EfiEventV1_1_6.h | 30 ++ .../Event/v1_1_7/EfiEventV1_1_7.h | 30 ++ .../Event/v1_1_8/EfiEventV1_1_8.h | 30 ++ .../Event/v1_1_9/EfiEventV1_1_9.h | 30 ++ .../Event/v1_2_0/EfiEventV1_2_0.h | 30 ++ .../Event/v1_2_1/EfiEventV1_2_1.h | 30 ++ .../Event/v1_2_2/EfiEventV1_2_2.h | 30 ++ .../Event/v1_2_3/EfiEventV1_2_3.h | 30 ++ .../Event/v1_2_4/EfiEventV1_2_4.h | 30 ++ .../Event/v1_2_5/EfiEventV1_2_5.h | 30 ++ .../Event/v1_2_6/EfiEventV1_2_6.h | 30 ++ .../Event/v1_2_7/EfiEventV1_2_7.h | 30 ++ .../Event/v1_2_8/EfiEventV1_2_8.h | 30 ++ .../Event/v1_3_0/EfiEventV1_3_0.h | 30 ++ .../Event/v1_3_1/EfiEventV1_3_1.h | 30 ++ .../Event/v1_3_2/EfiEventV1_3_2.h | 30 ++ .../Event/v1_3_3/EfiEventV1_3_3.h | 30 ++ .../Event/v1_3_4/EfiEventV1_3_4.h | 30 ++ .../Event/v1_3_5/EfiEventV1_3_5.h | 30 ++ .../Event/v1_3_6/EfiEventV1_3_6.h | 30 ++ .../Event/v1_4_0/EfiEventV1_4_0.h | 30 ++ .../Event/v1_4_1/EfiEventV1_4_1.h | 30 ++ .../Event/v1_4_2/EfiEventV1_4_2.h | 30 ++ .../Event/v1_4_3/EfiEventV1_4_3.h | 30 ++ .../Event/v1_4_4/EfiEventV1_4_4.h | 30 ++ .../Event/v1_5_0/EfiEventV1_5_0.h | 30 ++ .../Event/v1_5_1/EfiEventV1_5_1.h | 30 ++ .../Event/v1_5_2/EfiEventV1_5_2.h | 30 ++ .../Event/v1_6_0/EfiEventV1_6_0.h | 30 ++ .../Event/v1_6_1/EfiEventV1_6_1.h | 30 ++ .../v1_0_0/EfiEventDestinationV1_0_0.h | 30 ++ .../v1_0_2/EfiEventDestinationV1_0_2.h | 30 ++ .../v1_0_3/EfiEventDestinationV1_0_3.h | 30 ++ .../v1_0_4/EfiEventDestinationV1_0_4.h | 30 ++ .../v1_0_5/EfiEventDestinationV1_0_5.h | 30 ++ .../v1_0_6/EfiEventDestinationV1_0_6.h | 30 ++ .../v1_0_7/EfiEventDestinationV1_0_7.h | 30 ++ .../v1_0_8/EfiEventDestinationV1_0_8.h | 30 ++ .../v1_0_9/EfiEventDestinationV1_0_9.h | 30 ++ .../v1_10_0/EfiEventDestinationV1_10_0.h | 30 ++ .../v1_1_0/EfiEventDestinationV1_1_0.h | 30 ++ .../v1_1_1/EfiEventDestinationV1_1_1.h | 30 ++ .../v1_1_2/EfiEventDestinationV1_1_2.h | 30 ++ .../v1_1_3/EfiEventDestinationV1_1_3.h | 30 ++ .../v1_1_4/EfiEventDestinationV1_1_4.h | 30 ++ .../v1_1_5/EfiEventDestinationV1_1_5.h | 30 ++ .../v1_1_6/EfiEventDestinationV1_1_6.h | 30 ++ .../v1_1_7/EfiEventDestinationV1_1_7.h | 30 ++ .../v1_1_8/EfiEventDestinationV1_1_8.h | 30 ++ .../v1_2_0/EfiEventDestinationV1_2_0.h | 30 ++ .../v1_2_1/EfiEventDestinationV1_2_1.h | 30 ++ .../v1_2_2/EfiEventDestinationV1_2_2.h | 30 ++ .../v1_2_3/EfiEventDestinationV1_2_3.h | 30 ++ .../v1_2_4/EfiEventDestinationV1_2_4.h | 30 ++ .../v1_2_5/EfiEventDestinationV1_2_5.h | 30 ++ .../v1_2_6/EfiEventDestinationV1_2_6.h | 30 ++ .../v1_3_0/EfiEventDestinationV1_3_0.h | 30 ++ .../v1_3_1/EfiEventDestinationV1_3_1.h | 30 ++ .../v1_3_2/EfiEventDestinationV1_3_2.h | 30 ++ .../v1_3_3/EfiEventDestinationV1_3_3.h | 30 ++ .../v1_3_4/EfiEventDestinationV1_3_4.h | 30 ++ .../v1_4_0/EfiEventDestinationV1_4_0.h | 30 ++ .../v1_4_1/EfiEventDestinationV1_4_1.h | 30 ++ .../v1_4_2/EfiEventDestinationV1_4_2.h | 30 ++ .../v1_4_3/EfiEventDestinationV1_4_3.h | 30 ++ .../v1_5_0/EfiEventDestinationV1_5_0.h | 30 ++ .../v1_5_1/EfiEventDestinationV1_5_1.h | 30 ++ .../v1_5_2/EfiEventDestinationV1_5_2.h | 30 ++ .../v1_6_0/EfiEventDestinationV1_6_0.h | 30 ++ .../v1_6_1/EfiEventDestinationV1_6_1.h | 30 ++ .../v1_6_2/EfiEventDestinationV1_6_2.h | 30 ++ .../v1_7_0/EfiEventDestinationV1_7_0.h | 30 ++ .../v1_7_1/EfiEventDestinationV1_7_1.h | 30 ++ .../v1_7_2/EfiEventDestinationV1_7_2.h | 30 ++ .../v1_8_0/EfiEventDestinationV1_8_0.h | 30 ++ .../v1_8_1/EfiEventDestinationV1_8_1.h | 30 ++ .../v1_8_2/EfiEventDestinationV1_8_2.h | 30 ++ .../v1_9_0/EfiEventDestinationV1_9_0.h | 30 ++ .../v1_9_1/EfiEventDestinationV1_9_1.h | 30 ++ .../EfiEventDestinationCollection.h | 30 ++ .../v1_0_0/EfiEventServiceV1_0_0.h | 30 ++ .../v1_0_10/EfiEventServiceV1_0_10.h | 30 ++ .../v1_0_11/EfiEventServiceV1_0_11.h | 30 ++ .../v1_0_12/EfiEventServiceV1_0_12.h | 30 ++ .../v1_0_13/EfiEventServiceV1_0_13.h | 30 ++ .../v1_0_2/EfiEventServiceV1_0_2.h | 30 ++ .../v1_0_3/EfiEventServiceV1_0_3.h | 30 ++ .../v1_0_4/EfiEventServiceV1_0_4.h | 30 ++ .../v1_0_5/EfiEventServiceV1_0_5.h | 30 ++ .../v1_0_6/EfiEventServiceV1_0_6.h | 30 ++ .../v1_0_7/EfiEventServiceV1_0_7.h | 30 ++ .../v1_0_8/EfiEventServiceV1_0_8.h | 30 ++ .../v1_0_9/EfiEventServiceV1_0_9.h | 30 ++ .../v1_1_0/EfiEventServiceV1_1_0.h | 30 ++ .../v1_1_1/EfiEventServiceV1_1_1.h | 30 ++ .../v1_1_2/EfiEventServiceV1_1_2.h | 30 ++ .../v1_1_3/EfiEventServiceV1_1_3.h | 30 ++ .../v1_1_4/EfiEventServiceV1_1_4.h | 30 ++ .../v1_1_5/EfiEventServiceV1_1_5.h | 30 ++ .../v1_1_6/EfiEventServiceV1_1_6.h | 30 ++ .../v1_2_0/EfiEventServiceV1_2_0.h | 30 ++ .../v1_2_1/EfiEventServiceV1_2_1.h | 30 ++ .../v1_2_2/EfiEventServiceV1_2_2.h | 30 ++ .../v1_2_3/EfiEventServiceV1_2_3.h | 30 ++ .../v1_2_4/EfiEventServiceV1_2_4.h | 30 ++ .../v1_2_5/EfiEventServiceV1_2_5.h | 30 ++ .../v1_3_0/EfiEventServiceV1_3_0.h | 30 ++ .../v1_3_1/EfiEventServiceV1_3_1.h | 30 ++ .../v1_3_2/EfiEventServiceV1_3_2.h | 30 ++ .../v1_3_3/EfiEventServiceV1_3_3.h | 30 ++ .../v1_3_4/EfiEventServiceV1_3_4.h | 30 ++ .../v1_4_0/EfiEventServiceV1_4_0.h | 30 ++ .../v1_4_1/EfiEventServiceV1_4_1.h | 30 ++ .../v1_4_2/EfiEventServiceV1_4_2.h | 30 ++ .../v1_4_3/EfiEventServiceV1_4_3.h | 30 ++ .../v1_5_0/EfiEventServiceV1_5_0.h | 30 ++ .../v1_5_1/EfiEventServiceV1_5_1.h | 30 ++ .../v1_5_2/EfiEventServiceV1_5_2.h | 30 ++ .../v1_5_3/EfiEventServiceV1_5_3.h | 30 ++ .../v1_6_0/EfiEventServiceV1_6_0.h | 30 ++ .../v1_6_1/EfiEventServiceV1_6_1.h | 30 ++ .../v1_6_2/EfiEventServiceV1_6_2.h | 30 ++ .../v1_7_0/EfiEventServiceV1_7_0.h | 30 ++ .../v1_7_1/EfiEventServiceV1_7_1.h | 30 ++ .../v1_0_0/EfiExternalAccountProviderV1_0_0.h | 30 ++ .../v1_0_1/EfiExternalAccountProviderV1_0_1.h | 30 ++ .../v1_0_2/EfiExternalAccountProviderV1_0_2.h | 30 ++ .../v1_0_3/EfiExternalAccountProviderV1_0_3.h | 30 ++ .../v1_0_4/EfiExternalAccountProviderV1_0_4.h | 30 ++ .../v1_0_5/EfiExternalAccountProviderV1_0_5.h | 30 ++ .../v1_1_0/EfiExternalAccountProviderV1_1_0.h | 30 ++ .../v1_1_1/EfiExternalAccountProviderV1_1_1.h | 30 ++ .../v1_1_2/EfiExternalAccountProviderV1_1_2.h | 30 ++ .../v1_1_3/EfiExternalAccountProviderV1_1_3.h | 30 ++ .../v1_1_4/EfiExternalAccountProviderV1_1_4.h | 30 ++ .../v1_2_0/EfiExternalAccountProviderV1_2_0.h | 30 ++ .../EfiExternalAccountProviderCollection.h | 30 ++ .../Fabric/v1_0_0/EfiFabricV1_0_0.h | 30 ++ .../Fabric/v1_0_1/EfiFabricV1_0_1.h | 30 ++ .../Fabric/v1_0_2/EfiFabricV1_0_2.h | 30 ++ .../Fabric/v1_0_3/EfiFabricV1_0_3.h | 30 ++ .../Fabric/v1_0_4/EfiFabricV1_0_4.h | 30 ++ .../Fabric/v1_0_5/EfiFabricV1_0_5.h | 30 ++ .../Fabric/v1_0_6/EfiFabricV1_0_6.h | 30 ++ .../Fabric/v1_0_7/EfiFabricV1_0_7.h | 30 ++ .../Fabric/v1_0_8/EfiFabricV1_0_8.h | 30 ++ .../Fabric/v1_1_0/EfiFabricV1_1_0.h | 30 ++ .../Fabric/v1_1_1/EfiFabricV1_1_1.h | 30 ++ .../Fabric/v1_1_2/EfiFabricV1_1_2.h | 30 ++ .../Fabric/v1_2_0/EfiFabricV1_2_0.h | 30 ++ .../Fabric/v1_2_1/EfiFabricV1_2_1.h | 30 ++ .../v1_0_0/EfiFabricAdapterV1_0_0.h | 30 ++ .../EfiFabricAdapterCollection.h | 30 ++ .../FabricCollection/EfiFabricCollection.h | 30 ++ .../Facility/v1_0_0/EfiFacilityV1_0_0.h | 30 ++ .../Facility/v1_0_1/EfiFacilityV1_0_1.h | 30 ++ .../Facility/v1_1_0/EfiFacilityV1_1_0.h | 30 ++ .../EfiFacilityCollection.h | 30 ++ .../Fan/v1_0_0/EfiFanV1_0_0.h | 30 ++ .../FanCollection/EfiFanCollection.h | 30 ++ .../v1_0_0/EfiHostInterfaceV1_0_0.h | 30 ++ .../v1_0_1/EfiHostInterfaceV1_0_1.h | 30 ++ .../v1_0_2/EfiHostInterfaceV1_0_2.h | 30 ++ .../v1_0_3/EfiHostInterfaceV1_0_3.h | 30 ++ .../v1_0_4/EfiHostInterfaceV1_0_4.h | 30 ++ .../v1_0_5/EfiHostInterfaceV1_0_5.h | 30 ++ .../v1_1_0/EfiHostInterfaceV1_1_0.h | 30 ++ .../v1_1_1/EfiHostInterfaceV1_1_1.h | 30 ++ .../v1_1_2/EfiHostInterfaceV1_1_2.h | 30 ++ .../v1_1_3/EfiHostInterfaceV1_1_3.h | 30 ++ .../v1_1_4/EfiHostInterfaceV1_1_4.h | 30 ++ .../v1_1_5/EfiHostInterfaceV1_1_5.h | 30 ++ .../v1_2_0/EfiHostInterfaceV1_2_0.h | 30 ++ .../v1_2_1/EfiHostInterfaceV1_2_1.h | 30 ++ .../v1_2_2/EfiHostInterfaceV1_2_2.h | 30 ++ .../v1_3_0/EfiHostInterfaceV1_3_0.h | 30 ++ .../EfiHostInterfaceCollection.h | 30 ++ .../Job/v1_0_0/EfiJobV1_0_0.h | 30 ++ .../Job/v1_0_1/EfiJobV1_0_1.h | 30 ++ .../Job/v1_0_2/EfiJobV1_0_2.h | 30 ++ .../Job/v1_0_3/EfiJobV1_0_3.h | 30 ++ .../Job/v1_0_4/EfiJobV1_0_4.h | 30 ++ .../Job/v1_0_5/EfiJobV1_0_5.h | 30 ++ .../Job/v1_0_6/EfiJobV1_0_6.h | 30 ++ .../JobCollection/EfiJobCollection.h | 30 ++ .../JobService/v1_0_0/EfiJobServiceV1_0_0.h | 30 ++ .../JobService/v1_0_1/EfiJobServiceV1_0_1.h | 30 ++ .../JobService/v1_0_2/EfiJobServiceV1_0_2.h | 30 ++ .../JobService/v1_0_3/EfiJobServiceV1_0_3.h | 30 ++ .../JobService/v1_0_4/EfiJobServiceV1_0_4.h | 30 ++ .../v1_0_0/EfiJsonSchemaFileV1_0_0.h | 30 ++ .../v1_0_2/EfiJsonSchemaFileV1_0_2.h | 30 ++ .../v1_0_3/EfiJsonSchemaFileV1_0_3.h | 30 ++ .../v1_0_4/EfiJsonSchemaFileV1_0_4.h | 30 ++ .../v1_0_5/EfiJsonSchemaFileV1_0_5.h | 30 ++ .../v1_0_6/EfiJsonSchemaFileV1_0_6.h | 30 ++ .../v1_0_7/EfiJsonSchemaFileV1_0_7.h | 30 ++ .../v1_0_8/EfiJsonSchemaFileV1_0_8.h | 30 ++ .../v1_1_0/EfiJsonSchemaFileV1_1_0.h | 30 ++ .../v1_1_1/EfiJsonSchemaFileV1_1_1.h | 30 ++ .../v1_1_2/EfiJsonSchemaFileV1_1_2.h | 30 ++ .../v1_1_3/EfiJsonSchemaFileV1_1_3.h | 30 ++ .../v1_1_4/EfiJsonSchemaFileV1_1_4.h | 30 ++ .../EfiJsonSchemaFileCollection.h | 30 ++ .../LogEntry/v1_0_0/EfiLogEntryV1_0_0.h | 30 ++ .../LogEntry/v1_0_10/EfiLogEntryV1_0_10.h | 30 ++ .../LogEntry/v1_0_11/EfiLogEntryV1_0_11.h | 30 ++ .../LogEntry/v1_0_12/EfiLogEntryV1_0_12.h | 30 ++ .../LogEntry/v1_0_13/EfiLogEntryV1_0_13.h | 30 ++ .../LogEntry/v1_0_14/EfiLogEntryV1_0_14.h | 30 ++ .../LogEntry/v1_0_2/EfiLogEntryV1_0_2.h | 30 ++ .../LogEntry/v1_0_3/EfiLogEntryV1_0_3.h | 30 ++ .../LogEntry/v1_0_4/EfiLogEntryV1_0_4.h | 30 ++ .../LogEntry/v1_0_5/EfiLogEntryV1_0_5.h | 30 ++ .../LogEntry/v1_0_6/EfiLogEntryV1_0_6.h | 30 ++ .../LogEntry/v1_0_7/EfiLogEntryV1_0_7.h | 30 ++ .../LogEntry/v1_0_8/EfiLogEntryV1_0_8.h | 30 ++ .../LogEntry/v1_0_9/EfiLogEntryV1_0_9.h | 30 ++ .../LogEntry/v1_1_0/EfiLogEntryV1_1_0.h | 30 ++ .../LogEntry/v1_1_1/EfiLogEntryV1_1_1.h | 30 ++ .../LogEntry/v1_1_10/EfiLogEntryV1_1_10.h | 30 ++ .../LogEntry/v1_1_11/EfiLogEntryV1_1_11.h | 30 ++ .../LogEntry/v1_1_12/EfiLogEntryV1_1_12.h | 30 ++ .../LogEntry/v1_1_2/EfiLogEntryV1_1_2.h | 30 ++ .../LogEntry/v1_1_3/EfiLogEntryV1_1_3.h | 30 ++ .../LogEntry/v1_1_4/EfiLogEntryV1_1_4.h | 30 ++ .../LogEntry/v1_1_5/EfiLogEntryV1_1_5.h | 30 ++ .../LogEntry/v1_1_6/EfiLogEntryV1_1_6.h | 30 ++ .../LogEntry/v1_1_7/EfiLogEntryV1_1_7.h | 30 ++ .../LogEntry/v1_1_8/EfiLogEntryV1_1_8.h | 30 ++ .../LogEntry/v1_1_9/EfiLogEntryV1_1_9.h | 30 ++ .../LogEntry/v1_2_0/EfiLogEntryV1_2_0.h | 30 ++ .../LogEntry/v1_2_1/EfiLogEntryV1_2_1.h | 30 ++ .../LogEntry/v1_2_10/EfiLogEntryV1_2_10.h | 30 ++ .../LogEntry/v1_2_2/EfiLogEntryV1_2_2.h | 30 ++ .../LogEntry/v1_2_3/EfiLogEntryV1_2_3.h | 30 ++ .../LogEntry/v1_2_4/EfiLogEntryV1_2_4.h | 30 ++ .../LogEntry/v1_2_5/EfiLogEntryV1_2_5.h | 30 ++ .../LogEntry/v1_2_6/EfiLogEntryV1_2_6.h | 30 ++ .../LogEntry/v1_2_7/EfiLogEntryV1_2_7.h | 30 ++ .../LogEntry/v1_2_8/EfiLogEntryV1_2_8.h | 30 ++ .../LogEntry/v1_2_9/EfiLogEntryV1_2_9.h | 30 ++ .../LogEntry/v1_3_0/EfiLogEntryV1_3_0.h | 30 ++ .../LogEntry/v1_3_1/EfiLogEntryV1_3_1.h | 30 ++ .../LogEntry/v1_3_2/EfiLogEntryV1_3_2.h | 30 ++ .../LogEntry/v1_3_3/EfiLogEntryV1_3_3.h | 30 ++ .../LogEntry/v1_3_4/EfiLogEntryV1_3_4.h | 30 ++ .../LogEntry/v1_3_5/EfiLogEntryV1_3_5.h | 30 ++ .../LogEntry/v1_3_6/EfiLogEntryV1_3_6.h | 30 ++ .../LogEntry/v1_3_7/EfiLogEntryV1_3_7.h | 30 ++ .../LogEntry/v1_3_8/EfiLogEntryV1_3_8.h | 30 ++ .../LogEntry/v1_3_9/EfiLogEntryV1_3_9.h | 30 ++ .../LogEntry/v1_4_0/EfiLogEntryV1_4_0.h | 30 ++ .../LogEntry/v1_4_1/EfiLogEntryV1_4_1.h | 30 ++ .../LogEntry/v1_4_2/EfiLogEntryV1_4_2.h | 30 ++ .../LogEntry/v1_4_3/EfiLogEntryV1_4_3.h | 30 ++ .../LogEntry/v1_4_4/EfiLogEntryV1_4_4.h | 30 ++ .../LogEntry/v1_4_5/EfiLogEntryV1_4_5.h | 30 ++ .../LogEntry/v1_4_6/EfiLogEntryV1_4_6.h | 30 ++ .../LogEntry/v1_4_7/EfiLogEntryV1_4_7.h | 30 ++ .../LogEntry/v1_4_8/EfiLogEntryV1_4_8.h | 30 ++ .../LogEntry/v1_5_0/EfiLogEntryV1_5_0.h | 30 ++ .../LogEntry/v1_5_1/EfiLogEntryV1_5_1.h | 30 ++ .../LogEntry/v1_5_2/EfiLogEntryV1_5_2.h | 30 ++ .../LogEntry/v1_5_3/EfiLogEntryV1_5_3.h | 30 ++ .../LogEntry/v1_5_4/EfiLogEntryV1_5_4.h | 30 ++ .../LogEntry/v1_6_0/EfiLogEntryV1_6_0.h | 30 ++ .../LogEntry/v1_6_1/EfiLogEntryV1_6_1.h | 30 ++ .../LogEntry/v1_6_2/EfiLogEntryV1_6_2.h | 30 ++ .../LogEntry/v1_6_3/EfiLogEntryV1_6_3.h | 30 ++ .../LogEntry/v1_7_0/EfiLogEntryV1_7_0.h | 30 ++ .../LogEntry/v1_7_1/EfiLogEntryV1_7_1.h | 30 ++ .../LogEntry/v1_8_0/EfiLogEntryV1_8_0.h | 30 ++ .../EfiLogEntryCollection.h | 30 ++ .../LogService/v1_0_0/EfiLogServiceV1_0_0.h | 30 ++ .../LogService/v1_0_2/EfiLogServiceV1_0_2.h | 30 ++ .../LogService/v1_0_3/EfiLogServiceV1_0_3.h | 30 ++ .../LogService/v1_0_4/EfiLogServiceV1_0_4.h | 30 ++ .../LogService/v1_0_5/EfiLogServiceV1_0_5.h | 30 ++ .../LogService/v1_0_6/EfiLogServiceV1_0_6.h | 30 ++ .../LogService/v1_0_7/EfiLogServiceV1_0_7.h | 30 ++ .../LogService/v1_0_8/EfiLogServiceV1_0_8.h | 30 ++ .../LogService/v1_1_0/EfiLogServiceV1_1_0.h | 30 ++ .../LogService/v1_1_1/EfiLogServiceV1_1_1.h | 30 ++ .../LogService/v1_1_2/EfiLogServiceV1_1_2.h | 30 ++ .../LogService/v1_1_3/EfiLogServiceV1_1_3.h | 30 ++ .../LogService/v1_2_0/EfiLogServiceV1_2_0.h | 30 ++ .../EfiLogServiceCollection.h | 30 ++ .../Manager/v1_0_0/EfiManagerV1_0_0.h | 30 ++ .../Manager/v1_0_1/EfiManagerV1_0_1.h | 30 ++ .../Manager/v1_0_10/EfiManagerV1_0_10.h | 30 ++ .../Manager/v1_0_11/EfiManagerV1_0_11.h | 30 ++ .../Manager/v1_0_12/EfiManagerV1_0_12.h | 30 ++ .../Manager/v1_0_13/EfiManagerV1_0_13.h | 30 ++ .../Manager/v1_0_14/EfiManagerV1_0_14.h | 30 ++ .../Manager/v1_0_2/EfiManagerV1_0_2.h | 30 ++ .../Manager/v1_0_3/EfiManagerV1_0_3.h | 30 ++ .../Manager/v1_0_4/EfiManagerV1_0_4.h | 30 ++ .../Manager/v1_0_5/EfiManagerV1_0_5.h | 30 ++ .../Manager/v1_0_6/EfiManagerV1_0_6.h | 30 ++ .../Manager/v1_0_7/EfiManagerV1_0_7.h | 30 ++ .../Manager/v1_0_8/EfiManagerV1_0_8.h | 30 ++ .../Manager/v1_0_9/EfiManagerV1_0_9.h | 30 ++ .../Manager/v1_10_0/EfiManagerV1_10_0.h | 30 ++ .../Manager/v1_10_1/EfiManagerV1_10_1.h | 30 ++ .../Manager/v1_11_0/EfiManagerV1_11_0.h | 30 ++ .../Manager/v1_1_0/EfiManagerV1_1_0.h | 30 ++ .../Manager/v1_1_1/EfiManagerV1_1_1.h | 30 ++ .../Manager/v1_1_10/EfiManagerV1_1_10.h | 30 ++ .../Manager/v1_1_11/EfiManagerV1_1_11.h | 30 ++ .../Manager/v1_1_12/EfiManagerV1_1_12.h | 30 ++ .../Manager/v1_1_2/EfiManagerV1_1_2.h | 30 ++ .../Manager/v1_1_3/EfiManagerV1_1_3.h | 30 ++ .../Manager/v1_1_4/EfiManagerV1_1_4.h | 30 ++ .../Manager/v1_1_5/EfiManagerV1_1_5.h | 30 ++ .../Manager/v1_1_6/EfiManagerV1_1_6.h | 30 ++ .../Manager/v1_1_7/EfiManagerV1_1_7.h | 30 ++ .../Manager/v1_1_8/EfiManagerV1_1_8.h | 30 ++ .../Manager/v1_1_9/EfiManagerV1_1_9.h | 30 ++ .../Manager/v1_2_0/EfiManagerV1_2_0.h | 30 ++ .../Manager/v1_2_1/EfiManagerV1_2_1.h | 30 ++ .../Manager/v1_2_10/EfiManagerV1_2_10.h | 30 ++ .../Manager/v1_2_11/EfiManagerV1_2_11.h | 30 ++ .../Manager/v1_2_12/EfiManagerV1_2_12.h | 30 ++ .../Manager/v1_2_2/EfiManagerV1_2_2.h | 30 ++ .../Manager/v1_2_3/EfiManagerV1_2_3.h | 30 ++ .../Manager/v1_2_4/EfiManagerV1_2_4.h | 30 ++ .../Manager/v1_2_5/EfiManagerV1_2_5.h | 30 ++ .../Manager/v1_2_6/EfiManagerV1_2_6.h | 30 ++ .../Manager/v1_2_7/EfiManagerV1_2_7.h | 30 ++ .../Manager/v1_2_8/EfiManagerV1_2_8.h | 30 ++ .../Manager/v1_2_9/EfiManagerV1_2_9.h | 30 ++ .../Manager/v1_3_0/EfiManagerV1_3_0.h | 30 ++ .../Manager/v1_3_1/EfiManagerV1_3_1.h | 30 ++ .../Manager/v1_3_10/EfiManagerV1_3_10.h | 30 ++ .../Manager/v1_3_11/EfiManagerV1_3_11.h | 30 ++ .../Manager/v1_3_2/EfiManagerV1_3_2.h | 30 ++ .../Manager/v1_3_3/EfiManagerV1_3_3.h | 30 ++ .../Manager/v1_3_4/EfiManagerV1_3_4.h | 30 ++ .../Manager/v1_3_5/EfiManagerV1_3_5.h | 30 ++ .../Manager/v1_3_6/EfiManagerV1_3_6.h | 30 ++ .../Manager/v1_3_7/EfiManagerV1_3_7.h | 30 ++ .../Manager/v1_3_8/EfiManagerV1_3_8.h | 30 ++ .../Manager/v1_3_9/EfiManagerV1_3_9.h | 30 ++ .../Manager/v1_4_0/EfiManagerV1_4_0.h | 30 ++ .../Manager/v1_4_1/EfiManagerV1_4_1.h | 30 ++ .../Manager/v1_4_2/EfiManagerV1_4_2.h | 30 ++ .../Manager/v1_4_3/EfiManagerV1_4_3.h | 30 ++ .../Manager/v1_4_4/EfiManagerV1_4_4.h | 30 ++ .../Manager/v1_4_5/EfiManagerV1_4_5.h | 30 ++ .../Manager/v1_4_6/EfiManagerV1_4_6.h | 30 ++ .../Manager/v1_4_7/EfiManagerV1_4_7.h | 30 ++ .../Manager/v1_4_8/EfiManagerV1_4_8.h | 30 ++ .../Manager/v1_5_0/EfiManagerV1_5_0.h | 30 ++ .../Manager/v1_5_1/EfiManagerV1_5_1.h | 30 ++ .../Manager/v1_5_2/EfiManagerV1_5_2.h | 30 ++ .../Manager/v1_5_3/EfiManagerV1_5_3.h | 30 ++ .../Manager/v1_5_4/EfiManagerV1_5_4.h | 30 ++ .../Manager/v1_5_5/EfiManagerV1_5_5.h | 30 ++ .../Manager/v1_5_6/EfiManagerV1_5_6.h | 30 ++ .../Manager/v1_5_7/EfiManagerV1_5_7.h | 30 ++ .../Manager/v1_6_0/EfiManagerV1_6_0.h | 30 ++ .../Manager/v1_6_1/EfiManagerV1_6_1.h | 30 ++ .../Manager/v1_6_2/EfiManagerV1_6_2.h | 30 ++ .../Manager/v1_6_3/EfiManagerV1_6_3.h | 30 ++ .../Manager/v1_6_4/EfiManagerV1_6_4.h | 30 ++ .../Manager/v1_7_0/EfiManagerV1_7_0.h | 30 ++ .../Manager/v1_7_1/EfiManagerV1_7_1.h | 30 ++ .../Manager/v1_7_2/EfiManagerV1_7_2.h | 30 ++ .../Manager/v1_7_3/EfiManagerV1_7_3.h | 30 ++ .../Manager/v1_7_4/EfiManagerV1_7_4.h | 30 ++ .../Manager/v1_8_0/EfiManagerV1_8_0.h | 30 ++ .../Manager/v1_8_1/EfiManagerV1_8_1.h | 30 ++ .../Manager/v1_8_2/EfiManagerV1_8_2.h | 30 ++ .../Manager/v1_8_3/EfiManagerV1_8_3.h | 30 ++ .../Manager/v1_9_0/EfiManagerV1_9_0.h | 30 ++ .../Manager/v1_9_1/EfiManagerV1_9_1.h | 30 ++ .../Manager/v1_9_2/EfiManagerV1_9_2.h | 30 ++ .../v1_0_0/EfiManagerAccountV1_0_0.h | 30 ++ .../v1_0_10/EfiManagerAccountV1_0_10.h | 30 ++ .../v1_0_11/EfiManagerAccountV1_0_11.h | 30 ++ .../v1_0_2/EfiManagerAccountV1_0_2.h | 30 ++ .../v1_0_3/EfiManagerAccountV1_0_3.h | 30 ++ .../v1_0_4/EfiManagerAccountV1_0_4.h | 30 ++ .../v1_0_5/EfiManagerAccountV1_0_5.h | 30 ++ .../v1_0_6/EfiManagerAccountV1_0_6.h | 30 ++ .../v1_0_7/EfiManagerAccountV1_0_7.h | 30 ++ .../v1_0_8/EfiManagerAccountV1_0_8.h | 30 ++ .../v1_0_9/EfiManagerAccountV1_0_9.h | 30 ++ .../v1_1_0/EfiManagerAccountV1_1_0.h | 30 ++ .../v1_1_1/EfiManagerAccountV1_1_1.h | 30 ++ .../v1_1_2/EfiManagerAccountV1_1_2.h | 30 ++ .../v1_1_3/EfiManagerAccountV1_1_3.h | 30 ++ .../v1_1_4/EfiManagerAccountV1_1_4.h | 30 ++ .../v1_1_5/EfiManagerAccountV1_1_5.h | 30 ++ .../v1_1_6/EfiManagerAccountV1_1_6.h | 30 ++ .../v1_1_7/EfiManagerAccountV1_1_7.h | 30 ++ .../v1_2_0/EfiManagerAccountV1_2_0.h | 30 ++ .../v1_2_1/EfiManagerAccountV1_2_1.h | 30 ++ .../v1_2_2/EfiManagerAccountV1_2_2.h | 30 ++ .../v1_2_3/EfiManagerAccountV1_2_3.h | 30 ++ .../v1_2_4/EfiManagerAccountV1_2_4.h | 30 ++ .../v1_3_0/EfiManagerAccountV1_3_0.h | 30 ++ .../v1_3_1/EfiManagerAccountV1_3_1.h | 30 ++ .../v1_3_2/EfiManagerAccountV1_3_2.h | 30 ++ .../v1_3_3/EfiManagerAccountV1_3_3.h | 30 ++ .../v1_4_0/EfiManagerAccountV1_4_0.h | 30 ++ .../v1_4_1/EfiManagerAccountV1_4_1.h | 30 ++ .../v1_4_2/EfiManagerAccountV1_4_2.h | 30 ++ .../v1_4_3/EfiManagerAccountV1_4_3.h | 30 ++ .../v1_4_4/EfiManagerAccountV1_4_4.h | 30 ++ .../v1_5_0/EfiManagerAccountV1_5_0.h | 30 ++ .../v1_5_1/EfiManagerAccountV1_5_1.h | 30 ++ .../v1_5_2/EfiManagerAccountV1_5_2.h | 30 ++ .../v1_5_3/EfiManagerAccountV1_5_3.h | 30 ++ .../v1_6_0/EfiManagerAccountV1_6_0.h | 30 ++ .../v1_6_1/EfiManagerAccountV1_6_1.h | 30 ++ .../v1_6_2/EfiManagerAccountV1_6_2.h | 30 ++ .../v1_7_0/EfiManagerAccountV1_7_0.h | 30 ++ .../EfiManagerAccountCollection.h | 30 ++ .../ManagerCollection/EfiManagerCollection.h | 30 ++ .../v1_0_0/EfiManagerNetworkProtocolV1_0_0.h | 30 ++ .../v1_0_2/EfiManagerNetworkProtocolV1_0_2.h | 30 ++ .../v1_0_3/EfiManagerNetworkProtocolV1_0_3.h | 30 ++ .../v1_0_4/EfiManagerNetworkProtocolV1_0_4.h | 30 ++ .../v1_0_5/EfiManagerNetworkProtocolV1_0_5.h | 30 ++ .../v1_0_6/EfiManagerNetworkProtocolV1_0_6.h | 30 ++ .../v1_0_7/EfiManagerNetworkProtocolV1_0_7.h | 30 ++ .../v1_0_8/EfiManagerNetworkProtocolV1_0_8.h | 30 ++ .../v1_0_9/EfiManagerNetworkProtocolV1_0_9.h | 30 ++ .../v1_1_0/EfiManagerNetworkProtocolV1_1_0.h | 30 ++ .../v1_1_1/EfiManagerNetworkProtocolV1_1_1.h | 30 ++ .../v1_1_2/EfiManagerNetworkProtocolV1_1_2.h | 30 ++ .../v1_1_3/EfiManagerNetworkProtocolV1_1_3.h | 30 ++ .../v1_1_4/EfiManagerNetworkProtocolV1_1_4.h | 30 ++ .../v1_1_5/EfiManagerNetworkProtocolV1_1_5.h | 30 ++ .../v1_1_6/EfiManagerNetworkProtocolV1_1_6.h | 30 ++ .../v1_2_0/EfiManagerNetworkProtocolV1_2_0.h | 30 ++ .../v1_2_1/EfiManagerNetworkProtocolV1_2_1.h | 30 ++ .../v1_2_2/EfiManagerNetworkProtocolV1_2_2.h | 30 ++ .../v1_2_3/EfiManagerNetworkProtocolV1_2_3.h | 30 ++ .../v1_2_4/EfiManagerNetworkProtocolV1_2_4.h | 30 ++ .../v1_2_5/EfiManagerNetworkProtocolV1_2_5.h | 30 ++ .../v1_3_0/EfiManagerNetworkProtocolV1_3_0.h | 30 ++ .../v1_3_1/EfiManagerNetworkProtocolV1_3_1.h | 30 ++ .../v1_3_2/EfiManagerNetworkProtocolV1_3_2.h | 30 ++ .../v1_3_3/EfiManagerNetworkProtocolV1_3_3.h | 30 ++ .../v1_3_4/EfiManagerNetworkProtocolV1_3_4.h | 30 ++ .../v1_4_0/EfiManagerNetworkProtocolV1_4_0.h | 30 ++ .../v1_4_1/EfiManagerNetworkProtocolV1_4_1.h | 30 ++ .../v1_4_2/EfiManagerNetworkProtocolV1_4_2.h | 30 ++ .../v1_4_3/EfiManagerNetworkProtocolV1_4_3.h | 30 ++ .../v1_4_4/EfiManagerNetworkProtocolV1_4_4.h | 30 ++ .../v1_5_0/EfiManagerNetworkProtocolV1_5_0.h | 30 ++ .../v1_5_1/EfiManagerNetworkProtocolV1_5_1.h | 30 ++ .../v1_5_2/EfiManagerNetworkProtocolV1_5_2.h | 30 ++ .../v1_5_3/EfiManagerNetworkProtocolV1_5_3.h | 30 ++ .../v1_6_0/EfiManagerNetworkProtocolV1_6_0.h | 30 ++ .../v1_6_1/EfiManagerNetworkProtocolV1_6_1.h | 30 ++ .../v1_6_2/EfiManagerNetworkProtocolV1_6_2.h | 30 ++ .../v1_7_0/EfiManagerNetworkProtocolV1_7_0.h | 30 ++ .../v1_0_0/EfiMediaControllerV1_0_0.h | 30 ++ .../v1_0_1/EfiMediaControllerV1_0_1.h | 30 ++ .../v1_1_0/EfiMediaControllerV1_1_0.h | 30 ++ .../EfiMediaControllerCollection.h | 30 ++ .../Memory/v1_0_0/EfiMemoryV1_0_0.h | 30 ++ .../Memory/v1_0_1/EfiMemoryV1_0_1.h | 30 ++ .../Memory/v1_0_10/EfiMemoryV1_0_10.h | 30 ++ .../Memory/v1_0_11/EfiMemoryV1_0_11.h | 30 ++ .../Memory/v1_0_2/EfiMemoryV1_0_2.h | 30 ++ .../Memory/v1_0_3/EfiMemoryV1_0_3.h | 30 ++ .../Memory/v1_0_4/EfiMemoryV1_0_4.h | 30 ++ .../Memory/v1_0_5/EfiMemoryV1_0_5.h | 30 ++ .../Memory/v1_0_6/EfiMemoryV1_0_6.h | 30 ++ .../Memory/v1_0_7/EfiMemoryV1_0_7.h | 30 ++ .../Memory/v1_0_8/EfiMemoryV1_0_8.h | 30 ++ .../Memory/v1_0_9/EfiMemoryV1_0_9.h | 30 ++ .../Memory/v1_10_0/EfiMemoryV1_10_0.h | 30 ++ .../Memory/v1_10_1/EfiMemoryV1_10_1.h | 30 ++ .../Memory/v1_11_0/EfiMemoryV1_11_0.h | 30 ++ .../Memory/v1_1_0/EfiMemoryV1_1_0.h | 30 ++ .../Memory/v1_1_1/EfiMemoryV1_1_1.h | 30 ++ .../Memory/v1_1_10/EfiMemoryV1_1_10.h | 30 ++ .../Memory/v1_1_2/EfiMemoryV1_1_2.h | 30 ++ .../Memory/v1_1_3/EfiMemoryV1_1_3.h | 30 ++ .../Memory/v1_1_4/EfiMemoryV1_1_4.h | 30 ++ .../Memory/v1_1_5/EfiMemoryV1_1_5.h | 30 ++ .../Memory/v1_1_6/EfiMemoryV1_1_6.h | 30 ++ .../Memory/v1_1_7/EfiMemoryV1_1_7.h | 30 ++ .../Memory/v1_1_8/EfiMemoryV1_1_8.h | 30 ++ .../Memory/v1_1_9/EfiMemoryV1_1_9.h | 30 ++ .../Memory/v1_2_0/EfiMemoryV1_2_0.h | 30 ++ .../Memory/v1_2_1/EfiMemoryV1_2_1.h | 30 ++ .../Memory/v1_2_2/EfiMemoryV1_2_2.h | 30 ++ .../Memory/v1_2_3/EfiMemoryV1_2_3.h | 30 ++ .../Memory/v1_2_4/EfiMemoryV1_2_4.h | 30 ++ .../Memory/v1_2_5/EfiMemoryV1_2_5.h | 30 ++ .../Memory/v1_2_6/EfiMemoryV1_2_6.h | 30 ++ .../Memory/v1_2_7/EfiMemoryV1_2_7.h | 30 ++ .../Memory/v1_2_8/EfiMemoryV1_2_8.h | 30 ++ .../Memory/v1_2_9/EfiMemoryV1_2_9.h | 30 ++ .../Memory/v1_3_0/EfiMemoryV1_3_0.h | 30 ++ .../Memory/v1_3_1/EfiMemoryV1_3_1.h | 30 ++ .../Memory/v1_3_2/EfiMemoryV1_3_2.h | 30 ++ .../Memory/v1_3_3/EfiMemoryV1_3_3.h | 30 ++ .../Memory/v1_3_4/EfiMemoryV1_3_4.h | 30 ++ .../Memory/v1_3_5/EfiMemoryV1_3_5.h | 30 ++ .../Memory/v1_3_6/EfiMemoryV1_3_6.h | 30 ++ .../Memory/v1_3_7/EfiMemoryV1_3_7.h | 30 ++ .../Memory/v1_3_8/EfiMemoryV1_3_8.h | 30 ++ .../Memory/v1_3_9/EfiMemoryV1_3_9.h | 30 ++ .../Memory/v1_4_0/EfiMemoryV1_4_0.h | 30 ++ .../Memory/v1_4_1/EfiMemoryV1_4_1.h | 30 ++ .../Memory/v1_4_2/EfiMemoryV1_4_2.h | 30 ++ .../Memory/v1_4_3/EfiMemoryV1_4_3.h | 30 ++ .../Memory/v1_4_4/EfiMemoryV1_4_4.h | 30 ++ .../Memory/v1_4_5/EfiMemoryV1_4_5.h | 30 ++ .../Memory/v1_4_6/EfiMemoryV1_4_6.h | 30 ++ .../Memory/v1_4_7/EfiMemoryV1_4_7.h | 30 ++ .../Memory/v1_4_8/EfiMemoryV1_4_8.h | 30 ++ .../Memory/v1_4_9/EfiMemoryV1_4_9.h | 30 ++ .../Memory/v1_5_0/EfiMemoryV1_5_0.h | 30 ++ .../Memory/v1_5_1/EfiMemoryV1_5_1.h | 30 ++ .../Memory/v1_5_2/EfiMemoryV1_5_2.h | 30 ++ .../Memory/v1_5_3/EfiMemoryV1_5_3.h | 30 ++ .../Memory/v1_5_4/EfiMemoryV1_5_4.h | 30 ++ .../Memory/v1_5_5/EfiMemoryV1_5_5.h | 30 ++ .../Memory/v1_5_6/EfiMemoryV1_5_6.h | 30 ++ .../Memory/v1_5_7/EfiMemoryV1_5_7.h | 30 ++ .../Memory/v1_5_8/EfiMemoryV1_5_8.h | 30 ++ .../Memory/v1_6_0/EfiMemoryV1_6_0.h | 30 ++ .../Memory/v1_6_1/EfiMemoryV1_6_1.h | 30 ++ .../Memory/v1_6_2/EfiMemoryV1_6_2.h | 30 ++ .../Memory/v1_6_3/EfiMemoryV1_6_3.h | 30 ++ .../Memory/v1_6_4/EfiMemoryV1_6_4.h | 30 ++ .../Memory/v1_6_5/EfiMemoryV1_6_5.h | 30 ++ .../Memory/v1_6_6/EfiMemoryV1_6_6.h | 30 ++ .../Memory/v1_6_7/EfiMemoryV1_6_7.h | 30 ++ .../Memory/v1_7_0/EfiMemoryV1_7_0.h | 30 ++ .../Memory/v1_7_1/EfiMemoryV1_7_1.h | 30 ++ .../Memory/v1_7_2/EfiMemoryV1_7_2.h | 30 ++ .../Memory/v1_7_3/EfiMemoryV1_7_3.h | 30 ++ .../Memory/v1_7_4/EfiMemoryV1_7_4.h | 30 ++ .../Memory/v1_7_5/EfiMemoryV1_7_5.h | 30 ++ .../Memory/v1_7_6/EfiMemoryV1_7_6.h | 30 ++ .../Memory/v1_8_0/EfiMemoryV1_8_0.h | 30 ++ .../Memory/v1_8_1/EfiMemoryV1_8_1.h | 30 ++ .../Memory/v1_8_2/EfiMemoryV1_8_2.h | 30 ++ .../Memory/v1_8_3/EfiMemoryV1_8_3.h | 30 ++ .../Memory/v1_8_4/EfiMemoryV1_8_4.h | 30 ++ .../Memory/v1_9_0/EfiMemoryV1_9_0.h | 30 ++ .../Memory/v1_9_1/EfiMemoryV1_9_1.h | 30 ++ .../Memory/v1_9_2/EfiMemoryV1_9_2.h | 30 ++ .../Memory/v1_9_3/EfiMemoryV1_9_3.h | 30 ++ .../Memory/v1_9_4/EfiMemoryV1_9_4.h | 30 ++ .../v1_0_0/EfiMemoryChunksV1_0_0.h | 30 ++ .../v1_0_1/EfiMemoryChunksV1_0_1.h | 30 ++ .../v1_0_2/EfiMemoryChunksV1_0_2.h | 30 ++ .../v1_0_3/EfiMemoryChunksV1_0_3.h | 30 ++ .../v1_0_4/EfiMemoryChunksV1_0_4.h | 30 ++ .../v1_0_5/EfiMemoryChunksV1_0_5.h | 30 ++ .../v1_0_6/EfiMemoryChunksV1_0_6.h | 30 ++ .../v1_0_7/EfiMemoryChunksV1_0_7.h | 30 ++ .../v1_1_0/EfiMemoryChunksV1_1_0.h | 30 ++ .../v1_1_1/EfiMemoryChunksV1_1_1.h | 30 ++ .../v1_1_2/EfiMemoryChunksV1_1_2.h | 30 ++ .../v1_1_3/EfiMemoryChunksV1_1_3.h | 30 ++ .../v1_1_4/EfiMemoryChunksV1_1_4.h | 30 ++ .../v1_1_5/EfiMemoryChunksV1_1_5.h | 30 ++ .../v1_2_0/EfiMemoryChunksV1_2_0.h | 30 ++ .../v1_2_1/EfiMemoryChunksV1_2_1.h | 30 ++ .../v1_2_2/EfiMemoryChunksV1_2_2.h | 30 ++ .../v1_2_3/EfiMemoryChunksV1_2_3.h | 30 ++ .../v1_2_4/EfiMemoryChunksV1_2_4.h | 30 ++ .../v1_2_5/EfiMemoryChunksV1_2_5.h | 30 ++ .../v1_2_6/EfiMemoryChunksV1_2_6.h | 30 ++ .../v1_3_0/EfiMemoryChunksV1_3_0.h | 30 ++ .../v1_3_1/EfiMemoryChunksV1_3_1.h | 30 ++ .../v1_3_2/EfiMemoryChunksV1_3_2.h | 30 ++ .../v1_4_0/EfiMemoryChunksV1_4_0.h | 30 ++ .../v1_4_1/EfiMemoryChunksV1_4_1.h | 30 ++ .../EfiMemoryChunksCollection.h | 30 ++ .../MemoryCollection/EfiMemoryCollection.h | 30 ++ .../v1_0_0/EfiMemoryDomainV1_0_0.h | 30 ++ .../v1_0_1/EfiMemoryDomainV1_0_1.h | 30 ++ .../v1_0_2/EfiMemoryDomainV1_0_2.h | 30 ++ .../v1_0_3/EfiMemoryDomainV1_0_3.h | 30 ++ .../v1_0_4/EfiMemoryDomainV1_0_4.h | 30 ++ .../v1_0_5/EfiMemoryDomainV1_0_5.h | 30 ++ .../v1_1_0/EfiMemoryDomainV1_1_0.h | 30 ++ .../v1_1_1/EfiMemoryDomainV1_1_1.h | 30 ++ .../v1_1_2/EfiMemoryDomainV1_1_2.h | 30 ++ .../v1_1_3/EfiMemoryDomainV1_1_3.h | 30 ++ .../v1_1_4/EfiMemoryDomainV1_1_4.h | 30 ++ .../v1_2_0/EfiMemoryDomainV1_2_0.h | 30 ++ .../v1_2_1/EfiMemoryDomainV1_2_1.h | 30 ++ .../v1_2_2/EfiMemoryDomainV1_2_2.h | 30 ++ .../v1_2_3/EfiMemoryDomainV1_2_3.h | 30 ++ .../v1_3_0/EfiMemoryDomainV1_3_0.h | 30 ++ .../EfiMemoryDomainCollection.h | 30 ++ .../v1_0_0/EfiMemoryMetricsV1_0_0.h | 30 ++ .../v1_0_1/EfiMemoryMetricsV1_0_1.h | 30 ++ .../v1_0_2/EfiMemoryMetricsV1_0_2.h | 30 ++ .../v1_0_3/EfiMemoryMetricsV1_0_3.h | 30 ++ .../v1_0_4/EfiMemoryMetricsV1_0_4.h | 30 ++ .../v1_0_5/EfiMemoryMetricsV1_0_5.h | 30 ++ .../v1_0_6/EfiMemoryMetricsV1_0_6.h | 30 ++ .../v1_0_7/EfiMemoryMetricsV1_0_7.h | 30 ++ .../v1_0_8/EfiMemoryMetricsV1_0_8.h | 30 ++ .../v1_1_1/EfiMemoryMetricsV1_1_1.h | 30 ++ .../v1_1_2/EfiMemoryMetricsV1_1_2.h | 30 ++ .../v1_1_3/EfiMemoryMetricsV1_1_3.h | 30 ++ .../v1_1_4/EfiMemoryMetricsV1_1_4.h | 30 ++ .../v1_1_5/EfiMemoryMetricsV1_1_5.h | 30 ++ .../v1_1_6/EfiMemoryMetricsV1_1_6.h | 30 ++ .../v1_1_7/EfiMemoryMetricsV1_1_7.h | 30 ++ .../v1_1_8/EfiMemoryMetricsV1_1_8.h | 30 ++ .../v1_2_0/EfiMemoryMetricsV1_2_0.h | 30 ++ .../v1_2_1/EfiMemoryMetricsV1_2_1.h | 30 ++ .../v1_2_2/EfiMemoryMetricsV1_2_2.h | 30 ++ .../v1_3_0/EfiMemoryMetricsV1_3_0.h | 30 ++ .../v1_3_1/EfiMemoryMetricsV1_3_1.h | 30 ++ .../v1_4_0/EfiMemoryMetricsV1_4_0.h | 30 ++ .../v1_4_1/EfiMemoryMetricsV1_4_1.h | 30 ++ .../v1_0_0/EfiMessageRegistryV1_0_0.h | 30 ++ .../v1_0_10/EfiMessageRegistryV1_0_10.h | 30 ++ .../v1_0_2/EfiMessageRegistryV1_0_2.h | 30 ++ .../v1_0_3/EfiMessageRegistryV1_0_3.h | 30 ++ .../v1_0_4/EfiMessageRegistryV1_0_4.h | 30 ++ .../v1_0_5/EfiMessageRegistryV1_0_5.h | 30 ++ .../v1_0_6/EfiMessageRegistryV1_0_6.h | 30 ++ .../v1_0_7/EfiMessageRegistryV1_0_7.h | 30 ++ .../v1_0_8/EfiMessageRegistryV1_0_8.h | 30 ++ .../v1_0_9/EfiMessageRegistryV1_0_9.h | 30 ++ .../v1_1_0/EfiMessageRegistryV1_1_0.h | 30 ++ .../v1_1_1/EfiMessageRegistryV1_1_1.h | 30 ++ .../v1_1_2/EfiMessageRegistryV1_1_2.h | 30 ++ .../v1_1_3/EfiMessageRegistryV1_1_3.h | 30 ++ .../v1_1_4/EfiMessageRegistryV1_1_4.h | 30 ++ .../v1_1_5/EfiMessageRegistryV1_1_5.h | 30 ++ .../v1_1_6/EfiMessageRegistryV1_1_6.h | 30 ++ .../v1_2_0/EfiMessageRegistryV1_2_0.h | 30 ++ .../v1_2_1/EfiMessageRegistryV1_2_1.h | 30 ++ .../v1_2_2/EfiMessageRegistryV1_2_2.h | 30 ++ .../v1_2_3/EfiMessageRegistryV1_2_3.h | 30 ++ .../v1_2_4/EfiMessageRegistryV1_2_4.h | 30 ++ .../v1_3_0/EfiMessageRegistryV1_3_0.h | 30 ++ .../v1_3_1/EfiMessageRegistryV1_3_1.h | 30 ++ .../v1_3_2/EfiMessageRegistryV1_3_2.h | 30 ++ .../v1_3_3/EfiMessageRegistryV1_3_3.h | 30 ++ .../v1_4_0/EfiMessageRegistryV1_4_0.h | 30 ++ .../v1_4_1/EfiMessageRegistryV1_4_1.h | 30 ++ .../v1_4_2/EfiMessageRegistryV1_4_2.h | 30 ++ .../EfiMessageRegistryCollection.h | 30 ++ .../v1_0_0/EfiMessageRegistryFileV1_0_0.h | 30 ++ .../v1_0_2/EfiMessageRegistryFileV1_0_2.h | 30 ++ .../v1_0_3/EfiMessageRegistryFileV1_0_3.h | 30 ++ .../v1_0_4/EfiMessageRegistryFileV1_0_4.h | 30 ++ .../v1_0_5/EfiMessageRegistryFileV1_0_5.h | 30 ++ .../v1_0_6/EfiMessageRegistryFileV1_0_6.h | 30 ++ .../v1_0_7/EfiMessageRegistryFileV1_0_7.h | 30 ++ .../v1_1_0/EfiMessageRegistryFileV1_1_0.h | 30 ++ .../v1_1_1/EfiMessageRegistryFileV1_1_1.h | 30 ++ .../v1_1_2/EfiMessageRegistryFileV1_1_2.h | 30 ++ .../v1_1_3/EfiMessageRegistryFileV1_1_3.h | 30 ++ .../EfiMessageRegistryFileCollection.h | 30 ++ .../v1_0_0/EfiMetricDefinitionV1_0_0.h | 30 ++ .../v1_0_1/EfiMetricDefinitionV1_0_1.h | 30 ++ .../v1_0_2/EfiMetricDefinitionV1_0_2.h | 30 ++ .../v1_0_3/EfiMetricDefinitionV1_0_3.h | 30 ++ .../v1_0_4/EfiMetricDefinitionV1_0_4.h | 30 ++ .../v1_0_5/EfiMetricDefinitionV1_0_5.h | 30 ++ .../v1_0_6/EfiMetricDefinitionV1_0_6.h | 30 ++ .../v1_1_0/EfiMetricDefinitionV1_1_0.h | 30 ++ .../v1_1_1/EfiMetricDefinitionV1_1_1.h | 30 ++ .../EfiMetricDefinitionCollection.h | 30 ++ .../v1_0_0/EfiMetricReportV1_0_0.h | 30 ++ .../v1_0_1/EfiMetricReportV1_0_1.h | 30 ++ .../v1_0_2/EfiMetricReportV1_0_2.h | 30 ++ .../v1_0_3/EfiMetricReportV1_0_3.h | 30 ++ .../v1_0_4/EfiMetricReportV1_0_4.h | 30 ++ .../v1_0_5/EfiMetricReportV1_0_5.h | 30 ++ .../v1_0_6/EfiMetricReportV1_0_6.h | 30 ++ .../v1_1_0/EfiMetricReportV1_1_0.h | 30 ++ .../v1_1_1/EfiMetricReportV1_1_1.h | 30 ++ .../v1_1_2/EfiMetricReportV1_1_2.h | 30 ++ .../v1_1_3/EfiMetricReportV1_1_3.h | 30 ++ .../v1_1_4/EfiMetricReportV1_1_4.h | 30 ++ .../v1_1_5/EfiMetricReportV1_1_5.h | 30 ++ .../v1_2_0/EfiMetricReportV1_2_0.h | 30 ++ .../v1_2_1/EfiMetricReportV1_2_1.h | 30 ++ .../v1_2_2/EfiMetricReportV1_2_2.h | 30 ++ .../v1_2_3/EfiMetricReportV1_2_3.h | 30 ++ .../v1_3_0/EfiMetricReportV1_3_0.h | 30 ++ .../v1_3_1/EfiMetricReportV1_3_1.h | 30 ++ .../v1_3_2/EfiMetricReportV1_3_2.h | 30 ++ .../v1_4_0/EfiMetricReportV1_4_0.h | 30 ++ .../v1_4_1/EfiMetricReportV1_4_1.h | 30 ++ .../EfiMetricReportCollection.h | 30 ++ .../v1_0_0/EfiMetricReportDefinitionV1_0_0.h | 30 ++ .../v1_0_1/EfiMetricReportDefinitionV1_0_1.h | 30 ++ .../v1_0_2/EfiMetricReportDefinitionV1_0_2.h | 30 ++ .../v1_0_3/EfiMetricReportDefinitionV1_0_3.h | 30 ++ .../v1_0_4/EfiMetricReportDefinitionV1_0_4.h | 30 ++ .../v1_0_5/EfiMetricReportDefinitionV1_0_5.h | 30 ++ .../v1_0_6/EfiMetricReportDefinitionV1_0_6.h | 30 ++ .../v1_0_7/EfiMetricReportDefinitionV1_0_7.h | 30 ++ .../v1_1_0/EfiMetricReportDefinitionV1_1_0.h | 30 ++ .../v1_1_1/EfiMetricReportDefinitionV1_1_1.h | 30 ++ .../v1_1_2/EfiMetricReportDefinitionV1_1_2.h | 30 ++ .../v1_1_3/EfiMetricReportDefinitionV1_1_3.h | 30 ++ .../v1_1_4/EfiMetricReportDefinitionV1_1_4.h | 30 ++ .../v1_1_5/EfiMetricReportDefinitionV1_1_5.h | 30 ++ .../v1_1_6/EfiMetricReportDefinitionV1_1_6.h | 30 ++ .../v1_2_0/EfiMetricReportDefinitionV1_2_0.h | 30 ++ .../v1_2_1/EfiMetricReportDefinitionV1_2_1.h | 30 ++ .../v1_2_2/EfiMetricReportDefinitionV1_2_2.h | 30 ++ .../v1_2_3/EfiMetricReportDefinitionV1_2_3.h | 30 ++ .../v1_2_4/EfiMetricReportDefinitionV1_2_4.h | 30 ++ .../v1_2_5/EfiMetricReportDefinitionV1_2_5.h | 30 ++ .../v1_3_0/EfiMetricReportDefinitionV1_3_0.h | 30 ++ .../v1_3_1/EfiMetricReportDefinitionV1_3_1.h | 30 ++ .../v1_3_2/EfiMetricReportDefinitionV1_3_2.h | 30 ++ .../v1_3_3/EfiMetricReportDefinitionV1_3_3.h | 30 ++ .../v1_3_4/EfiMetricReportDefinitionV1_3_4.h | 30 ++ .../v1_4_0/EfiMetricReportDefinitionV1_4_0.h | 30 ++ .../EfiMetricReportDefinitionCollection.h | 30 ++ .../v1_0_0/EfiNetworkAdapterV1_0_0.h | 30 ++ .../v1_0_1/EfiNetworkAdapterV1_0_1.h | 30 ++ .../v1_0_2/EfiNetworkAdapterV1_0_2.h | 30 ++ .../v1_0_3/EfiNetworkAdapterV1_0_3.h | 30 ++ .../v1_0_4/EfiNetworkAdapterV1_0_4.h | 30 ++ .../v1_0_5/EfiNetworkAdapterV1_0_5.h | 30 ++ .../v1_0_6/EfiNetworkAdapterV1_0_6.h | 30 ++ .../v1_0_7/EfiNetworkAdapterV1_0_7.h | 30 ++ .../v1_1_0/EfiNetworkAdapterV1_1_0.h | 30 ++ .../v1_1_1/EfiNetworkAdapterV1_1_1.h | 30 ++ .../v1_1_2/EfiNetworkAdapterV1_1_2.h | 30 ++ .../v1_1_3/EfiNetworkAdapterV1_1_3.h | 30 ++ .../v1_1_4/EfiNetworkAdapterV1_1_4.h | 30 ++ .../v1_1_5/EfiNetworkAdapterV1_1_5.h | 30 ++ .../v1_1_6/EfiNetworkAdapterV1_1_6.h | 30 ++ .../v1_2_0/EfiNetworkAdapterV1_2_0.h | 30 ++ .../v1_2_1/EfiNetworkAdapterV1_2_1.h | 30 ++ .../v1_2_2/EfiNetworkAdapterV1_2_2.h | 30 ++ .../v1_2_3/EfiNetworkAdapterV1_2_3.h | 30 ++ .../v1_2_4/EfiNetworkAdapterV1_2_4.h | 30 ++ .../v1_2_5/EfiNetworkAdapterV1_2_5.h | 30 ++ .../v1_3_0/EfiNetworkAdapterV1_3_0.h | 30 ++ .../v1_3_1/EfiNetworkAdapterV1_3_1.h | 30 ++ .../v1_3_2/EfiNetworkAdapterV1_3_2.h | 30 ++ .../v1_3_3/EfiNetworkAdapterV1_3_3.h | 30 ++ .../v1_3_4/EfiNetworkAdapterV1_3_4.h | 30 ++ .../v1_4_0/EfiNetworkAdapterV1_4_0.h | 30 ++ .../v1_4_1/EfiNetworkAdapterV1_4_1.h | 30 ++ .../v1_5_0/EfiNetworkAdapterV1_5_0.h | 30 ++ .../v1_5_1/EfiNetworkAdapterV1_5_1.h | 30 ++ .../v1_6_0/EfiNetworkAdapterV1_6_0.h | 30 ++ .../EfiNetworkAdapterCollection.h | 30 ++ .../v1_0_0/EfiNetworkDeviceFunctionV1_0_0.h | 30 ++ .../v1_0_1/EfiNetworkDeviceFunctionV1_0_1.h | 30 ++ .../v1_0_2/EfiNetworkDeviceFunctionV1_0_2.h | 30 ++ .../v1_0_3/EfiNetworkDeviceFunctionV1_0_3.h | 30 ++ .../v1_0_4/EfiNetworkDeviceFunctionV1_0_4.h | 30 ++ .../v1_0_5/EfiNetworkDeviceFunctionV1_0_5.h | 30 ++ .../v1_0_6/EfiNetworkDeviceFunctionV1_0_6.h | 30 ++ .../v1_0_7/EfiNetworkDeviceFunctionV1_0_7.h | 30 ++ .../v1_0_8/EfiNetworkDeviceFunctionV1_0_8.h | 30 ++ .../v1_1_0/EfiNetworkDeviceFunctionV1_1_0.h | 30 ++ .../v1_1_1/EfiNetworkDeviceFunctionV1_1_1.h | 30 ++ .../v1_1_2/EfiNetworkDeviceFunctionV1_1_2.h | 30 ++ .../v1_1_3/EfiNetworkDeviceFunctionV1_1_3.h | 30 ++ .../v1_1_4/EfiNetworkDeviceFunctionV1_1_4.h | 30 ++ .../v1_1_5/EfiNetworkDeviceFunctionV1_1_5.h | 30 ++ .../v1_1_6/EfiNetworkDeviceFunctionV1_1_6.h | 30 ++ .../v1_1_7/EfiNetworkDeviceFunctionV1_1_7.h | 30 ++ .../v1_2_0/EfiNetworkDeviceFunctionV1_2_0.h | 30 ++ .../v1_2_1/EfiNetworkDeviceFunctionV1_2_1.h | 30 ++ .../v1_2_2/EfiNetworkDeviceFunctionV1_2_2.h | 30 ++ .../v1_2_3/EfiNetworkDeviceFunctionV1_2_3.h | 30 ++ .../v1_2_4/EfiNetworkDeviceFunctionV1_2_4.h | 30 ++ .../v1_2_5/EfiNetworkDeviceFunctionV1_2_5.h | 30 ++ .../v1_2_6/EfiNetworkDeviceFunctionV1_2_6.h | 30 ++ .../v1_2_7/EfiNetworkDeviceFunctionV1_2_7.h | 30 ++ .../v1_3_0/EfiNetworkDeviceFunctionV1_3_0.h | 30 ++ .../v1_3_1/EfiNetworkDeviceFunctionV1_3_1.h | 30 ++ .../v1_3_2/EfiNetworkDeviceFunctionV1_3_2.h | 30 ++ .../v1_3_3/EfiNetworkDeviceFunctionV1_3_3.h | 30 ++ .../v1_3_4/EfiNetworkDeviceFunctionV1_3_4.h | 30 ++ .../v1_3_5/EfiNetworkDeviceFunctionV1_3_5.h | 30 ++ .../v1_4_0/EfiNetworkDeviceFunctionV1_4_0.h | 30 ++ .../v1_4_1/EfiNetworkDeviceFunctionV1_4_1.h | 30 ++ .../v1_4_2/EfiNetworkDeviceFunctionV1_4_2.h | 30 ++ .../v1_5_0/EfiNetworkDeviceFunctionV1_5_0.h | 30 ++ .../v1_5_1/EfiNetworkDeviceFunctionV1_5_1.h | 30 ++ .../EfiNetworkDeviceFunctionCollection.h | 30 ++ .../v1_0_0/EfiNetworkInterfaceV1_0_0.h | 30 ++ .../v1_0_1/EfiNetworkInterfaceV1_0_1.h | 30 ++ .../v1_0_2/EfiNetworkInterfaceV1_0_2.h | 30 ++ .../v1_0_3/EfiNetworkInterfaceV1_0_3.h | 30 ++ .../v1_0_4/EfiNetworkInterfaceV1_0_4.h | 30 ++ .../v1_0_5/EfiNetworkInterfaceV1_0_5.h | 30 ++ .../v1_0_6/EfiNetworkInterfaceV1_0_6.h | 30 ++ .../v1_1_0/EfiNetworkInterfaceV1_1_0.h | 30 ++ .../v1_1_1/EfiNetworkInterfaceV1_1_1.h | 30 ++ .../v1_1_2/EfiNetworkInterfaceV1_1_2.h | 30 ++ .../v1_1_3/EfiNetworkInterfaceV1_1_3.h | 30 ++ .../v1_1_4/EfiNetworkInterfaceV1_1_4.h | 30 ++ .../v1_1_5/EfiNetworkInterfaceV1_1_5.h | 30 ++ .../v1_2_0/EfiNetworkInterfaceV1_2_0.h | 30 ++ .../v1_2_1/EfiNetworkInterfaceV1_2_1.h | 30 ++ .../EfiNetworkInterfaceCollection.h | 30 ++ .../NetworkPort/v1_0_0/EfiNetworkPortV1_0_0.h | 30 ++ .../NetworkPort/v1_0_1/EfiNetworkPortV1_0_1.h | 30 ++ .../NetworkPort/v1_0_2/EfiNetworkPortV1_0_2.h | 30 ++ .../NetworkPort/v1_0_3/EfiNetworkPortV1_0_3.h | 30 ++ .../NetworkPort/v1_0_4/EfiNetworkPortV1_0_4.h | 30 ++ .../NetworkPort/v1_0_5/EfiNetworkPortV1_0_5.h | 30 ++ .../NetworkPort/v1_0_6/EfiNetworkPortV1_0_6.h | 30 ++ .../NetworkPort/v1_0_7/EfiNetworkPortV1_0_7.h | 30 ++ .../NetworkPort/v1_0_8/EfiNetworkPortV1_0_8.h | 30 ++ .../NetworkPort/v1_1_0/EfiNetworkPortV1_1_0.h | 30 ++ .../NetworkPort/v1_1_1/EfiNetworkPortV1_1_1.h | 30 ++ .../NetworkPort/v1_1_2/EfiNetworkPortV1_1_2.h | 30 ++ .../NetworkPort/v1_1_3/EfiNetworkPortV1_1_3.h | 30 ++ .../NetworkPort/v1_1_4/EfiNetworkPortV1_1_4.h | 30 ++ .../NetworkPort/v1_1_5/EfiNetworkPortV1_1_5.h | 30 ++ .../NetworkPort/v1_1_6/EfiNetworkPortV1_1_6.h | 30 ++ .../NetworkPort/v1_1_7/EfiNetworkPortV1_1_7.h | 30 ++ .../NetworkPort/v1_2_0/EfiNetworkPortV1_2_0.h | 30 ++ .../NetworkPort/v1_2_1/EfiNetworkPortV1_2_1.h | 30 ++ .../NetworkPort/v1_2_2/EfiNetworkPortV1_2_2.h | 30 ++ .../NetworkPort/v1_2_3/EfiNetworkPortV1_2_3.h | 30 ++ .../NetworkPort/v1_2_4/EfiNetworkPortV1_2_4.h | 30 ++ .../NetworkPort/v1_2_5/EfiNetworkPortV1_2_5.h | 30 ++ .../NetworkPort/v1_2_6/EfiNetworkPortV1_2_6.h | 30 ++ .../NetworkPort/v1_3_0/EfiNetworkPortV1_3_0.h | 30 ++ .../NetworkPort/v1_3_1/EfiNetworkPortV1_3_1.h | 30 ++ .../NetworkPort/v1_4_0/EfiNetworkPortV1_4_0.h | 30 ++ .../EfiNetworkPortCollection.h | 30 ++ .../v1_0_0/EfiOperatingConfigV1_0_0.h | 30 ++ .../v1_0_1/EfiOperatingConfigV1_0_1.h | 30 ++ .../v1_0_2/EfiOperatingConfigV1_0_2.h | 30 ++ .../EfiOperatingConfigCollection.h | 30 ++ .../Outlet/v1_0_0/EfiOutletV1_0_0.h | 30 ++ .../Outlet/v1_0_1/EfiOutletV1_0_1.h | 30 ++ .../Outlet/v1_0_2/EfiOutletV1_0_2.h | 30 ++ .../Outlet/v1_1_0/EfiOutletV1_1_0.h | 30 ++ .../Outlet/v1_1_1/EfiOutletV1_1_1.h | 30 ++ .../OutletCollection/EfiOutletCollection.h | 30 ++ .../OutletGroup/v1_0_0/EfiOutletGroupV1_0_0.h | 30 ++ .../OutletGroup/v1_0_1/EfiOutletGroupV1_0_1.h | 30 ++ .../EfiOutletGroupCollection.h | 30 ++ .../PCIeDevice/v1_0_0/EfiPCIeDeviceV1_0_0.h | 30 ++ .../PCIeDevice/v1_0_1/EfiPCIeDeviceV1_0_1.h | 30 ++ .../PCIeDevice/v1_0_2/EfiPCIeDeviceV1_0_2.h | 30 ++ .../PCIeDevice/v1_0_3/EfiPCIeDeviceV1_0_3.h | 30 ++ .../PCIeDevice/v1_0_4/EfiPCIeDeviceV1_0_4.h | 30 ++ .../PCIeDevice/v1_0_5/EfiPCIeDeviceV1_0_5.h | 30 ++ .../PCIeDevice/v1_1_0/EfiPCIeDeviceV1_1_0.h | 30 ++ .../PCIeDevice/v1_1_1/EfiPCIeDeviceV1_1_1.h | 30 ++ .../PCIeDevice/v1_1_2/EfiPCIeDeviceV1_1_2.h | 30 ++ .../PCIeDevice/v1_1_3/EfiPCIeDeviceV1_1_3.h | 30 ++ .../PCIeDevice/v1_2_0/EfiPCIeDeviceV1_2_0.h | 30 ++ .../PCIeDevice/v1_2_1/EfiPCIeDeviceV1_2_1.h | 30 ++ .../PCIeDevice/v1_2_2/EfiPCIeDeviceV1_2_2.h | 30 ++ .../PCIeDevice/v1_2_3/EfiPCIeDeviceV1_2_3.h | 30 ++ .../PCIeDevice/v1_3_0/EfiPCIeDeviceV1_3_0.h | 30 ++ .../PCIeDevice/v1_3_1/EfiPCIeDeviceV1_3_1.h | 30 ++ .../PCIeDevice/v1_3_2/EfiPCIeDeviceV1_3_2.h | 30 ++ .../PCIeDevice/v1_4_0/EfiPCIeDeviceV1_4_0.h | 30 ++ .../PCIeDevice/v1_5_0/EfiPCIeDeviceV1_5_0.h | 30 ++ .../PCIeDevice/v1_6_0/EfiPCIeDeviceV1_6_0.h | 30 ++ .../EfiPCIeDeviceCollection.h | 30 ++ .../v1_0_0/EfiPCIeFunctionV1_0_0.h | 30 ++ .../v1_0_1/EfiPCIeFunctionV1_0_1.h | 30 ++ .../v1_0_2/EfiPCIeFunctionV1_0_2.h | 30 ++ .../v1_0_3/EfiPCIeFunctionV1_0_3.h | 30 ++ .../v1_0_4/EfiPCIeFunctionV1_0_4.h | 30 ++ .../v1_0_5/EfiPCIeFunctionV1_0_5.h | 30 ++ .../v1_0_6/EfiPCIeFunctionV1_0_6.h | 30 ++ .../v1_1_0/EfiPCIeFunctionV1_1_0.h | 30 ++ .../v1_1_1/EfiPCIeFunctionV1_1_1.h | 30 ++ .../v1_1_2/EfiPCIeFunctionV1_1_2.h | 30 ++ .../v1_1_3/EfiPCIeFunctionV1_1_3.h | 30 ++ .../v1_1_4/EfiPCIeFunctionV1_1_4.h | 30 ++ .../v1_2_0/EfiPCIeFunctionV1_2_0.h | 30 ++ .../v1_2_1/EfiPCIeFunctionV1_2_1.h | 30 ++ .../v1_2_2/EfiPCIeFunctionV1_2_2.h | 30 ++ .../v1_2_3/EfiPCIeFunctionV1_2_3.h | 30 ++ .../EfiPCIeFunctionCollection.h | 30 ++ .../PCIeSlots/v1_0_0/EfiPCIeSlotsV1_0_0.h | 30 ++ .../PCIeSlots/v1_0_1/EfiPCIeSlotsV1_0_1.h | 30 ++ .../PCIeSlots/v1_0_2/EfiPCIeSlotsV1_0_2.h | 30 ++ .../PCIeSlots/v1_0_3/EfiPCIeSlotsV1_0_3.h | 30 ++ .../PCIeSlots/v1_1_0/EfiPCIeSlotsV1_1_0.h | 30 ++ .../PCIeSlots/v1_1_1/EfiPCIeSlotsV1_1_1.h | 30 ++ .../PCIeSlots/v1_1_2/EfiPCIeSlotsV1_1_2.h | 30 ++ .../PCIeSlots/v1_2_0/EfiPCIeSlotsV1_2_0.h | 30 ++ .../PCIeSlots/v1_3_0/EfiPCIeSlotsV1_3_0.h | 30 ++ .../PCIeSlots/v1_4_0/EfiPCIeSlotsV1_4_0.h | 30 ++ .../PCIeSlots/v1_4_1/EfiPCIeSlotsV1_4_1.h | 30 ++ .../Port/v1_0_0/EfiPortV1_0_0.h | 30 ++ .../Port/v1_0_1/EfiPortV1_0_1.h | 30 ++ .../Port/v1_0_2/EfiPortV1_0_2.h | 30 ++ .../Port/v1_0_3/EfiPortV1_0_3.h | 30 ++ .../Port/v1_0_4/EfiPortV1_0_4.h | 30 ++ .../Port/v1_0_5/EfiPortV1_0_5.h | 30 ++ .../Port/v1_0_6/EfiPortV1_0_6.h | 30 ++ .../Port/v1_0_7/EfiPortV1_0_7.h | 30 ++ .../Port/v1_0_8/EfiPortV1_0_8.h | 30 ++ .../Port/v1_1_0/EfiPortV1_1_0.h | 30 ++ .../Port/v1_1_1/EfiPortV1_1_1.h | 30 ++ .../Port/v1_1_2/EfiPortV1_1_2.h | 30 ++ .../Port/v1_1_3/EfiPortV1_1_3.h | 30 ++ .../Port/v1_1_4/EfiPortV1_1_4.h | 30 ++ .../Port/v1_1_5/EfiPortV1_1_5.h | 30 ++ .../Port/v1_2_0/EfiPortV1_2_0.h | 30 ++ .../Port/v1_2_1/EfiPortV1_2_1.h | 30 ++ .../Port/v1_2_2/EfiPortV1_2_2.h | 30 ++ .../Port/v1_2_3/EfiPortV1_2_3.h | 30 ++ .../Port/v1_3_0/EfiPortV1_3_0.h | 30 ++ .../Port/v1_3_1/EfiPortV1_3_1.h | 30 ++ .../PortCollection/EfiPortCollection.h | 30 ++ .../PortMetrics/v1_0_0/EfiPortMetricsV1_0_0.h | 30 ++ .../PortMetrics/v1_0_1/EfiPortMetricsV1_0_1.h | 30 ++ .../Power/v1_0_0/EfiPowerV1_0_0.h | 30 ++ .../Power/v1_0_1/EfiPowerV1_0_1.h | 30 ++ .../Power/v1_0_10/EfiPowerV1_0_10.h | 30 ++ .../Power/v1_0_11/EfiPowerV1_0_11.h | 30 ++ .../Power/v1_0_12/EfiPowerV1_0_12.h | 30 ++ .../Power/v1_0_2/EfiPowerV1_0_2.h | 30 ++ .../Power/v1_0_3/EfiPowerV1_0_3.h | 30 ++ .../Power/v1_0_4/EfiPowerV1_0_4.h | 30 ++ .../Power/v1_0_5/EfiPowerV1_0_5.h | 30 ++ .../Power/v1_0_6/EfiPowerV1_0_6.h | 30 ++ .../Power/v1_0_7/EfiPowerV1_0_7.h | 30 ++ .../Power/v1_0_8/EfiPowerV1_0_8.h | 30 ++ .../Power/v1_0_9/EfiPowerV1_0_9.h | 30 ++ .../Power/v1_1_0/EfiPowerV1_1_0.h | 30 ++ .../Power/v1_1_1/EfiPowerV1_1_1.h | 30 ++ .../Power/v1_1_10/EfiPowerV1_1_10.h | 30 ++ .../Power/v1_1_2/EfiPowerV1_1_2.h | 30 ++ .../Power/v1_1_3/EfiPowerV1_1_3.h | 30 ++ .../Power/v1_1_4/EfiPowerV1_1_4.h | 30 ++ .../Power/v1_1_5/EfiPowerV1_1_5.h | 30 ++ .../Power/v1_1_6/EfiPowerV1_1_6.h | 30 ++ .../Power/v1_1_7/EfiPowerV1_1_7.h | 30 ++ .../Power/v1_1_8/EfiPowerV1_1_8.h | 30 ++ .../Power/v1_1_9/EfiPowerV1_1_9.h | 30 ++ .../Power/v1_2_0/EfiPowerV1_2_0.h | 30 ++ .../Power/v1_2_1/EfiPowerV1_2_1.h | 30 ++ .../Power/v1_2_10/EfiPowerV1_2_10.h | 30 ++ .../Power/v1_2_2/EfiPowerV1_2_2.h | 30 ++ .../Power/v1_2_3/EfiPowerV1_2_3.h | 30 ++ .../Power/v1_2_4/EfiPowerV1_2_4.h | 30 ++ .../Power/v1_2_5/EfiPowerV1_2_5.h | 30 ++ .../Power/v1_2_6/EfiPowerV1_2_6.h | 30 ++ .../Power/v1_2_7/EfiPowerV1_2_7.h | 30 ++ .../Power/v1_2_8/EfiPowerV1_2_8.h | 30 ++ .../Power/v1_2_9/EfiPowerV1_2_9.h | 30 ++ .../Power/v1_3_0/EfiPowerV1_3_0.h | 30 ++ .../Power/v1_3_1/EfiPowerV1_3_1.h | 30 ++ .../Power/v1_3_2/EfiPowerV1_3_2.h | 30 ++ .../Power/v1_3_3/EfiPowerV1_3_3.h | 30 ++ .../Power/v1_3_4/EfiPowerV1_3_4.h | 30 ++ .../Power/v1_3_5/EfiPowerV1_3_5.h | 30 ++ .../Power/v1_3_6/EfiPowerV1_3_6.h | 30 ++ .../Power/v1_3_7/EfiPowerV1_3_7.h | 30 ++ .../Power/v1_3_8/EfiPowerV1_3_8.h | 30 ++ .../Power/v1_4_0/EfiPowerV1_4_0.h | 30 ++ .../Power/v1_4_1/EfiPowerV1_4_1.h | 30 ++ .../Power/v1_4_2/EfiPowerV1_4_2.h | 30 ++ .../Power/v1_4_3/EfiPowerV1_4_3.h | 30 ++ .../Power/v1_4_4/EfiPowerV1_4_4.h | 30 ++ .../Power/v1_4_5/EfiPowerV1_4_5.h | 30 ++ .../Power/v1_4_6/EfiPowerV1_4_6.h | 30 ++ .../Power/v1_4_7/EfiPowerV1_4_7.h | 30 ++ .../Power/v1_5_0/EfiPowerV1_5_0.h | 30 ++ .../Power/v1_5_1/EfiPowerV1_5_1.h | 30 ++ .../Power/v1_5_2/EfiPowerV1_5_2.h | 30 ++ .../Power/v1_5_3/EfiPowerV1_5_3.h | 30 ++ .../Power/v1_5_4/EfiPowerV1_5_4.h | 30 ++ .../Power/v1_5_5/EfiPowerV1_5_5.h | 30 ++ .../Power/v1_5_6/EfiPowerV1_5_6.h | 30 ++ .../Power/v1_6_0/EfiPowerV1_6_0.h | 30 ++ .../Power/v1_6_1/EfiPowerV1_6_1.h | 30 ++ .../Power/v1_6_2/EfiPowerV1_6_2.h | 30 ++ .../Power/v1_7_0/EfiPowerV1_7_0.h | 30 ++ .../v1_0_0/EfiPowerDistributionV1_0_0.h | 30 ++ .../v1_0_1/EfiPowerDistributionV1_0_1.h | 30 ++ .../v1_0_2/EfiPowerDistributionV1_0_2.h | 30 ++ .../EfiPowerDistributionCollection.h | 30 ++ .../EfiPowerDistributionMetricsV1_0_0.h | 30 ++ .../PowerDomain/v1_0_0/EfiPowerDomainV1_0_0.h | 30 ++ .../PowerDomain/v1_0_1/EfiPowerDomainV1_0_1.h | 30 ++ .../EfiPowerDomainCollection.h | 30 ++ .../v1_0_0/EfiPowerEquipmentV1_0_0.h | 30 ++ .../v1_0_0/EfiPowerSubsystemV1_0_0.h | 30 ++ .../PowerSupply/v1_0_0/EfiPowerSupplyV1_0_0.h | 30 ++ .../EfiPowerSupplyCollection.h | 30 ++ .../v1_0_0/EfiPowerSupplyMetricsV1_0_0.h | 30 ++ .../v1_0_0/EfiPrivilegeRegistryV1_0_0.h | 30 ++ .../v1_0_1/EfiPrivilegeRegistryV1_0_1.h | 30 ++ .../v1_0_2/EfiPrivilegeRegistryV1_0_2.h | 30 ++ .../v1_0_3/EfiPrivilegeRegistryV1_0_3.h | 30 ++ .../v1_0_4/EfiPrivilegeRegistryV1_0_4.h | 30 ++ .../v1_0_5/EfiPrivilegeRegistryV1_0_5.h | 30 ++ .../v1_1_0/EfiPrivilegeRegistryV1_1_0.h | 30 ++ .../v1_1_1/EfiPrivilegeRegistryV1_1_1.h | 30 ++ .../v1_1_2/EfiPrivilegeRegistryV1_1_2.h | 30 ++ .../v1_1_3/EfiPrivilegeRegistryV1_1_3.h | 30 ++ .../v1_1_4/EfiPrivilegeRegistryV1_1_4.h | 30 ++ .../Processor/v1_0_0/EfiProcessorV1_0_0.h | 30 ++ .../Processor/v1_0_10/EfiProcessorV1_0_10.h | 30 ++ .../Processor/v1_0_11/EfiProcessorV1_0_11.h | 30 ++ .../Processor/v1_0_12/EfiProcessorV1_0_12.h | 30 ++ .../Processor/v1_0_2/EfiProcessorV1_0_2.h | 30 ++ .../Processor/v1_0_3/EfiProcessorV1_0_3.h | 30 ++ .../Processor/v1_0_4/EfiProcessorV1_0_4.h | 30 ++ .../Processor/v1_0_5/EfiProcessorV1_0_5.h | 30 ++ .../Processor/v1_0_6/EfiProcessorV1_0_6.h | 30 ++ .../Processor/v1_0_7/EfiProcessorV1_0_7.h | 30 ++ .../Processor/v1_0_8/EfiProcessorV1_0_8.h | 30 ++ .../Processor/v1_0_9/EfiProcessorV1_0_9.h | 30 ++ .../Processor/v1_10_0/EfiProcessorV1_10_0.h | 30 ++ .../Processor/v1_10_1/EfiProcessorV1_10_1.h | 30 ++ .../Processor/v1_11_0/EfiProcessorV1_11_0.h | 30 ++ .../Processor/v1_1_0/EfiProcessorV1_1_0.h | 30 ++ .../Processor/v1_1_1/EfiProcessorV1_1_1.h | 30 ++ .../Processor/v1_1_2/EfiProcessorV1_1_2.h | 30 ++ .../Processor/v1_1_3/EfiProcessorV1_1_3.h | 30 ++ .../Processor/v1_1_4/EfiProcessorV1_1_4.h | 30 ++ .../Processor/v1_1_5/EfiProcessorV1_1_5.h | 30 ++ .../Processor/v1_1_6/EfiProcessorV1_1_6.h | 30 ++ .../Processor/v1_1_7/EfiProcessorV1_1_7.h | 30 ++ .../Processor/v1_1_8/EfiProcessorV1_1_8.h | 30 ++ .../Processor/v1_2_0/EfiProcessorV1_2_0.h | 30 ++ .../Processor/v1_2_1/EfiProcessorV1_2_1.h | 30 ++ .../Processor/v1_2_2/EfiProcessorV1_2_2.h | 30 ++ .../Processor/v1_2_3/EfiProcessorV1_2_3.h | 30 ++ .../Processor/v1_2_4/EfiProcessorV1_2_4.h | 30 ++ .../Processor/v1_2_5/EfiProcessorV1_2_5.h | 30 ++ .../Processor/v1_2_6/EfiProcessorV1_2_6.h | 30 ++ .../Processor/v1_2_7/EfiProcessorV1_2_7.h | 30 ++ .../Processor/v1_2_8/EfiProcessorV1_2_8.h | 30 ++ .../Processor/v1_3_0/EfiProcessorV1_3_0.h | 30 ++ .../Processor/v1_3_1/EfiProcessorV1_3_1.h | 30 ++ .../Processor/v1_3_2/EfiProcessorV1_3_2.h | 30 ++ .../Processor/v1_3_3/EfiProcessorV1_3_3.h | 30 ++ .../Processor/v1_3_4/EfiProcessorV1_3_4.h | 30 ++ .../Processor/v1_3_5/EfiProcessorV1_3_5.h | 30 ++ .../Processor/v1_3_6/EfiProcessorV1_3_6.h | 30 ++ .../Processor/v1_3_7/EfiProcessorV1_3_7.h | 30 ++ .../Processor/v1_3_8/EfiProcessorV1_3_8.h | 30 ++ .../Processor/v1_4_0/EfiProcessorV1_4_0.h | 30 ++ .../Processor/v1_4_1/EfiProcessorV1_4_1.h | 30 ++ .../Processor/v1_4_2/EfiProcessorV1_4_2.h | 30 ++ .../Processor/v1_4_3/EfiProcessorV1_4_3.h | 30 ++ .../Processor/v1_4_4/EfiProcessorV1_4_4.h | 30 ++ .../Processor/v1_4_5/EfiProcessorV1_4_5.h | 30 ++ .../Processor/v1_4_6/EfiProcessorV1_4_6.h | 30 ++ .../Processor/v1_4_7/EfiProcessorV1_4_7.h | 30 ++ .../Processor/v1_5_0/EfiProcessorV1_5_0.h | 30 ++ .../Processor/v1_5_1/EfiProcessorV1_5_1.h | 30 ++ .../Processor/v1_5_2/EfiProcessorV1_5_2.h | 30 ++ .../Processor/v1_5_3/EfiProcessorV1_5_3.h | 30 ++ .../Processor/v1_5_4/EfiProcessorV1_5_4.h | 30 ++ .../Processor/v1_5_5/EfiProcessorV1_5_5.h | 30 ++ .../Processor/v1_5_6/EfiProcessorV1_5_6.h | 30 ++ .../Processor/v1_6_0/EfiProcessorV1_6_0.h | 30 ++ .../Processor/v1_6_1/EfiProcessorV1_6_1.h | 30 ++ .../Processor/v1_6_2/EfiProcessorV1_6_2.h | 30 ++ .../Processor/v1_6_3/EfiProcessorV1_6_3.h | 30 ++ .../Processor/v1_6_4/EfiProcessorV1_6_4.h | 30 ++ .../Processor/v1_7_0/EfiProcessorV1_7_0.h | 30 ++ .../Processor/v1_7_1/EfiProcessorV1_7_1.h | 30 ++ .../Processor/v1_7_2/EfiProcessorV1_7_2.h | 30 ++ .../Processor/v1_7_3/EfiProcessorV1_7_3.h | 30 ++ .../Processor/v1_8_0/EfiProcessorV1_8_0.h | 30 ++ .../Processor/v1_8_1/EfiProcessorV1_8_1.h | 30 ++ .../Processor/v1_8_2/EfiProcessorV1_8_2.h | 30 ++ .../Processor/v1_9_0/EfiProcessorV1_9_0.h | 30 ++ .../Processor/v1_9_1/EfiProcessorV1_9_1.h | 30 ++ .../EfiProcessorCollection.h | 30 ++ .../v1_0_0/EfiProcessorMetricsV1_0_0.h | 30 ++ .../v1_0_1/EfiProcessorMetricsV1_0_1.h | 30 ++ .../v1_0_2/EfiProcessorMetricsV1_0_2.h | 30 ++ .../v1_0_3/EfiProcessorMetricsV1_0_3.h | 30 ++ .../v1_0_4/EfiProcessorMetricsV1_0_4.h | 30 ++ .../v1_1_0/EfiProcessorMetricsV1_1_0.h | 30 ++ .../v1_1_1/EfiProcessorMetricsV1_1_1.h | 30 ++ .../v1_1_2/EfiProcessorMetricsV1_1_2.h | 30 ++ .../v1_2_0/EfiProcessorMetricsV1_2_0.h | 30 ++ .../v1_0_0/EfiResourceBlockV1_0_0.h | 30 ++ .../v1_0_1/EfiResourceBlockV1_0_1.h | 30 ++ .../v1_0_2/EfiResourceBlockV1_0_2.h | 30 ++ .../v1_0_3/EfiResourceBlockV1_0_3.h | 30 ++ .../v1_0_4/EfiResourceBlockV1_0_4.h | 30 ++ .../v1_0_5/EfiResourceBlockV1_0_5.h | 30 ++ .../v1_0_6/EfiResourceBlockV1_0_6.h | 30 ++ .../v1_1_0/EfiResourceBlockV1_1_0.h | 30 ++ .../v1_1_1/EfiResourceBlockV1_1_1.h | 30 ++ .../v1_1_2/EfiResourceBlockV1_1_2.h | 30 ++ .../v1_1_3/EfiResourceBlockV1_1_3.h | 30 ++ .../v1_1_4/EfiResourceBlockV1_1_4.h | 30 ++ .../v1_1_5/EfiResourceBlockV1_1_5.h | 30 ++ .../v1_1_6/EfiResourceBlockV1_1_6.h | 30 ++ .../v1_2_0/EfiResourceBlockV1_2_0.h | 30 ++ .../v1_2_1/EfiResourceBlockV1_2_1.h | 30 ++ .../v1_2_2/EfiResourceBlockV1_2_2.h | 30 ++ .../v1_2_3/EfiResourceBlockV1_2_3.h | 30 ++ .../v1_2_4/EfiResourceBlockV1_2_4.h | 30 ++ .../v1_2_5/EfiResourceBlockV1_2_5.h | 30 ++ .../v1_3_0/EfiResourceBlockV1_3_0.h | 30 ++ .../v1_3_1/EfiResourceBlockV1_3_1.h | 30 ++ .../v1_3_2/EfiResourceBlockV1_3_2.h | 30 ++ .../v1_3_3/EfiResourceBlockV1_3_3.h | 30 ++ .../v1_3_4/EfiResourceBlockV1_3_4.h | 30 ++ .../EfiResourceBlockCollection.h | 30 ++ .../Role/v1_0_0/EfiRoleV1_0_0.h | 30 ++ .../Role/v1_0_2/EfiRoleV1_0_2.h | 30 ++ .../Role/v1_0_3/EfiRoleV1_0_3.h | 30 ++ .../Role/v1_0_4/EfiRoleV1_0_4.h | 30 ++ .../Role/v1_0_5/EfiRoleV1_0_5.h | 30 ++ .../Role/v1_0_6/EfiRoleV1_0_6.h | 30 ++ .../Role/v1_0_7/EfiRoleV1_0_7.h | 30 ++ .../Role/v1_1_0/EfiRoleV1_1_0.h | 30 ++ .../Role/v1_1_1/EfiRoleV1_1_1.h | 30 ++ .../Role/v1_1_2/EfiRoleV1_1_2.h | 30 ++ .../Role/v1_1_3/EfiRoleV1_1_3.h | 30 ++ .../Role/v1_1_4/EfiRoleV1_1_4.h | 30 ++ .../Role/v1_1_5/EfiRoleV1_1_5.h | 30 ++ .../Role/v1_2_0/EfiRoleV1_2_0.h | 30 ++ .../Role/v1_2_1/EfiRoleV1_2_1.h | 30 ++ .../Role/v1_2_2/EfiRoleV1_2_2.h | 30 ++ .../Role/v1_2_3/EfiRoleV1_2_3.h | 30 ++ .../Role/v1_2_4/EfiRoleV1_2_4.h | 30 ++ .../Role/v1_2_5/EfiRoleV1_2_5.h | 30 ++ .../Role/v1_3_0/EfiRoleV1_3_0.h | 30 ++ .../RoleCollection/EfiRoleCollection.h | 30 ++ .../RouteEntry/v1_0_0/EfiRouteEntryV1_0_0.h | 30 ++ .../RouteEntry/v1_0_1/EfiRouteEntryV1_0_1.h | 30 ++ .../EfiRouteEntryCollection.h | 30 ++ .../v1_0_0/EfiRouteSetEntryV1_0_0.h | 30 ++ .../v1_0_1/EfiRouteSetEntryV1_0_1.h | 30 ++ .../EfiRouteSetEntryCollection.h | 30 ++ .../SecureBoot/v1_0_0/EfiSecureBootV1_0_0.h | 30 ++ .../SecureBoot/v1_0_1/EfiSecureBootV1_0_1.h | 30 ++ .../SecureBoot/v1_0_2/EfiSecureBootV1_0_2.h | 30 ++ .../SecureBoot/v1_0_3/EfiSecureBootV1_0_3.h | 30 ++ .../SecureBoot/v1_0_4/EfiSecureBootV1_0_4.h | 30 ++ .../SecureBoot/v1_0_5/EfiSecureBootV1_0_5.h | 30 ++ .../SecureBoot/v1_0_6/EfiSecureBootV1_0_6.h | 30 ++ .../SecureBoot/v1_0_7/EfiSecureBootV1_0_7.h | 30 ++ .../SecureBoot/v1_1_0/EfiSecureBootV1_1_0.h | 30 ++ .../v1_0_0/EfiSecureBootDatabaseV1_0_0.h | 30 ++ .../EfiSecureBootDatabaseCollection.h | 30 ++ .../Sensor/v1_0_0/EfiSensorV1_0_0.h | 30 ++ .../Sensor/v1_0_1/EfiSensorV1_0_1.h | 30 ++ .../Sensor/v1_0_2/EfiSensorV1_0_2.h | 30 ++ .../Sensor/v1_0_3/EfiSensorV1_0_3.h | 30 ++ .../Sensor/v1_0_4/EfiSensorV1_0_4.h | 30 ++ .../Sensor/v1_0_5/EfiSensorV1_0_5.h | 30 ++ .../Sensor/v1_0_6/EfiSensorV1_0_6.h | 30 ++ .../Sensor/v1_1_0/EfiSensorV1_1_0.h | 30 ++ .../Sensor/v1_1_1/EfiSensorV1_1_1.h | 30 ++ .../Sensor/v1_1_2/EfiSensorV1_1_2.h | 30 ++ .../Sensor/v1_2_0/EfiSensorV1_2_0.h | 30 ++ .../SensorCollection/EfiSensorCollection.h | 30 ++ .../v1_0_0/EfiSerialInterfaceV1_0_0.h | 30 ++ .../v1_0_10/EfiSerialInterfaceV1_0_10.h | 30 ++ .../v1_0_2/EfiSerialInterfaceV1_0_2.h | 30 ++ .../v1_0_3/EfiSerialInterfaceV1_0_3.h | 30 ++ .../v1_0_4/EfiSerialInterfaceV1_0_4.h | 30 ++ .../v1_0_5/EfiSerialInterfaceV1_0_5.h | 30 ++ .../v1_0_6/EfiSerialInterfaceV1_0_6.h | 30 ++ .../v1_0_7/EfiSerialInterfaceV1_0_7.h | 30 ++ .../v1_0_8/EfiSerialInterfaceV1_0_8.h | 30 ++ .../v1_0_9/EfiSerialInterfaceV1_0_9.h | 30 ++ .../v1_1_0/EfiSerialInterfaceV1_1_0.h | 30 ++ .../v1_1_1/EfiSerialInterfaceV1_1_1.h | 30 ++ .../v1_1_2/EfiSerialInterfaceV1_1_2.h | 30 ++ .../v1_1_3/EfiSerialInterfaceV1_1_3.h | 30 ++ .../v1_1_4/EfiSerialInterfaceV1_1_4.h | 30 ++ .../v1_1_5/EfiSerialInterfaceV1_1_5.h | 30 ++ .../v1_1_6/EfiSerialInterfaceV1_1_6.h | 30 ++ .../v1_1_7/EfiSerialInterfaceV1_1_7.h | 30 ++ .../EfiSerialInterfaceCollection.h | 30 ++ .../ServiceRoot/v1_0_0/EfiServiceRootV1_0_0.h | 30 ++ .../ServiceRoot/v1_0_2/EfiServiceRootV1_0_2.h | 30 ++ .../ServiceRoot/v1_0_3/EfiServiceRootV1_0_3.h | 30 ++ .../ServiceRoot/v1_0_4/EfiServiceRootV1_0_4.h | 30 ++ .../ServiceRoot/v1_0_5/EfiServiceRootV1_0_5.h | 30 ++ .../ServiceRoot/v1_0_6/EfiServiceRootV1_0_6.h | 30 ++ .../ServiceRoot/v1_0_7/EfiServiceRootV1_0_7.h | 30 ++ .../ServiceRoot/v1_0_8/EfiServiceRootV1_0_8.h | 30 ++ .../ServiceRoot/v1_0_9/EfiServiceRootV1_0_9.h | 30 ++ .../ServiceRoot/v1_1_0/EfiServiceRootV1_1_0.h | 30 ++ .../ServiceRoot/v1_1_1/EfiServiceRootV1_1_1.h | 30 ++ .../ServiceRoot/v1_1_2/EfiServiceRootV1_1_2.h | 30 ++ .../ServiceRoot/v1_1_3/EfiServiceRootV1_1_3.h | 30 ++ .../ServiceRoot/v1_1_4/EfiServiceRootV1_1_4.h | 30 ++ .../ServiceRoot/v1_1_5/EfiServiceRootV1_1_5.h | 30 ++ .../ServiceRoot/v1_1_6/EfiServiceRootV1_1_6.h | 30 ++ .../ServiceRoot/v1_2_0/EfiServiceRootV1_2_0.h | 30 ++ .../ServiceRoot/v1_2_1/EfiServiceRootV1_2_1.h | 30 ++ .../ServiceRoot/v1_2_2/EfiServiceRootV1_2_2.h | 30 ++ .../ServiceRoot/v1_2_3/EfiServiceRootV1_2_3.h | 30 ++ .../ServiceRoot/v1_2_4/EfiServiceRootV1_2_4.h | 30 ++ .../ServiceRoot/v1_3_0/EfiServiceRootV1_3_0.h | 30 ++ .../ServiceRoot/v1_3_1/EfiServiceRootV1_3_1.h | 30 ++ .../ServiceRoot/v1_3_2/EfiServiceRootV1_3_2.h | 30 ++ .../ServiceRoot/v1_3_3/EfiServiceRootV1_3_3.h | 30 ++ .../ServiceRoot/v1_3_4/EfiServiceRootV1_3_4.h | 30 ++ .../ServiceRoot/v1_3_5/EfiServiceRootV1_3_5.h | 30 ++ .../ServiceRoot/v1_4_0/EfiServiceRootV1_4_0.h | 30 ++ .../ServiceRoot/v1_4_1/EfiServiceRootV1_4_1.h | 30 ++ .../ServiceRoot/v1_4_2/EfiServiceRootV1_4_2.h | 30 ++ .../ServiceRoot/v1_4_3/EfiServiceRootV1_4_3.h | 30 ++ .../ServiceRoot/v1_5_0/EfiServiceRootV1_5_0.h | 30 ++ .../ServiceRoot/v1_5_1/EfiServiceRootV1_5_1.h | 30 ++ .../ServiceRoot/v1_5_2/EfiServiceRootV1_5_2.h | 30 ++ .../ServiceRoot/v1_6_0/EfiServiceRootV1_6_0.h | 30 ++ .../ServiceRoot/v1_7_0/EfiServiceRootV1_7_0.h | 30 ++ .../ServiceRoot/v1_8_0/EfiServiceRootV1_8_0.h | 30 ++ .../ServiceRoot/v1_9_0/EfiServiceRootV1_9_0.h | 30 ++ .../Session/v1_0_0/EfiSessionV1_0_0.h | 30 ++ .../Session/v1_0_2/EfiSessionV1_0_2.h | 30 ++ .../Session/v1_0_3/EfiSessionV1_0_3.h | 30 ++ .../Session/v1_0_4/EfiSessionV1_0_4.h | 30 ++ .../Session/v1_0_5/EfiSessionV1_0_5.h | 30 ++ .../Session/v1_0_6/EfiSessionV1_0_6.h | 30 ++ .../Session/v1_1_0/EfiSessionV1_1_0.h | 30 ++ .../Session/v1_1_1/EfiSessionV1_1_1.h | 30 ++ .../Session/v1_1_2/EfiSessionV1_1_2.h | 30 ++ .../Session/v1_1_3/EfiSessionV1_1_3.h | 30 ++ .../Session/v1_2_0/EfiSessionV1_2_0.h | 30 ++ .../Session/v1_2_1/EfiSessionV1_2_1.h | 30 ++ .../Session/v1_3_0/EfiSessionV1_3_0.h | 30 ++ .../SessionCollection/EfiSessionCollection.h | 30 ++ .../v1_0_0/EfiSessionServiceV1_0_0.h | 30 ++ .../v1_0_2/EfiSessionServiceV1_0_2.h | 30 ++ .../v1_0_3/EfiSessionServiceV1_0_3.h | 30 ++ .../v1_0_4/EfiSessionServiceV1_0_4.h | 30 ++ .../v1_0_5/EfiSessionServiceV1_0_5.h | 30 ++ .../v1_0_6/EfiSessionServiceV1_0_6.h | 30 ++ .../v1_0_7/EfiSessionServiceV1_0_7.h | 30 ++ .../v1_0_8/EfiSessionServiceV1_0_8.h | 30 ++ .../v1_0_9/EfiSessionServiceV1_0_9.h | 30 ++ .../v1_1_0/EfiSessionServiceV1_1_0.h | 30 ++ .../v1_1_1/EfiSessionServiceV1_1_1.h | 30 ++ .../v1_1_2/EfiSessionServiceV1_1_2.h | 30 ++ .../v1_1_3/EfiSessionServiceV1_1_3.h | 30 ++ .../v1_1_4/EfiSessionServiceV1_1_4.h | 30 ++ .../v1_1_5/EfiSessionServiceV1_1_5.h | 30 ++ .../v1_1_6/EfiSessionServiceV1_1_6.h | 30 ++ .../v1_1_7/EfiSessionServiceV1_1_7.h | 30 ++ .../v1_1_8/EfiSessionServiceV1_1_8.h | 30 ++ .../Signature/v1_0_0/EfiSignatureV1_0_0.h | 30 ++ .../Signature/v1_0_1/EfiSignatureV1_0_1.h | 30 ++ .../Signature/v1_0_2/EfiSignatureV1_0_2.h | 30 ++ .../EfiSignatureCollection.h | 30 ++ .../v1_0_0/EfiSimpleStorageV1_0_0.h | 30 ++ .../v1_0_2/EfiSimpleStorageV1_0_2.h | 30 ++ .../v1_0_3/EfiSimpleStorageV1_0_3.h | 30 ++ .../v1_0_4/EfiSimpleStorageV1_0_4.h | 30 ++ .../v1_0_5/EfiSimpleStorageV1_0_5.h | 30 ++ .../v1_0_6/EfiSimpleStorageV1_0_6.h | 30 ++ .../v1_0_7/EfiSimpleStorageV1_0_7.h | 30 ++ .../v1_0_8/EfiSimpleStorageV1_0_8.h | 30 ++ .../v1_1_0/EfiSimpleStorageV1_1_0.h | 30 ++ .../v1_1_1/EfiSimpleStorageV1_1_1.h | 30 ++ .../v1_1_2/EfiSimpleStorageV1_1_2.h | 30 ++ .../v1_1_3/EfiSimpleStorageV1_1_3.h | 30 ++ .../v1_1_4/EfiSimpleStorageV1_1_4.h | 30 ++ .../v1_1_5/EfiSimpleStorageV1_1_5.h | 30 ++ .../v1_1_6/EfiSimpleStorageV1_1_6.h | 30 ++ .../v1_2_0/EfiSimpleStorageV1_2_0.h | 30 ++ .../v1_2_1/EfiSimpleStorageV1_2_1.h | 30 ++ .../v1_2_2/EfiSimpleStorageV1_2_2.h | 30 ++ .../v1_2_3/EfiSimpleStorageV1_2_3.h | 30 ++ .../v1_2_4/EfiSimpleStorageV1_2_4.h | 30 ++ .../v1_3_0/EfiSimpleStorageV1_3_0.h | 30 ++ .../v1_3_1/EfiSimpleStorageV1_3_1.h | 30 ++ .../EfiSimpleStorageCollection.h | 30 ++ .../v1_0_0/EfiSoftwareInventoryV1_0_0.h | 30 ++ .../v1_0_1/EfiSoftwareInventoryV1_0_1.h | 30 ++ .../v1_0_2/EfiSoftwareInventoryV1_0_2.h | 30 ++ .../v1_0_3/EfiSoftwareInventoryV1_0_3.h | 30 ++ .../v1_0_4/EfiSoftwareInventoryV1_0_4.h | 30 ++ .../v1_0_5/EfiSoftwareInventoryV1_0_5.h | 30 ++ .../v1_1_0/EfiSoftwareInventoryV1_1_0.h | 30 ++ .../v1_1_1/EfiSoftwareInventoryV1_1_1.h | 30 ++ .../v1_1_2/EfiSoftwareInventoryV1_1_2.h | 30 ++ .../v1_1_3/EfiSoftwareInventoryV1_1_3.h | 30 ++ .../v1_1_4/EfiSoftwareInventoryV1_1_4.h | 30 ++ .../v1_2_0/EfiSoftwareInventoryV1_2_0.h | 30 ++ .../v1_2_1/EfiSoftwareInventoryV1_2_1.h | 30 ++ .../v1_2_2/EfiSoftwareInventoryV1_2_2.h | 30 ++ .../v1_2_3/EfiSoftwareInventoryV1_2_3.h | 30 ++ .../v1_3_0/EfiSoftwareInventoryV1_3_0.h | 30 ++ .../v1_4_0/EfiSoftwareInventoryV1_4_0.h | 30 ++ .../EfiSoftwareInventoryCollection.h | 30 ++ .../Storage/v1_0_1/EfiStorageV1_0_1.h | 30 ++ .../Storage/v1_0_10/EfiStorageV1_0_10.h | 30 ++ .../Storage/v1_0_2/EfiStorageV1_0_2.h | 30 ++ .../Storage/v1_0_3/EfiStorageV1_0_3.h | 30 ++ .../Storage/v1_0_4/EfiStorageV1_0_4.h | 30 ++ .../Storage/v1_0_5/EfiStorageV1_0_5.h | 30 ++ .../Storage/v1_0_6/EfiStorageV1_0_6.h | 30 ++ .../Storage/v1_0_7/EfiStorageV1_0_7.h | 30 ++ .../Storage/v1_0_8/EfiStorageV1_0_8.h | 30 ++ .../Storage/v1_0_9/EfiStorageV1_0_9.h | 30 ++ .../Storage/v1_10_0/EfiStorageV1_10_0.h | 30 ++ .../Storage/v1_1_1/EfiStorageV1_1_1.h | 30 ++ .../Storage/v1_1_2/EfiStorageV1_1_2.h | 30 ++ .../Storage/v1_1_3/EfiStorageV1_1_3.h | 30 ++ .../Storage/v1_1_4/EfiStorageV1_1_4.h | 30 ++ .../Storage/v1_1_5/EfiStorageV1_1_5.h | 30 ++ .../Storage/v1_1_6/EfiStorageV1_1_6.h | 30 ++ .../Storage/v1_1_7/EfiStorageV1_1_7.h | 30 ++ .../Storage/v1_1_8/EfiStorageV1_1_8.h | 30 ++ .../Storage/v1_1_9/EfiStorageV1_1_9.h | 30 ++ .../Storage/v1_2_0/EfiStorageV1_2_0.h | 30 ++ .../Storage/v1_2_1/EfiStorageV1_2_1.h | 30 ++ .../Storage/v1_2_2/EfiStorageV1_2_2.h | 30 ++ .../Storage/v1_2_3/EfiStorageV1_2_3.h | 30 ++ .../Storage/v1_2_4/EfiStorageV1_2_4.h | 30 ++ .../Storage/v1_2_5/EfiStorageV1_2_5.h | 30 ++ .../Storage/v1_2_6/EfiStorageV1_2_6.h | 30 ++ .../Storage/v1_2_7/EfiStorageV1_2_7.h | 30 ++ .../Storage/v1_3_0/EfiStorageV1_3_0.h | 30 ++ .../Storage/v1_3_1/EfiStorageV1_3_1.h | 30 ++ .../Storage/v1_3_2/EfiStorageV1_3_2.h | 30 ++ .../Storage/v1_3_3/EfiStorageV1_3_3.h | 30 ++ .../Storage/v1_3_4/EfiStorageV1_3_4.h | 30 ++ .../Storage/v1_3_5/EfiStorageV1_3_5.h | 30 ++ .../Storage/v1_3_6/EfiStorageV1_3_6.h | 30 ++ .../Storage/v1_3_7/EfiStorageV1_3_7.h | 30 ++ .../Storage/v1_4_0/EfiStorageV1_4_0.h | 30 ++ .../Storage/v1_4_1/EfiStorageV1_4_1.h | 30 ++ .../Storage/v1_4_2/EfiStorageV1_4_2.h | 30 ++ .../Storage/v1_4_3/EfiStorageV1_4_3.h | 30 ++ .../Storage/v1_4_4/EfiStorageV1_4_4.h | 30 ++ .../Storage/v1_4_5/EfiStorageV1_4_5.h | 30 ++ .../Storage/v1_4_6/EfiStorageV1_4_6.h | 30 ++ .../Storage/v1_5_0/EfiStorageV1_5_0.h | 30 ++ .../Storage/v1_5_1/EfiStorageV1_5_1.h | 30 ++ .../Storage/v1_5_2/EfiStorageV1_5_2.h | 30 ++ .../Storage/v1_5_3/EfiStorageV1_5_3.h | 30 ++ .../Storage/v1_5_4/EfiStorageV1_5_4.h | 30 ++ .../Storage/v1_5_5/EfiStorageV1_5_5.h | 30 ++ .../Storage/v1_6_0/EfiStorageV1_6_0.h | 30 ++ .../Storage/v1_6_1/EfiStorageV1_6_1.h | 30 ++ .../Storage/v1_6_2/EfiStorageV1_6_2.h | 30 ++ .../Storage/v1_6_3/EfiStorageV1_6_3.h | 30 ++ .../Storage/v1_6_4/EfiStorageV1_6_4.h | 30 ++ .../Storage/v1_7_0/EfiStorageV1_7_0.h | 30 ++ .../Storage/v1_7_1/EfiStorageV1_7_1.h | 30 ++ .../Storage/v1_7_2/EfiStorageV1_7_2.h | 30 ++ .../Storage/v1_7_3/EfiStorageV1_7_3.h | 30 ++ .../Storage/v1_8_0/EfiStorageV1_8_0.h | 30 ++ .../Storage/v1_8_1/EfiStorageV1_8_1.h | 30 ++ .../Storage/v1_8_2/EfiStorageV1_8_2.h | 30 ++ .../Storage/v1_9_0/EfiStorageV1_9_0.h | 30 ++ .../Storage/v1_9_1/EfiStorageV1_9_1.h | 30 ++ .../StorageCollection/EfiStorageCollection.h | 30 ++ .../v1_0_0/EfiStorageControllerV1_0_0.h | 30 ++ .../v1_0_1/EfiStorageControllerV1_0_1.h | 30 ++ .../v1_1_0/EfiStorageControllerV1_1_0.h | 30 ++ .../EfiStorageControllerCollection.h | 30 ++ .../Switch/v1_0_0/EfiSwitchV1_0_0.h | 30 ++ .../Switch/v1_0_1/EfiSwitchV1_0_1.h | 30 ++ .../Switch/v1_0_2/EfiSwitchV1_0_2.h | 30 ++ .../Switch/v1_0_3/EfiSwitchV1_0_3.h | 30 ++ .../Switch/v1_0_4/EfiSwitchV1_0_4.h | 30 ++ .../Switch/v1_0_5/EfiSwitchV1_0_5.h | 30 ++ .../Switch/v1_0_6/EfiSwitchV1_0_6.h | 30 ++ .../Switch/v1_0_7/EfiSwitchV1_0_7.h | 30 ++ .../Switch/v1_0_8/EfiSwitchV1_0_8.h | 30 ++ .../Switch/v1_1_0/EfiSwitchV1_1_0.h | 30 ++ .../Switch/v1_1_1/EfiSwitchV1_1_1.h | 30 ++ .../Switch/v1_1_2/EfiSwitchV1_1_2.h | 30 ++ .../Switch/v1_1_3/EfiSwitchV1_1_3.h | 30 ++ .../Switch/v1_1_4/EfiSwitchV1_1_4.h | 30 ++ .../Switch/v1_1_5/EfiSwitchV1_1_5.h | 30 ++ .../Switch/v1_2_0/EfiSwitchV1_2_0.h | 30 ++ .../Switch/v1_2_1/EfiSwitchV1_2_1.h | 30 ++ .../Switch/v1_2_2/EfiSwitchV1_2_2.h | 30 ++ .../Switch/v1_3_0/EfiSwitchV1_3_0.h | 30 ++ .../Switch/v1_3_1/EfiSwitchV1_3_1.h | 30 ++ .../Switch/v1_3_2/EfiSwitchV1_3_2.h | 30 ++ .../Switch/v1_4_0/EfiSwitchV1_4_0.h | 30 ++ .../Switch/v1_4_1/EfiSwitchV1_4_1.h | 30 ++ .../Switch/v1_5_0/EfiSwitchV1_5_0.h | 30 ++ .../SwitchCollection/EfiSwitchCollection.h | 30 ++ .../Task/v1_0_0/EfiTaskV1_0_0.h | 30 ++ .../Task/v1_0_2/EfiTaskV1_0_2.h | 30 ++ .../Task/v1_0_3/EfiTaskV1_0_3.h | 30 ++ .../Task/v1_0_4/EfiTaskV1_0_4.h | 30 ++ .../Task/v1_0_5/EfiTaskV1_0_5.h | 30 ++ .../Task/v1_0_6/EfiTaskV1_0_6.h | 30 ++ .../Task/v1_0_7/EfiTaskV1_0_7.h | 30 ++ .../Task/v1_0_8/EfiTaskV1_0_8.h | 30 ++ .../Task/v1_0_9/EfiTaskV1_0_9.h | 30 ++ .../Task/v1_1_0/EfiTaskV1_1_0.h | 30 ++ .../Task/v1_1_1/EfiTaskV1_1_1.h | 30 ++ .../Task/v1_1_2/EfiTaskV1_1_2.h | 30 ++ .../Task/v1_1_3/EfiTaskV1_1_3.h | 30 ++ .../Task/v1_1_4/EfiTaskV1_1_4.h | 30 ++ .../Task/v1_1_5/EfiTaskV1_1_5.h | 30 ++ .../Task/v1_1_6/EfiTaskV1_1_6.h | 30 ++ .../Task/v1_2_0/EfiTaskV1_2_0.h | 30 ++ .../Task/v1_2_1/EfiTaskV1_2_1.h | 30 ++ .../Task/v1_2_2/EfiTaskV1_2_2.h | 30 ++ .../Task/v1_2_3/EfiTaskV1_2_3.h | 30 ++ .../Task/v1_2_4/EfiTaskV1_2_4.h | 30 ++ .../Task/v1_2_5/EfiTaskV1_2_5.h | 30 ++ .../Task/v1_3_0/EfiTaskV1_3_0.h | 30 ++ .../Task/v1_3_1/EfiTaskV1_3_1.h | 30 ++ .../Task/v1_3_2/EfiTaskV1_3_2.h | 30 ++ .../Task/v1_3_3/EfiTaskV1_3_3.h | 30 ++ .../Task/v1_3_4/EfiTaskV1_3_4.h | 30 ++ .../Task/v1_3_5/EfiTaskV1_3_5.h | 30 ++ .../Task/v1_4_0/EfiTaskV1_4_0.h | 30 ++ .../Task/v1_4_1/EfiTaskV1_4_1.h | 30 ++ .../Task/v1_4_2/EfiTaskV1_4_2.h | 30 ++ .../Task/v1_4_3/EfiTaskV1_4_3.h | 30 ++ .../Task/v1_4_4/EfiTaskV1_4_4.h | 30 ++ .../Task/v1_5_0/EfiTaskV1_5_0.h | 30 ++ .../Task/v1_5_1/EfiTaskV1_5_1.h | 30 ++ .../TaskCollection/EfiTaskCollection.h | 30 ++ .../TaskService/v1_0_0/EfiTaskServiceV1_0_0.h | 30 ++ .../TaskService/v1_0_2/EfiTaskServiceV1_0_2.h | 30 ++ .../TaskService/v1_0_3/EfiTaskServiceV1_0_3.h | 30 ++ .../TaskService/v1_0_4/EfiTaskServiceV1_0_4.h | 30 ++ .../TaskService/v1_0_5/EfiTaskServiceV1_0_5.h | 30 ++ .../TaskService/v1_0_6/EfiTaskServiceV1_0_6.h | 30 ++ .../TaskService/v1_0_7/EfiTaskServiceV1_0_7.h | 30 ++ .../TaskService/v1_0_8/EfiTaskServiceV1_0_8.h | 30 ++ .../TaskService/v1_0_9/EfiTaskServiceV1_0_9.h | 30 ++ .../TaskService/v1_1_0/EfiTaskServiceV1_1_0.h | 30 ++ .../TaskService/v1_1_1/EfiTaskServiceV1_1_1.h | 30 ++ .../TaskService/v1_1_2/EfiTaskServiceV1_1_2.h | 30 ++ .../TaskService/v1_1_3/EfiTaskServiceV1_1_3.h | 30 ++ .../TaskService/v1_1_4/EfiTaskServiceV1_1_4.h | 30 ++ .../TaskService/v1_1_5/EfiTaskServiceV1_1_5.h | 30 ++ .../TaskService/v1_1_6/EfiTaskServiceV1_1_6.h | 30 ++ .../v1_0_0/EfiTelemetryServiceV1_0_0.h | 30 ++ .../v1_0_1/EfiTelemetryServiceV1_0_1.h | 30 ++ .../v1_0_2/EfiTelemetryServiceV1_0_2.h | 30 ++ .../v1_0_3/EfiTelemetryServiceV1_0_3.h | 30 ++ .../v1_0_4/EfiTelemetryServiceV1_0_4.h | 30 ++ .../v1_1_0/EfiTelemetryServiceV1_1_0.h | 30 ++ .../v1_1_1/EfiTelemetryServiceV1_1_1.h | 30 ++ .../v1_1_2/EfiTelemetryServiceV1_1_2.h | 30 ++ .../v1_1_3/EfiTelemetryServiceV1_1_3.h | 30 ++ .../v1_1_4/EfiTelemetryServiceV1_1_4.h | 30 ++ .../v1_2_0/EfiTelemetryServiceV1_2_0.h | 30 ++ .../v1_2_1/EfiTelemetryServiceV1_2_1.h | 30 ++ .../v1_2_2/EfiTelemetryServiceV1_2_2.h | 30 ++ .../v1_3_0/EfiTelemetryServiceV1_3_0.h | 30 ++ .../Thermal/v1_0_0/EfiThermalV1_0_0.h | 30 ++ .../Thermal/v1_0_1/EfiThermalV1_0_1.h | 30 ++ .../Thermal/v1_0_10/EfiThermalV1_0_10.h | 30 ++ .../Thermal/v1_0_11/EfiThermalV1_0_11.h | 30 ++ .../Thermal/v1_0_2/EfiThermalV1_0_2.h | 30 ++ .../Thermal/v1_0_3/EfiThermalV1_0_3.h | 30 ++ .../Thermal/v1_0_4/EfiThermalV1_0_4.h | 30 ++ .../Thermal/v1_0_5/EfiThermalV1_0_5.h | 30 ++ .../Thermal/v1_0_6/EfiThermalV1_0_6.h | 30 ++ .../Thermal/v1_0_7/EfiThermalV1_0_7.h | 30 ++ .../Thermal/v1_0_8/EfiThermalV1_0_8.h | 30 ++ .../Thermal/v1_0_9/EfiThermalV1_0_9.h | 30 ++ .../Thermal/v1_1_0/EfiThermalV1_1_0.h | 30 ++ .../Thermal/v1_1_1/EfiThermalV1_1_1.h | 30 ++ .../Thermal/v1_1_2/EfiThermalV1_1_2.h | 30 ++ .../Thermal/v1_1_3/EfiThermalV1_1_3.h | 30 ++ .../Thermal/v1_1_4/EfiThermalV1_1_4.h | 30 ++ .../Thermal/v1_1_5/EfiThermalV1_1_5.h | 30 ++ .../Thermal/v1_1_6/EfiThermalV1_1_6.h | 30 ++ .../Thermal/v1_1_7/EfiThermalV1_1_7.h | 30 ++ .../Thermal/v1_1_8/EfiThermalV1_1_8.h | 30 ++ .../Thermal/v1_1_9/EfiThermalV1_1_9.h | 30 ++ .../Thermal/v1_2_0/EfiThermalV1_2_0.h | 30 ++ .../Thermal/v1_2_1/EfiThermalV1_2_1.h | 30 ++ .../Thermal/v1_2_2/EfiThermalV1_2_2.h | 30 ++ .../Thermal/v1_2_3/EfiThermalV1_2_3.h | 30 ++ .../Thermal/v1_2_4/EfiThermalV1_2_4.h | 30 ++ .../Thermal/v1_2_5/EfiThermalV1_2_5.h | 30 ++ .../Thermal/v1_2_6/EfiThermalV1_2_6.h | 30 ++ .../Thermal/v1_2_7/EfiThermalV1_2_7.h | 30 ++ .../Thermal/v1_2_8/EfiThermalV1_2_8.h | 30 ++ .../Thermal/v1_3_0/EfiThermalV1_3_0.h | 30 ++ .../Thermal/v1_3_1/EfiThermalV1_3_1.h | 30 ++ .../Thermal/v1_3_2/EfiThermalV1_3_2.h | 30 ++ .../Thermal/v1_3_3/EfiThermalV1_3_3.h | 30 ++ .../Thermal/v1_3_4/EfiThermalV1_3_4.h | 30 ++ .../Thermal/v1_3_5/EfiThermalV1_3_5.h | 30 ++ .../Thermal/v1_3_6/EfiThermalV1_3_6.h | 30 ++ .../Thermal/v1_3_7/EfiThermalV1_3_7.h | 30 ++ .../Thermal/v1_4_0/EfiThermalV1_4_0.h | 30 ++ .../Thermal/v1_4_1/EfiThermalV1_4_1.h | 30 ++ .../Thermal/v1_4_2/EfiThermalV1_4_2.h | 30 ++ .../Thermal/v1_4_3/EfiThermalV1_4_3.h | 30 ++ .../Thermal/v1_4_4/EfiThermalV1_4_4.h | 30 ++ .../Thermal/v1_4_5/EfiThermalV1_4_5.h | 30 ++ .../Thermal/v1_4_6/EfiThermalV1_4_6.h | 30 ++ .../Thermal/v1_5_0/EfiThermalV1_5_0.h | 30 ++ .../Thermal/v1_5_1/EfiThermalV1_5_1.h | 30 ++ .../Thermal/v1_5_2/EfiThermalV1_5_2.h | 30 ++ .../Thermal/v1_5_3/EfiThermalV1_5_3.h | 30 ++ .../Thermal/v1_5_4/EfiThermalV1_5_4.h | 30 ++ .../Thermal/v1_5_5/EfiThermalV1_5_5.h | 30 ++ .../Thermal/v1_6_0/EfiThermalV1_6_0.h | 30 ++ .../Thermal/v1_6_1/EfiThermalV1_6_1.h | 30 ++ .../Thermal/v1_6_2/EfiThermalV1_6_2.h | 30 ++ .../Thermal/v1_7_0/EfiThermalV1_7_0.h | 30 ++ .../v1_0_0/EfiThermalMetricsV1_0_0.h | 30 ++ .../v1_0_0/EfiThermalSubsystemV1_0_0.h | 30 ++ .../Triggers/v1_0_0/EfiTriggersV1_0_0.h | 30 ++ .../Triggers/v1_0_1/EfiTriggersV1_0_1.h | 30 ++ .../Triggers/v1_0_2/EfiTriggersV1_0_2.h | 30 ++ .../Triggers/v1_0_3/EfiTriggersV1_0_3.h | 30 ++ .../Triggers/v1_0_4/EfiTriggersV1_0_4.h | 30 ++ .../Triggers/v1_0_5/EfiTriggersV1_0_5.h | 30 ++ .../Triggers/v1_1_0/EfiTriggersV1_1_0.h | 30 ++ .../Triggers/v1_1_1/EfiTriggersV1_1_1.h | 30 ++ .../Triggers/v1_1_2/EfiTriggersV1_1_2.h | 30 ++ .../Triggers/v1_1_3/EfiTriggersV1_1_3.h | 30 ++ .../EfiTriggersCollection.h | 30 ++ .../v1_0_0/EfiUpdateServiceV1_0_0.h | 30 ++ .../v1_0_1/EfiUpdateServiceV1_0_1.h | 30 ++ .../v1_0_10/EfiUpdateServiceV1_0_10.h | 30 ++ .../v1_0_2/EfiUpdateServiceV1_0_2.h | 30 ++ .../v1_0_3/EfiUpdateServiceV1_0_3.h | 30 ++ .../v1_0_4/EfiUpdateServiceV1_0_4.h | 30 ++ .../v1_0_5/EfiUpdateServiceV1_0_5.h | 30 ++ .../v1_0_6/EfiUpdateServiceV1_0_6.h | 30 ++ .../v1_0_7/EfiUpdateServiceV1_0_7.h | 30 ++ .../v1_0_8/EfiUpdateServiceV1_0_8.h | 30 ++ .../v1_0_9/EfiUpdateServiceV1_0_9.h | 30 ++ .../v1_1_0/EfiUpdateServiceV1_1_0.h | 30 ++ .../v1_1_1/EfiUpdateServiceV1_1_1.h | 30 ++ .../v1_1_2/EfiUpdateServiceV1_1_2.h | 30 ++ .../v1_1_3/EfiUpdateServiceV1_1_3.h | 30 ++ .../v1_1_4/EfiUpdateServiceV1_1_4.h | 30 ++ .../v1_1_5/EfiUpdateServiceV1_1_5.h | 30 ++ .../v1_1_6/EfiUpdateServiceV1_1_6.h | 30 ++ .../v1_1_7/EfiUpdateServiceV1_1_7.h | 30 ++ .../v1_1_8/EfiUpdateServiceV1_1_8.h | 30 ++ .../v1_1_9/EfiUpdateServiceV1_1_9.h | 30 ++ .../v1_2_0/EfiUpdateServiceV1_2_0.h | 30 ++ .../v1_2_1/EfiUpdateServiceV1_2_1.h | 30 ++ .../v1_2_2/EfiUpdateServiceV1_2_2.h | 30 ++ .../v1_2_3/EfiUpdateServiceV1_2_3.h | 30 ++ .../v1_2_4/EfiUpdateServiceV1_2_4.h | 30 ++ .../v1_2_5/EfiUpdateServiceV1_2_5.h | 30 ++ .../v1_2_6/EfiUpdateServiceV1_2_6.h | 30 ++ .../v1_2_7/EfiUpdateServiceV1_2_7.h | 30 ++ .../v1_2_8/EfiUpdateServiceV1_2_8.h | 30 ++ .../v1_3_0/EfiUpdateServiceV1_3_0.h | 30 ++ .../v1_3_1/EfiUpdateServiceV1_3_1.h | 30 ++ .../v1_3_2/EfiUpdateServiceV1_3_2.h | 30 ++ .../v1_3_3/EfiUpdateServiceV1_3_3.h | 30 ++ .../v1_3_4/EfiUpdateServiceV1_3_4.h | 30 ++ .../v1_3_5/EfiUpdateServiceV1_3_5.h | 30 ++ .../v1_3_6/EfiUpdateServiceV1_3_6.h | 30 ++ .../v1_4_0/EfiUpdateServiceV1_4_0.h | 30 ++ .../v1_4_1/EfiUpdateServiceV1_4_1.h | 30 ++ .../v1_4_2/EfiUpdateServiceV1_4_2.h | 30 ++ .../v1_4_3/EfiUpdateServiceV1_4_3.h | 30 ++ .../v1_4_4/EfiUpdateServiceV1_4_4.h | 30 ++ .../v1_4_5/EfiUpdateServiceV1_4_5.h | 30 ++ .../v1_5_0/EfiUpdateServiceV1_5_0.h | 30 ++ .../v1_5_1/EfiUpdateServiceV1_5_1.h | 30 ++ .../v1_5_2/EfiUpdateServiceV1_5_2.h | 30 ++ .../v1_5_3/EfiUpdateServiceV1_5_3.h | 30 ++ .../v1_5_4/EfiUpdateServiceV1_5_4.h | 30 ++ .../v1_6_0/EfiUpdateServiceV1_6_0.h | 30 ++ .../v1_6_1/EfiUpdateServiceV1_6_1.h | 30 ++ .../v1_6_2/EfiUpdateServiceV1_6_2.h | 30 ++ .../v1_6_3/EfiUpdateServiceV1_6_3.h | 30 ++ .../v1_7_0/EfiUpdateServiceV1_7_0.h | 30 ++ .../v1_7_1/EfiUpdateServiceV1_7_1.h | 30 ++ .../v1_7_2/EfiUpdateServiceV1_7_2.h | 30 ++ .../v1_7_3/EfiUpdateServiceV1_7_3.h | 30 ++ .../v1_8_0/EfiUpdateServiceV1_8_0.h | 30 ++ .../v1_8_1/EfiUpdateServiceV1_8_1.h | 30 ++ .../v1_8_2/EfiUpdateServiceV1_8_2.h | 30 ++ .../v1_8_3/EfiUpdateServiceV1_8_3.h | 30 ++ .../VCATEntry/v1_0_0/EfiVCATEntryV1_0_0.h | 30 ++ .../VCATEntry/v1_0_1/EfiVCATEntryV1_0_1.h | 30 ++ .../EfiVCATEntryCollection.h | 30 ++ .../v1_0_0/EfiVLanNetworkInterfaceV1_0_0.h | 30 ++ .../v1_0_1/EfiVLanNetworkInterfaceV1_0_1.h | 30 ++ .../v1_0_2/EfiVLanNetworkInterfaceV1_0_2.h | 30 ++ .../v1_0_3/EfiVLanNetworkInterfaceV1_0_3.h | 30 ++ .../v1_0_4/EfiVLanNetworkInterfaceV1_0_4.h | 30 ++ .../v1_0_5/EfiVLanNetworkInterfaceV1_0_5.h | 30 ++ .../v1_0_6/EfiVLanNetworkInterfaceV1_0_6.h | 30 ++ .../v1_0_7/EfiVLanNetworkInterfaceV1_0_7.h | 30 ++ .../v1_0_8/EfiVLanNetworkInterfaceV1_0_8.h | 30 ++ .../v1_0_9/EfiVLanNetworkInterfaceV1_0_9.h | 30 ++ .../v1_1_0/EfiVLanNetworkInterfaceV1_1_0.h | 30 ++ .../v1_1_1/EfiVLanNetworkInterfaceV1_1_1.h | 30 ++ .../v1_1_2/EfiVLanNetworkInterfaceV1_1_2.h | 30 ++ .../v1_1_3/EfiVLanNetworkInterfaceV1_1_3.h | 30 ++ .../v1_1_4/EfiVLanNetworkInterfaceV1_1_4.h | 30 ++ .../v1_1_5/EfiVLanNetworkInterfaceV1_1_5.h | 30 ++ .../v1_2_0/EfiVLanNetworkInterfaceV1_2_0.h | 30 ++ .../EfiVLanNetworkInterfaceCollection.h | 30 ++ .../v1_0_0/EfiVirtualMediaV1_0_0.h | 30 ++ .../v1_0_2/EfiVirtualMediaV1_0_2.h | 30 ++ .../v1_0_3/EfiVirtualMediaV1_0_3.h | 30 ++ .../v1_0_4/EfiVirtualMediaV1_0_4.h | 30 ++ .../v1_0_5/EfiVirtualMediaV1_0_5.h | 30 ++ .../v1_0_6/EfiVirtualMediaV1_0_6.h | 30 ++ .../v1_0_7/EfiVirtualMediaV1_0_7.h | 30 ++ .../v1_1_0/EfiVirtualMediaV1_1_0.h | 30 ++ .../v1_1_1/EfiVirtualMediaV1_1_1.h | 30 ++ .../v1_1_2/EfiVirtualMediaV1_1_2.h | 30 ++ .../v1_1_3/EfiVirtualMediaV1_1_3.h | 30 ++ .../v1_1_4/EfiVirtualMediaV1_1_4.h | 30 ++ .../v1_1_5/EfiVirtualMediaV1_1_5.h | 30 ++ .../v1_2_0/EfiVirtualMediaV1_2_0.h | 30 ++ .../v1_2_1/EfiVirtualMediaV1_2_1.h | 30 ++ .../v1_2_2/EfiVirtualMediaV1_2_2.h | 30 ++ .../v1_2_3/EfiVirtualMediaV1_2_3.h | 30 ++ .../v1_2_4/EfiVirtualMediaV1_2_4.h | 30 ++ .../v1_3_0/EfiVirtualMediaV1_3_0.h | 30 ++ .../v1_3_1/EfiVirtualMediaV1_3_1.h | 30 ++ .../v1_3_2/EfiVirtualMediaV1_3_2.h | 30 ++ .../EfiVirtualMediaCollection.h | 30 ++ .../Volume/v1_0_0/EfiVolumeV1_0_0.h | 30 ++ .../Volume/v1_0_1/EfiVolumeV1_0_1.h | 30 ++ .../Volume/v1_0_2/EfiVolumeV1_0_2.h | 30 ++ .../Volume/v1_0_3/EfiVolumeV1_0_3.h | 30 ++ .../Volume/v1_0_4/EfiVolumeV1_0_4.h | 30 ++ .../Volume/v1_1_0/EfiVolumeV1_1_0.h | 30 ++ .../Volume/v1_1_1/EfiVolumeV1_1_1.h | 30 ++ .../Volume/v1_1_2/EfiVolumeV1_1_2.h | 30 ++ .../Volume/v1_1_3/EfiVolumeV1_1_3.h | 30 ++ .../Volume/v1_1_4/EfiVolumeV1_1_4.h | 30 ++ .../Volume/v1_1_5/EfiVolumeV1_1_5.h | 30 ++ .../Volume/v1_2_0/EfiVolumeV1_2_0.h | 30 ++ .../Volume/v1_2_1/EfiVolumeV1_2_1.h | 30 ++ .../Volume/v1_2_2/EfiVolumeV1_2_2.h | 30 ++ .../Volume/v1_2_3/EfiVolumeV1_2_3.h | 30 ++ .../Volume/v1_2_4/EfiVolumeV1_2_4.h | 30 ++ .../Volume/v1_2_5/EfiVolumeV1_2_5.h | 30 ++ .../Volume/v1_3_0/EfiVolumeV1_3_0.h | 30 ++ .../Volume/v1_3_1/EfiVolumeV1_3_1.h | 30 ++ .../Volume/v1_3_2/EfiVolumeV1_3_2.h | 30 ++ .../Volume/v1_3_3/EfiVolumeV1_3_3.h | 30 ++ .../Volume/v1_3_4/EfiVolumeV1_3_4.h | 30 ++ .../Volume/v1_4_0/EfiVolumeV1_4_0.h | 30 ++ .../Volume/v1_4_1/EfiVolumeV1_4_1.h | 30 ++ .../Volume/v1_4_2/EfiVolumeV1_4_2.h | 30 ++ .../Volume/v1_4_3/EfiVolumeV1_4_3.h | 30 ++ .../Volume/v1_5_0/EfiVolumeV1_5_0.h | 30 ++ .../Volume/v1_5_1/EfiVolumeV1_5_1.h | 30 ++ .../Volume/v1_6_0/EfiVolumeV1_6_0.h | 30 ++ .../Volume/v1_6_1/EfiVolumeV1_6_1.h | 30 ++ .../VolumeCollection/EfiVolumeCollection.h | 30 ++ .../Zone/v1_0_0/EfiZoneV1_0_0.h | 30 ++ .../Zone/v1_0_1/EfiZoneV1_0_1.h | 30 ++ .../Zone/v1_0_2/EfiZoneV1_0_2.h | 30 ++ .../Zone/v1_0_3/EfiZoneV1_0_3.h | 30 ++ .../Zone/v1_0_4/EfiZoneV1_0_4.h | 30 ++ .../Zone/v1_0_5/EfiZoneV1_0_5.h | 30 ++ .../Zone/v1_0_6/EfiZoneV1_0_6.h | 30 ++ .../Zone/v1_1_0/EfiZoneV1_1_0.h | 30 ++ .../Zone/v1_1_1/EfiZoneV1_1_1.h | 30 ++ .../Zone/v1_1_2/EfiZoneV1_1_2.h | 30 ++ .../Zone/v1_1_3/EfiZoneV1_1_3.h | 30 ++ .../Zone/v1_1_4/EfiZoneV1_1_4.h | 30 ++ .../Zone/v1_1_5/EfiZoneV1_1_5.h | 30 ++ .../Zone/v1_2_0/EfiZoneV1_2_0.h | 30 ++ .../Zone/v1_2_1/EfiZoneV1_2_1.h | 30 ++ .../Zone/v1_2_2/EfiZoneV1_2_2.h | 30 ++ .../Zone/v1_2_3/EfiZoneV1_2_3.h | 30 ++ .../Zone/v1_2_4/EfiZoneV1_2_4.h | 30 ++ .../Zone/v1_3_0/EfiZoneV1_3_0.h | 30 ++ .../Zone/v1_3_1/EfiZoneV1_3_1.h | 30 ++ .../Zone/v1_3_2/EfiZoneV1_3_2.h | 30 ++ .../Zone/v1_3_3/EfiZoneV1_3_3.h | 30 ++ .../Zone/v1_4_0/EfiZoneV1_4_0.h | 30 ++ .../Zone/v1_4_1/EfiZoneV1_4_1.h | 30 ++ .../Zone/v1_4_2/EfiZoneV1_4_2.h | 30 ++ .../Zone/v1_5_0/EfiZoneV1_5_0.h | 30 ++ .../Zone/v1_6_0/EfiZoneV1_6_0.h | 30 ++ .../ZoneCollection/EfiZoneCollection.h | 30 ++ .../v1_0_0/EfiredfisherrorV1_0_0.h | 30 ++ .../v1_0_1/EfiredfisherrorV1_0_1.h | 30 ++ 7044 files changed, 1202176 insertions(+) create mode 100644 RedfishClientPkg/Converter/AccelerationFunction/v1_0_0/AccelerationFunction_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccelerationFunction/v1_0_0/RedfishAccelerationFunction_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccelerationFunction/v1_0_1/AccelerationFunction_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccelerationFunction/v1_0_1/RedfishAccelerationFunction_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccelerationFunction/v1_0_2/AccelerationFunction_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccelerationFunction/v1_0_2/RedfishAccelerationFunction_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccelerationFunction/v1_0_3/AccelerationFunction_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccelerationFunction/v1_0_3/RedfishAccelerationFunction_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccelerationFunctionCollection/AccelerationFunctionCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccelerationFunctionCollection/RedfishAccelerationFunctionCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_0_0/AccountService_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_0_0/RedfishAccountService_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_0_10/AccountService_V1_0_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_0_10/RedfishAccountService_V1_0_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_0_11/AccountService_V1_0_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_0_11/RedfishAccountService_V1_0_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_0_2/AccountService_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_0_2/RedfishAccountService_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_0_3/AccountService_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_0_3/RedfishAccountService_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_0_4/AccountService_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_0_4/RedfishAccountService_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_0_5/AccountService_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_0_5/RedfishAccountService_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_0_6/AccountService_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_0_6/RedfishAccountService_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_0_7/AccountService_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_0_7/RedfishAccountService_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_0_8/AccountService_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_0_8/RedfishAccountService_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_0_9/AccountService_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_0_9/RedfishAccountService_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_1_0/AccountService_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_1_0/RedfishAccountService_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_1_1/AccountService_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_1_1/RedfishAccountService_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_1_2/AccountService_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_1_2/RedfishAccountService_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_1_3/AccountService_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_1_3/RedfishAccountService_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_1_4/AccountService_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_1_4/RedfishAccountService_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_1_5/AccountService_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_1_5/RedfishAccountService_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_1_6/AccountService_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_1_6/RedfishAccountService_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_1_7/AccountService_V1_1_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_1_7/RedfishAccountService_V1_1_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_1_8/AccountService_V1_1_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_1_8/RedfishAccountService_V1_1_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_2_0/AccountService_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_2_0/RedfishAccountService_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_2_1/AccountService_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_2_1/RedfishAccountService_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_2_2/AccountService_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_2_2/RedfishAccountService_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_2_3/AccountService_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_2_3/RedfishAccountService_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_2_4/AccountService_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_2_4/RedfishAccountService_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_2_5/AccountService_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_2_5/RedfishAccountService_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_2_6/AccountService_V1_2_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_2_6/RedfishAccountService_V1_2_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_2_7/AccountService_V1_2_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_2_7/RedfishAccountService_V1_2_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_2_8/AccountService_V1_2_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_2_8/RedfishAccountService_V1_2_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_3_0/AccountService_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_3_0/RedfishAccountService_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_3_1/AccountService_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_3_1/RedfishAccountService_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_3_2/AccountService_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_3_2/RedfishAccountService_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_3_3/AccountService_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_3_3/RedfishAccountService_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_3_4/AccountService_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_3_4/RedfishAccountService_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_3_5/AccountService_V1_3_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_3_5/RedfishAccountService_V1_3_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_3_6/AccountService_V1_3_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_3_6/RedfishAccountService_V1_3_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_3_7/AccountService_V1_3_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_3_7/RedfishAccountService_V1_3_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_4_0/AccountService_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_4_0/RedfishAccountService_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_4_1/AccountService_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_4_1/RedfishAccountService_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_4_2/AccountService_V1_4_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_4_2/RedfishAccountService_V1_4_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_4_3/AccountService_V1_4_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_4_3/RedfishAccountService_V1_4_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_4_4/AccountService_V1_4_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_4_4/RedfishAccountService_V1_4_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_4_5/AccountService_V1_4_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_4_5/RedfishAccountService_V1_4_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_5_0/AccountService_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_5_0/RedfishAccountService_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_5_1/AccountService_V1_5_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_5_1/RedfishAccountService_V1_5_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_5_2/AccountService_V1_5_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_5_2/RedfishAccountService_V1_5_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_5_3/AccountService_V1_5_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_5_3/RedfishAccountService_V1_5_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_5_4/AccountService_V1_5_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_5_4/RedfishAccountService_V1_5_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_6_0/AccountService_V1_6_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_6_0/RedfishAccountService_V1_6_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_6_1/AccountService_V1_6_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_6_1/RedfishAccountService_V1_6_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_6_2/AccountService_V1_6_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_6_2/RedfishAccountService_V1_6_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_6_3/AccountService_V1_6_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_6_3/RedfishAccountService_V1_6_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_7_0/AccountService_V1_7_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_7_0/RedfishAccountService_V1_7_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_7_1/AccountService_V1_7_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_7_1/RedfishAccountService_V1_7_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_7_2/AccountService_V1_7_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_7_2/RedfishAccountService_V1_7_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_7_3/AccountService_V1_7_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_7_3/RedfishAccountService_V1_7_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AccountService/v1_8_0/AccountService_V1_8_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/AccountService/v1_8_0/RedfishAccountService_V1_8_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ActionInfo/v1_0_0/ActionInfo_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ActionInfo/v1_0_0/RedfishActionInfo_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ActionInfo/v1_0_1/ActionInfo_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ActionInfo/v1_0_1/RedfishActionInfo_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ActionInfo/v1_0_2/ActionInfo_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ActionInfo/v1_0_2/RedfishActionInfo_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ActionInfo/v1_0_3/ActionInfo_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ActionInfo/v1_0_3/RedfishActionInfo_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ActionInfo/v1_0_4/ActionInfo_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ActionInfo/v1_0_4/RedfishActionInfo_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ActionInfo/v1_0_5/ActionInfo_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/ActionInfo/v1_0_5/RedfishActionInfo_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ActionInfo/v1_0_6/ActionInfo_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/ActionInfo/v1_0_6/RedfishActionInfo_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ActionInfo/v1_1_0/ActionInfo_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ActionInfo/v1_1_0/RedfishActionInfo_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ActionInfo/v1_1_1/ActionInfo_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ActionInfo/v1_1_1/RedfishActionInfo_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ActionInfo/v1_1_2/ActionInfo_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ActionInfo/v1_1_2/RedfishActionInfo_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AddressPool/v1_0_0/AddressPool_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/AddressPool/v1_0_0/RedfishAddressPool_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AddressPool/v1_0_1/AddressPool_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/AddressPool/v1_0_1/RedfishAddressPool_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AddressPool/v1_0_2/AddressPool_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/AddressPool/v1_0_2/RedfishAddressPool_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AddressPool/v1_1_0/AddressPool_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/AddressPool/v1_1_0/RedfishAddressPool_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AddressPool/v1_1_1/AddressPool_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/AddressPool/v1_1_1/RedfishAddressPool_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AddressPoolCollection/AddressPoolCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/AddressPoolCollection/RedfishAddressPoolCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Aggregate/v1_0_0/Aggregate_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Aggregate/v1_0_0/RedfishAggregate_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Aggregate/v1_0_1/Aggregate_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Aggregate/v1_0_1/RedfishAggregate_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AggregateCollection/AggregateCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/AggregateCollection/RedfishAggregateCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AggregationService/v1_0_0/AggregationService_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/AggregationService/v1_0_0/RedfishAggregationService_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AggregationService/v1_0_1/AggregationService_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/AggregationService/v1_0_1/RedfishAggregationService_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AggregationSource/v1_0_0/AggregationSource_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/AggregationSource/v1_0_0/RedfishAggregationSource_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AggregationSource/v1_1_0/AggregationSource_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/AggregationSource/v1_1_0/RedfishAggregationSource_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AggregationSourceCollection/AggregationSourceCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/AggregationSourceCollection/RedfishAggregationSourceCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Assembly/v1_0_0/Assembly_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Assembly/v1_0_0/RedfishAssembly_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Assembly/v1_0_1/Assembly_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Assembly/v1_0_1/RedfishAssembly_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Assembly/v1_0_2/Assembly_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Assembly/v1_0_2/RedfishAssembly_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Assembly/v1_0_3/Assembly_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Assembly/v1_0_3/RedfishAssembly_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Assembly/v1_0_4/Assembly_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Assembly/v1_0_4/RedfishAssembly_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Assembly/v1_1_0/Assembly_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Assembly/v1_1_0/RedfishAssembly_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Assembly/v1_1_1/Assembly_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Assembly/v1_1_1/RedfishAssembly_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Assembly/v1_1_2/Assembly_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Assembly/v1_1_2/RedfishAssembly_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Assembly/v1_1_3/Assembly_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Assembly/v1_1_3/RedfishAssembly_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Assembly/v1_1_4/Assembly_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Assembly/v1_1_4/RedfishAssembly_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Assembly/v1_2_0/Assembly_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Assembly/v1_2_0/RedfishAssembly_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Assembly/v1_2_1/Assembly_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Assembly/v1_2_1/RedfishAssembly_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Assembly/v1_2_2/Assembly_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Assembly/v1_2_2/RedfishAssembly_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Assembly/v1_2_3/Assembly_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Assembly/v1_2_3/RedfishAssembly_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Assembly/v1_3_0/Assembly_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Assembly/v1_3_0/RedfishAssembly_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_0_0/AttributeRegistry_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_0_0/RedfishAttributeRegistry_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_0_1/AttributeRegistry_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_0_1/RedfishAttributeRegistry_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_0_10/AttributeRegistry_V1_0_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_0_10/RedfishAttributeRegistry_V1_0_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_0_2/AttributeRegistry_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_0_2/RedfishAttributeRegistry_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_0_3/AttributeRegistry_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_0_3/RedfishAttributeRegistry_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_0_4/AttributeRegistry_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_0_4/RedfishAttributeRegistry_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_0_5/AttributeRegistry_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_0_5/RedfishAttributeRegistry_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_0_6/AttributeRegistry_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_0_6/RedfishAttributeRegistry_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_0_7/AttributeRegistry_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_0_7/RedfishAttributeRegistry_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_0_8/AttributeRegistry_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_0_8/RedfishAttributeRegistry_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_0_9/AttributeRegistry_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_0_9/RedfishAttributeRegistry_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_1_0/AttributeRegistry_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_1_0/RedfishAttributeRegistry_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_1_1/AttributeRegistry_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_1_1/RedfishAttributeRegistry_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_1_2/AttributeRegistry_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_1_2/RedfishAttributeRegistry_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_1_3/AttributeRegistry_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_1_3/RedfishAttributeRegistry_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_1_4/AttributeRegistry_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_1_4/RedfishAttributeRegistry_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_1_5/AttributeRegistry_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_1_5/RedfishAttributeRegistry_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_1_6/AttributeRegistry_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_1_6/RedfishAttributeRegistry_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_1_7/AttributeRegistry_V1_1_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_1_7/RedfishAttributeRegistry_V1_1_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_1_8/AttributeRegistry_V1_1_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_1_8/RedfishAttributeRegistry_V1_1_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_1_9/AttributeRegistry_V1_1_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_1_9/RedfishAttributeRegistry_V1_1_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_2_0/AttributeRegistry_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_2_0/RedfishAttributeRegistry_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_2_1/AttributeRegistry_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_2_1/RedfishAttributeRegistry_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_2_2/AttributeRegistry_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_2_2/RedfishAttributeRegistry_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_2_3/AttributeRegistry_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_2_3/RedfishAttributeRegistry_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_2_4/AttributeRegistry_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_2_4/RedfishAttributeRegistry_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_2_5/AttributeRegistry_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_2_5/RedfishAttributeRegistry_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_2_6/AttributeRegistry_V1_2_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_2_6/RedfishAttributeRegistry_V1_2_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_2_7/AttributeRegistry_V1_2_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_2_7/RedfishAttributeRegistry_V1_2_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_3_0/AttributeRegistry_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_3_0/RedfishAttributeRegistry_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_3_1/AttributeRegistry_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_3_1/RedfishAttributeRegistry_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_3_2/AttributeRegistry_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_3_2/RedfishAttributeRegistry_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_3_3/AttributeRegistry_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_3_3/RedfishAttributeRegistry_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_3_4/AttributeRegistry_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_3_4/RedfishAttributeRegistry_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_3_5/AttributeRegistry_V1_3_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/AttributeRegistry/v1_3_5/RedfishAttributeRegistry_V1_3_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Bios/v1_0_0/Bios_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Bios/v1_0_0/RedfishBios_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Bios/v1_0_1/Bios_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Bios/v1_0_1/RedfishBios_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Bios/v1_0_2/Bios_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Bios/v1_0_2/RedfishBios_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Bios/v1_0_3/Bios_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Bios/v1_0_3/RedfishBios_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Bios/v1_0_4/Bios_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Bios/v1_0_4/RedfishBios_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Bios/v1_0_5/Bios_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Bios/v1_0_5/RedfishBios_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Bios/v1_0_6/Bios_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Bios/v1_0_6/RedfishBios_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Bios/v1_0_7/Bios_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Bios/v1_0_7/RedfishBios_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Bios/v1_0_8/Bios_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Bios/v1_0_8/RedfishBios_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Bios/v1_1_0/Bios_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Bios/v1_1_0/RedfishBios_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Bios/v1_1_1/Bios_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Bios/v1_1_1/RedfishBios_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/BootOption/v1_0_0/BootOption_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/BootOption/v1_0_0/RedfishBootOption_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/BootOption/v1_0_1/BootOption_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/BootOption/v1_0_1/RedfishBootOption_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/BootOption/v1_0_2/BootOption_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/BootOption/v1_0_2/RedfishBootOption_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/BootOption/v1_0_3/BootOption_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/BootOption/v1_0_3/RedfishBootOption_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/BootOption/v1_0_4/BootOption_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/BootOption/v1_0_4/RedfishBootOption_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/BootOptionCollection/BootOptionCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/BootOptionCollection/RedfishBootOptionCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Certificate/v1_0_0/Certificate_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Certificate/v1_0_0/RedfishCertificate_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Certificate/v1_0_1/Certificate_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Certificate/v1_0_1/RedfishCertificate_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Certificate/v1_0_2/Certificate_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Certificate/v1_0_2/RedfishCertificate_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Certificate/v1_0_3/Certificate_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Certificate/v1_0_3/RedfishCertificate_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Certificate/v1_0_4/Certificate_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Certificate/v1_0_4/RedfishCertificate_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Certificate/v1_1_0/Certificate_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Certificate/v1_1_0/RedfishCertificate_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Certificate/v1_1_1/Certificate_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Certificate/v1_1_1/RedfishCertificate_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Certificate/v1_1_2/Certificate_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Certificate/v1_1_2/RedfishCertificate_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Certificate/v1_1_3/Certificate_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Certificate/v1_1_3/RedfishCertificate_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Certificate/v1_2_0/Certificate_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Certificate/v1_2_0/RedfishCertificate_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Certificate/v1_2_1/Certificate_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Certificate/v1_2_1/RedfishCertificate_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Certificate/v1_2_2/Certificate_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Certificate/v1_2_2/RedfishCertificate_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/CertificateCollection/CertificateCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/CertificateCollection/RedfishCertificateCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/CertificateLocations/v1_0_0/CertificateLocations_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/CertificateLocations/v1_0_0/RedfishCertificateLocations_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/CertificateLocations/v1_0_1/CertificateLocations_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/CertificateLocations/v1_0_1/RedfishCertificateLocations_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/CertificateLocations/v1_0_2/CertificateLocations_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/CertificateLocations/v1_0_2/RedfishCertificateLocations_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/CertificateService/v1_0_0/CertificateService_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/CertificateService/v1_0_0/RedfishCertificateService_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/CertificateService/v1_0_1/CertificateService_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/CertificateService/v1_0_1/RedfishCertificateService_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/CertificateService/v1_0_2/CertificateService_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/CertificateService/v1_0_2/RedfishCertificateService_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/CertificateService/v1_0_3/CertificateService_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/CertificateService/v1_0_3/RedfishCertificateService_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/CertificateService/v1_0_4/CertificateService_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/CertificateService/v1_0_4/RedfishCertificateService_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_0/Chassis_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_0/RedfishChassis_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_1/Chassis_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_1/RedfishChassis_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_10/Chassis_V1_0_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_10/RedfishChassis_V1_0_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_11/Chassis_V1_0_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_11/RedfishChassis_V1_0_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_12/Chassis_V1_0_12_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_12/RedfishChassis_V1_0_12_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_13/Chassis_V1_0_13_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_13/RedfishChassis_V1_0_13_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_2/Chassis_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_2/RedfishChassis_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_3/Chassis_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_3/RedfishChassis_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_4/Chassis_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_4/RedfishChassis_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_5/Chassis_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_5/RedfishChassis_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_6/Chassis_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_6/RedfishChassis_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_7/Chassis_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_7/RedfishChassis_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_8/Chassis_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_8/RedfishChassis_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_9/Chassis_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_0_9/RedfishChassis_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_10_0/Chassis_V1_10_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_10_0/RedfishChassis_V1_10_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_10_1/Chassis_V1_10_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_10_1/RedfishChassis_V1_10_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_10_2/Chassis_V1_10_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_10_2/RedfishChassis_V1_10_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_10_3/Chassis_V1_10_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_10_3/RedfishChassis_V1_10_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_11_0/Chassis_V1_11_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_11_0/RedfishChassis_V1_11_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_11_1/Chassis_V1_11_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_11_1/RedfishChassis_V1_11_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_11_2/Chassis_V1_11_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_11_2/RedfishChassis_V1_11_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_11_3/Chassis_V1_11_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_11_3/RedfishChassis_V1_11_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_12_0/Chassis_V1_12_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_12_0/RedfishChassis_V1_12_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_12_1/Chassis_V1_12_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_12_1/RedfishChassis_V1_12_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_12_2/Chassis_V1_12_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_12_2/RedfishChassis_V1_12_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_13_0/Chassis_V1_13_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_13_0/RedfishChassis_V1_13_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_13_1/Chassis_V1_13_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_13_1/RedfishChassis_V1_13_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_14_0/Chassis_V1_14_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_14_0/RedfishChassis_V1_14_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_15_0/Chassis_V1_15_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_15_0/RedfishChassis_V1_15_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_0/Chassis_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_0/RedfishChassis_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_10/Chassis_V1_1_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_10/RedfishChassis_V1_1_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_11/Chassis_V1_1_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_11/RedfishChassis_V1_1_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_12/Chassis_V1_1_12_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_12/RedfishChassis_V1_1_12_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_13/Chassis_V1_1_13_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_13/RedfishChassis_V1_1_13_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_2/Chassis_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_2/RedfishChassis_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_3/Chassis_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_3/RedfishChassis_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_4/Chassis_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_4/RedfishChassis_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_5/Chassis_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_5/RedfishChassis_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_6/Chassis_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_6/RedfishChassis_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_7/Chassis_V1_1_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_7/RedfishChassis_V1_1_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_8/Chassis_V1_1_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_8/RedfishChassis_V1_1_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_9/Chassis_V1_1_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_1_9/RedfishChassis_V1_1_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_2_0/Chassis_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_2_0/RedfishChassis_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_2_1/Chassis_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_2_1/RedfishChassis_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_2_10/Chassis_V1_2_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_2_10/RedfishChassis_V1_2_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_2_11/Chassis_V1_2_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_2_11/RedfishChassis_V1_2_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_2_2/Chassis_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_2_2/RedfishChassis_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_2_3/Chassis_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_2_3/RedfishChassis_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_2_4/Chassis_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_2_4/RedfishChassis_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_2_5/Chassis_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_2_5/RedfishChassis_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_2_6/Chassis_V1_2_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_2_6/RedfishChassis_V1_2_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_2_7/Chassis_V1_2_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_2_7/RedfishChassis_V1_2_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_2_8/Chassis_V1_2_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_2_8/RedfishChassis_V1_2_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_2_9/Chassis_V1_2_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_2_9/RedfishChassis_V1_2_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_3_0/Chassis_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_3_0/RedfishChassis_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_3_1/Chassis_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_3_1/RedfishChassis_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_3_10/Chassis_V1_3_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_3_10/RedfishChassis_V1_3_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_3_11/Chassis_V1_3_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_3_11/RedfishChassis_V1_3_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_3_2/Chassis_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_3_2/RedfishChassis_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_3_3/Chassis_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_3_3/RedfishChassis_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_3_4/Chassis_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_3_4/RedfishChassis_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_3_5/Chassis_V1_3_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_3_5/RedfishChassis_V1_3_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_3_6/Chassis_V1_3_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_3_6/RedfishChassis_V1_3_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_3_7/Chassis_V1_3_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_3_7/RedfishChassis_V1_3_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_3_8/Chassis_V1_3_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_3_8/RedfishChassis_V1_3_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_3_9/Chassis_V1_3_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_3_9/RedfishChassis_V1_3_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_4_0/Chassis_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_4_0/RedfishChassis_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_4_1/Chassis_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_4_1/RedfishChassis_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_4_10/Chassis_V1_4_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_4_10/RedfishChassis_V1_4_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_4_2/Chassis_V1_4_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_4_2/RedfishChassis_V1_4_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_4_3/Chassis_V1_4_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_4_3/RedfishChassis_V1_4_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_4_4/Chassis_V1_4_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_4_4/RedfishChassis_V1_4_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_4_5/Chassis_V1_4_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_4_5/RedfishChassis_V1_4_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_4_6/Chassis_V1_4_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_4_6/RedfishChassis_V1_4_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_4_7/Chassis_V1_4_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_4_7/RedfishChassis_V1_4_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_4_8/Chassis_V1_4_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_4_8/RedfishChassis_V1_4_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_4_9/Chassis_V1_4_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_4_9/RedfishChassis_V1_4_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_5_0/Chassis_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_5_0/RedfishChassis_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_5_1/Chassis_V1_5_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_5_1/RedfishChassis_V1_5_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_5_2/Chassis_V1_5_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_5_2/RedfishChassis_V1_5_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_5_3/Chassis_V1_5_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_5_3/RedfishChassis_V1_5_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_5_4/Chassis_V1_5_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_5_4/RedfishChassis_V1_5_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_5_5/Chassis_V1_5_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_5_5/RedfishChassis_V1_5_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_5_6/Chassis_V1_5_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_5_6/RedfishChassis_V1_5_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_5_7/Chassis_V1_5_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_5_7/RedfishChassis_V1_5_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_5_8/Chassis_V1_5_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_5_8/RedfishChassis_V1_5_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_5_9/Chassis_V1_5_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_5_9/RedfishChassis_V1_5_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_6_0/Chassis_V1_6_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_6_0/RedfishChassis_V1_6_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_6_1/Chassis_V1_6_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_6_1/RedfishChassis_V1_6_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_6_2/Chassis_V1_6_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_6_2/RedfishChassis_V1_6_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_6_3/Chassis_V1_6_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_6_3/RedfishChassis_V1_6_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_6_4/Chassis_V1_6_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_6_4/RedfishChassis_V1_6_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_6_5/Chassis_V1_6_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_6_5/RedfishChassis_V1_6_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_6_6/Chassis_V1_6_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_6_6/RedfishChassis_V1_6_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_6_7/Chassis_V1_6_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_6_7/RedfishChassis_V1_6_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_7_0/Chassis_V1_7_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_7_0/RedfishChassis_V1_7_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_7_1/Chassis_V1_7_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_7_1/RedfishChassis_V1_7_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_7_2/Chassis_V1_7_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_7_2/RedfishChassis_V1_7_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_7_3/Chassis_V1_7_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_7_3/RedfishChassis_V1_7_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_7_4/Chassis_V1_7_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_7_4/RedfishChassis_V1_7_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_7_5/Chassis_V1_7_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_7_5/RedfishChassis_V1_7_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_7_6/Chassis_V1_7_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_7_6/RedfishChassis_V1_7_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_7_7/Chassis_V1_7_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_7_7/RedfishChassis_V1_7_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_8_0/Chassis_V1_8_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_8_0/RedfishChassis_V1_8_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_8_1/Chassis_V1_8_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_8_1/RedfishChassis_V1_8_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_8_2/Chassis_V1_8_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_8_2/RedfishChassis_V1_8_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_8_3/Chassis_V1_8_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_8_3/RedfishChassis_V1_8_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_8_4/Chassis_V1_8_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_8_4/RedfishChassis_V1_8_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_8_5/Chassis_V1_8_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_8_5/RedfishChassis_V1_8_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_8_6/Chassis_V1_8_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_8_6/RedfishChassis_V1_8_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_9_0/Chassis_V1_9_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_9_0/RedfishChassis_V1_9_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_9_1/Chassis_V1_9_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_9_1/RedfishChassis_V1_9_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_9_2/Chassis_V1_9_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_9_2/RedfishChassis_V1_9_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_9_3/Chassis_V1_9_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_9_3/RedfishChassis_V1_9_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_9_4/Chassis_V1_9_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_9_4/RedfishChassis_V1_9_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Chassis/v1_9_5/Chassis_V1_9_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Chassis/v1_9_5/RedfishChassis_V1_9_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ChassisCollection/ChassisCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/ChassisCollection/RedfishChassisCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Circuit/v1_0_0/Circuit_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Circuit/v1_0_0/RedfishCircuit_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Circuit/v1_0_1/Circuit_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Circuit/v1_0_1/RedfishCircuit_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Circuit/v1_0_2/Circuit_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Circuit/v1_0_2/RedfishCircuit_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Circuit/v1_1_0/Circuit_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Circuit/v1_1_0/RedfishCircuit_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Circuit/v1_1_1/Circuit_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Circuit/v1_1_1/RedfishCircuit_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Circuit/v1_2_0/Circuit_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Circuit/v1_2_0/RedfishCircuit_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/CircuitCollection/CircuitCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/CircuitCollection/RedfishCircuitCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/CompositionService/v1_0_0/CompositionService_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/CompositionService/v1_0_0/RedfishCompositionService_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/CompositionService/v1_0_1/CompositionService_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/CompositionService/v1_0_1/RedfishCompositionService_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/CompositionService/v1_0_2/CompositionService_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/CompositionService/v1_0_2/RedfishCompositionService_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/CompositionService/v1_0_3/CompositionService_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/CompositionService/v1_0_3/RedfishCompositionService_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/CompositionService/v1_0_4/CompositionService_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/CompositionService/v1_0_4/RedfishCompositionService_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/CompositionService/v1_1_0/CompositionService_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/CompositionService/v1_1_0/RedfishCompositionService_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/CompositionService/v1_1_1/CompositionService_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/CompositionService/v1_1_1/RedfishCompositionService_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/CompositionService/v1_1_2/CompositionService_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/CompositionService/v1_1_2/RedfishCompositionService_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_0/ComputerSystem_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_0/RedfishComputerSystem_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_1/ComputerSystem_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_1/RedfishComputerSystem_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_10/ComputerSystem_V1_0_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_10/RedfishComputerSystem_V1_0_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_11/ComputerSystem_V1_0_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_11/RedfishComputerSystem_V1_0_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_12/ComputerSystem_V1_0_12_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_12/RedfishComputerSystem_V1_0_12_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_13/ComputerSystem_V1_0_13_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_13/RedfishComputerSystem_V1_0_13_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_14/ComputerSystem_V1_0_14_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_14/RedfishComputerSystem_V1_0_14_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_15/ComputerSystem_V1_0_15_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_15/RedfishComputerSystem_V1_0_15_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_16/ComputerSystem_V1_0_16_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_16/RedfishComputerSystem_V1_0_16_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_2/ComputerSystem_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_2/RedfishComputerSystem_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_3/ComputerSystem_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_3/RedfishComputerSystem_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_4/ComputerSystem_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_4/RedfishComputerSystem_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_5/ComputerSystem_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_5/RedfishComputerSystem_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_6/ComputerSystem_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_6/RedfishComputerSystem_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_7/ComputerSystem_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_7/RedfishComputerSystem_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_8/ComputerSystem_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_8/RedfishComputerSystem_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_9/ComputerSystem_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_0_9/RedfishComputerSystem_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_10_0/ComputerSystem_V1_10_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_10_0/RedfishComputerSystem_V1_10_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_10_1/ComputerSystem_V1_10_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_10_1/RedfishComputerSystem_V1_10_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_10_2/ComputerSystem_V1_10_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_10_2/RedfishComputerSystem_V1_10_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_10_3/ComputerSystem_V1_10_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_10_3/RedfishComputerSystem_V1_10_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_10_4/ComputerSystem_V1_10_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_10_4/RedfishComputerSystem_V1_10_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_11_0/ComputerSystem_V1_11_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_11_0/RedfishComputerSystem_V1_11_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_11_1/ComputerSystem_V1_11_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_11_1/RedfishComputerSystem_V1_11_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_11_2/ComputerSystem_V1_11_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_11_2/RedfishComputerSystem_V1_11_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_11_3/ComputerSystem_V1_11_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_11_3/RedfishComputerSystem_V1_11_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_12_0/ComputerSystem_V1_12_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_12_0/RedfishComputerSystem_V1_12_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_12_1/ComputerSystem_V1_12_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_12_1/RedfishComputerSystem_V1_12_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_12_2/ComputerSystem_V1_12_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_12_2/RedfishComputerSystem_V1_12_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_13_0/ComputerSystem_V1_13_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_13_0/RedfishComputerSystem_V1_13_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_13_1/ComputerSystem_V1_13_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_13_1/RedfishComputerSystem_V1_13_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_14_0/ComputerSystem_V1_14_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_14_0/RedfishComputerSystem_V1_14_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_0/ComputerSystem_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_0/RedfishComputerSystem_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_1/ComputerSystem_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_1/RedfishComputerSystem_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_10/ComputerSystem_V1_1_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_10/RedfishComputerSystem_V1_1_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_11/ComputerSystem_V1_1_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_11/RedfishComputerSystem_V1_1_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_12/ComputerSystem_V1_1_12_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_12/RedfishComputerSystem_V1_1_12_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_13/ComputerSystem_V1_1_13_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_13/RedfishComputerSystem_V1_1_13_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_14/ComputerSystem_V1_1_14_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_14/RedfishComputerSystem_V1_1_14_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_2/ComputerSystem_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_2/RedfishComputerSystem_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_3/ComputerSystem_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_3/RedfishComputerSystem_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_4/ComputerSystem_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_4/RedfishComputerSystem_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_5/ComputerSystem_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_5/RedfishComputerSystem_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_6/ComputerSystem_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_6/RedfishComputerSystem_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_7/ComputerSystem_V1_1_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_7/RedfishComputerSystem_V1_1_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_8/ComputerSystem_V1_1_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_8/RedfishComputerSystem_V1_1_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_9/ComputerSystem_V1_1_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_1_9/RedfishComputerSystem_V1_1_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_0/ComputerSystem_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_0/RedfishComputerSystem_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_1/ComputerSystem_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_1/RedfishComputerSystem_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_10/ComputerSystem_V1_2_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_10/RedfishComputerSystem_V1_2_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_11/ComputerSystem_V1_2_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_11/RedfishComputerSystem_V1_2_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_12/ComputerSystem_V1_2_12_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_12/RedfishComputerSystem_V1_2_12_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_13/ComputerSystem_V1_2_13_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_13/RedfishComputerSystem_V1_2_13_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_2/ComputerSystem_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_2/RedfishComputerSystem_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_3/ComputerSystem_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_3/RedfishComputerSystem_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_4/ComputerSystem_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_4/RedfishComputerSystem_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_5/ComputerSystem_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_5/RedfishComputerSystem_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_6/ComputerSystem_V1_2_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_6/RedfishComputerSystem_V1_2_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_7/ComputerSystem_V1_2_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_7/RedfishComputerSystem_V1_2_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_8/ComputerSystem_V1_2_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_8/RedfishComputerSystem_V1_2_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_9/ComputerSystem_V1_2_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_2_9/RedfishComputerSystem_V1_2_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_0/ComputerSystem_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_0/RedfishComputerSystem_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_1/ComputerSystem_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_1/RedfishComputerSystem_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_10/ComputerSystem_V1_3_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_10/RedfishComputerSystem_V1_3_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_11/ComputerSystem_V1_3_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_11/RedfishComputerSystem_V1_3_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_12/ComputerSystem_V1_3_12_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_12/RedfishComputerSystem_V1_3_12_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_2/ComputerSystem_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_2/RedfishComputerSystem_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_3/ComputerSystem_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_3/RedfishComputerSystem_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_4/ComputerSystem_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_4/RedfishComputerSystem_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_5/ComputerSystem_V1_3_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_5/RedfishComputerSystem_V1_3_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_6/ComputerSystem_V1_3_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_6/RedfishComputerSystem_V1_3_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_7/ComputerSystem_V1_3_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_7/RedfishComputerSystem_V1_3_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_8/ComputerSystem_V1_3_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_8/RedfishComputerSystem_V1_3_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_9/ComputerSystem_V1_3_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_3_9/RedfishComputerSystem_V1_3_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_4_0/ComputerSystem_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_4_0/RedfishComputerSystem_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_4_1/ComputerSystem_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_4_1/RedfishComputerSystem_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_4_10/ComputerSystem_V1_4_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_4_10/RedfishComputerSystem_V1_4_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_4_11/ComputerSystem_V1_4_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_4_11/RedfishComputerSystem_V1_4_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_4_2/ComputerSystem_V1_4_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_4_2/RedfishComputerSystem_V1_4_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_4_3/ComputerSystem_V1_4_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_4_3/RedfishComputerSystem_V1_4_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_4_4/ComputerSystem_V1_4_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_4_4/RedfishComputerSystem_V1_4_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_4_5/ComputerSystem_V1_4_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_4_5/RedfishComputerSystem_V1_4_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_4_6/ComputerSystem_V1_4_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_4_6/RedfishComputerSystem_V1_4_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_4_7/ComputerSystem_V1_4_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_4_7/RedfishComputerSystem_V1_4_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_4_8/ComputerSystem_V1_4_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_4_8/RedfishComputerSystem_V1_4_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_4_9/ComputerSystem_V1_4_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_4_9/RedfishComputerSystem_V1_4_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_5_0/ComputerSystem_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_5_0/RedfishComputerSystem_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_5_1/ComputerSystem_V1_5_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_5_1/RedfishComputerSystem_V1_5_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_5_2/ComputerSystem_V1_5_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_5_2/RedfishComputerSystem_V1_5_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_5_3/ComputerSystem_V1_5_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_5_3/RedfishComputerSystem_V1_5_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_5_4/ComputerSystem_V1_5_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_5_4/RedfishComputerSystem_V1_5_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_5_5/ComputerSystem_V1_5_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_5_5/RedfishComputerSystem_V1_5_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_5_6/ComputerSystem_V1_5_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_5_6/RedfishComputerSystem_V1_5_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_5_7/ComputerSystem_V1_5_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_5_7/RedfishComputerSystem_V1_5_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_5_8/ComputerSystem_V1_5_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_5_8/RedfishComputerSystem_V1_5_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_5_9/ComputerSystem_V1_5_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_5_9/RedfishComputerSystem_V1_5_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_6_0/ComputerSystem_V1_6_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_6_0/RedfishComputerSystem_V1_6_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_6_1/ComputerSystem_V1_6_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_6_1/RedfishComputerSystem_V1_6_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_6_2/ComputerSystem_V1_6_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_6_2/RedfishComputerSystem_V1_6_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_6_3/ComputerSystem_V1_6_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_6_3/RedfishComputerSystem_V1_6_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_6_4/ComputerSystem_V1_6_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_6_4/RedfishComputerSystem_V1_6_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_6_5/ComputerSystem_V1_6_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_6_5/RedfishComputerSystem_V1_6_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_6_6/ComputerSystem_V1_6_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_6_6/RedfishComputerSystem_V1_6_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_6_7/ComputerSystem_V1_6_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_6_7/RedfishComputerSystem_V1_6_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_7_0/ComputerSystem_V1_7_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_7_0/RedfishComputerSystem_V1_7_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_7_1/ComputerSystem_V1_7_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_7_1/RedfishComputerSystem_V1_7_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_7_2/ComputerSystem_V1_7_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_7_2/RedfishComputerSystem_V1_7_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_7_3/ComputerSystem_V1_7_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_7_3/RedfishComputerSystem_V1_7_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_7_4/ComputerSystem_V1_7_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_7_4/RedfishComputerSystem_V1_7_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_7_5/ComputerSystem_V1_7_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_7_5/RedfishComputerSystem_V1_7_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_7_6/ComputerSystem_V1_7_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_7_6/RedfishComputerSystem_V1_7_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_8_0/ComputerSystem_V1_8_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_8_0/RedfishComputerSystem_V1_8_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_8_1/ComputerSystem_V1_8_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_8_1/RedfishComputerSystem_V1_8_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_8_2/ComputerSystem_V1_8_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_8_2/RedfishComputerSystem_V1_8_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_8_3/ComputerSystem_V1_8_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_8_3/RedfishComputerSystem_V1_8_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_8_4/ComputerSystem_V1_8_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_8_4/RedfishComputerSystem_V1_8_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_8_5/ComputerSystem_V1_8_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_8_5/RedfishComputerSystem_V1_8_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_9_0/ComputerSystem_V1_9_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_9_0/RedfishComputerSystem_V1_9_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_9_1/ComputerSystem_V1_9_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_9_1/RedfishComputerSystem_V1_9_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_9_2/ComputerSystem_V1_9_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_9_2/RedfishComputerSystem_V1_9_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_9_3/ComputerSystem_V1_9_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_9_3/RedfishComputerSystem_V1_9_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_9_4/ComputerSystem_V1_9_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_9_4/RedfishComputerSystem_V1_9_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_9_5/ComputerSystem_V1_9_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystem/v1_9_5/RedfishComputerSystem_V1_9_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ComputerSystemCollection/ComputerSystemCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/ComputerSystemCollection/RedfishComputerSystemCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Connection/v1_0_0/Connection_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Connection/v1_0_0/RedfishConnection_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ConnectionCollection/ConnectionCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/ConnectionCollection/RedfishConnectionCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ConnectionMethod/v1_0_0/ConnectionMethod_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ConnectionMethod/v1_0_0/RedfishConnectionMethod_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ConnectionMethodCollection/ConnectionMethodCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/ConnectionMethodCollection/RedfishConnectionMethodCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_0_0/Drive_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_0_0/RedfishDrive_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_0_1/Drive_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_0_1/RedfishDrive_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_0_10/Drive_V1_0_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_0_10/RedfishDrive_V1_0_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_0_11/Drive_V1_0_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_0_11/RedfishDrive_V1_0_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_0_2/Drive_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_0_2/RedfishDrive_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_0_3/Drive_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_0_3/RedfishDrive_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_0_4/Drive_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_0_4/RedfishDrive_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_0_5/Drive_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_0_5/RedfishDrive_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_0_6/Drive_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_0_6/RedfishDrive_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_0_7/Drive_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_0_7/RedfishDrive_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_0_8/Drive_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_0_8/RedfishDrive_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_0_9/Drive_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_0_9/RedfishDrive_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_10_0/Drive_V1_10_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_10_0/RedfishDrive_V1_10_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_10_1/Drive_V1_10_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_10_1/RedfishDrive_V1_10_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_11_0/Drive_V1_11_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_11_0/RedfishDrive_V1_11_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_11_1/Drive_V1_11_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_11_1/RedfishDrive_V1_11_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_12_0/Drive_V1_12_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_12_0/RedfishDrive_V1_12_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_1_0/Drive_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_1_0/RedfishDrive_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_1_1/Drive_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_1_1/RedfishDrive_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_1_10/Drive_V1_1_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_1_10/RedfishDrive_V1_1_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_1_2/Drive_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_1_2/RedfishDrive_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_1_3/Drive_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_1_3/RedfishDrive_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_1_4/Drive_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_1_4/RedfishDrive_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_1_5/Drive_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_1_5/RedfishDrive_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_1_6/Drive_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_1_6/RedfishDrive_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_1_7/Drive_V1_1_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_1_7/RedfishDrive_V1_1_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_1_8/Drive_V1_1_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_1_8/RedfishDrive_V1_1_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_1_9/Drive_V1_1_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_1_9/RedfishDrive_V1_1_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_2_0/Drive_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_2_0/RedfishDrive_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_2_1/Drive_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_2_1/RedfishDrive_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_2_2/Drive_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_2_2/RedfishDrive_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_2_3/Drive_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_2_3/RedfishDrive_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_2_4/Drive_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_2_4/RedfishDrive_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_2_5/Drive_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_2_5/RedfishDrive_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_2_6/Drive_V1_2_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_2_6/RedfishDrive_V1_2_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_2_7/Drive_V1_2_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_2_7/RedfishDrive_V1_2_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_2_8/Drive_V1_2_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_2_8/RedfishDrive_V1_2_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_3_0/Drive_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_3_0/RedfishDrive_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_3_1/Drive_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_3_1/RedfishDrive_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_3_2/Drive_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_3_2/RedfishDrive_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_3_3/Drive_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_3_3/RedfishDrive_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_3_4/Drive_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_3_4/RedfishDrive_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_3_5/Drive_V1_3_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_3_5/RedfishDrive_V1_3_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_3_6/Drive_V1_3_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_3_6/RedfishDrive_V1_3_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_3_7/Drive_V1_3_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_3_7/RedfishDrive_V1_3_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_4_0/Drive_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_4_0/RedfishDrive_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_4_1/Drive_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_4_1/RedfishDrive_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_4_2/Drive_V1_4_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_4_2/RedfishDrive_V1_4_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_4_3/Drive_V1_4_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_4_3/RedfishDrive_V1_4_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_4_4/Drive_V1_4_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_4_4/RedfishDrive_V1_4_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_4_5/Drive_V1_4_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_4_5/RedfishDrive_V1_4_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_4_6/Drive_V1_4_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_4_6/RedfishDrive_V1_4_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_4_7/Drive_V1_4_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_4_7/RedfishDrive_V1_4_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_5_0/Drive_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_5_0/RedfishDrive_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_5_1/Drive_V1_5_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_5_1/RedfishDrive_V1_5_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_5_2/Drive_V1_5_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_5_2/RedfishDrive_V1_5_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_5_3/Drive_V1_5_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_5_3/RedfishDrive_V1_5_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_5_4/Drive_V1_5_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_5_4/RedfishDrive_V1_5_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_5_5/Drive_V1_5_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_5_5/RedfishDrive_V1_5_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_5_6/Drive_V1_5_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_5_6/RedfishDrive_V1_5_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_6_0/Drive_V1_6_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_6_0/RedfishDrive_V1_6_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_6_1/Drive_V1_6_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_6_1/RedfishDrive_V1_6_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_6_2/Drive_V1_6_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_6_2/RedfishDrive_V1_6_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_6_3/Drive_V1_6_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_6_3/RedfishDrive_V1_6_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_6_4/Drive_V1_6_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_6_4/RedfishDrive_V1_6_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_7_0/Drive_V1_7_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_7_0/RedfishDrive_V1_7_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_7_1/Drive_V1_7_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_7_1/RedfishDrive_V1_7_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_7_2/Drive_V1_7_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_7_2/RedfishDrive_V1_7_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_7_3/Drive_V1_7_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_7_3/RedfishDrive_V1_7_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_8_0/Drive_V1_8_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_8_0/RedfishDrive_V1_8_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_8_1/Drive_V1_8_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_8_1/RedfishDrive_V1_8_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_8_2/Drive_V1_8_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_8_2/RedfishDrive_V1_8_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_8_3/Drive_V1_8_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_8_3/RedfishDrive_V1_8_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_9_0/Drive_V1_9_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_9_0/RedfishDrive_V1_9_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_9_1/Drive_V1_9_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_9_1/RedfishDrive_V1_9_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_9_2/Drive_V1_9_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_9_2/RedfishDrive_V1_9_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Drive/v1_9_3/Drive_V1_9_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Drive/v1_9_3/RedfishDrive_V1_9_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/DriveCollection/DriveCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/DriveCollection/RedfishDriveCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_0_0/Endpoint_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_0_0/RedfishEndpoint_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_0_1/Endpoint_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_0_1/RedfishEndpoint_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_0_10/Endpoint_V1_0_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_0_10/RedfishEndpoint_V1_0_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_0_2/Endpoint_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_0_2/RedfishEndpoint_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_0_3/Endpoint_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_0_3/RedfishEndpoint_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_0_4/Endpoint_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_0_4/RedfishEndpoint_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_0_5/Endpoint_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_0_5/RedfishEndpoint_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_0_6/Endpoint_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_0_6/RedfishEndpoint_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_0_7/Endpoint_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_0_7/RedfishEndpoint_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_0_8/Endpoint_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_0_8/RedfishEndpoint_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_0_9/Endpoint_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_0_9/RedfishEndpoint_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_1_0/Endpoint_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_1_0/RedfishEndpoint_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_1_1/Endpoint_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_1_1/RedfishEndpoint_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_1_2/Endpoint_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_1_2/RedfishEndpoint_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_1_3/Endpoint_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_1_3/RedfishEndpoint_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_1_4/Endpoint_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_1_4/RedfishEndpoint_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_1_5/Endpoint_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_1_5/RedfishEndpoint_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_1_6/Endpoint_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_1_6/RedfishEndpoint_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_1_7/Endpoint_V1_1_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_1_7/RedfishEndpoint_V1_1_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_2_0/Endpoint_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_2_0/RedfishEndpoint_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_2_1/Endpoint_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_2_1/RedfishEndpoint_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_2_2/Endpoint_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_2_2/RedfishEndpoint_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_2_3/Endpoint_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_2_3/RedfishEndpoint_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_2_4/Endpoint_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_2_4/RedfishEndpoint_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_2_5/Endpoint_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_2_5/RedfishEndpoint_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_2_6/Endpoint_V1_2_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_2_6/RedfishEndpoint_V1_2_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_3_0/Endpoint_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_3_0/RedfishEndpoint_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_3_1/Endpoint_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_3_1/RedfishEndpoint_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_3_2/Endpoint_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_3_2/RedfishEndpoint_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_3_3/Endpoint_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_3_3/RedfishEndpoint_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_3_4/Endpoint_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_3_4/RedfishEndpoint_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_3_5/Endpoint_V1_3_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_3_5/RedfishEndpoint_V1_3_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_4_0/Endpoint_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_4_0/RedfishEndpoint_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_4_1/Endpoint_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_4_1/RedfishEndpoint_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_4_2/Endpoint_V1_4_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_4_2/RedfishEndpoint_V1_4_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_4_3/Endpoint_V1_4_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_4_3/RedfishEndpoint_V1_4_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_5_0/Endpoint_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_5_0/RedfishEndpoint_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_5_1/Endpoint_V1_5_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Endpoint/v1_5_1/RedfishEndpoint_V1_5_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EndpointCollection/EndpointCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/EndpointCollection/RedfishEndpointCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_0_0/EndpointGroup_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_0_0/RedfishEndpointGroup_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_0_1/EndpointGroup_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_0_1/RedfishEndpointGroup_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_0_2/EndpointGroup_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_0_2/RedfishEndpointGroup_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_0_3/EndpointGroup_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_0_3/RedfishEndpointGroup_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_0_4/EndpointGroup_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_0_4/RedfishEndpointGroup_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_1_0/EndpointGroup_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_1_0/RedfishEndpointGroup_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_1_1/EndpointGroup_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_1_1/RedfishEndpointGroup_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_1_2/EndpointGroup_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_1_2/RedfishEndpointGroup_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_1_3/EndpointGroup_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_1_3/RedfishEndpointGroup_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_1_4/EndpointGroup_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_1_4/RedfishEndpointGroup_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_1_5/EndpointGroup_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_1_5/RedfishEndpointGroup_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_2_0/EndpointGroup_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_2_0/RedfishEndpointGroup_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_2_1/EndpointGroup_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_2_1/RedfishEndpointGroup_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_2_2/EndpointGroup_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_2_2/RedfishEndpointGroup_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_2_3/EndpointGroup_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_2_3/RedfishEndpointGroup_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_3_0/EndpointGroup_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_3_0/RedfishEndpointGroup_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_3_1/EndpointGroup_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EndpointGroup/v1_3_1/RedfishEndpointGroup_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EndpointGroupCollection/EndpointGroupCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/EndpointGroupCollection/RedfishEndpointGroupCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EnvironmentMetrics/v1_0_0/EnvironmentMetrics_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EnvironmentMetrics/v1_0_0/RedfishEnvironmentMetrics_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_0_0/EthernetInterface_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_0_0/RedfishEthernetInterface_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_0_10/EthernetInterface_V1_0_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_0_10/RedfishEthernetInterface_V1_0_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_0_11/EthernetInterface_V1_0_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_0_11/RedfishEthernetInterface_V1_0_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_0_12/EthernetInterface_V1_0_12_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_0_12/RedfishEthernetInterface_V1_0_12_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_0_2/EthernetInterface_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_0_2/RedfishEthernetInterface_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_0_3/EthernetInterface_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_0_3/RedfishEthernetInterface_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_0_4/EthernetInterface_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_0_4/RedfishEthernetInterface_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_0_5/EthernetInterface_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_0_5/RedfishEthernetInterface_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_0_6/EthernetInterface_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_0_6/RedfishEthernetInterface_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_0_7/EthernetInterface_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_0_7/RedfishEthernetInterface_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_0_8/EthernetInterface_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_0_8/RedfishEthernetInterface_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_0_9/EthernetInterface_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_0_9/RedfishEthernetInterface_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_1_0/EthernetInterface_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_1_0/RedfishEthernetInterface_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_1_1/EthernetInterface_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_1_1/RedfishEthernetInterface_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_1_10/EthernetInterface_V1_1_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_1_10/RedfishEthernetInterface_V1_1_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_1_2/EthernetInterface_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_1_2/RedfishEthernetInterface_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_1_3/EthernetInterface_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_1_3/RedfishEthernetInterface_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_1_4/EthernetInterface_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_1_4/RedfishEthernetInterface_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_1_5/EthernetInterface_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_1_5/RedfishEthernetInterface_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_1_6/EthernetInterface_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_1_6/RedfishEthernetInterface_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_1_7/EthernetInterface_V1_1_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_1_7/RedfishEthernetInterface_V1_1_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_1_8/EthernetInterface_V1_1_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_1_8/RedfishEthernetInterface_V1_1_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_1_9/EthernetInterface_V1_1_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_1_9/RedfishEthernetInterface_V1_1_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_2_0/EthernetInterface_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_2_0/RedfishEthernetInterface_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_2_1/EthernetInterface_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_2_1/RedfishEthernetInterface_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_2_2/EthernetInterface_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_2_2/RedfishEthernetInterface_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_2_3/EthernetInterface_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_2_3/RedfishEthernetInterface_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_2_4/EthernetInterface_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_2_4/RedfishEthernetInterface_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_2_5/EthernetInterface_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_2_5/RedfishEthernetInterface_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_2_6/EthernetInterface_V1_2_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_2_6/RedfishEthernetInterface_V1_2_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_2_7/EthernetInterface_V1_2_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_2_7/RedfishEthernetInterface_V1_2_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_2_8/EthernetInterface_V1_2_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_2_8/RedfishEthernetInterface_V1_2_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_2_9/EthernetInterface_V1_2_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_2_9/RedfishEthernetInterface_V1_2_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_3_0/EthernetInterface_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_3_0/RedfishEthernetInterface_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_3_1/EthernetInterface_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_3_1/RedfishEthernetInterface_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_3_2/EthernetInterface_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_3_2/RedfishEthernetInterface_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_3_3/EthernetInterface_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_3_3/RedfishEthernetInterface_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_3_4/EthernetInterface_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_3_4/RedfishEthernetInterface_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_3_5/EthernetInterface_V1_3_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_3_5/RedfishEthernetInterface_V1_3_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_3_6/EthernetInterface_V1_3_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_3_6/RedfishEthernetInterface_V1_3_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_3_7/EthernetInterface_V1_3_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_3_7/RedfishEthernetInterface_V1_3_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_3_8/EthernetInterface_V1_3_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_3_8/RedfishEthernetInterface_V1_3_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_4_0/EthernetInterface_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_4_0/RedfishEthernetInterface_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_4_1/EthernetInterface_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_4_1/RedfishEthernetInterface_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_4_2/EthernetInterface_V1_4_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_4_2/RedfishEthernetInterface_V1_4_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_4_3/EthernetInterface_V1_4_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_4_3/RedfishEthernetInterface_V1_4_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_4_4/EthernetInterface_V1_4_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_4_4/RedfishEthernetInterface_V1_4_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_4_5/EthernetInterface_V1_4_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_4_5/RedfishEthernetInterface_V1_4_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_4_6/EthernetInterface_V1_4_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_4_6/RedfishEthernetInterface_V1_4_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_4_7/EthernetInterface_V1_4_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_4_7/RedfishEthernetInterface_V1_4_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_5_0/EthernetInterface_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_5_0/RedfishEthernetInterface_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_5_1/EthernetInterface_V1_5_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_5_1/RedfishEthernetInterface_V1_5_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_5_2/EthernetInterface_V1_5_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_5_2/RedfishEthernetInterface_V1_5_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_5_3/EthernetInterface_V1_5_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_5_3/RedfishEthernetInterface_V1_5_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_5_4/EthernetInterface_V1_5_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_5_4/RedfishEthernetInterface_V1_5_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_5_5/EthernetInterface_V1_5_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_5_5/RedfishEthernetInterface_V1_5_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_6_0/EthernetInterface_V1_6_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_6_0/RedfishEthernetInterface_V1_6_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_6_1/EthernetInterface_V1_6_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_6_1/RedfishEthernetInterface_V1_6_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_6_2/EthernetInterface_V1_6_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_6_2/RedfishEthernetInterface_V1_6_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_6_3/EthernetInterface_V1_6_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterface/v1_6_3/RedfishEthernetInterface_V1_6_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EthernetInterfaceCollection/EthernetInterfaceCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/EthernetInterfaceCollection/RedfishEthernetInterfaceCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_0_0/Event_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_0_0/RedfishEvent_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_0_10/Event_V1_0_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_0_10/RedfishEvent_V1_0_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_0_11/Event_V1_0_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_0_11/RedfishEvent_V1_0_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_0_12/Event_V1_0_12_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_0_12/RedfishEvent_V1_0_12_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_0_13/Event_V1_0_13_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_0_13/RedfishEvent_V1_0_13_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_0_2/Event_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_0_2/RedfishEvent_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_0_3/Event_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_0_3/RedfishEvent_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_0_4/Event_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_0_4/RedfishEvent_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_0_5/Event_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_0_5/RedfishEvent_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_0_6/Event_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_0_6/RedfishEvent_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_0_7/Event_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_0_7/RedfishEvent_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_0_8/Event_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_0_8/RedfishEvent_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_0_9/Event_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_0_9/RedfishEvent_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_1_0/Event_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_1_0/RedfishEvent_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_1_1/Event_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_1_1/RedfishEvent_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_1_10/Event_V1_1_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_1_10/RedfishEvent_V1_1_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_1_11/Event_V1_1_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_1_11/RedfishEvent_V1_1_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_1_2/Event_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_1_2/RedfishEvent_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_1_3/Event_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_1_3/RedfishEvent_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_1_4/Event_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_1_4/RedfishEvent_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_1_5/Event_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_1_5/RedfishEvent_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_1_6/Event_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_1_6/RedfishEvent_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_1_7/Event_V1_1_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_1_7/RedfishEvent_V1_1_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_1_8/Event_V1_1_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_1_8/RedfishEvent_V1_1_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_1_9/Event_V1_1_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_1_9/RedfishEvent_V1_1_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_2_0/Event_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_2_0/RedfishEvent_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_2_1/Event_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_2_1/RedfishEvent_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_2_2/Event_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_2_2/RedfishEvent_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_2_3/Event_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_2_3/RedfishEvent_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_2_4/Event_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_2_4/RedfishEvent_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_2_5/Event_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_2_5/RedfishEvent_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_2_6/Event_V1_2_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_2_6/RedfishEvent_V1_2_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_2_7/Event_V1_2_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_2_7/RedfishEvent_V1_2_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_2_8/Event_V1_2_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_2_8/RedfishEvent_V1_2_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_3_0/Event_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_3_0/RedfishEvent_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_3_1/Event_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_3_1/RedfishEvent_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_3_2/Event_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_3_2/RedfishEvent_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_3_3/Event_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_3_3/RedfishEvent_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_3_4/Event_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_3_4/RedfishEvent_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_3_5/Event_V1_3_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_3_5/RedfishEvent_V1_3_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_3_6/Event_V1_3_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_3_6/RedfishEvent_V1_3_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_4_0/Event_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_4_0/RedfishEvent_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_4_1/Event_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_4_1/RedfishEvent_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_4_2/Event_V1_4_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_4_2/RedfishEvent_V1_4_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_4_3/Event_V1_4_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_4_3/RedfishEvent_V1_4_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_4_4/Event_V1_4_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_4_4/RedfishEvent_V1_4_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_5_0/Event_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_5_0/RedfishEvent_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_5_1/Event_V1_5_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_5_1/RedfishEvent_V1_5_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_5_2/Event_V1_5_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_5_2/RedfishEvent_V1_5_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_6_0/Event_V1_6_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_6_0/RedfishEvent_V1_6_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Event/v1_6_1/Event_V1_6_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Event/v1_6_1/RedfishEvent_V1_6_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_0_0/EventDestination_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_0_0/RedfishEventDestination_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_0_2/EventDestination_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_0_2/RedfishEventDestination_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_0_3/EventDestination_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_0_3/RedfishEventDestination_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_0_4/EventDestination_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_0_4/RedfishEventDestination_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_0_5/EventDestination_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_0_5/RedfishEventDestination_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_0_6/EventDestination_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_0_6/RedfishEventDestination_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_0_7/EventDestination_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_0_7/RedfishEventDestination_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_0_8/EventDestination_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_0_8/RedfishEventDestination_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_0_9/EventDestination_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_0_9/RedfishEventDestination_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_10_0/EventDestination_V1_10_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_10_0/RedfishEventDestination_V1_10_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_1_0/EventDestination_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_1_0/RedfishEventDestination_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_1_1/EventDestination_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_1_1/RedfishEventDestination_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_1_2/EventDestination_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_1_2/RedfishEventDestination_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_1_3/EventDestination_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_1_3/RedfishEventDestination_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_1_4/EventDestination_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_1_4/RedfishEventDestination_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_1_5/EventDestination_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_1_5/RedfishEventDestination_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_1_6/EventDestination_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_1_6/RedfishEventDestination_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_1_7/EventDestination_V1_1_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_1_7/RedfishEventDestination_V1_1_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_1_8/EventDestination_V1_1_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_1_8/RedfishEventDestination_V1_1_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_2_0/EventDestination_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_2_0/RedfishEventDestination_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_2_1/EventDestination_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_2_1/RedfishEventDestination_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_2_2/EventDestination_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_2_2/RedfishEventDestination_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_2_3/EventDestination_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_2_3/RedfishEventDestination_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_2_4/EventDestination_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_2_4/RedfishEventDestination_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_2_5/EventDestination_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_2_5/RedfishEventDestination_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_2_6/EventDestination_V1_2_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_2_6/RedfishEventDestination_V1_2_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_3_0/EventDestination_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_3_0/RedfishEventDestination_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_3_1/EventDestination_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_3_1/RedfishEventDestination_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_3_2/EventDestination_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_3_2/RedfishEventDestination_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_3_3/EventDestination_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_3_3/RedfishEventDestination_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_3_4/EventDestination_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_3_4/RedfishEventDestination_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_4_0/EventDestination_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_4_0/RedfishEventDestination_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_4_1/EventDestination_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_4_1/RedfishEventDestination_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_4_2/EventDestination_V1_4_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_4_2/RedfishEventDestination_V1_4_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_4_3/EventDestination_V1_4_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_4_3/RedfishEventDestination_V1_4_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_5_0/EventDestination_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_5_0/RedfishEventDestination_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_5_1/EventDestination_V1_5_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_5_1/RedfishEventDestination_V1_5_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_5_2/EventDestination_V1_5_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_5_2/RedfishEventDestination_V1_5_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_6_0/EventDestination_V1_6_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_6_0/RedfishEventDestination_V1_6_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_6_1/EventDestination_V1_6_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_6_1/RedfishEventDestination_V1_6_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_6_2/EventDestination_V1_6_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_6_2/RedfishEventDestination_V1_6_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_7_0/EventDestination_V1_7_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_7_0/RedfishEventDestination_V1_7_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_7_1/EventDestination_V1_7_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_7_1/RedfishEventDestination_V1_7_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_7_2/EventDestination_V1_7_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_7_2/RedfishEventDestination_V1_7_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_8_0/EventDestination_V1_8_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_8_0/RedfishEventDestination_V1_8_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_8_1/EventDestination_V1_8_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_8_1/RedfishEventDestination_V1_8_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_8_2/EventDestination_V1_8_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_8_2/RedfishEventDestination_V1_8_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_9_0/EventDestination_V1_9_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_9_0/RedfishEventDestination_V1_9_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_9_1/EventDestination_V1_9_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestination/v1_9_1/RedfishEventDestination_V1_9_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventDestinationCollection/EventDestinationCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventDestinationCollection/RedfishEventDestinationCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_0/EventService_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_0/RedfishEventService_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_10/EventService_V1_0_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_10/RedfishEventService_V1_0_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_11/EventService_V1_0_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_11/RedfishEventService_V1_0_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_12/EventService_V1_0_12_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_12/RedfishEventService_V1_0_12_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_13/EventService_V1_0_13_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_13/RedfishEventService_V1_0_13_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_2/EventService_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_2/RedfishEventService_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_3/EventService_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_3/RedfishEventService_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_4/EventService_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_4/RedfishEventService_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_5/EventService_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_5/RedfishEventService_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_6/EventService_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_6/RedfishEventService_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_7/EventService_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_7/RedfishEventService_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_8/EventService_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_8/RedfishEventService_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_9/EventService_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_0_9/RedfishEventService_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_1_0/EventService_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_1_0/RedfishEventService_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_1_1/EventService_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_1_1/RedfishEventService_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_1_2/EventService_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_1_2/RedfishEventService_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_1_3/EventService_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_1_3/RedfishEventService_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_1_4/EventService_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_1_4/RedfishEventService_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_1_5/EventService_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_1_5/RedfishEventService_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_1_6/EventService_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_1_6/RedfishEventService_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_2_0/EventService_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_2_0/RedfishEventService_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_2_1/EventService_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_2_1/RedfishEventService_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_2_2/EventService_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_2_2/RedfishEventService_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_2_3/EventService_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_2_3/RedfishEventService_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_2_4/EventService_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_2_4/RedfishEventService_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_2_5/EventService_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_2_5/RedfishEventService_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_3_0/EventService_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_3_0/RedfishEventService_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_3_1/EventService_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_3_1/RedfishEventService_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_3_2/EventService_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_3_2/RedfishEventService_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_3_3/EventService_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_3_3/RedfishEventService_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_3_4/EventService_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_3_4/RedfishEventService_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_4_0/EventService_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_4_0/RedfishEventService_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_4_1/EventService_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_4_1/RedfishEventService_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_4_2/EventService_V1_4_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_4_2/RedfishEventService_V1_4_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_4_3/EventService_V1_4_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_4_3/RedfishEventService_V1_4_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_5_0/EventService_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_5_0/RedfishEventService_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_5_1/EventService_V1_5_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_5_1/RedfishEventService_V1_5_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_5_2/EventService_V1_5_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_5_2/RedfishEventService_V1_5_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_5_3/EventService_V1_5_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_5_3/RedfishEventService_V1_5_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_6_0/EventService_V1_6_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_6_0/RedfishEventService_V1_6_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_6_1/EventService_V1_6_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_6_1/RedfishEventService_V1_6_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_6_2/EventService_V1_6_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_6_2/RedfishEventService_V1_6_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_7_0/EventService_V1_7_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_7_0/RedfishEventService_V1_7_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/EventService/v1_7_1/EventService_V1_7_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/EventService/v1_7_1/RedfishEventService_V1_7_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_0/ExternalAccountProvider_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_0/RedfishExternalAccountProvider_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_1/ExternalAccountProvider_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_1/RedfishExternalAccountProvider_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_2/ExternalAccountProvider_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_2/RedfishExternalAccountProvider_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_3/ExternalAccountProvider_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_3/RedfishExternalAccountProvider_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_4/ExternalAccountProvider_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_4/RedfishExternalAccountProvider_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_5/ExternalAccountProvider_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_5/RedfishExternalAccountProvider_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_0/ExternalAccountProvider_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_0/RedfishExternalAccountProvider_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_1/ExternalAccountProvider_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_1/RedfishExternalAccountProvider_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_2/ExternalAccountProvider_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_2/RedfishExternalAccountProvider_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_3/ExternalAccountProvider_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_3/RedfishExternalAccountProvider_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_4/ExternalAccountProvider_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_4/RedfishExternalAccountProvider_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ExternalAccountProvider/v1_2_0/ExternalAccountProvider_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ExternalAccountProvider/v1_2_0/RedfishExternalAccountProvider_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ExternalAccountProviderCollection/ExternalAccountProviderCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/ExternalAccountProviderCollection/RedfishExternalAccountProviderCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Fabric/v1_0_0/Fabric_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Fabric/v1_0_0/RedfishFabric_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Fabric/v1_0_1/Fabric_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Fabric/v1_0_1/RedfishFabric_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Fabric/v1_0_2/Fabric_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Fabric/v1_0_2/RedfishFabric_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Fabric/v1_0_3/Fabric_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Fabric/v1_0_3/RedfishFabric_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Fabric/v1_0_4/Fabric_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Fabric/v1_0_4/RedfishFabric_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Fabric/v1_0_5/Fabric_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Fabric/v1_0_5/RedfishFabric_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Fabric/v1_0_6/Fabric_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Fabric/v1_0_6/RedfishFabric_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Fabric/v1_0_7/Fabric_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Fabric/v1_0_7/RedfishFabric_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Fabric/v1_0_8/Fabric_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Fabric/v1_0_8/RedfishFabric_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Fabric/v1_1_0/Fabric_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Fabric/v1_1_0/RedfishFabric_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Fabric/v1_1_1/Fabric_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Fabric/v1_1_1/RedfishFabric_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Fabric/v1_1_2/Fabric_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Fabric/v1_1_2/RedfishFabric_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Fabric/v1_2_0/Fabric_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Fabric/v1_2_0/RedfishFabric_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Fabric/v1_2_1/Fabric_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Fabric/v1_2_1/RedfishFabric_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/FabricAdapter/v1_0_0/FabricAdapter_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/FabricAdapter/v1_0_0/RedfishFabricAdapter_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/FabricAdapterCollection/FabricAdapterCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/FabricAdapterCollection/RedfishFabricAdapterCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/FabricCollection/FabricCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/FabricCollection/RedfishFabricCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Facility/v1_0_0/Facility_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Facility/v1_0_0/RedfishFacility_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Facility/v1_0_1/Facility_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Facility/v1_0_1/RedfishFacility_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Facility/v1_1_0/Facility_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Facility/v1_1_0/RedfishFacility_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/FacilityCollection/FacilityCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/FacilityCollection/RedfishFacilityCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Fan/v1_0_0/Fan_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Fan/v1_0_0/RedfishFan_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/FanCollection/FanCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/FanCollection/RedfishFanCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_0_0/HostInterface_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_0_0/RedfishHostInterface_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_0_1/HostInterface_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_0_1/RedfishHostInterface_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_0_2/HostInterface_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_0_2/RedfishHostInterface_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_0_3/HostInterface_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_0_3/RedfishHostInterface_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_0_4/HostInterface_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_0_4/RedfishHostInterface_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_0_5/HostInterface_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_0_5/RedfishHostInterface_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_1_0/HostInterface_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_1_0/RedfishHostInterface_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_1_1/HostInterface_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_1_1/RedfishHostInterface_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_1_2/HostInterface_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_1_2/RedfishHostInterface_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_1_3/HostInterface_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_1_3/RedfishHostInterface_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_1_4/HostInterface_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_1_4/RedfishHostInterface_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_1_5/HostInterface_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_1_5/RedfishHostInterface_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_2_0/HostInterface_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_2_0/RedfishHostInterface_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_2_1/HostInterface_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_2_1/RedfishHostInterface_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_2_2/HostInterface_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_2_2/RedfishHostInterface_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_3_0/HostInterface_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/HostInterface/v1_3_0/RedfishHostInterface_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/HostInterfaceCollection/HostInterfaceCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/HostInterfaceCollection/RedfishHostInterfaceCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Job/v1_0_0/Job_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Job/v1_0_0/RedfishJob_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Job/v1_0_1/Job_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Job/v1_0_1/RedfishJob_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Job/v1_0_2/Job_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Job/v1_0_2/RedfishJob_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Job/v1_0_3/Job_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Job/v1_0_3/RedfishJob_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Job/v1_0_4/Job_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Job/v1_0_4/RedfishJob_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Job/v1_0_5/Job_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Job/v1_0_5/RedfishJob_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Job/v1_0_6/Job_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Job/v1_0_6/RedfishJob_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/JobCollection/JobCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/JobCollection/RedfishJobCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/JobService/v1_0_0/JobService_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/JobService/v1_0_0/RedfishJobService_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/JobService/v1_0_1/JobService_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/JobService/v1_0_1/RedfishJobService_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/JobService/v1_0_2/JobService_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/JobService/v1_0_2/RedfishJobService_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/JobService/v1_0_3/JobService_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/JobService/v1_0_3/RedfishJobService_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/JobService/v1_0_4/JobService_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/JobService/v1_0_4/RedfishJobService_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_0_0/JsonSchemaFile_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_0_0/RedfishJsonSchemaFile_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_0_2/JsonSchemaFile_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_0_2/RedfishJsonSchemaFile_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_0_3/JsonSchemaFile_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_0_3/RedfishJsonSchemaFile_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_0_4/JsonSchemaFile_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_0_4/RedfishJsonSchemaFile_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_0_5/JsonSchemaFile_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_0_5/RedfishJsonSchemaFile_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_0_6/JsonSchemaFile_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_0_6/RedfishJsonSchemaFile_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_0_7/JsonSchemaFile_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_0_7/RedfishJsonSchemaFile_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_0_8/JsonSchemaFile_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_0_8/RedfishJsonSchemaFile_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_1_0/JsonSchemaFile_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_1_0/RedfishJsonSchemaFile_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_1_1/JsonSchemaFile_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_1_1/RedfishJsonSchemaFile_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_1_2/JsonSchemaFile_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_1_2/RedfishJsonSchemaFile_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_1_3/JsonSchemaFile_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_1_3/RedfishJsonSchemaFile_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_1_4/JsonSchemaFile_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/JsonSchemaFile/v1_1_4/RedfishJsonSchemaFile_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/JsonSchemaFileCollection/JsonSchemaFileCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/JsonSchemaFileCollection/RedfishJsonSchemaFileCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_0/LogEntry_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_0/RedfishLogEntry_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_10/LogEntry_V1_0_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_10/RedfishLogEntry_V1_0_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_11/LogEntry_V1_0_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_11/RedfishLogEntry_V1_0_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_12/LogEntry_V1_0_12_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_12/RedfishLogEntry_V1_0_12_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_13/LogEntry_V1_0_13_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_13/RedfishLogEntry_V1_0_13_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_14/LogEntry_V1_0_14_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_14/RedfishLogEntry_V1_0_14_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_2/LogEntry_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_2/RedfishLogEntry_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_3/LogEntry_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_3/RedfishLogEntry_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_4/LogEntry_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_4/RedfishLogEntry_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_5/LogEntry_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_5/RedfishLogEntry_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_6/LogEntry_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_6/RedfishLogEntry_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_7/LogEntry_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_7/RedfishLogEntry_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_8/LogEntry_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_8/RedfishLogEntry_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_9/LogEntry_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_0_9/RedfishLogEntry_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_0/LogEntry_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_0/RedfishLogEntry_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_1/LogEntry_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_1/RedfishLogEntry_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_10/LogEntry_V1_1_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_10/RedfishLogEntry_V1_1_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_11/LogEntry_V1_1_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_11/RedfishLogEntry_V1_1_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_12/LogEntry_V1_1_12_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_12/RedfishLogEntry_V1_1_12_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_2/LogEntry_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_2/RedfishLogEntry_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_3/LogEntry_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_3/RedfishLogEntry_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_4/LogEntry_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_4/RedfishLogEntry_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_5/LogEntry_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_5/RedfishLogEntry_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_6/LogEntry_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_6/RedfishLogEntry_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_7/LogEntry_V1_1_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_7/RedfishLogEntry_V1_1_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_8/LogEntry_V1_1_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_8/RedfishLogEntry_V1_1_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_9/LogEntry_V1_1_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_1_9/RedfishLogEntry_V1_1_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_2_0/LogEntry_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_2_0/RedfishLogEntry_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_2_1/LogEntry_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_2_1/RedfishLogEntry_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_2_10/LogEntry_V1_2_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_2_10/RedfishLogEntry_V1_2_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_2_2/LogEntry_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_2_2/RedfishLogEntry_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_2_3/LogEntry_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_2_3/RedfishLogEntry_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_2_4/LogEntry_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_2_4/RedfishLogEntry_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_2_5/LogEntry_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_2_5/RedfishLogEntry_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_2_6/LogEntry_V1_2_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_2_6/RedfishLogEntry_V1_2_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_2_7/LogEntry_V1_2_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_2_7/RedfishLogEntry_V1_2_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_2_8/LogEntry_V1_2_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_2_8/RedfishLogEntry_V1_2_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_2_9/LogEntry_V1_2_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_2_9/RedfishLogEntry_V1_2_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_3_0/LogEntry_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_3_0/RedfishLogEntry_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_3_1/LogEntry_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_3_1/RedfishLogEntry_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_3_2/LogEntry_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_3_2/RedfishLogEntry_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_3_3/LogEntry_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_3_3/RedfishLogEntry_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_3_4/LogEntry_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_3_4/RedfishLogEntry_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_3_5/LogEntry_V1_3_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_3_5/RedfishLogEntry_V1_3_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_3_6/LogEntry_V1_3_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_3_6/RedfishLogEntry_V1_3_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_3_7/LogEntry_V1_3_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_3_7/RedfishLogEntry_V1_3_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_3_8/LogEntry_V1_3_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_3_8/RedfishLogEntry_V1_3_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_3_9/LogEntry_V1_3_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_3_9/RedfishLogEntry_V1_3_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_4_0/LogEntry_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_4_0/RedfishLogEntry_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_4_1/LogEntry_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_4_1/RedfishLogEntry_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_4_2/LogEntry_V1_4_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_4_2/RedfishLogEntry_V1_4_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_4_3/LogEntry_V1_4_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_4_3/RedfishLogEntry_V1_4_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_4_4/LogEntry_V1_4_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_4_4/RedfishLogEntry_V1_4_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_4_5/LogEntry_V1_4_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_4_5/RedfishLogEntry_V1_4_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_4_6/LogEntry_V1_4_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_4_6/RedfishLogEntry_V1_4_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_4_7/LogEntry_V1_4_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_4_7/RedfishLogEntry_V1_4_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_4_8/LogEntry_V1_4_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_4_8/RedfishLogEntry_V1_4_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_5_0/LogEntry_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_5_0/RedfishLogEntry_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_5_1/LogEntry_V1_5_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_5_1/RedfishLogEntry_V1_5_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_5_2/LogEntry_V1_5_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_5_2/RedfishLogEntry_V1_5_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_5_3/LogEntry_V1_5_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_5_3/RedfishLogEntry_V1_5_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_5_4/LogEntry_V1_5_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_5_4/RedfishLogEntry_V1_5_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_6_0/LogEntry_V1_6_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_6_0/RedfishLogEntry_V1_6_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_6_1/LogEntry_V1_6_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_6_1/RedfishLogEntry_V1_6_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_6_2/LogEntry_V1_6_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_6_2/RedfishLogEntry_V1_6_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_6_3/LogEntry_V1_6_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_6_3/RedfishLogEntry_V1_6_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_7_0/LogEntry_V1_7_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_7_0/RedfishLogEntry_V1_7_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_7_1/LogEntry_V1_7_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_7_1/RedfishLogEntry_V1_7_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_8_0/LogEntry_V1_8_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntry/v1_8_0/RedfishLogEntry_V1_8_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogEntryCollection/LogEntryCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogEntryCollection/RedfishLogEntryCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogService/v1_0_0/LogService_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogService/v1_0_0/RedfishLogService_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogService/v1_0_2/LogService_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogService/v1_0_2/RedfishLogService_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogService/v1_0_3/LogService_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogService/v1_0_3/RedfishLogService_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogService/v1_0_4/LogService_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogService/v1_0_4/RedfishLogService_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogService/v1_0_5/LogService_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogService/v1_0_5/RedfishLogService_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogService/v1_0_6/LogService_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogService/v1_0_6/RedfishLogService_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogService/v1_0_7/LogService_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogService/v1_0_7/RedfishLogService_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogService/v1_0_8/LogService_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogService/v1_0_8/RedfishLogService_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogService/v1_1_0/LogService_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogService/v1_1_0/RedfishLogService_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogService/v1_1_1/LogService_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogService/v1_1_1/RedfishLogService_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogService/v1_1_2/LogService_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogService/v1_1_2/RedfishLogService_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogService/v1_1_3/LogService_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogService/v1_1_3/RedfishLogService_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogService/v1_2_0/LogService_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogService/v1_2_0/RedfishLogService_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/LogServiceCollection/LogServiceCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/LogServiceCollection/RedfishLogServiceCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_0/Manager_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_0/RedfishManager_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_1/Manager_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_1/RedfishManager_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_10/Manager_V1_0_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_10/RedfishManager_V1_0_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_11/Manager_V1_0_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_11/RedfishManager_V1_0_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_12/Manager_V1_0_12_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_12/RedfishManager_V1_0_12_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_13/Manager_V1_0_13_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_13/RedfishManager_V1_0_13_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_14/Manager_V1_0_14_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_14/RedfishManager_V1_0_14_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_2/Manager_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_2/RedfishManager_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_3/Manager_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_3/RedfishManager_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_4/Manager_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_4/RedfishManager_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_5/Manager_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_5/RedfishManager_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_6/Manager_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_6/RedfishManager_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_7/Manager_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_7/RedfishManager_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_8/Manager_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_8/RedfishManager_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_9/Manager_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_0_9/RedfishManager_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_10_0/Manager_V1_10_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_10_0/RedfishManager_V1_10_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_10_1/Manager_V1_10_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_10_1/RedfishManager_V1_10_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_11_0/Manager_V1_11_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_11_0/RedfishManager_V1_11_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_0/Manager_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_0/RedfishManager_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_1/Manager_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_1/RedfishManager_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_10/Manager_V1_1_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_10/RedfishManager_V1_1_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_11/Manager_V1_1_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_11/RedfishManager_V1_1_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_12/Manager_V1_1_12_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_12/RedfishManager_V1_1_12_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_2/Manager_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_2/RedfishManager_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_3/Manager_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_3/RedfishManager_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_4/Manager_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_4/RedfishManager_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_5/Manager_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_5/RedfishManager_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_6/Manager_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_6/RedfishManager_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_7/Manager_V1_1_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_7/RedfishManager_V1_1_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_8/Manager_V1_1_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_8/RedfishManager_V1_1_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_9/Manager_V1_1_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_1_9/RedfishManager_V1_1_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_0/Manager_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_0/RedfishManager_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_1/Manager_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_1/RedfishManager_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_10/Manager_V1_2_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_10/RedfishManager_V1_2_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_11/Manager_V1_2_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_11/RedfishManager_V1_2_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_12/Manager_V1_2_12_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_12/RedfishManager_V1_2_12_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_2/Manager_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_2/RedfishManager_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_3/Manager_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_3/RedfishManager_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_4/Manager_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_4/RedfishManager_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_5/Manager_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_5/RedfishManager_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_6/Manager_V1_2_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_6/RedfishManager_V1_2_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_7/Manager_V1_2_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_7/RedfishManager_V1_2_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_8/Manager_V1_2_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_8/RedfishManager_V1_2_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_9/Manager_V1_2_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_2_9/RedfishManager_V1_2_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_3_0/Manager_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_3_0/RedfishManager_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_3_1/Manager_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_3_1/RedfishManager_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_3_10/Manager_V1_3_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_3_10/RedfishManager_V1_3_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_3_11/Manager_V1_3_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_3_11/RedfishManager_V1_3_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_3_2/Manager_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_3_2/RedfishManager_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_3_3/Manager_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_3_3/RedfishManager_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_3_4/Manager_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_3_4/RedfishManager_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_3_5/Manager_V1_3_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_3_5/RedfishManager_V1_3_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_3_6/Manager_V1_3_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_3_6/RedfishManager_V1_3_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_3_7/Manager_V1_3_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_3_7/RedfishManager_V1_3_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_3_8/Manager_V1_3_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_3_8/RedfishManager_V1_3_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_3_9/Manager_V1_3_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_3_9/RedfishManager_V1_3_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_4_0/Manager_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_4_0/RedfishManager_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_4_1/Manager_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_4_1/RedfishManager_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_4_2/Manager_V1_4_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_4_2/RedfishManager_V1_4_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_4_3/Manager_V1_4_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_4_3/RedfishManager_V1_4_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_4_4/Manager_V1_4_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_4_4/RedfishManager_V1_4_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_4_5/Manager_V1_4_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_4_5/RedfishManager_V1_4_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_4_6/Manager_V1_4_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_4_6/RedfishManager_V1_4_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_4_7/Manager_V1_4_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_4_7/RedfishManager_V1_4_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_4_8/Manager_V1_4_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_4_8/RedfishManager_V1_4_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_5_0/Manager_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_5_0/RedfishManager_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_5_1/Manager_V1_5_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_5_1/RedfishManager_V1_5_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_5_2/Manager_V1_5_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_5_2/RedfishManager_V1_5_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_5_3/Manager_V1_5_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_5_3/RedfishManager_V1_5_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_5_4/Manager_V1_5_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_5_4/RedfishManager_V1_5_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_5_5/Manager_V1_5_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_5_5/RedfishManager_V1_5_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_5_6/Manager_V1_5_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_5_6/RedfishManager_V1_5_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_5_7/Manager_V1_5_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_5_7/RedfishManager_V1_5_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_6_0/Manager_V1_6_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_6_0/RedfishManager_V1_6_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_6_1/Manager_V1_6_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_6_1/RedfishManager_V1_6_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_6_2/Manager_V1_6_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_6_2/RedfishManager_V1_6_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_6_3/Manager_V1_6_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_6_3/RedfishManager_V1_6_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_6_4/Manager_V1_6_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_6_4/RedfishManager_V1_6_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_7_0/Manager_V1_7_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_7_0/RedfishManager_V1_7_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_7_1/Manager_V1_7_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_7_1/RedfishManager_V1_7_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_7_2/Manager_V1_7_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_7_2/RedfishManager_V1_7_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_7_3/Manager_V1_7_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_7_3/RedfishManager_V1_7_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_7_4/Manager_V1_7_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_7_4/RedfishManager_V1_7_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_8_0/Manager_V1_8_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_8_0/RedfishManager_V1_8_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_8_1/Manager_V1_8_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_8_1/RedfishManager_V1_8_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_8_2/Manager_V1_8_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_8_2/RedfishManager_V1_8_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_8_3/Manager_V1_8_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_8_3/RedfishManager_V1_8_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_9_0/Manager_V1_9_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_9_0/RedfishManager_V1_9_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_9_1/Manager_V1_9_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_9_1/RedfishManager_V1_9_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Manager/v1_9_2/Manager_V1_9_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Manager/v1_9_2/RedfishManager_V1_9_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_0_0/ManagerAccount_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_0_0/RedfishManagerAccount_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_0_10/ManagerAccount_V1_0_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_0_10/RedfishManagerAccount_V1_0_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_0_11/ManagerAccount_V1_0_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_0_11/RedfishManagerAccount_V1_0_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_0_2/ManagerAccount_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_0_2/RedfishManagerAccount_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_0_3/ManagerAccount_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_0_3/RedfishManagerAccount_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_0_4/ManagerAccount_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_0_4/RedfishManagerAccount_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_0_5/ManagerAccount_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_0_5/RedfishManagerAccount_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_0_6/ManagerAccount_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_0_6/RedfishManagerAccount_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_0_7/ManagerAccount_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_0_7/RedfishManagerAccount_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_0_8/ManagerAccount_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_0_8/RedfishManagerAccount_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_0_9/ManagerAccount_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_0_9/RedfishManagerAccount_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_1_0/ManagerAccount_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_1_0/RedfishManagerAccount_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_1_1/ManagerAccount_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_1_1/RedfishManagerAccount_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_1_2/ManagerAccount_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_1_2/RedfishManagerAccount_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_1_3/ManagerAccount_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_1_3/RedfishManagerAccount_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_1_4/ManagerAccount_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_1_4/RedfishManagerAccount_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_1_5/ManagerAccount_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_1_5/RedfishManagerAccount_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_1_6/ManagerAccount_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_1_6/RedfishManagerAccount_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_1_7/ManagerAccount_V1_1_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_1_7/RedfishManagerAccount_V1_1_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_2_0/ManagerAccount_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_2_0/RedfishManagerAccount_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_2_1/ManagerAccount_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_2_1/RedfishManagerAccount_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_2_2/ManagerAccount_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_2_2/RedfishManagerAccount_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_2_3/ManagerAccount_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_2_3/RedfishManagerAccount_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_2_4/ManagerAccount_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_2_4/RedfishManagerAccount_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_3_0/ManagerAccount_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_3_0/RedfishManagerAccount_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_3_1/ManagerAccount_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_3_1/RedfishManagerAccount_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_3_2/ManagerAccount_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_3_2/RedfishManagerAccount_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_3_3/ManagerAccount_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_3_3/RedfishManagerAccount_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_4_0/ManagerAccount_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_4_0/RedfishManagerAccount_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_4_1/ManagerAccount_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_4_1/RedfishManagerAccount_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_4_2/ManagerAccount_V1_4_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_4_2/RedfishManagerAccount_V1_4_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_4_3/ManagerAccount_V1_4_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_4_3/RedfishManagerAccount_V1_4_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_4_4/ManagerAccount_V1_4_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_4_4/RedfishManagerAccount_V1_4_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_5_0/ManagerAccount_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_5_0/RedfishManagerAccount_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_5_1/ManagerAccount_V1_5_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_5_1/RedfishManagerAccount_V1_5_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_5_2/ManagerAccount_V1_5_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_5_2/RedfishManagerAccount_V1_5_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_5_3/ManagerAccount_V1_5_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_5_3/RedfishManagerAccount_V1_5_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_6_0/ManagerAccount_V1_6_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_6_0/RedfishManagerAccount_V1_6_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_6_1/ManagerAccount_V1_6_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_6_1/RedfishManagerAccount_V1_6_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_6_2/ManagerAccount_V1_6_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_6_2/RedfishManagerAccount_V1_6_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_7_0/ManagerAccount_V1_7_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccount/v1_7_0/RedfishManagerAccount_V1_7_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerAccountCollection/ManagerAccountCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerAccountCollection/RedfishManagerAccountCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerCollection/ManagerCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerCollection/RedfishManagerCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_0/ManagerNetworkProtocol_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_0/RedfishManagerNetworkProtocol_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_2/ManagerNetworkProtocol_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_2/RedfishManagerNetworkProtocol_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_3/ManagerNetworkProtocol_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_3/RedfishManagerNetworkProtocol_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_4/ManagerNetworkProtocol_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_4/RedfishManagerNetworkProtocol_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_5/ManagerNetworkProtocol_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_5/RedfishManagerNetworkProtocol_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_6/ManagerNetworkProtocol_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_6/RedfishManagerNetworkProtocol_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_7/ManagerNetworkProtocol_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_7/RedfishManagerNetworkProtocol_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_8/ManagerNetworkProtocol_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_8/RedfishManagerNetworkProtocol_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_9/ManagerNetworkProtocol_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_9/RedfishManagerNetworkProtocol_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_0/ManagerNetworkProtocol_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_0/RedfishManagerNetworkProtocol_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_1/ManagerNetworkProtocol_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_1/RedfishManagerNetworkProtocol_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_2/ManagerNetworkProtocol_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_2/RedfishManagerNetworkProtocol_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_3/ManagerNetworkProtocol_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_3/RedfishManagerNetworkProtocol_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_4/ManagerNetworkProtocol_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_4/RedfishManagerNetworkProtocol_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_5/ManagerNetworkProtocol_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_5/RedfishManagerNetworkProtocol_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_6/ManagerNetworkProtocol_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_6/RedfishManagerNetworkProtocol_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_0/ManagerNetworkProtocol_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_0/RedfishManagerNetworkProtocol_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_1/ManagerNetworkProtocol_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_1/RedfishManagerNetworkProtocol_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_2/ManagerNetworkProtocol_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_2/RedfishManagerNetworkProtocol_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_3/ManagerNetworkProtocol_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_3/RedfishManagerNetworkProtocol_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_4/ManagerNetworkProtocol_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_4/RedfishManagerNetworkProtocol_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_5/ManagerNetworkProtocol_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_5/RedfishManagerNetworkProtocol_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_0/ManagerNetworkProtocol_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_0/RedfishManagerNetworkProtocol_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_1/ManagerNetworkProtocol_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_1/RedfishManagerNetworkProtocol_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_2/ManagerNetworkProtocol_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_2/RedfishManagerNetworkProtocol_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_3/ManagerNetworkProtocol_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_3/RedfishManagerNetworkProtocol_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_4/ManagerNetworkProtocol_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_4/RedfishManagerNetworkProtocol_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_0/ManagerNetworkProtocol_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_0/RedfishManagerNetworkProtocol_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_1/ManagerNetworkProtocol_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_1/RedfishManagerNetworkProtocol_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_2/ManagerNetworkProtocol_V1_4_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_2/RedfishManagerNetworkProtocol_V1_4_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_3/ManagerNetworkProtocol_V1_4_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_3/RedfishManagerNetworkProtocol_V1_4_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_4/ManagerNetworkProtocol_V1_4_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_4/RedfishManagerNetworkProtocol_V1_4_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_0/ManagerNetworkProtocol_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_0/RedfishManagerNetworkProtocol_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_1/ManagerNetworkProtocol_V1_5_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_1/RedfishManagerNetworkProtocol_V1_5_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_2/ManagerNetworkProtocol_V1_5_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_2/RedfishManagerNetworkProtocol_V1_5_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_3/ManagerNetworkProtocol_V1_5_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_3/RedfishManagerNetworkProtocol_V1_5_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_6_0/ManagerNetworkProtocol_V1_6_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_6_0/RedfishManagerNetworkProtocol_V1_6_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_6_1/ManagerNetworkProtocol_V1_6_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_6_1/RedfishManagerNetworkProtocol_V1_6_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_6_2/ManagerNetworkProtocol_V1_6_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_6_2/RedfishManagerNetworkProtocol_V1_6_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_7_0/ManagerNetworkProtocol_V1_7_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_7_0/RedfishManagerNetworkProtocol_V1_7_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MediaController/v1_0_0/MediaController_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MediaController/v1_0_0/RedfishMediaController_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MediaController/v1_0_1/MediaController_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MediaController/v1_0_1/RedfishMediaController_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MediaController/v1_1_0/MediaController_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MediaController/v1_1_0/RedfishMediaController_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MediaControllerCollection/MediaControllerCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/MediaControllerCollection/RedfishMediaControllerCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_0_0/Memory_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_0_0/RedfishMemory_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_0_1/Memory_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_0_1/RedfishMemory_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_0_10/Memory_V1_0_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_0_10/RedfishMemory_V1_0_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_0_11/Memory_V1_0_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_0_11/RedfishMemory_V1_0_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_0_2/Memory_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_0_2/RedfishMemory_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_0_3/Memory_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_0_3/RedfishMemory_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_0_4/Memory_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_0_4/RedfishMemory_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_0_5/Memory_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_0_5/RedfishMemory_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_0_6/Memory_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_0_6/RedfishMemory_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_0_7/Memory_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_0_7/RedfishMemory_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_0_8/Memory_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_0_8/RedfishMemory_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_0_9/Memory_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_0_9/RedfishMemory_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_10_0/Memory_V1_10_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_10_0/RedfishMemory_V1_10_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_10_1/Memory_V1_10_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_10_1/RedfishMemory_V1_10_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_11_0/Memory_V1_11_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_11_0/RedfishMemory_V1_11_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_1_0/Memory_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_1_0/RedfishMemory_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_1_1/Memory_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_1_1/RedfishMemory_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_1_10/Memory_V1_1_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_1_10/RedfishMemory_V1_1_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_1_2/Memory_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_1_2/RedfishMemory_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_1_3/Memory_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_1_3/RedfishMemory_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_1_4/Memory_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_1_4/RedfishMemory_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_1_5/Memory_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_1_5/RedfishMemory_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_1_6/Memory_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_1_6/RedfishMemory_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_1_7/Memory_V1_1_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_1_7/RedfishMemory_V1_1_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_1_8/Memory_V1_1_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_1_8/RedfishMemory_V1_1_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_1_9/Memory_V1_1_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_1_9/RedfishMemory_V1_1_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_2_0/Memory_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_2_0/RedfishMemory_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_2_1/Memory_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_2_1/RedfishMemory_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_2_2/Memory_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_2_2/RedfishMemory_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_2_3/Memory_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_2_3/RedfishMemory_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_2_4/Memory_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_2_4/RedfishMemory_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_2_5/Memory_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_2_5/RedfishMemory_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_2_6/Memory_V1_2_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_2_6/RedfishMemory_V1_2_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_2_7/Memory_V1_2_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_2_7/RedfishMemory_V1_2_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_2_8/Memory_V1_2_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_2_8/RedfishMemory_V1_2_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_2_9/Memory_V1_2_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_2_9/RedfishMemory_V1_2_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_3_0/Memory_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_3_0/RedfishMemory_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_3_1/Memory_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_3_1/RedfishMemory_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_3_2/Memory_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_3_2/RedfishMemory_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_3_3/Memory_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_3_3/RedfishMemory_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_3_4/Memory_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_3_4/RedfishMemory_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_3_5/Memory_V1_3_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_3_5/RedfishMemory_V1_3_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_3_6/Memory_V1_3_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_3_6/RedfishMemory_V1_3_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_3_7/Memory_V1_3_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_3_7/RedfishMemory_V1_3_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_3_8/Memory_V1_3_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_3_8/RedfishMemory_V1_3_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_3_9/Memory_V1_3_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_3_9/RedfishMemory_V1_3_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_4_0/Memory_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_4_0/RedfishMemory_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_4_1/Memory_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_4_1/RedfishMemory_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_4_2/Memory_V1_4_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_4_2/RedfishMemory_V1_4_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_4_3/Memory_V1_4_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_4_3/RedfishMemory_V1_4_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_4_4/Memory_V1_4_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_4_4/RedfishMemory_V1_4_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_4_5/Memory_V1_4_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_4_5/RedfishMemory_V1_4_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_4_6/Memory_V1_4_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_4_6/RedfishMemory_V1_4_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_4_7/Memory_V1_4_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_4_7/RedfishMemory_V1_4_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_4_8/Memory_V1_4_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_4_8/RedfishMemory_V1_4_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_4_9/Memory_V1_4_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_4_9/RedfishMemory_V1_4_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_5_0/Memory_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_5_0/RedfishMemory_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_5_1/Memory_V1_5_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_5_1/RedfishMemory_V1_5_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_5_2/Memory_V1_5_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_5_2/RedfishMemory_V1_5_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_5_3/Memory_V1_5_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_5_3/RedfishMemory_V1_5_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_5_4/Memory_V1_5_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_5_4/RedfishMemory_V1_5_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_5_5/Memory_V1_5_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_5_5/RedfishMemory_V1_5_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_5_6/Memory_V1_5_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_5_6/RedfishMemory_V1_5_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_5_7/Memory_V1_5_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_5_7/RedfishMemory_V1_5_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_5_8/Memory_V1_5_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_5_8/RedfishMemory_V1_5_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_6_0/Memory_V1_6_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_6_0/RedfishMemory_V1_6_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_6_1/Memory_V1_6_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_6_1/RedfishMemory_V1_6_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_6_2/Memory_V1_6_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_6_2/RedfishMemory_V1_6_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_6_3/Memory_V1_6_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_6_3/RedfishMemory_V1_6_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_6_4/Memory_V1_6_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_6_4/RedfishMemory_V1_6_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_6_5/Memory_V1_6_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_6_5/RedfishMemory_V1_6_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_6_6/Memory_V1_6_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_6_6/RedfishMemory_V1_6_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_6_7/Memory_V1_6_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_6_7/RedfishMemory_V1_6_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_7_0/Memory_V1_7_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_7_0/RedfishMemory_V1_7_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_7_1/Memory_V1_7_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_7_1/RedfishMemory_V1_7_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_7_2/Memory_V1_7_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_7_2/RedfishMemory_V1_7_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_7_3/Memory_V1_7_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_7_3/RedfishMemory_V1_7_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_7_4/Memory_V1_7_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_7_4/RedfishMemory_V1_7_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_7_5/Memory_V1_7_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_7_5/RedfishMemory_V1_7_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_7_6/Memory_V1_7_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_7_6/RedfishMemory_V1_7_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_8_0/Memory_V1_8_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_8_0/RedfishMemory_V1_8_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_8_1/Memory_V1_8_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_8_1/RedfishMemory_V1_8_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_8_2/Memory_V1_8_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_8_2/RedfishMemory_V1_8_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_8_3/Memory_V1_8_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_8_3/RedfishMemory_V1_8_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_8_4/Memory_V1_8_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_8_4/RedfishMemory_V1_8_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_9_0/Memory_V1_9_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_9_0/RedfishMemory_V1_9_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_9_1/Memory_V1_9_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_9_1/RedfishMemory_V1_9_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_9_2/Memory_V1_9_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_9_2/RedfishMemory_V1_9_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_9_3/Memory_V1_9_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_9_3/RedfishMemory_V1_9_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Memory/v1_9_4/Memory_V1_9_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Memory/v1_9_4/RedfishMemory_V1_9_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_0_0/MemoryChunks_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_0_0/RedfishMemoryChunks_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_0_1/MemoryChunks_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_0_1/RedfishMemoryChunks_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_0_2/MemoryChunks_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_0_2/RedfishMemoryChunks_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_0_3/MemoryChunks_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_0_3/RedfishMemoryChunks_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_0_4/MemoryChunks_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_0_4/RedfishMemoryChunks_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_0_5/MemoryChunks_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_0_5/RedfishMemoryChunks_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_0_6/MemoryChunks_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_0_6/RedfishMemoryChunks_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_0_7/MemoryChunks_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_0_7/RedfishMemoryChunks_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_1_0/MemoryChunks_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_1_0/RedfishMemoryChunks_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_1_1/MemoryChunks_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_1_1/RedfishMemoryChunks_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_1_2/MemoryChunks_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_1_2/RedfishMemoryChunks_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_1_3/MemoryChunks_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_1_3/RedfishMemoryChunks_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_1_4/MemoryChunks_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_1_4/RedfishMemoryChunks_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_1_5/MemoryChunks_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_1_5/RedfishMemoryChunks_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_2_0/MemoryChunks_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_2_0/RedfishMemoryChunks_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_2_1/MemoryChunks_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_2_1/RedfishMemoryChunks_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_2_2/MemoryChunks_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_2_2/RedfishMemoryChunks_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_2_3/MemoryChunks_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_2_3/RedfishMemoryChunks_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_2_4/MemoryChunks_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_2_4/RedfishMemoryChunks_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_2_5/MemoryChunks_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_2_5/RedfishMemoryChunks_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_2_6/MemoryChunks_V1_2_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_2_6/RedfishMemoryChunks_V1_2_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_3_0/MemoryChunks_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_3_0/RedfishMemoryChunks_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_3_1/MemoryChunks_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_3_1/RedfishMemoryChunks_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_3_2/MemoryChunks_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_3_2/RedfishMemoryChunks_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_4_0/MemoryChunks_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_4_0/RedfishMemoryChunks_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_4_1/MemoryChunks_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunks/v1_4_1/RedfishMemoryChunks_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryChunksCollection/MemoryChunksCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryChunksCollection/RedfishMemoryChunksCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryCollection/MemoryCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryCollection/RedfishMemoryCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_0_0/MemoryDomain_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_0_0/RedfishMemoryDomain_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_0_1/MemoryDomain_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_0_1/RedfishMemoryDomain_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_0_2/MemoryDomain_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_0_2/RedfishMemoryDomain_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_0_3/MemoryDomain_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_0_3/RedfishMemoryDomain_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_0_4/MemoryDomain_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_0_4/RedfishMemoryDomain_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_0_5/MemoryDomain_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_0_5/RedfishMemoryDomain_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_1_0/MemoryDomain_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_1_0/RedfishMemoryDomain_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_1_1/MemoryDomain_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_1_1/RedfishMemoryDomain_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_1_2/MemoryDomain_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_1_2/RedfishMemoryDomain_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_1_3/MemoryDomain_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_1_3/RedfishMemoryDomain_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_1_4/MemoryDomain_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_1_4/RedfishMemoryDomain_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_2_0/MemoryDomain_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_2_0/RedfishMemoryDomain_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_2_1/MemoryDomain_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_2_1/RedfishMemoryDomain_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_2_2/MemoryDomain_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_2_2/RedfishMemoryDomain_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_2_3/MemoryDomain_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_2_3/RedfishMemoryDomain_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_3_0/MemoryDomain_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryDomain/v1_3_0/RedfishMemoryDomain_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryDomainCollection/MemoryDomainCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryDomainCollection/RedfishMemoryDomainCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_0_0/MemoryMetrics_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_0_0/RedfishMemoryMetrics_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_0_1/MemoryMetrics_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_0_1/RedfishMemoryMetrics_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_0_2/MemoryMetrics_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_0_2/RedfishMemoryMetrics_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_0_3/MemoryMetrics_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_0_3/RedfishMemoryMetrics_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_0_4/MemoryMetrics_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_0_4/RedfishMemoryMetrics_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_0_5/MemoryMetrics_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_0_5/RedfishMemoryMetrics_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_0_6/MemoryMetrics_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_0_6/RedfishMemoryMetrics_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_0_7/MemoryMetrics_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_0_7/RedfishMemoryMetrics_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_0_8/MemoryMetrics_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_0_8/RedfishMemoryMetrics_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_1_1/MemoryMetrics_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_1_1/RedfishMemoryMetrics_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_1_2/MemoryMetrics_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_1_2/RedfishMemoryMetrics_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_1_3/MemoryMetrics_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_1_3/RedfishMemoryMetrics_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_1_4/MemoryMetrics_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_1_4/RedfishMemoryMetrics_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_1_5/MemoryMetrics_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_1_5/RedfishMemoryMetrics_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_1_6/MemoryMetrics_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_1_6/RedfishMemoryMetrics_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_1_7/MemoryMetrics_V1_1_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_1_7/RedfishMemoryMetrics_V1_1_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_1_8/MemoryMetrics_V1_1_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_1_8/RedfishMemoryMetrics_V1_1_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_2_0/MemoryMetrics_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_2_0/RedfishMemoryMetrics_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_2_1/MemoryMetrics_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_2_1/RedfishMemoryMetrics_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_2_2/MemoryMetrics_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_2_2/RedfishMemoryMetrics_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_3_0/MemoryMetrics_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_3_0/RedfishMemoryMetrics_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_3_1/MemoryMetrics_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_3_1/RedfishMemoryMetrics_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_4_0/MemoryMetrics_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_4_0/RedfishMemoryMetrics_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_4_1/MemoryMetrics_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MemoryMetrics/v1_4_1/RedfishMemoryMetrics_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_0_0/MessageRegistry_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_0_0/RedfishMessageRegistry_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_0_10/MessageRegistry_V1_0_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_0_10/RedfishMessageRegistry_V1_0_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_0_2/MessageRegistry_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_0_2/RedfishMessageRegistry_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_0_3/MessageRegistry_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_0_3/RedfishMessageRegistry_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_0_4/MessageRegistry_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_0_4/RedfishMessageRegistry_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_0_5/MessageRegistry_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_0_5/RedfishMessageRegistry_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_0_6/MessageRegistry_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_0_6/RedfishMessageRegistry_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_0_7/MessageRegistry_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_0_7/RedfishMessageRegistry_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_0_8/MessageRegistry_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_0_8/RedfishMessageRegistry_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_0_9/MessageRegistry_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_0_9/RedfishMessageRegistry_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_1_0/MessageRegistry_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_1_0/RedfishMessageRegistry_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_1_1/MessageRegistry_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_1_1/RedfishMessageRegistry_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_1_2/MessageRegistry_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_1_2/RedfishMessageRegistry_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_1_3/MessageRegistry_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_1_3/RedfishMessageRegistry_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_1_4/MessageRegistry_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_1_4/RedfishMessageRegistry_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_1_5/MessageRegistry_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_1_5/RedfishMessageRegistry_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_1_6/MessageRegistry_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_1_6/RedfishMessageRegistry_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_2_0/MessageRegistry_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_2_0/RedfishMessageRegistry_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_2_1/MessageRegistry_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_2_1/RedfishMessageRegistry_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_2_2/MessageRegistry_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_2_2/RedfishMessageRegistry_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_2_3/MessageRegistry_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_2_3/RedfishMessageRegistry_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_2_4/MessageRegistry_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_2_4/RedfishMessageRegistry_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_3_0/MessageRegistry_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_3_0/RedfishMessageRegistry_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_3_1/MessageRegistry_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_3_1/RedfishMessageRegistry_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_3_2/MessageRegistry_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_3_2/RedfishMessageRegistry_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_3_3/MessageRegistry_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_3_3/RedfishMessageRegistry_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_4_0/MessageRegistry_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_4_0/RedfishMessageRegistry_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_4_1/MessageRegistry_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_4_1/RedfishMessageRegistry_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_4_2/MessageRegistry_V1_4_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistry/v1_4_2/RedfishMessageRegistry_V1_4_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistryCollection/MessageRegistryCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistryCollection/RedfishMessageRegistryCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistryFile/v1_0_0/MessageRegistryFile_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistryFile/v1_0_0/RedfishMessageRegistryFile_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistryFile/v1_0_2/MessageRegistryFile_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistryFile/v1_0_2/RedfishMessageRegistryFile_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistryFile/v1_0_3/MessageRegistryFile_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistryFile/v1_0_3/RedfishMessageRegistryFile_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistryFile/v1_0_4/MessageRegistryFile_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistryFile/v1_0_4/RedfishMessageRegistryFile_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistryFile/v1_0_5/MessageRegistryFile_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistryFile/v1_0_5/RedfishMessageRegistryFile_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistryFile/v1_0_6/MessageRegistryFile_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistryFile/v1_0_6/RedfishMessageRegistryFile_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistryFile/v1_0_7/MessageRegistryFile_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistryFile/v1_0_7/RedfishMessageRegistryFile_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistryFile/v1_1_0/MessageRegistryFile_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistryFile/v1_1_0/RedfishMessageRegistryFile_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistryFile/v1_1_1/MessageRegistryFile_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistryFile/v1_1_1/RedfishMessageRegistryFile_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistryFile/v1_1_2/MessageRegistryFile_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistryFile/v1_1_2/RedfishMessageRegistryFile_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistryFile/v1_1_3/MessageRegistryFile_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistryFile/v1_1_3/RedfishMessageRegistryFile_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MessageRegistryFileCollection/MessageRegistryFileCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/MessageRegistryFileCollection/RedfishMessageRegistryFileCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricDefinition/v1_0_0/MetricDefinition_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricDefinition/v1_0_0/RedfishMetricDefinition_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricDefinition/v1_0_1/MetricDefinition_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricDefinition/v1_0_1/RedfishMetricDefinition_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricDefinition/v1_0_2/MetricDefinition_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricDefinition/v1_0_2/RedfishMetricDefinition_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricDefinition/v1_0_3/MetricDefinition_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricDefinition/v1_0_3/RedfishMetricDefinition_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricDefinition/v1_0_4/MetricDefinition_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricDefinition/v1_0_4/RedfishMetricDefinition_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricDefinition/v1_0_5/MetricDefinition_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricDefinition/v1_0_5/RedfishMetricDefinition_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricDefinition/v1_0_6/MetricDefinition_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricDefinition/v1_0_6/RedfishMetricDefinition_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricDefinition/v1_1_0/MetricDefinition_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricDefinition/v1_1_0/RedfishMetricDefinition_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricDefinition/v1_1_1/MetricDefinition_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricDefinition/v1_1_1/RedfishMetricDefinition_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricDefinitionCollection/MetricDefinitionCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricDefinitionCollection/RedfishMetricDefinitionCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_0_0/MetricReport_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_0_0/RedfishMetricReport_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_0_1/MetricReport_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_0_1/RedfishMetricReport_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_0_2/MetricReport_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_0_2/RedfishMetricReport_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_0_3/MetricReport_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_0_3/RedfishMetricReport_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_0_4/MetricReport_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_0_4/RedfishMetricReport_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_0_5/MetricReport_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_0_5/RedfishMetricReport_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_0_6/MetricReport_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_0_6/RedfishMetricReport_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_1_0/MetricReport_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_1_0/RedfishMetricReport_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_1_1/MetricReport_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_1_1/RedfishMetricReport_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_1_2/MetricReport_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_1_2/RedfishMetricReport_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_1_3/MetricReport_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_1_3/RedfishMetricReport_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_1_4/MetricReport_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_1_4/RedfishMetricReport_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_1_5/MetricReport_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_1_5/RedfishMetricReport_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_2_0/MetricReport_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_2_0/RedfishMetricReport_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_2_1/MetricReport_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_2_1/RedfishMetricReport_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_2_2/MetricReport_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_2_2/RedfishMetricReport_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_2_3/MetricReport_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_2_3/RedfishMetricReport_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_3_0/MetricReport_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_3_0/RedfishMetricReport_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_3_1/MetricReport_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_3_1/RedfishMetricReport_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_3_2/MetricReport_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_3_2/RedfishMetricReport_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_4_0/MetricReport_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_4_0/RedfishMetricReport_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_4_1/MetricReport_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReport/v1_4_1/RedfishMetricReport_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportCollection/MetricReportCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportCollection/RedfishMetricReportCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_0_0/MetricReportDefinition_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_0_0/RedfishMetricReportDefinition_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_0_1/MetricReportDefinition_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_0_1/RedfishMetricReportDefinition_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_0_2/MetricReportDefinition_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_0_2/RedfishMetricReportDefinition_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_0_3/MetricReportDefinition_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_0_3/RedfishMetricReportDefinition_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_0_4/MetricReportDefinition_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_0_4/RedfishMetricReportDefinition_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_0_5/MetricReportDefinition_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_0_5/RedfishMetricReportDefinition_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_0_6/MetricReportDefinition_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_0_6/RedfishMetricReportDefinition_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_0_7/MetricReportDefinition_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_0_7/RedfishMetricReportDefinition_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_1_0/MetricReportDefinition_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_1_0/RedfishMetricReportDefinition_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_1_1/MetricReportDefinition_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_1_1/RedfishMetricReportDefinition_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_1_2/MetricReportDefinition_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_1_2/RedfishMetricReportDefinition_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_1_3/MetricReportDefinition_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_1_3/RedfishMetricReportDefinition_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_1_4/MetricReportDefinition_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_1_4/RedfishMetricReportDefinition_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_1_5/MetricReportDefinition_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_1_5/RedfishMetricReportDefinition_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_1_6/MetricReportDefinition_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_1_6/RedfishMetricReportDefinition_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_2_0/MetricReportDefinition_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_2_0/RedfishMetricReportDefinition_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_2_1/MetricReportDefinition_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_2_1/RedfishMetricReportDefinition_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_2_2/MetricReportDefinition_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_2_2/RedfishMetricReportDefinition_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_2_3/MetricReportDefinition_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_2_3/RedfishMetricReportDefinition_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_2_4/MetricReportDefinition_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_2_4/RedfishMetricReportDefinition_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_2_5/MetricReportDefinition_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_2_5/RedfishMetricReportDefinition_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_3_0/MetricReportDefinition_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_3_0/RedfishMetricReportDefinition_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_3_1/MetricReportDefinition_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_3_1/RedfishMetricReportDefinition_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_3_2/MetricReportDefinition_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_3_2/RedfishMetricReportDefinition_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_3_3/MetricReportDefinition_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_3_3/RedfishMetricReportDefinition_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_3_4/MetricReportDefinition_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_3_4/RedfishMetricReportDefinition_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_4_0/MetricReportDefinition_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinition/v1_4_0/RedfishMetricReportDefinition_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/MetricReportDefinitionCollection/MetricReportDefinitionCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/MetricReportDefinitionCollection/RedfishMetricReportDefinitionCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_0_0/NetworkAdapter_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_0_0/RedfishNetworkAdapter_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_0_1/NetworkAdapter_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_0_1/RedfishNetworkAdapter_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_0_2/NetworkAdapter_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_0_2/RedfishNetworkAdapter_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_0_3/NetworkAdapter_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_0_3/RedfishNetworkAdapter_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_0_4/NetworkAdapter_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_0_4/RedfishNetworkAdapter_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_0_5/NetworkAdapter_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_0_5/RedfishNetworkAdapter_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_0_6/NetworkAdapter_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_0_6/RedfishNetworkAdapter_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_0_7/NetworkAdapter_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_0_7/RedfishNetworkAdapter_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_1_0/NetworkAdapter_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_1_0/RedfishNetworkAdapter_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_1_1/NetworkAdapter_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_1_1/RedfishNetworkAdapter_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_1_2/NetworkAdapter_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_1_2/RedfishNetworkAdapter_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_1_3/NetworkAdapter_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_1_3/RedfishNetworkAdapter_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_1_4/NetworkAdapter_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_1_4/RedfishNetworkAdapter_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_1_5/NetworkAdapter_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_1_5/RedfishNetworkAdapter_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_1_6/NetworkAdapter_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_1_6/RedfishNetworkAdapter_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_2_0/NetworkAdapter_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_2_0/RedfishNetworkAdapter_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_2_1/NetworkAdapter_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_2_1/RedfishNetworkAdapter_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_2_2/NetworkAdapter_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_2_2/RedfishNetworkAdapter_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_2_3/NetworkAdapter_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_2_3/RedfishNetworkAdapter_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_2_4/NetworkAdapter_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_2_4/RedfishNetworkAdapter_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_2_5/NetworkAdapter_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_2_5/RedfishNetworkAdapter_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_3_0/NetworkAdapter_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_3_0/RedfishNetworkAdapter_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_3_1/NetworkAdapter_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_3_1/RedfishNetworkAdapter_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_3_2/NetworkAdapter_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_3_2/RedfishNetworkAdapter_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_3_3/NetworkAdapter_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_3_3/RedfishNetworkAdapter_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_3_4/NetworkAdapter_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_3_4/RedfishNetworkAdapter_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_4_0/NetworkAdapter_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_4_0/RedfishNetworkAdapter_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_4_1/NetworkAdapter_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_4_1/RedfishNetworkAdapter_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_5_0/NetworkAdapter_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_5_0/RedfishNetworkAdapter_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_5_1/NetworkAdapter_V1_5_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_5_1/RedfishNetworkAdapter_V1_5_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_6_0/NetworkAdapter_V1_6_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapter/v1_6_0/RedfishNetworkAdapter_V1_6_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkAdapterCollection/NetworkAdapterCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkAdapterCollection/RedfishNetworkAdapterCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_0/NetworkDeviceFunction_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_0/RedfishNetworkDeviceFunction_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_1/NetworkDeviceFunction_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_1/RedfishNetworkDeviceFunction_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_2/NetworkDeviceFunction_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_2/RedfishNetworkDeviceFunction_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_3/NetworkDeviceFunction_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_3/RedfishNetworkDeviceFunction_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_4/NetworkDeviceFunction_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_4/RedfishNetworkDeviceFunction_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_5/NetworkDeviceFunction_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_5/RedfishNetworkDeviceFunction_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_6/NetworkDeviceFunction_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_6/RedfishNetworkDeviceFunction_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_7/NetworkDeviceFunction_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_7/RedfishNetworkDeviceFunction_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_8/NetworkDeviceFunction_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_8/RedfishNetworkDeviceFunction_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_0/NetworkDeviceFunction_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_0/RedfishNetworkDeviceFunction_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_1/NetworkDeviceFunction_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_1/RedfishNetworkDeviceFunction_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_2/NetworkDeviceFunction_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_2/RedfishNetworkDeviceFunction_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_3/NetworkDeviceFunction_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_3/RedfishNetworkDeviceFunction_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_4/NetworkDeviceFunction_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_4/RedfishNetworkDeviceFunction_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_5/NetworkDeviceFunction_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_5/RedfishNetworkDeviceFunction_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_6/NetworkDeviceFunction_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_6/RedfishNetworkDeviceFunction_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_7/NetworkDeviceFunction_V1_1_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_7/RedfishNetworkDeviceFunction_V1_1_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_0/NetworkDeviceFunction_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_0/RedfishNetworkDeviceFunction_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_1/NetworkDeviceFunction_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_1/RedfishNetworkDeviceFunction_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_2/NetworkDeviceFunction_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_2/RedfishNetworkDeviceFunction_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_3/NetworkDeviceFunction_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_3/RedfishNetworkDeviceFunction_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_4/NetworkDeviceFunction_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_4/RedfishNetworkDeviceFunction_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_5/NetworkDeviceFunction_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_5/RedfishNetworkDeviceFunction_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_6/NetworkDeviceFunction_V1_2_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_6/RedfishNetworkDeviceFunction_V1_2_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_7/NetworkDeviceFunction_V1_2_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_7/RedfishNetworkDeviceFunction_V1_2_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_0/NetworkDeviceFunction_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_0/RedfishNetworkDeviceFunction_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_1/NetworkDeviceFunction_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_1/RedfishNetworkDeviceFunction_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_2/NetworkDeviceFunction_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_2/RedfishNetworkDeviceFunction_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_3/NetworkDeviceFunction_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_3/RedfishNetworkDeviceFunction_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_4/NetworkDeviceFunction_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_4/RedfishNetworkDeviceFunction_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_5/NetworkDeviceFunction_V1_3_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_5/RedfishNetworkDeviceFunction_V1_3_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_4_0/NetworkDeviceFunction_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_4_0/RedfishNetworkDeviceFunction_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_4_1/NetworkDeviceFunction_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_4_1/RedfishNetworkDeviceFunction_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_4_2/NetworkDeviceFunction_V1_4_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_4_2/RedfishNetworkDeviceFunction_V1_4_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_5_0/NetworkDeviceFunction_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_5_0/RedfishNetworkDeviceFunction_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_5_1/NetworkDeviceFunction_V1_5_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunction/v1_5_1/RedfishNetworkDeviceFunction_V1_5_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunctionCollection/NetworkDeviceFunctionCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkDeviceFunctionCollection/RedfishNetworkDeviceFunctionCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_0_0/NetworkInterface_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_0_0/RedfishNetworkInterface_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_0_1/NetworkInterface_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_0_1/RedfishNetworkInterface_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_0_2/NetworkInterface_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_0_2/RedfishNetworkInterface_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_0_3/NetworkInterface_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_0_3/RedfishNetworkInterface_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_0_4/NetworkInterface_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_0_4/RedfishNetworkInterface_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_0_5/NetworkInterface_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_0_5/RedfishNetworkInterface_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_0_6/NetworkInterface_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_0_6/RedfishNetworkInterface_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_1_0/NetworkInterface_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_1_0/RedfishNetworkInterface_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_1_1/NetworkInterface_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_1_1/RedfishNetworkInterface_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_1_2/NetworkInterface_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_1_2/RedfishNetworkInterface_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_1_3/NetworkInterface_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_1_3/RedfishNetworkInterface_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_1_4/NetworkInterface_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_1_4/RedfishNetworkInterface_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_1_5/NetworkInterface_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_1_5/RedfishNetworkInterface_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_2_0/NetworkInterface_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_2_0/RedfishNetworkInterface_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_2_1/NetworkInterface_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkInterface/v1_2_1/RedfishNetworkInterface_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkInterfaceCollection/NetworkInterfaceCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkInterfaceCollection/RedfishNetworkInterfaceCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_0_0/NetworkPort_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_0_0/RedfishNetworkPort_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_0_1/NetworkPort_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_0_1/RedfishNetworkPort_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_0_2/NetworkPort_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_0_2/RedfishNetworkPort_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_0_3/NetworkPort_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_0_3/RedfishNetworkPort_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_0_4/NetworkPort_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_0_4/RedfishNetworkPort_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_0_5/NetworkPort_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_0_5/RedfishNetworkPort_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_0_6/NetworkPort_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_0_6/RedfishNetworkPort_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_0_7/NetworkPort_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_0_7/RedfishNetworkPort_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_0_8/NetworkPort_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_0_8/RedfishNetworkPort_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_1_0/NetworkPort_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_1_0/RedfishNetworkPort_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_1_1/NetworkPort_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_1_1/RedfishNetworkPort_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_1_2/NetworkPort_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_1_2/RedfishNetworkPort_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_1_3/NetworkPort_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_1_3/RedfishNetworkPort_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_1_4/NetworkPort_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_1_4/RedfishNetworkPort_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_1_5/NetworkPort_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_1_5/RedfishNetworkPort_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_1_6/NetworkPort_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_1_6/RedfishNetworkPort_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_1_7/NetworkPort_V1_1_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_1_7/RedfishNetworkPort_V1_1_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_2_0/NetworkPort_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_2_0/RedfishNetworkPort_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_2_1/NetworkPort_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_2_1/RedfishNetworkPort_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_2_2/NetworkPort_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_2_2/RedfishNetworkPort_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_2_3/NetworkPort_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_2_3/RedfishNetworkPort_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_2_4/NetworkPort_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_2_4/RedfishNetworkPort_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_2_5/NetworkPort_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_2_5/RedfishNetworkPort_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_2_6/NetworkPort_V1_2_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_2_6/RedfishNetworkPort_V1_2_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_3_0/NetworkPort_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_3_0/RedfishNetworkPort_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_3_1/NetworkPort_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_3_1/RedfishNetworkPort_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_4_0/NetworkPort_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPort/v1_4_0/RedfishNetworkPort_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/NetworkPortCollection/NetworkPortCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/NetworkPortCollection/RedfishNetworkPortCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/OperatingConfig/v1_0_0/OperatingConfig_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/OperatingConfig/v1_0_0/RedfishOperatingConfig_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/OperatingConfig/v1_0_1/OperatingConfig_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/OperatingConfig/v1_0_1/RedfishOperatingConfig_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/OperatingConfig/v1_0_2/OperatingConfig_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/OperatingConfig/v1_0_2/RedfishOperatingConfig_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/OperatingConfigCollection/OperatingConfigCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/OperatingConfigCollection/RedfishOperatingConfigCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Outlet/v1_0_0/Outlet_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Outlet/v1_0_0/RedfishOutlet_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Outlet/v1_0_1/Outlet_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Outlet/v1_0_1/RedfishOutlet_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Outlet/v1_0_2/Outlet_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Outlet/v1_0_2/RedfishOutlet_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Outlet/v1_1_0/Outlet_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Outlet/v1_1_0/RedfishOutlet_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Outlet/v1_1_1/Outlet_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Outlet/v1_1_1/RedfishOutlet_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/OutletCollection/OutletCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/OutletCollection/RedfishOutletCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/OutletGroup/v1_0_0/OutletGroup_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/OutletGroup/v1_0_0/RedfishOutletGroup_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/OutletGroup/v1_0_1/OutletGroup_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/OutletGroup/v1_0_1/RedfishOutletGroup_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/OutletGroupCollection/OutletGroupCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/OutletGroupCollection/RedfishOutletGroupCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_0_0/PCIeDevice_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_0_0/RedfishPCIeDevice_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_0_1/PCIeDevice_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_0_1/RedfishPCIeDevice_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_0_2/PCIeDevice_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_0_2/RedfishPCIeDevice_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_0_3/PCIeDevice_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_0_3/RedfishPCIeDevice_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_0_4/PCIeDevice_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_0_4/RedfishPCIeDevice_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_0_5/PCIeDevice_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_0_5/RedfishPCIeDevice_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_1_0/PCIeDevice_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_1_0/RedfishPCIeDevice_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_1_1/PCIeDevice_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_1_1/RedfishPCIeDevice_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_1_2/PCIeDevice_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_1_2/RedfishPCIeDevice_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_1_3/PCIeDevice_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_1_3/RedfishPCIeDevice_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_2_0/PCIeDevice_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_2_0/RedfishPCIeDevice_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_2_1/PCIeDevice_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_2_1/RedfishPCIeDevice_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_2_2/PCIeDevice_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_2_2/RedfishPCIeDevice_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_2_3/PCIeDevice_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_2_3/RedfishPCIeDevice_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_3_0/PCIeDevice_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_3_0/RedfishPCIeDevice_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_3_1/PCIeDevice_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_3_1/RedfishPCIeDevice_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_3_2/PCIeDevice_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_3_2/RedfishPCIeDevice_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_4_0/PCIeDevice_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_4_0/RedfishPCIeDevice_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_5_0/PCIeDevice_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_5_0/RedfishPCIeDevice_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_6_0/PCIeDevice_V1_6_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeDevice/v1_6_0/RedfishPCIeDevice_V1_6_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeDeviceCollection/PCIeDeviceCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeDeviceCollection/RedfishPCIeDeviceCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_0_0/PCIeFunction_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_0_0/RedfishPCIeFunction_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_0_1/PCIeFunction_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_0_1/RedfishPCIeFunction_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_0_2/PCIeFunction_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_0_2/RedfishPCIeFunction_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_0_3/PCIeFunction_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_0_3/RedfishPCIeFunction_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_0_4/PCIeFunction_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_0_4/RedfishPCIeFunction_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_0_5/PCIeFunction_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_0_5/RedfishPCIeFunction_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_0_6/PCIeFunction_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_0_6/RedfishPCIeFunction_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_1_0/PCIeFunction_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_1_0/RedfishPCIeFunction_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_1_1/PCIeFunction_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_1_1/RedfishPCIeFunction_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_1_2/PCIeFunction_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_1_2/RedfishPCIeFunction_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_1_3/PCIeFunction_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_1_3/RedfishPCIeFunction_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_1_4/PCIeFunction_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_1_4/RedfishPCIeFunction_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_2_0/PCIeFunction_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_2_0/RedfishPCIeFunction_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_2_1/PCIeFunction_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_2_1/RedfishPCIeFunction_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_2_2/PCIeFunction_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_2_2/RedfishPCIeFunction_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_2_3/PCIeFunction_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeFunction/v1_2_3/RedfishPCIeFunction_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeFunctionCollection/PCIeFunctionCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeFunctionCollection/RedfishPCIeFunctionCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeSlots/v1_0_0/PCIeSlots_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeSlots/v1_0_0/RedfishPCIeSlots_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeSlots/v1_0_1/PCIeSlots_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeSlots/v1_0_1/RedfishPCIeSlots_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeSlots/v1_0_2/PCIeSlots_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeSlots/v1_0_2/RedfishPCIeSlots_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeSlots/v1_0_3/PCIeSlots_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeSlots/v1_0_3/RedfishPCIeSlots_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeSlots/v1_1_0/PCIeSlots_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeSlots/v1_1_0/RedfishPCIeSlots_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeSlots/v1_1_1/PCIeSlots_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeSlots/v1_1_1/RedfishPCIeSlots_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeSlots/v1_1_2/PCIeSlots_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeSlots/v1_1_2/RedfishPCIeSlots_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeSlots/v1_2_0/PCIeSlots_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeSlots/v1_2_0/RedfishPCIeSlots_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeSlots/v1_3_0/PCIeSlots_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeSlots/v1_3_0/RedfishPCIeSlots_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeSlots/v1_4_0/PCIeSlots_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeSlots/v1_4_0/RedfishPCIeSlots_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PCIeSlots/v1_4_1/PCIeSlots_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/PCIeSlots/v1_4_1/RedfishPCIeSlots_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Port/v1_0_0/Port_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Port/v1_0_0/RedfishPort_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Port/v1_0_1/Port_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Port/v1_0_1/RedfishPort_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Port/v1_0_2/Port_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Port/v1_0_2/RedfishPort_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Port/v1_0_3/Port_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Port/v1_0_3/RedfishPort_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Port/v1_0_4/Port_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Port/v1_0_4/RedfishPort_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Port/v1_0_5/Port_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Port/v1_0_5/RedfishPort_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Port/v1_0_6/Port_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Port/v1_0_6/RedfishPort_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Port/v1_0_7/Port_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Port/v1_0_7/RedfishPort_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Port/v1_0_8/Port_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Port/v1_0_8/RedfishPort_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Port/v1_1_0/Port_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Port/v1_1_0/RedfishPort_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Port/v1_1_1/Port_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Port/v1_1_1/RedfishPort_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Port/v1_1_2/Port_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Port/v1_1_2/RedfishPort_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Port/v1_1_3/Port_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Port/v1_1_3/RedfishPort_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Port/v1_1_4/Port_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Port/v1_1_4/RedfishPort_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Port/v1_1_5/Port_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Port/v1_1_5/RedfishPort_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Port/v1_2_0/Port_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Port/v1_2_0/RedfishPort_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Port/v1_2_1/Port_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Port/v1_2_1/RedfishPort_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Port/v1_2_2/Port_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Port/v1_2_2/RedfishPort_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Port/v1_2_3/Port_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Port/v1_2_3/RedfishPort_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Port/v1_3_0/Port_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Port/v1_3_0/RedfishPort_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Port/v1_3_1/Port_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Port/v1_3_1/RedfishPort_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PortCollection/PortCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/PortCollection/RedfishPortCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PortMetrics/v1_0_0/PortMetrics_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/PortMetrics/v1_0_0/RedfishPortMetrics_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PortMetrics/v1_0_1/PortMetrics_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/PortMetrics/v1_0_1/RedfishPortMetrics_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_0_0/Power_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_0_0/RedfishPower_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_0_1/Power_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_0_1/RedfishPower_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_0_10/Power_V1_0_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_0_10/RedfishPower_V1_0_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_0_11/Power_V1_0_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_0_11/RedfishPower_V1_0_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_0_12/Power_V1_0_12_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_0_12/RedfishPower_V1_0_12_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_0_2/Power_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_0_2/RedfishPower_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_0_3/Power_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_0_3/RedfishPower_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_0_4/Power_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_0_4/RedfishPower_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_0_5/Power_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_0_5/RedfishPower_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_0_6/Power_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_0_6/RedfishPower_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_0_7/Power_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_0_7/RedfishPower_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_0_8/Power_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_0_8/RedfishPower_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_0_9/Power_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_0_9/RedfishPower_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_1_0/Power_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_1_0/RedfishPower_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_1_1/Power_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_1_1/RedfishPower_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_1_10/Power_V1_1_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_1_10/RedfishPower_V1_1_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_1_2/Power_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_1_2/RedfishPower_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_1_3/Power_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_1_3/RedfishPower_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_1_4/Power_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_1_4/RedfishPower_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_1_5/Power_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_1_5/RedfishPower_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_1_6/Power_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_1_6/RedfishPower_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_1_7/Power_V1_1_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_1_7/RedfishPower_V1_1_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_1_8/Power_V1_1_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_1_8/RedfishPower_V1_1_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_1_9/Power_V1_1_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_1_9/RedfishPower_V1_1_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_2_0/Power_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_2_0/RedfishPower_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_2_1/Power_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_2_1/RedfishPower_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_2_10/Power_V1_2_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_2_10/RedfishPower_V1_2_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_2_2/Power_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_2_2/RedfishPower_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_2_3/Power_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_2_3/RedfishPower_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_2_4/Power_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_2_4/RedfishPower_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_2_5/Power_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_2_5/RedfishPower_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_2_6/Power_V1_2_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_2_6/RedfishPower_V1_2_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_2_7/Power_V1_2_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_2_7/RedfishPower_V1_2_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_2_8/Power_V1_2_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_2_8/RedfishPower_V1_2_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_2_9/Power_V1_2_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_2_9/RedfishPower_V1_2_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_3_0/Power_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_3_0/RedfishPower_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_3_1/Power_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_3_1/RedfishPower_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_3_2/Power_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_3_2/RedfishPower_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_3_3/Power_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_3_3/RedfishPower_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_3_4/Power_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_3_4/RedfishPower_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_3_5/Power_V1_3_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_3_5/RedfishPower_V1_3_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_3_6/Power_V1_3_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_3_6/RedfishPower_V1_3_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_3_7/Power_V1_3_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_3_7/RedfishPower_V1_3_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_3_8/Power_V1_3_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_3_8/RedfishPower_V1_3_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_4_0/Power_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_4_0/RedfishPower_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_4_1/Power_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_4_1/RedfishPower_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_4_2/Power_V1_4_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_4_2/RedfishPower_V1_4_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_4_3/Power_V1_4_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_4_3/RedfishPower_V1_4_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_4_4/Power_V1_4_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_4_4/RedfishPower_V1_4_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_4_5/Power_V1_4_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_4_5/RedfishPower_V1_4_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_4_6/Power_V1_4_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_4_6/RedfishPower_V1_4_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_4_7/Power_V1_4_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_4_7/RedfishPower_V1_4_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_5_0/Power_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_5_0/RedfishPower_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_5_1/Power_V1_5_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_5_1/RedfishPower_V1_5_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_5_2/Power_V1_5_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_5_2/RedfishPower_V1_5_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_5_3/Power_V1_5_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_5_3/RedfishPower_V1_5_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_5_4/Power_V1_5_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_5_4/RedfishPower_V1_5_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_5_5/Power_V1_5_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_5_5/RedfishPower_V1_5_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_5_6/Power_V1_5_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_5_6/RedfishPower_V1_5_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_6_0/Power_V1_6_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_6_0/RedfishPower_V1_6_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_6_1/Power_V1_6_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_6_1/RedfishPower_V1_6_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_6_2/Power_V1_6_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_6_2/RedfishPower_V1_6_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Power/v1_7_0/Power_V1_7_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Power/v1_7_0/RedfishPower_V1_7_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PowerDistribution/v1_0_0/PowerDistribution_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/PowerDistribution/v1_0_0/RedfishPowerDistribution_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PowerDistribution/v1_0_1/PowerDistribution_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/PowerDistribution/v1_0_1/RedfishPowerDistribution_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PowerDistribution/v1_0_2/PowerDistribution_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/PowerDistribution/v1_0_2/RedfishPowerDistribution_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PowerDistributionCollection/PowerDistributionCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/PowerDistributionCollection/RedfishPowerDistributionCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PowerDistributionMetrics/v1_0_0/PowerDistributionMetrics_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/PowerDistributionMetrics/v1_0_0/RedfishPowerDistributionMetrics_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PowerDomain/v1_0_0/PowerDomain_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/PowerDomain/v1_0_0/RedfishPowerDomain_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PowerDomain/v1_0_1/PowerDomain_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/PowerDomain/v1_0_1/RedfishPowerDomain_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PowerDomainCollection/PowerDomainCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/PowerDomainCollection/RedfishPowerDomainCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PowerEquipment/v1_0_0/PowerEquipment_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/PowerEquipment/v1_0_0/RedfishPowerEquipment_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PowerSubsystem/v1_0_0/PowerSubsystem_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/PowerSubsystem/v1_0_0/RedfishPowerSubsystem_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PowerSupply/v1_0_0/PowerSupply_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/PowerSupply/v1_0_0/RedfishPowerSupply_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PowerSupplyCollection/PowerSupplyCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/PowerSupplyCollection/RedfishPowerSupplyCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PowerSupplyMetrics/v1_0_0/PowerSupplyMetrics_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/PowerSupplyMetrics/v1_0_0/RedfishPowerSupplyMetrics_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_0/PrivilegeRegistry_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_0/RedfishPrivilegeRegistry_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_1/PrivilegeRegistry_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_1/RedfishPrivilegeRegistry_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_2/PrivilegeRegistry_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_2/RedfishPrivilegeRegistry_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_3/PrivilegeRegistry_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_3/RedfishPrivilegeRegistry_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_4/PrivilegeRegistry_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_4/RedfishPrivilegeRegistry_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_5/PrivilegeRegistry_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_5/RedfishPrivilegeRegistry_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_0/PrivilegeRegistry_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_0/RedfishPrivilegeRegistry_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_1/PrivilegeRegistry_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_1/RedfishPrivilegeRegistry_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_2/PrivilegeRegistry_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_2/RedfishPrivilegeRegistry_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_3/PrivilegeRegistry_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_3/RedfishPrivilegeRegistry_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_4/PrivilegeRegistry_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_4/RedfishPrivilegeRegistry_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_0_0/Processor_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_0_0/RedfishProcessor_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_0_10/Processor_V1_0_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_0_10/RedfishProcessor_V1_0_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_0_11/Processor_V1_0_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_0_11/RedfishProcessor_V1_0_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_0_12/Processor_V1_0_12_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_0_12/RedfishProcessor_V1_0_12_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_0_2/Processor_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_0_2/RedfishProcessor_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_0_3/Processor_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_0_3/RedfishProcessor_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_0_4/Processor_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_0_4/RedfishProcessor_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_0_5/Processor_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_0_5/RedfishProcessor_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_0_6/Processor_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_0_6/RedfishProcessor_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_0_7/Processor_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_0_7/RedfishProcessor_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_0_8/Processor_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_0_8/RedfishProcessor_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_0_9/Processor_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_0_9/RedfishProcessor_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_10_0/Processor_V1_10_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_10_0/RedfishProcessor_V1_10_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_10_1/Processor_V1_10_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_10_1/RedfishProcessor_V1_10_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_11_0/Processor_V1_11_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_11_0/RedfishProcessor_V1_11_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_1_0/Processor_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_1_0/RedfishProcessor_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_1_1/Processor_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_1_1/RedfishProcessor_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_1_2/Processor_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_1_2/RedfishProcessor_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_1_3/Processor_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_1_3/RedfishProcessor_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_1_4/Processor_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_1_4/RedfishProcessor_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_1_5/Processor_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_1_5/RedfishProcessor_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_1_6/Processor_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_1_6/RedfishProcessor_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_1_7/Processor_V1_1_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_1_7/RedfishProcessor_V1_1_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_1_8/Processor_V1_1_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_1_8/RedfishProcessor_V1_1_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_2_0/Processor_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_2_0/RedfishProcessor_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_2_1/Processor_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_2_1/RedfishProcessor_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_2_2/Processor_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_2_2/RedfishProcessor_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_2_3/Processor_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_2_3/RedfishProcessor_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_2_4/Processor_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_2_4/RedfishProcessor_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_2_5/Processor_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_2_5/RedfishProcessor_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_2_6/Processor_V1_2_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_2_6/RedfishProcessor_V1_2_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_2_7/Processor_V1_2_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_2_7/RedfishProcessor_V1_2_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_2_8/Processor_V1_2_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_2_8/RedfishProcessor_V1_2_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_3_0/Processor_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_3_0/RedfishProcessor_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_3_1/Processor_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_3_1/RedfishProcessor_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_3_2/Processor_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_3_2/RedfishProcessor_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_3_3/Processor_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_3_3/RedfishProcessor_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_3_4/Processor_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_3_4/RedfishProcessor_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_3_5/Processor_V1_3_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_3_5/RedfishProcessor_V1_3_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_3_6/Processor_V1_3_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_3_6/RedfishProcessor_V1_3_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_3_7/Processor_V1_3_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_3_7/RedfishProcessor_V1_3_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_3_8/Processor_V1_3_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_3_8/RedfishProcessor_V1_3_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_4_0/Processor_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_4_0/RedfishProcessor_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_4_1/Processor_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_4_1/RedfishProcessor_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_4_2/Processor_V1_4_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_4_2/RedfishProcessor_V1_4_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_4_3/Processor_V1_4_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_4_3/RedfishProcessor_V1_4_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_4_4/Processor_V1_4_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_4_4/RedfishProcessor_V1_4_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_4_5/Processor_V1_4_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_4_5/RedfishProcessor_V1_4_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_4_6/Processor_V1_4_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_4_6/RedfishProcessor_V1_4_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_4_7/Processor_V1_4_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_4_7/RedfishProcessor_V1_4_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_5_0/Processor_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_5_0/RedfishProcessor_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_5_1/Processor_V1_5_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_5_1/RedfishProcessor_V1_5_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_5_2/Processor_V1_5_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_5_2/RedfishProcessor_V1_5_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_5_3/Processor_V1_5_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_5_3/RedfishProcessor_V1_5_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_5_4/Processor_V1_5_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_5_4/RedfishProcessor_V1_5_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_5_5/Processor_V1_5_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_5_5/RedfishProcessor_V1_5_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_5_6/Processor_V1_5_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_5_6/RedfishProcessor_V1_5_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_6_0/Processor_V1_6_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_6_0/RedfishProcessor_V1_6_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_6_1/Processor_V1_6_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_6_1/RedfishProcessor_V1_6_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_6_2/Processor_V1_6_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_6_2/RedfishProcessor_V1_6_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_6_3/Processor_V1_6_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_6_3/RedfishProcessor_V1_6_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_6_4/Processor_V1_6_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_6_4/RedfishProcessor_V1_6_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_7_0/Processor_V1_7_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_7_0/RedfishProcessor_V1_7_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_7_1/Processor_V1_7_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_7_1/RedfishProcessor_V1_7_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_7_2/Processor_V1_7_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_7_2/RedfishProcessor_V1_7_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_7_3/Processor_V1_7_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_7_3/RedfishProcessor_V1_7_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_8_0/Processor_V1_8_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_8_0/RedfishProcessor_V1_8_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_8_1/Processor_V1_8_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_8_1/RedfishProcessor_V1_8_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_8_2/Processor_V1_8_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_8_2/RedfishProcessor_V1_8_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_9_0/Processor_V1_9_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_9_0/RedfishProcessor_V1_9_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Processor/v1_9_1/Processor_V1_9_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Processor/v1_9_1/RedfishProcessor_V1_9_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ProcessorCollection/ProcessorCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/ProcessorCollection/RedfishProcessorCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ProcessorMetrics/v1_0_0/ProcessorMetrics_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ProcessorMetrics/v1_0_0/RedfishProcessorMetrics_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ProcessorMetrics/v1_0_1/ProcessorMetrics_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ProcessorMetrics/v1_0_1/RedfishProcessorMetrics_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ProcessorMetrics/v1_0_2/ProcessorMetrics_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ProcessorMetrics/v1_0_2/RedfishProcessorMetrics_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ProcessorMetrics/v1_0_3/ProcessorMetrics_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ProcessorMetrics/v1_0_3/RedfishProcessorMetrics_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ProcessorMetrics/v1_0_4/ProcessorMetrics_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ProcessorMetrics/v1_0_4/RedfishProcessorMetrics_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ProcessorMetrics/v1_1_0/ProcessorMetrics_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ProcessorMetrics/v1_1_0/RedfishProcessorMetrics_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ProcessorMetrics/v1_1_1/ProcessorMetrics_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ProcessorMetrics/v1_1_1/RedfishProcessorMetrics_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ProcessorMetrics/v1_1_2/ProcessorMetrics_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ProcessorMetrics/v1_1_2/RedfishProcessorMetrics_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ProcessorMetrics/v1_2_0/ProcessorMetrics_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ProcessorMetrics/v1_2_0/RedfishProcessorMetrics_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_0_0/RedfishResourceBlock_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_0_0/ResourceBlock_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_0_1/RedfishResourceBlock_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_0_1/ResourceBlock_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_0_2/RedfishResourceBlock_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_0_2/ResourceBlock_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_0_3/RedfishResourceBlock_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_0_3/ResourceBlock_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_0_4/RedfishResourceBlock_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_0_4/ResourceBlock_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_0_5/RedfishResourceBlock_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_0_5/ResourceBlock_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_0_6/RedfishResourceBlock_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_0_6/ResourceBlock_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_1_0/RedfishResourceBlock_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_1_0/ResourceBlock_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_1_1/RedfishResourceBlock_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_1_1/ResourceBlock_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_1_2/RedfishResourceBlock_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_1_2/ResourceBlock_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_1_3/RedfishResourceBlock_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_1_3/ResourceBlock_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_1_4/RedfishResourceBlock_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_1_4/ResourceBlock_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_1_5/RedfishResourceBlock_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_1_5/ResourceBlock_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_1_6/RedfishResourceBlock_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_1_6/ResourceBlock_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_2_0/RedfishResourceBlock_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_2_0/ResourceBlock_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_2_1/RedfishResourceBlock_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_2_1/ResourceBlock_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_2_2/RedfishResourceBlock_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_2_2/ResourceBlock_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_2_3/RedfishResourceBlock_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_2_3/ResourceBlock_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_2_4/RedfishResourceBlock_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_2_4/ResourceBlock_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_2_5/RedfishResourceBlock_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_2_5/ResourceBlock_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_3_0/RedfishResourceBlock_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_3_0/ResourceBlock_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_3_1/RedfishResourceBlock_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_3_1/ResourceBlock_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_3_2/RedfishResourceBlock_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_3_2/ResourceBlock_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_3_3/RedfishResourceBlock_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_3_3/ResourceBlock_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_3_4/RedfishResourceBlock_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlock/v1_3_4/ResourceBlock_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ResourceBlockCollection/RedfishResourceBlockCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ResourceBlockCollection/ResourceBlockCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/Role/v1_0_0/RedfishRole_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Role/v1_0_0/Role_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Role/v1_0_2/RedfishRole_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Role/v1_0_2/Role_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Role/v1_0_3/RedfishRole_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Role/v1_0_3/Role_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Role/v1_0_4/RedfishRole_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Role/v1_0_4/Role_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Role/v1_0_5/RedfishRole_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Role/v1_0_5/Role_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Role/v1_0_6/RedfishRole_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Role/v1_0_6/Role_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Role/v1_0_7/RedfishRole_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Role/v1_0_7/Role_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Role/v1_1_0/RedfishRole_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Role/v1_1_0/Role_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Role/v1_1_1/RedfishRole_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Role/v1_1_1/Role_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Role/v1_1_2/RedfishRole_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Role/v1_1_2/Role_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Role/v1_1_3/RedfishRole_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Role/v1_1_3/Role_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Role/v1_1_4/RedfishRole_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Role/v1_1_4/Role_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Role/v1_1_5/RedfishRole_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Role/v1_1_5/Role_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Role/v1_2_0/RedfishRole_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Role/v1_2_0/Role_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Role/v1_2_1/RedfishRole_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Role/v1_2_1/Role_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Role/v1_2_2/RedfishRole_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Role/v1_2_2/Role_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Role/v1_2_3/RedfishRole_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Role/v1_2_3/Role_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Role/v1_2_4/RedfishRole_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Role/v1_2_4/Role_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Role/v1_2_5/RedfishRole_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Role/v1_2_5/Role_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Role/v1_3_0/RedfishRole_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Role/v1_3_0/Role_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/RoleCollection/RedfishRoleCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/RoleCollection/RoleCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/RouteEntry/v1_0_0/RedfishRouteEntry_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/RouteEntry/v1_0_0/RouteEntry_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/RouteEntry/v1_0_1/RedfishRouteEntry_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/RouteEntry/v1_0_1/RouteEntry_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/RouteEntryCollection/RedfishRouteEntryCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/RouteEntryCollection/RouteEntryCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/RouteSetEntry/v1_0_0/RedfishRouteSetEntry_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/RouteSetEntry/v1_0_0/RouteSetEntry_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/RouteSetEntry/v1_0_1/RedfishRouteSetEntry_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/RouteSetEntry/v1_0_1/RouteSetEntry_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/RouteSetEntryCollection/RedfishRouteSetEntryCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/RouteSetEntryCollection/RouteSetEntryCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/SecureBoot/v1_0_0/RedfishSecureBoot_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SecureBoot/v1_0_0/SecureBoot_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/SecureBoot/v1_0_1/RedfishSecureBoot_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SecureBoot/v1_0_1/SecureBoot_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/SecureBoot/v1_0_2/RedfishSecureBoot_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SecureBoot/v1_0_2/SecureBoot_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/SecureBoot/v1_0_3/RedfishSecureBoot_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SecureBoot/v1_0_3/SecureBoot_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/SecureBoot/v1_0_4/RedfishSecureBoot_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SecureBoot/v1_0_4/SecureBoot_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/SecureBoot/v1_0_5/RedfishSecureBoot_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SecureBoot/v1_0_5/SecureBoot_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/SecureBoot/v1_0_6/RedfishSecureBoot_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SecureBoot/v1_0_6/SecureBoot_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/SecureBoot/v1_0_7/RedfishSecureBoot_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SecureBoot/v1_0_7/SecureBoot_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/SecureBoot/v1_1_0/RedfishSecureBoot_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SecureBoot/v1_1_0/SecureBoot_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/SecureBootDatabase/v1_0_0/RedfishSecureBootDatabase_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SecureBootDatabase/v1_0_0/SecureBootDatabase_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/SecureBootDatabaseCollection/RedfishSecureBootDatabaseCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SecureBootDatabaseCollection/SecureBootDatabaseCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/Sensor/v1_0_0/RedfishSensor_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Sensor/v1_0_0/Sensor_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Sensor/v1_0_1/RedfishSensor_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Sensor/v1_0_1/Sensor_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Sensor/v1_0_2/RedfishSensor_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Sensor/v1_0_2/Sensor_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Sensor/v1_0_3/RedfishSensor_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Sensor/v1_0_3/Sensor_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Sensor/v1_0_4/RedfishSensor_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Sensor/v1_0_4/Sensor_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Sensor/v1_0_5/RedfishSensor_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Sensor/v1_0_5/Sensor_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Sensor/v1_0_6/RedfishSensor_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Sensor/v1_0_6/Sensor_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Sensor/v1_1_0/RedfishSensor_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Sensor/v1_1_0/Sensor_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Sensor/v1_1_1/RedfishSensor_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Sensor/v1_1_1/Sensor_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Sensor/v1_1_2/RedfishSensor_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Sensor/v1_1_2/Sensor_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Sensor/v1_2_0/RedfishSensor_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Sensor/v1_2_0/Sensor_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/SensorCollection/RedfishSensorCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SensorCollection/SensorCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_0_0/RedfishSerialInterface_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_0_0/SerialInterface_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_0_10/RedfishSerialInterface_V1_0_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_0_10/SerialInterface_V1_0_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_0_2/RedfishSerialInterface_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_0_2/SerialInterface_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_0_3/RedfishSerialInterface_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_0_3/SerialInterface_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_0_4/RedfishSerialInterface_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_0_4/SerialInterface_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_0_5/RedfishSerialInterface_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_0_5/SerialInterface_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_0_6/RedfishSerialInterface_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_0_6/SerialInterface_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_0_7/RedfishSerialInterface_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_0_7/SerialInterface_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_0_8/RedfishSerialInterface_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_0_8/SerialInterface_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_0_9/RedfishSerialInterface_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_0_9/SerialInterface_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_1_0/RedfishSerialInterface_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_1_0/SerialInterface_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_1_1/RedfishSerialInterface_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_1_1/SerialInterface_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_1_2/RedfishSerialInterface_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_1_2/SerialInterface_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_1_3/RedfishSerialInterface_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_1_3/SerialInterface_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_1_4/RedfishSerialInterface_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_1_4/SerialInterface_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_1_5/RedfishSerialInterface_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_1_5/SerialInterface_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_1_6/RedfishSerialInterface_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_1_6/SerialInterface_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_1_7/RedfishSerialInterface_V1_1_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SerialInterface/v1_1_7/SerialInterface_V1_1_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/SerialInterfaceCollection/RedfishSerialInterfaceCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SerialInterfaceCollection/SerialInterfaceCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_0_0/RedfishServiceRoot_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_0_0/ServiceRoot_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_0_2/RedfishServiceRoot_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_0_2/ServiceRoot_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_0_3/RedfishServiceRoot_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_0_3/ServiceRoot_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_0_4/RedfishServiceRoot_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_0_4/ServiceRoot_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_0_5/RedfishServiceRoot_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_0_5/ServiceRoot_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_0_6/RedfishServiceRoot_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_0_6/ServiceRoot_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_0_7/RedfishServiceRoot_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_0_7/ServiceRoot_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_0_8/RedfishServiceRoot_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_0_8/ServiceRoot_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_0_9/RedfishServiceRoot_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_0_9/ServiceRoot_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_1_0/RedfishServiceRoot_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_1_0/ServiceRoot_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_1_1/RedfishServiceRoot_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_1_1/ServiceRoot_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_1_2/RedfishServiceRoot_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_1_2/ServiceRoot_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_1_3/RedfishServiceRoot_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_1_3/ServiceRoot_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_1_4/RedfishServiceRoot_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_1_4/ServiceRoot_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_1_5/RedfishServiceRoot_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_1_5/ServiceRoot_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_1_6/RedfishServiceRoot_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_1_6/ServiceRoot_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_2_0/RedfishServiceRoot_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_2_0/ServiceRoot_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_2_1/RedfishServiceRoot_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_2_1/ServiceRoot_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_2_2/RedfishServiceRoot_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_2_2/ServiceRoot_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_2_3/RedfishServiceRoot_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_2_3/ServiceRoot_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_2_4/RedfishServiceRoot_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_2_4/ServiceRoot_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_3_0/RedfishServiceRoot_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_3_0/ServiceRoot_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_3_1/RedfishServiceRoot_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_3_1/ServiceRoot_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_3_2/RedfishServiceRoot_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_3_2/ServiceRoot_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_3_3/RedfishServiceRoot_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_3_3/ServiceRoot_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_3_4/RedfishServiceRoot_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_3_4/ServiceRoot_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_3_5/RedfishServiceRoot_V1_3_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_3_5/ServiceRoot_V1_3_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_4_0/RedfishServiceRoot_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_4_0/ServiceRoot_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_4_1/RedfishServiceRoot_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_4_1/ServiceRoot_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_4_2/RedfishServiceRoot_V1_4_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_4_2/ServiceRoot_V1_4_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_4_3/RedfishServiceRoot_V1_4_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_4_3/ServiceRoot_V1_4_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_5_0/RedfishServiceRoot_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_5_0/ServiceRoot_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_5_1/RedfishServiceRoot_V1_5_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_5_1/ServiceRoot_V1_5_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_5_2/RedfishServiceRoot_V1_5_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_5_2/ServiceRoot_V1_5_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_6_0/RedfishServiceRoot_V1_6_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_6_0/ServiceRoot_V1_6_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_7_0/RedfishServiceRoot_V1_7_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_7_0/ServiceRoot_V1_7_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_8_0/RedfishServiceRoot_V1_8_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_8_0/ServiceRoot_V1_8_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_9_0/RedfishServiceRoot_V1_9_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ServiceRoot/v1_9_0/ServiceRoot_V1_9_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Session/v1_0_0/RedfishSession_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Session/v1_0_0/Session_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Session/v1_0_2/RedfishSession_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Session/v1_0_2/Session_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Session/v1_0_3/RedfishSession_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Session/v1_0_3/Session_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Session/v1_0_4/RedfishSession_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Session/v1_0_4/Session_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Session/v1_0_5/RedfishSession_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Session/v1_0_5/Session_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Session/v1_0_6/RedfishSession_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Session/v1_0_6/Session_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Session/v1_1_0/RedfishSession_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Session/v1_1_0/Session_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Session/v1_1_1/RedfishSession_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Session/v1_1_1/Session_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Session/v1_1_2/RedfishSession_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Session/v1_1_2/Session_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Session/v1_1_3/RedfishSession_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Session/v1_1_3/Session_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Session/v1_2_0/RedfishSession_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Session/v1_2_0/Session_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Session/v1_2_1/RedfishSession_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Session/v1_2_1/Session_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Session/v1_3_0/RedfishSession_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Session/v1_3_0/Session_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/SessionCollection/RedfishSessionCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SessionCollection/SessionCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/SessionService/v1_0_0/RedfishSessionService_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SessionService/v1_0_0/SessionService_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/SessionService/v1_0_2/RedfishSessionService_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SessionService/v1_0_2/SessionService_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/SessionService/v1_0_3/RedfishSessionService_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SessionService/v1_0_3/SessionService_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/SessionService/v1_0_4/RedfishSessionService_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SessionService/v1_0_4/SessionService_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/SessionService/v1_0_5/RedfishSessionService_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SessionService/v1_0_5/SessionService_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/SessionService/v1_0_6/RedfishSessionService_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SessionService/v1_0_6/SessionService_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/SessionService/v1_0_7/RedfishSessionService_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SessionService/v1_0_7/SessionService_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/SessionService/v1_0_8/RedfishSessionService_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SessionService/v1_0_8/SessionService_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/SessionService/v1_0_9/RedfishSessionService_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SessionService/v1_0_9/SessionService_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/SessionService/v1_1_0/RedfishSessionService_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SessionService/v1_1_0/SessionService_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/SessionService/v1_1_1/RedfishSessionService_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SessionService/v1_1_1/SessionService_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/SessionService/v1_1_2/RedfishSessionService_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SessionService/v1_1_2/SessionService_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/SessionService/v1_1_3/RedfishSessionService_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SessionService/v1_1_3/SessionService_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/SessionService/v1_1_4/RedfishSessionService_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SessionService/v1_1_4/SessionService_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/SessionService/v1_1_5/RedfishSessionService_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SessionService/v1_1_5/SessionService_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/SessionService/v1_1_6/RedfishSessionService_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SessionService/v1_1_6/SessionService_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/SessionService/v1_1_7/RedfishSessionService_V1_1_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SessionService/v1_1_7/SessionService_V1_1_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/SessionService/v1_1_8/RedfishSessionService_V1_1_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SessionService/v1_1_8/SessionService_V1_1_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Signature/v1_0_0/RedfishSignature_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Signature/v1_0_0/Signature_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Signature/v1_0_1/RedfishSignature_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Signature/v1_0_1/Signature_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Signature/v1_0_2/RedfishSignature_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Signature/v1_0_2/Signature_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/SignatureCollection/RedfishSignatureCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SignatureCollection/SignatureCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_0_0/RedfishSimpleStorage_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_0_0/SimpleStorage_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_0_2/RedfishSimpleStorage_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_0_2/SimpleStorage_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_0_3/RedfishSimpleStorage_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_0_3/SimpleStorage_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_0_4/RedfishSimpleStorage_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_0_4/SimpleStorage_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_0_5/RedfishSimpleStorage_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_0_5/SimpleStorage_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_0_6/RedfishSimpleStorage_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_0_6/SimpleStorage_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_0_7/RedfishSimpleStorage_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_0_7/SimpleStorage_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_0_8/RedfishSimpleStorage_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_0_8/SimpleStorage_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_1_0/RedfishSimpleStorage_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_1_0/SimpleStorage_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_1_1/RedfishSimpleStorage_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_1_1/SimpleStorage_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_1_2/RedfishSimpleStorage_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_1_2/SimpleStorage_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_1_3/RedfishSimpleStorage_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_1_3/SimpleStorage_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_1_4/RedfishSimpleStorage_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_1_4/SimpleStorage_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_1_5/RedfishSimpleStorage_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_1_5/SimpleStorage_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_1_6/RedfishSimpleStorage_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_1_6/SimpleStorage_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_2_0/RedfishSimpleStorage_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_2_0/SimpleStorage_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_2_1/RedfishSimpleStorage_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_2_1/SimpleStorage_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_2_2/RedfishSimpleStorage_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_2_2/SimpleStorage_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_2_3/RedfishSimpleStorage_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_2_3/SimpleStorage_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_2_4/RedfishSimpleStorage_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_2_4/SimpleStorage_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_3_0/RedfishSimpleStorage_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_3_0/SimpleStorage_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_3_1/RedfishSimpleStorage_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SimpleStorage/v1_3_1/SimpleStorage_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/SimpleStorageCollection/RedfishSimpleStorageCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SimpleStorageCollection/SimpleStorageCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_0_0/RedfishSoftwareInventory_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_0_0/SoftwareInventory_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_0_1/RedfishSoftwareInventory_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_0_1/SoftwareInventory_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_0_2/RedfishSoftwareInventory_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_0_2/SoftwareInventory_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_0_3/RedfishSoftwareInventory_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_0_3/SoftwareInventory_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_0_4/RedfishSoftwareInventory_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_0_4/SoftwareInventory_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_0_5/RedfishSoftwareInventory_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_0_5/SoftwareInventory_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_1_0/RedfishSoftwareInventory_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_1_0/SoftwareInventory_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_1_1/RedfishSoftwareInventory_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_1_1/SoftwareInventory_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_1_2/RedfishSoftwareInventory_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_1_2/SoftwareInventory_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_1_3/RedfishSoftwareInventory_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_1_3/SoftwareInventory_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_1_4/RedfishSoftwareInventory_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_1_4/SoftwareInventory_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_2_0/RedfishSoftwareInventory_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_2_0/SoftwareInventory_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_2_1/RedfishSoftwareInventory_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_2_1/SoftwareInventory_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_2_2/RedfishSoftwareInventory_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_2_2/SoftwareInventory_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_2_3/RedfishSoftwareInventory_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_2_3/SoftwareInventory_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_3_0/RedfishSoftwareInventory_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_3_0/SoftwareInventory_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_4_0/RedfishSoftwareInventory_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SoftwareInventory/v1_4_0/SoftwareInventory_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/SoftwareInventoryCollection/RedfishSoftwareInventoryCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SoftwareInventoryCollection/SoftwareInventoryCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_0_1/RedfishStorage_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_0_1/Storage_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_0_10/RedfishStorage_V1_0_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_0_10/Storage_V1_0_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_0_2/RedfishStorage_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_0_2/Storage_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_0_3/RedfishStorage_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_0_3/Storage_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_0_4/RedfishStorage_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_0_4/Storage_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_0_5/RedfishStorage_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_0_5/Storage_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_0_6/RedfishStorage_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_0_6/Storage_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_0_7/RedfishStorage_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_0_7/Storage_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_0_8/RedfishStorage_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_0_8/Storage_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_0_9/RedfishStorage_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_0_9/Storage_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_10_0/RedfishStorage_V1_10_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_10_0/Storage_V1_10_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_1_1/RedfishStorage_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_1_1/Storage_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_1_2/RedfishStorage_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_1_2/Storage_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_1_3/RedfishStorage_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_1_3/Storage_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_1_4/RedfishStorage_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_1_4/Storage_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_1_5/RedfishStorage_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_1_5/Storage_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_1_6/RedfishStorage_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_1_6/Storage_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_1_7/RedfishStorage_V1_1_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_1_7/Storage_V1_1_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_1_8/RedfishStorage_V1_1_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_1_8/Storage_V1_1_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_1_9/RedfishStorage_V1_1_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_1_9/Storage_V1_1_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_2_0/RedfishStorage_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_2_0/Storage_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_2_1/RedfishStorage_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_2_1/Storage_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_2_2/RedfishStorage_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_2_2/Storage_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_2_3/RedfishStorage_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_2_3/Storage_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_2_4/RedfishStorage_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_2_4/Storage_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_2_5/RedfishStorage_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_2_5/Storage_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_2_6/RedfishStorage_V1_2_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_2_6/Storage_V1_2_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_2_7/RedfishStorage_V1_2_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_2_7/Storage_V1_2_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_3_0/RedfishStorage_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_3_0/Storage_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_3_1/RedfishStorage_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_3_1/Storage_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_3_2/RedfishStorage_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_3_2/Storage_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_3_3/RedfishStorage_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_3_3/Storage_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_3_4/RedfishStorage_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_3_4/Storage_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_3_5/RedfishStorage_V1_3_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_3_5/Storage_V1_3_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_3_6/RedfishStorage_V1_3_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_3_6/Storage_V1_3_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_3_7/RedfishStorage_V1_3_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_3_7/Storage_V1_3_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_4_0/RedfishStorage_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_4_0/Storage_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_4_1/RedfishStorage_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_4_1/Storage_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_4_2/RedfishStorage_V1_4_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_4_2/Storage_V1_4_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_4_3/RedfishStorage_V1_4_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_4_3/Storage_V1_4_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_4_4/RedfishStorage_V1_4_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_4_4/Storage_V1_4_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_4_5/RedfishStorage_V1_4_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_4_5/Storage_V1_4_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_4_6/RedfishStorage_V1_4_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_4_6/Storage_V1_4_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_5_0/RedfishStorage_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_5_0/Storage_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_5_1/RedfishStorage_V1_5_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_5_1/Storage_V1_5_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_5_2/RedfishStorage_V1_5_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_5_2/Storage_V1_5_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_5_3/RedfishStorage_V1_5_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_5_3/Storage_V1_5_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_5_4/RedfishStorage_V1_5_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_5_4/Storage_V1_5_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_5_5/RedfishStorage_V1_5_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_5_5/Storage_V1_5_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_6_0/RedfishStorage_V1_6_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_6_0/Storage_V1_6_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_6_1/RedfishStorage_V1_6_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_6_1/Storage_V1_6_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_6_2/RedfishStorage_V1_6_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_6_2/Storage_V1_6_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_6_3/RedfishStorage_V1_6_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_6_3/Storage_V1_6_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_6_4/RedfishStorage_V1_6_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_6_4/Storage_V1_6_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_7_0/RedfishStorage_V1_7_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_7_0/Storage_V1_7_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_7_1/RedfishStorage_V1_7_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_7_1/Storage_V1_7_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_7_2/RedfishStorage_V1_7_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_7_2/Storage_V1_7_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_7_3/RedfishStorage_V1_7_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_7_3/Storage_V1_7_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_8_0/RedfishStorage_V1_8_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_8_0/Storage_V1_8_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_8_1/RedfishStorage_V1_8_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_8_1/Storage_V1_8_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_8_2/RedfishStorage_V1_8_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_8_2/Storage_V1_8_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_9_0/RedfishStorage_V1_9_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_9_0/Storage_V1_9_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Storage/v1_9_1/RedfishStorage_V1_9_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Storage/v1_9_1/Storage_V1_9_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/StorageCollection/RedfishStorageCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/StorageCollection/StorageCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/StorageController/v1_0_0/RedfishStorageController_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/StorageController/v1_0_0/StorageController_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/StorageController/v1_0_1/RedfishStorageController_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/StorageController/v1_0_1/StorageController_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/StorageController/v1_1_0/RedfishStorageController_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/StorageController/v1_1_0/StorageController_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/StorageControllerCollection/RedfishStorageControllerCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/StorageControllerCollection/StorageControllerCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/Switch/v1_0_0/RedfishSwitch_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Switch/v1_0_0/Switch_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Switch/v1_0_1/RedfishSwitch_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Switch/v1_0_1/Switch_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Switch/v1_0_2/RedfishSwitch_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Switch/v1_0_2/Switch_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Switch/v1_0_3/RedfishSwitch_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Switch/v1_0_3/Switch_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Switch/v1_0_4/RedfishSwitch_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Switch/v1_0_4/Switch_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Switch/v1_0_5/RedfishSwitch_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Switch/v1_0_5/Switch_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Switch/v1_0_6/RedfishSwitch_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Switch/v1_0_6/Switch_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Switch/v1_0_7/RedfishSwitch_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Switch/v1_0_7/Switch_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Switch/v1_0_8/RedfishSwitch_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Switch/v1_0_8/Switch_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Switch/v1_1_0/RedfishSwitch_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Switch/v1_1_0/Switch_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Switch/v1_1_1/RedfishSwitch_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Switch/v1_1_1/Switch_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Switch/v1_1_2/RedfishSwitch_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Switch/v1_1_2/Switch_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Switch/v1_1_3/RedfishSwitch_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Switch/v1_1_3/Switch_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Switch/v1_1_4/RedfishSwitch_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Switch/v1_1_4/Switch_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Switch/v1_1_5/RedfishSwitch_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Switch/v1_1_5/Switch_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Switch/v1_2_0/RedfishSwitch_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Switch/v1_2_0/Switch_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Switch/v1_2_1/RedfishSwitch_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Switch/v1_2_1/Switch_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Switch/v1_2_2/RedfishSwitch_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Switch/v1_2_2/Switch_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Switch/v1_3_0/RedfishSwitch_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Switch/v1_3_0/Switch_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Switch/v1_3_1/RedfishSwitch_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Switch/v1_3_1/Switch_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Switch/v1_3_2/RedfishSwitch_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Switch/v1_3_2/Switch_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Switch/v1_4_0/RedfishSwitch_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Switch/v1_4_0/Switch_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Switch/v1_4_1/RedfishSwitch_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Switch/v1_4_1/Switch_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Switch/v1_5_0/RedfishSwitch_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Switch/v1_5_0/Switch_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/SwitchCollection/RedfishSwitchCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/SwitchCollection/SwitchCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_0_0/RedfishTask_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_0_0/Task_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_0_2/RedfishTask_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_0_2/Task_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_0_3/RedfishTask_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_0_3/Task_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_0_4/RedfishTask_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_0_4/Task_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_0_5/RedfishTask_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_0_5/Task_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_0_6/RedfishTask_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_0_6/Task_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_0_7/RedfishTask_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_0_7/Task_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_0_8/RedfishTask_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_0_8/Task_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_0_9/RedfishTask_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_0_9/Task_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_1_0/RedfishTask_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_1_0/Task_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_1_1/RedfishTask_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_1_1/Task_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_1_2/RedfishTask_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_1_2/Task_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_1_3/RedfishTask_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_1_3/Task_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_1_4/RedfishTask_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_1_4/Task_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_1_5/RedfishTask_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_1_5/Task_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_1_6/RedfishTask_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_1_6/Task_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_2_0/RedfishTask_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_2_0/Task_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_2_1/RedfishTask_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_2_1/Task_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_2_2/RedfishTask_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_2_2/Task_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_2_3/RedfishTask_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_2_3/Task_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_2_4/RedfishTask_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_2_4/Task_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_2_5/RedfishTask_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_2_5/Task_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_3_0/RedfishTask_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_3_0/Task_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_3_1/RedfishTask_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_3_1/Task_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_3_2/RedfishTask_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_3_2/Task_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_3_3/RedfishTask_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_3_3/Task_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_3_4/RedfishTask_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_3_4/Task_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_3_5/RedfishTask_V1_3_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_3_5/Task_V1_3_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_4_0/RedfishTask_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_4_0/Task_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_4_1/RedfishTask_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_4_1/Task_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_4_2/RedfishTask_V1_4_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_4_2/Task_V1_4_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_4_3/RedfishTask_V1_4_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_4_3/Task_V1_4_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_4_4/RedfishTask_V1_4_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_4_4/Task_V1_4_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_5_0/RedfishTask_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_5_0/Task_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Task/v1_5_1/RedfishTask_V1_5_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Task/v1_5_1/Task_V1_5_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/TaskCollection/RedfishTaskCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TaskCollection/TaskCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/TaskService/v1_0_0/RedfishTaskService_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TaskService/v1_0_0/TaskService_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/TaskService/v1_0_2/RedfishTaskService_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TaskService/v1_0_2/TaskService_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/TaskService/v1_0_3/RedfishTaskService_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TaskService/v1_0_3/TaskService_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/TaskService/v1_0_4/RedfishTaskService_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TaskService/v1_0_4/TaskService_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/TaskService/v1_0_5/RedfishTaskService_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TaskService/v1_0_5/TaskService_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/TaskService/v1_0_6/RedfishTaskService_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TaskService/v1_0_6/TaskService_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/TaskService/v1_0_7/RedfishTaskService_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TaskService/v1_0_7/TaskService_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/TaskService/v1_0_8/RedfishTaskService_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TaskService/v1_0_8/TaskService_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/TaskService/v1_0_9/RedfishTaskService_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TaskService/v1_0_9/TaskService_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/TaskService/v1_1_0/RedfishTaskService_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TaskService/v1_1_0/TaskService_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/TaskService/v1_1_1/RedfishTaskService_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TaskService/v1_1_1/TaskService_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/TaskService/v1_1_2/RedfishTaskService_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TaskService/v1_1_2/TaskService_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/TaskService/v1_1_3/RedfishTaskService_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TaskService/v1_1_3/TaskService_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/TaskService/v1_1_4/RedfishTaskService_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TaskService/v1_1_4/TaskService_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/TaskService/v1_1_5/RedfishTaskService_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TaskService/v1_1_5/TaskService_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/TaskService/v1_1_6/RedfishTaskService_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TaskService/v1_1_6/TaskService_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_0_0/RedfishTelemetryService_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_0_0/TelemetryService_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_0_1/RedfishTelemetryService_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_0_1/TelemetryService_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_0_2/RedfishTelemetryService_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_0_2/TelemetryService_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_0_3/RedfishTelemetryService_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_0_3/TelemetryService_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_0_4/RedfishTelemetryService_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_0_4/TelemetryService_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_1_0/RedfishTelemetryService_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_1_0/TelemetryService_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_1_1/RedfishTelemetryService_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_1_1/TelemetryService_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_1_2/RedfishTelemetryService_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_1_2/TelemetryService_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_1_3/RedfishTelemetryService_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_1_3/TelemetryService_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_1_4/RedfishTelemetryService_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_1_4/TelemetryService_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_2_0/RedfishTelemetryService_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_2_0/TelemetryService_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_2_1/RedfishTelemetryService_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_2_1/TelemetryService_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_2_2/RedfishTelemetryService_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_2_2/TelemetryService_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_3_0/RedfishTelemetryService_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TelemetryService/v1_3_0/TelemetryService_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_0_0/RedfishThermal_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_0_0/Thermal_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_0_1/RedfishThermal_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_0_1/Thermal_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_0_10/RedfishThermal_V1_0_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_0_10/Thermal_V1_0_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_0_11/RedfishThermal_V1_0_11_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_0_11/Thermal_V1_0_11_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_0_2/RedfishThermal_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_0_2/Thermal_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_0_3/RedfishThermal_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_0_3/Thermal_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_0_4/RedfishThermal_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_0_4/Thermal_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_0_5/RedfishThermal_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_0_5/Thermal_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_0_6/RedfishThermal_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_0_6/Thermal_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_0_7/RedfishThermal_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_0_7/Thermal_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_0_8/RedfishThermal_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_0_8/Thermal_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_0_9/RedfishThermal_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_0_9/Thermal_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_1_0/RedfishThermal_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_1_0/Thermal_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_1_1/RedfishThermal_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_1_1/Thermal_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_1_2/RedfishThermal_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_1_2/Thermal_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_1_3/RedfishThermal_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_1_3/Thermal_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_1_4/RedfishThermal_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_1_4/Thermal_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_1_5/RedfishThermal_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_1_5/Thermal_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_1_6/RedfishThermal_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_1_6/Thermal_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_1_7/RedfishThermal_V1_1_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_1_7/Thermal_V1_1_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_1_8/RedfishThermal_V1_1_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_1_8/Thermal_V1_1_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_1_9/RedfishThermal_V1_1_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_1_9/Thermal_V1_1_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_2_0/RedfishThermal_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_2_0/Thermal_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_2_1/RedfishThermal_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_2_1/Thermal_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_2_2/RedfishThermal_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_2_2/Thermal_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_2_3/RedfishThermal_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_2_3/Thermal_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_2_4/RedfishThermal_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_2_4/Thermal_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_2_5/RedfishThermal_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_2_5/Thermal_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_2_6/RedfishThermal_V1_2_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_2_6/Thermal_V1_2_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_2_7/RedfishThermal_V1_2_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_2_7/Thermal_V1_2_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_2_8/RedfishThermal_V1_2_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_2_8/Thermal_V1_2_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_3_0/RedfishThermal_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_3_0/Thermal_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_3_1/RedfishThermal_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_3_1/Thermal_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_3_2/RedfishThermal_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_3_2/Thermal_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_3_3/RedfishThermal_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_3_3/Thermal_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_3_4/RedfishThermal_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_3_4/Thermal_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_3_5/RedfishThermal_V1_3_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_3_5/Thermal_V1_3_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_3_6/RedfishThermal_V1_3_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_3_6/Thermal_V1_3_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_3_7/RedfishThermal_V1_3_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_3_7/Thermal_V1_3_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_4_0/RedfishThermal_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_4_0/Thermal_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_4_1/RedfishThermal_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_4_1/Thermal_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_4_2/RedfishThermal_V1_4_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_4_2/Thermal_V1_4_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_4_3/RedfishThermal_V1_4_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_4_3/Thermal_V1_4_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_4_4/RedfishThermal_V1_4_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_4_4/Thermal_V1_4_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_4_5/RedfishThermal_V1_4_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_4_5/Thermal_V1_4_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_4_6/RedfishThermal_V1_4_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_4_6/Thermal_V1_4_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_5_0/RedfishThermal_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_5_0/Thermal_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_5_1/RedfishThermal_V1_5_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_5_1/Thermal_V1_5_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_5_2/RedfishThermal_V1_5_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_5_2/Thermal_V1_5_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_5_3/RedfishThermal_V1_5_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_5_3/Thermal_V1_5_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_5_4/RedfishThermal_V1_5_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_5_4/Thermal_V1_5_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_5_5/RedfishThermal_V1_5_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_5_5/Thermal_V1_5_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_6_0/RedfishThermal_V1_6_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_6_0/Thermal_V1_6_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_6_1/RedfishThermal_V1_6_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_6_1/Thermal_V1_6_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_6_2/RedfishThermal_V1_6_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_6_2/Thermal_V1_6_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Thermal/v1_7_0/RedfishThermal_V1_7_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Thermal/v1_7_0/Thermal_V1_7_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ThermalMetrics/v1_0_0/RedfishThermalMetrics_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ThermalMetrics/v1_0_0/ThermalMetrics_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ThermalSubsystem/v1_0_0/RedfishThermalSubsystem_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ThermalSubsystem/v1_0_0/ThermalSubsystem_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Triggers/v1_0_0/RedfishTriggers_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Triggers/v1_0_0/Triggers_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Triggers/v1_0_1/RedfishTriggers_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Triggers/v1_0_1/Triggers_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Triggers/v1_0_2/RedfishTriggers_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Triggers/v1_0_2/Triggers_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Triggers/v1_0_3/RedfishTriggers_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Triggers/v1_0_3/Triggers_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Triggers/v1_0_4/RedfishTriggers_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Triggers/v1_0_4/Triggers_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Triggers/v1_0_5/RedfishTriggers_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Triggers/v1_0_5/Triggers_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Triggers/v1_1_0/RedfishTriggers_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Triggers/v1_1_0/Triggers_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Triggers/v1_1_1/RedfishTriggers_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Triggers/v1_1_1/Triggers_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Triggers/v1_1_2/RedfishTriggers_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Triggers/v1_1_2/Triggers_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Triggers/v1_1_3/RedfishTriggers_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Triggers/v1_1_3/Triggers_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/TriggersCollection/RedfishTriggersCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/TriggersCollection/TriggersCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_0_0/RedfishUpdateService_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_0_0/UpdateService_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_0_1/RedfishUpdateService_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_0_1/UpdateService_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_0_10/RedfishUpdateService_V1_0_10_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_0_10/UpdateService_V1_0_10_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_0_2/RedfishUpdateService_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_0_2/UpdateService_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_0_3/RedfishUpdateService_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_0_3/UpdateService_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_0_4/RedfishUpdateService_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_0_4/UpdateService_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_0_5/RedfishUpdateService_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_0_5/UpdateService_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_0_6/RedfishUpdateService_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_0_6/UpdateService_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_0_7/RedfishUpdateService_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_0_7/UpdateService_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_0_8/RedfishUpdateService_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_0_8/UpdateService_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_0_9/RedfishUpdateService_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_0_9/UpdateService_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_1_0/RedfishUpdateService_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_1_0/UpdateService_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_1_1/RedfishUpdateService_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_1_1/UpdateService_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_1_2/RedfishUpdateService_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_1_2/UpdateService_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_1_3/RedfishUpdateService_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_1_3/UpdateService_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_1_4/RedfishUpdateService_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_1_4/UpdateService_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_1_5/RedfishUpdateService_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_1_5/UpdateService_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_1_6/RedfishUpdateService_V1_1_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_1_6/UpdateService_V1_1_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_1_7/RedfishUpdateService_V1_1_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_1_7/UpdateService_V1_1_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_1_8/RedfishUpdateService_V1_1_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_1_8/UpdateService_V1_1_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_1_9/RedfishUpdateService_V1_1_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_1_9/UpdateService_V1_1_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_2_0/RedfishUpdateService_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_2_0/UpdateService_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_2_1/RedfishUpdateService_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_2_1/UpdateService_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_2_2/RedfishUpdateService_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_2_2/UpdateService_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_2_3/RedfishUpdateService_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_2_3/UpdateService_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_2_4/RedfishUpdateService_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_2_4/UpdateService_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_2_5/RedfishUpdateService_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_2_5/UpdateService_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_2_6/RedfishUpdateService_V1_2_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_2_6/UpdateService_V1_2_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_2_7/RedfishUpdateService_V1_2_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_2_7/UpdateService_V1_2_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_2_8/RedfishUpdateService_V1_2_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_2_8/UpdateService_V1_2_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_3_0/RedfishUpdateService_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_3_0/UpdateService_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_3_1/RedfishUpdateService_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_3_1/UpdateService_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_3_2/RedfishUpdateService_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_3_2/UpdateService_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_3_3/RedfishUpdateService_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_3_3/UpdateService_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_3_4/RedfishUpdateService_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_3_4/UpdateService_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_3_5/RedfishUpdateService_V1_3_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_3_5/UpdateService_V1_3_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_3_6/RedfishUpdateService_V1_3_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_3_6/UpdateService_V1_3_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_4_0/RedfishUpdateService_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_4_0/UpdateService_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_4_1/RedfishUpdateService_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_4_1/UpdateService_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_4_2/RedfishUpdateService_V1_4_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_4_2/UpdateService_V1_4_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_4_3/RedfishUpdateService_V1_4_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_4_3/UpdateService_V1_4_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_4_4/RedfishUpdateService_V1_4_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_4_4/UpdateService_V1_4_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_4_5/RedfishUpdateService_V1_4_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_4_5/UpdateService_V1_4_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_5_0/RedfishUpdateService_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_5_0/UpdateService_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_5_1/RedfishUpdateService_V1_5_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_5_1/UpdateService_V1_5_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_5_2/RedfishUpdateService_V1_5_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_5_2/UpdateService_V1_5_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_5_3/RedfishUpdateService_V1_5_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_5_3/UpdateService_V1_5_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_5_4/RedfishUpdateService_V1_5_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_5_4/UpdateService_V1_5_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_6_0/RedfishUpdateService_V1_6_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_6_0/UpdateService_V1_6_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_6_1/RedfishUpdateService_V1_6_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_6_1/UpdateService_V1_6_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_6_2/RedfishUpdateService_V1_6_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_6_2/UpdateService_V1_6_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_6_3/RedfishUpdateService_V1_6_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_6_3/UpdateService_V1_6_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_7_0/RedfishUpdateService_V1_7_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_7_0/UpdateService_V1_7_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_7_1/RedfishUpdateService_V1_7_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_7_1/UpdateService_V1_7_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_7_2/RedfishUpdateService_V1_7_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_7_2/UpdateService_V1_7_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_7_3/RedfishUpdateService_V1_7_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_7_3/UpdateService_V1_7_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_8_0/RedfishUpdateService_V1_8_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_8_0/UpdateService_V1_8_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_8_1/RedfishUpdateService_V1_8_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_8_1/UpdateService_V1_8_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_8_2/RedfishUpdateService_V1_8_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_8_2/UpdateService_V1_8_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_8_3/RedfishUpdateService_V1_8_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/UpdateService/v1_8_3/UpdateService_V1_8_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/VCATEntry/v1_0_0/RedfishVCATEntry_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VCATEntry/v1_0_0/VCATEntry_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/VCATEntry/v1_0_1/RedfishVCATEntry_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VCATEntry/v1_0_1/VCATEntry_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/VCATEntryCollection/RedfishVCATEntryCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VCATEntryCollection/VCATEntryCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_0/RedfishVLanNetworkInterface_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_0/VLanNetworkInterface_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_1/RedfishVLanNetworkInterface_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_1/VLanNetworkInterface_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_2/RedfishVLanNetworkInterface_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_2/VLanNetworkInterface_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_3/RedfishVLanNetworkInterface_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_3/VLanNetworkInterface_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_4/RedfishVLanNetworkInterface_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_4/VLanNetworkInterface_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_5/RedfishVLanNetworkInterface_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_5/VLanNetworkInterface_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_6/RedfishVLanNetworkInterface_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_6/VLanNetworkInterface_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_7/RedfishVLanNetworkInterface_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_7/VLanNetworkInterface_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_8/RedfishVLanNetworkInterface_V1_0_8_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_8/VLanNetworkInterface_V1_0_8_Dxe.c create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_9/RedfishVLanNetworkInterface_V1_0_9_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_9/VLanNetworkInterface_V1_0_9_Dxe.c create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_0/RedfishVLanNetworkInterface_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_0/VLanNetworkInterface_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_1/RedfishVLanNetworkInterface_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_1/VLanNetworkInterface_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_2/RedfishVLanNetworkInterface_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_2/VLanNetworkInterface_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_3/RedfishVLanNetworkInterface_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_3/VLanNetworkInterface_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_4/RedfishVLanNetworkInterface_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_4/VLanNetworkInterface_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_5/RedfishVLanNetworkInterface_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_5/VLanNetworkInterface_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_2_0/RedfishVLanNetworkInterface_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterface/v1_2_0/VLanNetworkInterface_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterfaceCollection/RedfishVLanNetworkInterfaceCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VLanNetworkInterfaceCollection/VLanNetworkInterfaceCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_0_0/RedfishVirtualMedia_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_0_0/VirtualMedia_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_0_2/RedfishVirtualMedia_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_0_2/VirtualMedia_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_0_3/RedfishVirtualMedia_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_0_3/VirtualMedia_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_0_4/RedfishVirtualMedia_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_0_4/VirtualMedia_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_0_5/RedfishVirtualMedia_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_0_5/VirtualMedia_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_0_6/RedfishVirtualMedia_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_0_6/VirtualMedia_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_0_7/RedfishVirtualMedia_V1_0_7_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_0_7/VirtualMedia_V1_0_7_Dxe.c create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_1_0/RedfishVirtualMedia_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_1_0/VirtualMedia_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_1_1/RedfishVirtualMedia_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_1_1/VirtualMedia_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_1_2/RedfishVirtualMedia_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_1_2/VirtualMedia_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_1_3/RedfishVirtualMedia_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_1_3/VirtualMedia_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_1_4/RedfishVirtualMedia_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_1_4/VirtualMedia_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_1_5/RedfishVirtualMedia_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_1_5/VirtualMedia_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_2_0/RedfishVirtualMedia_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_2_0/VirtualMedia_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_2_1/RedfishVirtualMedia_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_2_1/VirtualMedia_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_2_2/RedfishVirtualMedia_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_2_2/VirtualMedia_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_2_3/RedfishVirtualMedia_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_2_3/VirtualMedia_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_2_4/RedfishVirtualMedia_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_2_4/VirtualMedia_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_3_0/RedfishVirtualMedia_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_3_0/VirtualMedia_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_3_1/RedfishVirtualMedia_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_3_1/VirtualMedia_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_3_2/RedfishVirtualMedia_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VirtualMedia/v1_3_2/VirtualMedia_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/VirtualMediaCollection/RedfishVirtualMediaCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VirtualMediaCollection/VirtualMediaCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_0_0/RedfishVolume_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_0_0/Volume_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_0_1/RedfishVolume_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_0_1/Volume_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_0_2/RedfishVolume_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_0_2/Volume_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_0_3/RedfishVolume_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_0_3/Volume_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_0_4/RedfishVolume_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_0_4/Volume_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_1_0/RedfishVolume_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_1_0/Volume_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_1_1/RedfishVolume_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_1_1/Volume_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_1_2/RedfishVolume_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_1_2/Volume_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_1_3/RedfishVolume_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_1_3/Volume_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_1_4/RedfishVolume_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_1_4/Volume_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_1_5/RedfishVolume_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_1_5/Volume_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_2_0/RedfishVolume_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_2_0/Volume_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_2_1/RedfishVolume_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_2_1/Volume_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_2_2/RedfishVolume_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_2_2/Volume_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_2_3/RedfishVolume_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_2_3/Volume_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_2_4/RedfishVolume_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_2_4/Volume_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_2_5/RedfishVolume_V1_2_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_2_5/Volume_V1_2_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_3_0/RedfishVolume_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_3_0/Volume_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_3_1/RedfishVolume_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_3_1/Volume_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_3_2/RedfishVolume_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_3_2/Volume_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_3_3/RedfishVolume_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_3_3/Volume_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_3_4/RedfishVolume_V1_3_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_3_4/Volume_V1_3_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_4_0/RedfishVolume_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_4_0/Volume_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_4_1/RedfishVolume_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_4_1/Volume_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_4_2/RedfishVolume_V1_4_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_4_2/Volume_V1_4_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_4_3/RedfishVolume_V1_4_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_4_3/Volume_V1_4_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_5_0/RedfishVolume_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_5_0/Volume_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_5_1/RedfishVolume_V1_5_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_5_1/Volume_V1_5_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_6_0/RedfishVolume_V1_6_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_6_0/Volume_V1_6_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Volume/v1_6_1/RedfishVolume_V1_6_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Volume/v1_6_1/Volume_V1_6_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/VolumeCollection/RedfishVolumeCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/VolumeCollection/VolumeCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_0_0/RedfishZone_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_0_0/Zone_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_0_1/RedfishZone_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_0_1/Zone_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_0_2/RedfishZone_V1_0_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_0_2/Zone_V1_0_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_0_3/RedfishZone_V1_0_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_0_3/Zone_V1_0_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_0_4/RedfishZone_V1_0_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_0_4/Zone_V1_0_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_0_5/RedfishZone_V1_0_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_0_5/Zone_V1_0_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_0_6/RedfishZone_V1_0_6_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_0_6/Zone_V1_0_6_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_1_0/RedfishZone_V1_1_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_1_0/Zone_V1_1_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_1_1/RedfishZone_V1_1_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_1_1/Zone_V1_1_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_1_2/RedfishZone_V1_1_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_1_2/Zone_V1_1_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_1_3/RedfishZone_V1_1_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_1_3/Zone_V1_1_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_1_4/RedfishZone_V1_1_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_1_4/Zone_V1_1_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_1_5/RedfishZone_V1_1_5_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_1_5/Zone_V1_1_5_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_2_0/RedfishZone_V1_2_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_2_0/Zone_V1_2_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_2_1/RedfishZone_V1_2_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_2_1/Zone_V1_2_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_2_2/RedfishZone_V1_2_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_2_2/Zone_V1_2_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_2_3/RedfishZone_V1_2_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_2_3/Zone_V1_2_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_2_4/RedfishZone_V1_2_4_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_2_4/Zone_V1_2_4_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_3_0/RedfishZone_V1_3_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_3_0/Zone_V1_3_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_3_1/RedfishZone_V1_3_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_3_1/Zone_V1_3_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_3_2/RedfishZone_V1_3_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_3_2/Zone_V1_3_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_3_3/RedfishZone_V1_3_3_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_3_3/Zone_V1_3_3_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_4_0/RedfishZone_V1_4_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_4_0/Zone_V1_4_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_4_1/RedfishZone_V1_4_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_4_1/Zone_V1_4_1_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_4_2/RedfishZone_V1_4_2_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_4_2/Zone_V1_4_2_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_5_0/RedfishZone_V1_5_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_5_0/Zone_V1_5_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/Zone/v1_6_0/RedfishZone_V1_6_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/Zone/v1_6_0/Zone_V1_6_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/ZoneCollection/RedfishZoneCollection_Dxe.inf create mode 100644 RedfishClientPkg/Converter/ZoneCollection/ZoneCollection_Dxe.c create mode 100644 RedfishClientPkg/Converter/redfisherror/v1_0_0/Redfishredfisherror_V1_0_0_Dxe.inf create mode 100644 RedfishClientPkg/Converter/redfisherror/v1_0_0/redfisherror_V1_0_0_Dxe.c create mode 100644 RedfishClientPkg/Converter/redfisherror/v1_0_1/Redfishredfisherror_V1_0_1_Dxe.inf create mode 100644 RedfishClientPkg/Converter/redfisherror/v1_0_1/redfisherror_V1_0_1_Dxe.c create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccelerationFunction/v1_0_0/EfiAccelerationFunctionV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccelerationFunction/v1_0_1/EfiAccelerationFunctionV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccelerationFunction/v1_0_2/EfiAccelerationFunctionV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccelerationFunction/v1_0_3/EfiAccelerationFunctionV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccelerationFunctionCollection/EfiAccelerationFunctionCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_0/EfiAccountServiceV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_10/EfiAccountServiceV1_0_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_11/EfiAccountServiceV1_0_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_2/EfiAccountServiceV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_3/EfiAccountServiceV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_4/EfiAccountServiceV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_5/EfiAccountServiceV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_6/EfiAccountServiceV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_7/EfiAccountServiceV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_8/EfiAccountServiceV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_9/EfiAccountServiceV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_0/EfiAccountServiceV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_1/EfiAccountServiceV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_2/EfiAccountServiceV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_3/EfiAccountServiceV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_4/EfiAccountServiceV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_5/EfiAccountServiceV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_6/EfiAccountServiceV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_7/EfiAccountServiceV1_1_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_8/EfiAccountServiceV1_1_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_0/EfiAccountServiceV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_1/EfiAccountServiceV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_2/EfiAccountServiceV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_3/EfiAccountServiceV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_4/EfiAccountServiceV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_5/EfiAccountServiceV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_6/EfiAccountServiceV1_2_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_7/EfiAccountServiceV1_2_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_8/EfiAccountServiceV1_2_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_0/EfiAccountServiceV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_1/EfiAccountServiceV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_2/EfiAccountServiceV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_3/EfiAccountServiceV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_4/EfiAccountServiceV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_5/EfiAccountServiceV1_3_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_6/EfiAccountServiceV1_3_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_7/EfiAccountServiceV1_3_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_4_0/EfiAccountServiceV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_4_1/EfiAccountServiceV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_4_2/EfiAccountServiceV1_4_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_4_3/EfiAccountServiceV1_4_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_4_4/EfiAccountServiceV1_4_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_4_5/EfiAccountServiceV1_4_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_5_0/EfiAccountServiceV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_5_1/EfiAccountServiceV1_5_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_5_2/EfiAccountServiceV1_5_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_5_3/EfiAccountServiceV1_5_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_5_4/EfiAccountServiceV1_5_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_6_0/EfiAccountServiceV1_6_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_6_1/EfiAccountServiceV1_6_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_6_2/EfiAccountServiceV1_6_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_6_3/EfiAccountServiceV1_6_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_7_0/EfiAccountServiceV1_7_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_7_1/EfiAccountServiceV1_7_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_7_2/EfiAccountServiceV1_7_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_7_3/EfiAccountServiceV1_7_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_8_0/EfiAccountServiceV1_8_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_0/EfiActionInfoV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_1/EfiActionInfoV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_2/EfiActionInfoV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_3/EfiActionInfoV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_4/EfiActionInfoV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_5/EfiActionInfoV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_6/EfiActionInfoV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_1_0/EfiActionInfoV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_1_1/EfiActionInfoV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_1_2/EfiActionInfoV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AddressPool/v1_0_0/EfiAddressPoolV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AddressPool/v1_0_1/EfiAddressPoolV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AddressPool/v1_0_2/EfiAddressPoolV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AddressPool/v1_1_0/EfiAddressPoolV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AddressPool/v1_1_1/EfiAddressPoolV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AddressPoolCollection/EfiAddressPoolCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Aggregate/v1_0_0/EfiAggregateV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Aggregate/v1_0_1/EfiAggregateV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AggregateCollection/EfiAggregateCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AggregationService/v1_0_0/EfiAggregationServiceV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AggregationService/v1_0_1/EfiAggregationServiceV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AggregationSource/v1_0_0/EfiAggregationSourceV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AggregationSource/v1_1_0/EfiAggregationSourceV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AggregationSourceCollection/EfiAggregationSourceCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_0_0/EfiAssemblyV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_0_1/EfiAssemblyV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_0_2/EfiAssemblyV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_0_3/EfiAssemblyV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_0_4/EfiAssemblyV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_1_0/EfiAssemblyV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_1_1/EfiAssemblyV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_1_2/EfiAssemblyV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_1_3/EfiAssemblyV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_1_4/EfiAssemblyV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_2_0/EfiAssemblyV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_2_1/EfiAssemblyV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_2_2/EfiAssemblyV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_2_3/EfiAssemblyV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_3_0/EfiAssemblyV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_0/EfiAttributeRegistryV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_1/EfiAttributeRegistryV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_10/EfiAttributeRegistryV1_0_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_2/EfiAttributeRegistryV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_3/EfiAttributeRegistryV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_4/EfiAttributeRegistryV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_5/EfiAttributeRegistryV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_6/EfiAttributeRegistryV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_7/EfiAttributeRegistryV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_8/EfiAttributeRegistryV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_9/EfiAttributeRegistryV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_0/EfiAttributeRegistryV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_1/EfiAttributeRegistryV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_2/EfiAttributeRegistryV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_3/EfiAttributeRegistryV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_4/EfiAttributeRegistryV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_5/EfiAttributeRegistryV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_6/EfiAttributeRegistryV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_7/EfiAttributeRegistryV1_1_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_8/EfiAttributeRegistryV1_1_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_9/EfiAttributeRegistryV1_1_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_0/EfiAttributeRegistryV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_1/EfiAttributeRegistryV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_2/EfiAttributeRegistryV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_3/EfiAttributeRegistryV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_4/EfiAttributeRegistryV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_5/EfiAttributeRegistryV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_6/EfiAttributeRegistryV1_2_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_7/EfiAttributeRegistryV1_2_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_3_0/EfiAttributeRegistryV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_3_1/EfiAttributeRegistryV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_3_2/EfiAttributeRegistryV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_3_3/EfiAttributeRegistryV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_3_4/EfiAttributeRegistryV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_3_5/EfiAttributeRegistryV1_3_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_0/EfiBiosV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_1/EfiBiosV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_2/EfiBiosV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_3/EfiBiosV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_4/EfiBiosV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_5/EfiBiosV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_6/EfiBiosV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_7/EfiBiosV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_8/EfiBiosV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_1_0/EfiBiosV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_1_1/EfiBiosV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/BootOption/v1_0_0/EfiBootOptionV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/BootOption/v1_0_1/EfiBootOptionV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/BootOption/v1_0_2/EfiBootOptionV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/BootOption/v1_0_3/EfiBootOptionV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/BootOption/v1_0_4/EfiBootOptionV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/BootOptionCollection/EfiBootOptionCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_0_0/EfiCertificateV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_0_1/EfiCertificateV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_0_2/EfiCertificateV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_0_3/EfiCertificateV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_0_4/EfiCertificateV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_1_0/EfiCertificateV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_1_1/EfiCertificateV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_1_2/EfiCertificateV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_1_3/EfiCertificateV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_2_0/EfiCertificateV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_2_1/EfiCertificateV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_2_2/EfiCertificateV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/CertificateCollection/EfiCertificateCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/CertificateLocations/v1_0_0/EfiCertificateLocationsV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/CertificateLocations/v1_0_1/EfiCertificateLocationsV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/CertificateLocations/v1_0_2/EfiCertificateLocationsV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/CertificateService/v1_0_0/EfiCertificateServiceV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/CertificateService/v1_0_1/EfiCertificateServiceV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/CertificateService/v1_0_2/EfiCertificateServiceV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/CertificateService/v1_0_3/EfiCertificateServiceV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/CertificateService/v1_0_4/EfiCertificateServiceV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_0/EfiChassisV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_1/EfiChassisV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_10/EfiChassisV1_0_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_11/EfiChassisV1_0_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_12/EfiChassisV1_0_12.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_13/EfiChassisV1_0_13.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_2/EfiChassisV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_3/EfiChassisV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_4/EfiChassisV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_5/EfiChassisV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_6/EfiChassisV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_7/EfiChassisV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_8/EfiChassisV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_9/EfiChassisV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_10_0/EfiChassisV1_10_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_10_1/EfiChassisV1_10_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_10_2/EfiChassisV1_10_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_10_3/EfiChassisV1_10_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_11_0/EfiChassisV1_11_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_11_1/EfiChassisV1_11_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_11_2/EfiChassisV1_11_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_11_3/EfiChassisV1_11_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_12_0/EfiChassisV1_12_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_12_1/EfiChassisV1_12_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_12_2/EfiChassisV1_12_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_13_0/EfiChassisV1_13_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_13_1/EfiChassisV1_13_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_14_0/EfiChassisV1_14_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_15_0/EfiChassisV1_15_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_0/EfiChassisV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_10/EfiChassisV1_1_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_11/EfiChassisV1_1_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_12/EfiChassisV1_1_12.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_13/EfiChassisV1_1_13.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_2/EfiChassisV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_3/EfiChassisV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_4/EfiChassisV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_5/EfiChassisV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_6/EfiChassisV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_7/EfiChassisV1_1_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_8/EfiChassisV1_1_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_9/EfiChassisV1_1_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_0/EfiChassisV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_1/EfiChassisV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_10/EfiChassisV1_2_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_11/EfiChassisV1_2_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_2/EfiChassisV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_3/EfiChassisV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_4/EfiChassisV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_5/EfiChassisV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_6/EfiChassisV1_2_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_7/EfiChassisV1_2_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_8/EfiChassisV1_2_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_9/EfiChassisV1_2_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_0/EfiChassisV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_1/EfiChassisV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_10/EfiChassisV1_3_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_11/EfiChassisV1_3_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_2/EfiChassisV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_3/EfiChassisV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_4/EfiChassisV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_5/EfiChassisV1_3_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_6/EfiChassisV1_3_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_7/EfiChassisV1_3_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_8/EfiChassisV1_3_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_9/EfiChassisV1_3_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_0/EfiChassisV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_1/EfiChassisV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_10/EfiChassisV1_4_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_2/EfiChassisV1_4_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_3/EfiChassisV1_4_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_4/EfiChassisV1_4_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_5/EfiChassisV1_4_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_6/EfiChassisV1_4_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_7/EfiChassisV1_4_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_8/EfiChassisV1_4_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_9/EfiChassisV1_4_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_0/EfiChassisV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_1/EfiChassisV1_5_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_2/EfiChassisV1_5_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_3/EfiChassisV1_5_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_4/EfiChassisV1_5_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_5/EfiChassisV1_5_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_6/EfiChassisV1_5_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_7/EfiChassisV1_5_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_8/EfiChassisV1_5_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_9/EfiChassisV1_5_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_0/EfiChassisV1_6_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_1/EfiChassisV1_6_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_2/EfiChassisV1_6_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_3/EfiChassisV1_6_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_4/EfiChassisV1_6_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_5/EfiChassisV1_6_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_6/EfiChassisV1_6_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_7/EfiChassisV1_6_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_0/EfiChassisV1_7_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_1/EfiChassisV1_7_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_2/EfiChassisV1_7_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_3/EfiChassisV1_7_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_4/EfiChassisV1_7_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_5/EfiChassisV1_7_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_6/EfiChassisV1_7_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_7/EfiChassisV1_7_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_0/EfiChassisV1_8_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_1/EfiChassisV1_8_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_2/EfiChassisV1_8_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_3/EfiChassisV1_8_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_4/EfiChassisV1_8_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_5/EfiChassisV1_8_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_6/EfiChassisV1_8_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_9_0/EfiChassisV1_9_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_9_1/EfiChassisV1_9_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_9_2/EfiChassisV1_9_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_9_3/EfiChassisV1_9_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_9_4/EfiChassisV1_9_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_9_5/EfiChassisV1_9_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ChassisCollection/EfiChassisCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Circuit/v1_0_0/EfiCircuitV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Circuit/v1_0_1/EfiCircuitV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Circuit/v1_0_2/EfiCircuitV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Circuit/v1_1_0/EfiCircuitV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Circuit/v1_1_1/EfiCircuitV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Circuit/v1_2_0/EfiCircuitV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/CircuitCollection/EfiCircuitCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_0_0/EfiCompositionServiceV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_0_1/EfiCompositionServiceV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_0_2/EfiCompositionServiceV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_0_3/EfiCompositionServiceV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_0_4/EfiCompositionServiceV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_1_0/EfiCompositionServiceV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_1_1/EfiCompositionServiceV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_1_2/EfiCompositionServiceV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_0/EfiComputerSystemV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_1/EfiComputerSystemV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_10/EfiComputerSystemV1_0_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_11/EfiComputerSystemV1_0_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_12/EfiComputerSystemV1_0_12.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_13/EfiComputerSystemV1_0_13.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_14/EfiComputerSystemV1_0_14.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_15/EfiComputerSystemV1_0_15.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_16/EfiComputerSystemV1_0_16.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_2/EfiComputerSystemV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_3/EfiComputerSystemV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_4/EfiComputerSystemV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_5/EfiComputerSystemV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_6/EfiComputerSystemV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_7/EfiComputerSystemV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_8/EfiComputerSystemV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_9/EfiComputerSystemV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_10_0/EfiComputerSystemV1_10_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_10_1/EfiComputerSystemV1_10_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_10_2/EfiComputerSystemV1_10_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_10_3/EfiComputerSystemV1_10_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_10_4/EfiComputerSystemV1_10_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_11_0/EfiComputerSystemV1_11_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_11_1/EfiComputerSystemV1_11_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_11_2/EfiComputerSystemV1_11_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_11_3/EfiComputerSystemV1_11_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_12_0/EfiComputerSystemV1_12_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_12_1/EfiComputerSystemV1_12_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_12_2/EfiComputerSystemV1_12_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_13_0/EfiComputerSystemV1_13_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_13_1/EfiComputerSystemV1_13_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_14_0/EfiComputerSystemV1_14_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_0/EfiComputerSystemV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_1/EfiComputerSystemV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_10/EfiComputerSystemV1_1_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_11/EfiComputerSystemV1_1_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_12/EfiComputerSystemV1_1_12.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_13/EfiComputerSystemV1_1_13.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_14/EfiComputerSystemV1_1_14.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_2/EfiComputerSystemV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_3/EfiComputerSystemV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_4/EfiComputerSystemV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_5/EfiComputerSystemV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_6/EfiComputerSystemV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_7/EfiComputerSystemV1_1_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_8/EfiComputerSystemV1_1_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_9/EfiComputerSystemV1_1_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_0/EfiComputerSystemV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_1/EfiComputerSystemV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_10/EfiComputerSystemV1_2_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_11/EfiComputerSystemV1_2_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_12/EfiComputerSystemV1_2_12.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_13/EfiComputerSystemV1_2_13.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_2/EfiComputerSystemV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_3/EfiComputerSystemV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_4/EfiComputerSystemV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_5/EfiComputerSystemV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_6/EfiComputerSystemV1_2_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_7/EfiComputerSystemV1_2_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_8/EfiComputerSystemV1_2_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_9/EfiComputerSystemV1_2_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_0/EfiComputerSystemV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_1/EfiComputerSystemV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_10/EfiComputerSystemV1_3_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_11/EfiComputerSystemV1_3_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_12/EfiComputerSystemV1_3_12.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_2/EfiComputerSystemV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_3/EfiComputerSystemV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_4/EfiComputerSystemV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_5/EfiComputerSystemV1_3_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_6/EfiComputerSystemV1_3_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_7/EfiComputerSystemV1_3_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_8/EfiComputerSystemV1_3_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_9/EfiComputerSystemV1_3_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_0/EfiComputerSystemV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_1/EfiComputerSystemV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_10/EfiComputerSystemV1_4_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_11/EfiComputerSystemV1_4_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_2/EfiComputerSystemV1_4_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_3/EfiComputerSystemV1_4_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_4/EfiComputerSystemV1_4_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_5/EfiComputerSystemV1_4_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_6/EfiComputerSystemV1_4_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_7/EfiComputerSystemV1_4_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_8/EfiComputerSystemV1_4_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_9/EfiComputerSystemV1_4_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_0/EfiComputerSystemV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_1/EfiComputerSystemV1_5_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_2/EfiComputerSystemV1_5_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_3/EfiComputerSystemV1_5_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_4/EfiComputerSystemV1_5_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_5/EfiComputerSystemV1_5_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_6/EfiComputerSystemV1_5_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_7/EfiComputerSystemV1_5_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_8/EfiComputerSystemV1_5_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_9/EfiComputerSystemV1_5_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_0/EfiComputerSystemV1_6_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_1/EfiComputerSystemV1_6_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_2/EfiComputerSystemV1_6_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_3/EfiComputerSystemV1_6_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_4/EfiComputerSystemV1_6_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_5/EfiComputerSystemV1_6_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_6/EfiComputerSystemV1_6_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_7/EfiComputerSystemV1_6_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_0/EfiComputerSystemV1_7_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_1/EfiComputerSystemV1_7_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_2/EfiComputerSystemV1_7_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_3/EfiComputerSystemV1_7_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_4/EfiComputerSystemV1_7_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_5/EfiComputerSystemV1_7_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_6/EfiComputerSystemV1_7_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_8_0/EfiComputerSystemV1_8_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_8_1/EfiComputerSystemV1_8_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_8_2/EfiComputerSystemV1_8_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_8_3/EfiComputerSystemV1_8_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_8_4/EfiComputerSystemV1_8_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_8_5/EfiComputerSystemV1_8_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_9_0/EfiComputerSystemV1_9_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_9_1/EfiComputerSystemV1_9_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_9_2/EfiComputerSystemV1_9_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_9_3/EfiComputerSystemV1_9_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_9_4/EfiComputerSystemV1_9_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_9_5/EfiComputerSystemV1_9_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystemCollection/EfiComputerSystemCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Connection/v1_0_0/EfiConnectionV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ConnectionCollection/EfiConnectionCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ConnectionMethod/v1_0_0/EfiConnectionMethodV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ConnectionMethodCollection/EfiConnectionMethodCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_0/EfiDriveV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_1/EfiDriveV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_10/EfiDriveV1_0_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_11/EfiDriveV1_0_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_2/EfiDriveV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_3/EfiDriveV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_4/EfiDriveV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_5/EfiDriveV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_6/EfiDriveV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_7/EfiDriveV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_8/EfiDriveV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_9/EfiDriveV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_10_0/EfiDriveV1_10_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_10_1/EfiDriveV1_10_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_11_0/EfiDriveV1_11_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_11_1/EfiDriveV1_11_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_12_0/EfiDriveV1_12_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_0/EfiDriveV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_1/EfiDriveV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_10/EfiDriveV1_1_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_2/EfiDriveV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_3/EfiDriveV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_4/EfiDriveV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_5/EfiDriveV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_6/EfiDriveV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_7/EfiDriveV1_1_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_8/EfiDriveV1_1_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_9/EfiDriveV1_1_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_0/EfiDriveV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_1/EfiDriveV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_2/EfiDriveV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_3/EfiDriveV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_4/EfiDriveV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_5/EfiDriveV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_6/EfiDriveV1_2_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_7/EfiDriveV1_2_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_8/EfiDriveV1_2_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_0/EfiDriveV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_1/EfiDriveV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_2/EfiDriveV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_3/EfiDriveV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_4/EfiDriveV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_5/EfiDriveV1_3_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_6/EfiDriveV1_3_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_7/EfiDriveV1_3_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_0/EfiDriveV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_1/EfiDriveV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_2/EfiDriveV1_4_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_3/EfiDriveV1_4_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_4/EfiDriveV1_4_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_5/EfiDriveV1_4_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_6/EfiDriveV1_4_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_7/EfiDriveV1_4_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_0/EfiDriveV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_1/EfiDriveV1_5_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_2/EfiDriveV1_5_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_3/EfiDriveV1_5_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_4/EfiDriveV1_5_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_5/EfiDriveV1_5_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_6/EfiDriveV1_5_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_6_0/EfiDriveV1_6_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_6_1/EfiDriveV1_6_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_6_2/EfiDriveV1_6_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_6_3/EfiDriveV1_6_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_6_4/EfiDriveV1_6_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_7_0/EfiDriveV1_7_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_7_1/EfiDriveV1_7_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_7_2/EfiDriveV1_7_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_7_3/EfiDriveV1_7_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_8_0/EfiDriveV1_8_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_8_1/EfiDriveV1_8_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_8_2/EfiDriveV1_8_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_8_3/EfiDriveV1_8_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_9_0/EfiDriveV1_9_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_9_1/EfiDriveV1_9_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_9_2/EfiDriveV1_9_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_9_3/EfiDriveV1_9_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/DriveCollection/EfiDriveCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_0/EfiEndpointV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_1/EfiEndpointV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_10/EfiEndpointV1_0_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_2/EfiEndpointV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_3/EfiEndpointV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_4/EfiEndpointV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_5/EfiEndpointV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_6/EfiEndpointV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_7/EfiEndpointV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_8/EfiEndpointV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_9/EfiEndpointV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_0/EfiEndpointV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_1/EfiEndpointV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_2/EfiEndpointV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_3/EfiEndpointV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_4/EfiEndpointV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_5/EfiEndpointV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_6/EfiEndpointV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_7/EfiEndpointV1_1_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_0/EfiEndpointV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_1/EfiEndpointV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_2/EfiEndpointV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_3/EfiEndpointV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_4/EfiEndpointV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_5/EfiEndpointV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_6/EfiEndpointV1_2_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_3_0/EfiEndpointV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_3_1/EfiEndpointV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_3_2/EfiEndpointV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_3_3/EfiEndpointV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_3_4/EfiEndpointV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_3_5/EfiEndpointV1_3_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_4_0/EfiEndpointV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_4_1/EfiEndpointV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_4_2/EfiEndpointV1_4_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_4_3/EfiEndpointV1_4_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_5_0/EfiEndpointV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_5_1/EfiEndpointV1_5_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EndpointCollection/EfiEndpointCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_0_0/EfiEndpointGroupV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_0_1/EfiEndpointGroupV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_0_2/EfiEndpointGroupV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_0_3/EfiEndpointGroupV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_0_4/EfiEndpointGroupV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_1_0/EfiEndpointGroupV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_1_1/EfiEndpointGroupV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_1_2/EfiEndpointGroupV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_1_3/EfiEndpointGroupV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_1_4/EfiEndpointGroupV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_1_5/EfiEndpointGroupV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_2_0/EfiEndpointGroupV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_2_1/EfiEndpointGroupV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_2_2/EfiEndpointGroupV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_2_3/EfiEndpointGroupV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_3_0/EfiEndpointGroupV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_3_1/EfiEndpointGroupV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroupCollection/EfiEndpointGroupCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EnvironmentMetrics/v1_0_0/EfiEnvironmentMetricsV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_0/EfiEthernetInterfaceV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_10/EfiEthernetInterfaceV1_0_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_11/EfiEthernetInterfaceV1_0_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_12/EfiEthernetInterfaceV1_0_12.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_2/EfiEthernetInterfaceV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_3/EfiEthernetInterfaceV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_4/EfiEthernetInterfaceV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_5/EfiEthernetInterfaceV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_6/EfiEthernetInterfaceV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_7/EfiEthernetInterfaceV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_8/EfiEthernetInterfaceV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_9/EfiEthernetInterfaceV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_0/EfiEthernetInterfaceV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_1/EfiEthernetInterfaceV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_10/EfiEthernetInterfaceV1_1_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_2/EfiEthernetInterfaceV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_3/EfiEthernetInterfaceV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_4/EfiEthernetInterfaceV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_5/EfiEthernetInterfaceV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_6/EfiEthernetInterfaceV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_7/EfiEthernetInterfaceV1_1_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_8/EfiEthernetInterfaceV1_1_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_9/EfiEthernetInterfaceV1_1_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_0/EfiEthernetInterfaceV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_1/EfiEthernetInterfaceV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_2/EfiEthernetInterfaceV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_3/EfiEthernetInterfaceV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_4/EfiEthernetInterfaceV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_5/EfiEthernetInterfaceV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_6/EfiEthernetInterfaceV1_2_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_7/EfiEthernetInterfaceV1_2_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_8/EfiEthernetInterfaceV1_2_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_9/EfiEthernetInterfaceV1_2_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_0/EfiEthernetInterfaceV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_1/EfiEthernetInterfaceV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_2/EfiEthernetInterfaceV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_3/EfiEthernetInterfaceV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_4/EfiEthernetInterfaceV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_5/EfiEthernetInterfaceV1_3_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_6/EfiEthernetInterfaceV1_3_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_7/EfiEthernetInterfaceV1_3_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_8/EfiEthernetInterfaceV1_3_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_0/EfiEthernetInterfaceV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_1/EfiEthernetInterfaceV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_2/EfiEthernetInterfaceV1_4_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_3/EfiEthernetInterfaceV1_4_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_4/EfiEthernetInterfaceV1_4_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_5/EfiEthernetInterfaceV1_4_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_6/EfiEthernetInterfaceV1_4_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_7/EfiEthernetInterfaceV1_4_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_5_0/EfiEthernetInterfaceV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_5_1/EfiEthernetInterfaceV1_5_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_5_2/EfiEthernetInterfaceV1_5_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_5_3/EfiEthernetInterfaceV1_5_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_5_4/EfiEthernetInterfaceV1_5_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_5_5/EfiEthernetInterfaceV1_5_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_6_0/EfiEthernetInterfaceV1_6_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_6_1/EfiEthernetInterfaceV1_6_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_6_2/EfiEthernetInterfaceV1_6_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_6_3/EfiEthernetInterfaceV1_6_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterfaceCollection/EfiEthernetInterfaceCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_0/EfiEventV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_10/EfiEventV1_0_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_11/EfiEventV1_0_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_12/EfiEventV1_0_12.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_13/EfiEventV1_0_13.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_2/EfiEventV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_3/EfiEventV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_4/EfiEventV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_5/EfiEventV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_6/EfiEventV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_7/EfiEventV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_8/EfiEventV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_9/EfiEventV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_0/EfiEventV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_1/EfiEventV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_10/EfiEventV1_1_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_11/EfiEventV1_1_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_2/EfiEventV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_3/EfiEventV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_4/EfiEventV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_5/EfiEventV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_6/EfiEventV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_7/EfiEventV1_1_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_8/EfiEventV1_1_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_9/EfiEventV1_1_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_0/EfiEventV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_1/EfiEventV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_2/EfiEventV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_3/EfiEventV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_4/EfiEventV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_5/EfiEventV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_6/EfiEventV1_2_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_7/EfiEventV1_2_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_8/EfiEventV1_2_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_0/EfiEventV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_1/EfiEventV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_2/EfiEventV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_3/EfiEventV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_4/EfiEventV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_5/EfiEventV1_3_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_6/EfiEventV1_3_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_4_0/EfiEventV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_4_1/EfiEventV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_4_2/EfiEventV1_4_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_4_3/EfiEventV1_4_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_4_4/EfiEventV1_4_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_5_0/EfiEventV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_5_1/EfiEventV1_5_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_5_2/EfiEventV1_5_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_6_0/EfiEventV1_6_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_6_1/EfiEventV1_6_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_0/EfiEventDestinationV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_2/EfiEventDestinationV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_3/EfiEventDestinationV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_4/EfiEventDestinationV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_5/EfiEventDestinationV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_6/EfiEventDestinationV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_7/EfiEventDestinationV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_8/EfiEventDestinationV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_9/EfiEventDestinationV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_10_0/EfiEventDestinationV1_10_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_0/EfiEventDestinationV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_1/EfiEventDestinationV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_2/EfiEventDestinationV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_3/EfiEventDestinationV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_4/EfiEventDestinationV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_5/EfiEventDestinationV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_6/EfiEventDestinationV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_7/EfiEventDestinationV1_1_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_8/EfiEventDestinationV1_1_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_0/EfiEventDestinationV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_1/EfiEventDestinationV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_2/EfiEventDestinationV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_3/EfiEventDestinationV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_4/EfiEventDestinationV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_5/EfiEventDestinationV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_6/EfiEventDestinationV1_2_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_3_0/EfiEventDestinationV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_3_1/EfiEventDestinationV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_3_2/EfiEventDestinationV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_3_3/EfiEventDestinationV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_3_4/EfiEventDestinationV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_4_0/EfiEventDestinationV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_4_1/EfiEventDestinationV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_4_2/EfiEventDestinationV1_4_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_4_3/EfiEventDestinationV1_4_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_5_0/EfiEventDestinationV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_5_1/EfiEventDestinationV1_5_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_5_2/EfiEventDestinationV1_5_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_6_0/EfiEventDestinationV1_6_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_6_1/EfiEventDestinationV1_6_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_6_2/EfiEventDestinationV1_6_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_7_0/EfiEventDestinationV1_7_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_7_1/EfiEventDestinationV1_7_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_7_2/EfiEventDestinationV1_7_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_8_0/EfiEventDestinationV1_8_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_8_1/EfiEventDestinationV1_8_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_8_2/EfiEventDestinationV1_8_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_9_0/EfiEventDestinationV1_9_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_9_1/EfiEventDestinationV1_9_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventDestinationCollection/EfiEventDestinationCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_0/EfiEventServiceV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_10/EfiEventServiceV1_0_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_11/EfiEventServiceV1_0_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_12/EfiEventServiceV1_0_12.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_13/EfiEventServiceV1_0_13.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_2/EfiEventServiceV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_3/EfiEventServiceV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_4/EfiEventServiceV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_5/EfiEventServiceV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_6/EfiEventServiceV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_7/EfiEventServiceV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_8/EfiEventServiceV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_9/EfiEventServiceV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_0/EfiEventServiceV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_1/EfiEventServiceV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_2/EfiEventServiceV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_3/EfiEventServiceV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_4/EfiEventServiceV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_5/EfiEventServiceV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_6/EfiEventServiceV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_2_0/EfiEventServiceV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_2_1/EfiEventServiceV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_2_2/EfiEventServiceV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_2_3/EfiEventServiceV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_2_4/EfiEventServiceV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_2_5/EfiEventServiceV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_3_0/EfiEventServiceV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_3_1/EfiEventServiceV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_3_2/EfiEventServiceV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_3_3/EfiEventServiceV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_3_4/EfiEventServiceV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_4_0/EfiEventServiceV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_4_1/EfiEventServiceV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_4_2/EfiEventServiceV1_4_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_4_3/EfiEventServiceV1_4_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_5_0/EfiEventServiceV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_5_1/EfiEventServiceV1_5_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_5_2/EfiEventServiceV1_5_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_5_3/EfiEventServiceV1_5_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_6_0/EfiEventServiceV1_6_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_6_1/EfiEventServiceV1_6_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_6_2/EfiEventServiceV1_6_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_7_0/EfiEventServiceV1_7_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_7_1/EfiEventServiceV1_7_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_0_0/EfiExternalAccountProviderV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_0_1/EfiExternalAccountProviderV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_0_2/EfiExternalAccountProviderV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_0_3/EfiExternalAccountProviderV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_0_4/EfiExternalAccountProviderV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_0_5/EfiExternalAccountProviderV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_1_0/EfiExternalAccountProviderV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_1_1/EfiExternalAccountProviderV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_1_2/EfiExternalAccountProviderV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_1_3/EfiExternalAccountProviderV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_1_4/EfiExternalAccountProviderV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_2_0/EfiExternalAccountProviderV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProviderCollection/EfiExternalAccountProviderCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_0/EfiFabricV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_1/EfiFabricV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_2/EfiFabricV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_3/EfiFabricV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_4/EfiFabricV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_5/EfiFabricV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_6/EfiFabricV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_7/EfiFabricV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_8/EfiFabricV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_1_0/EfiFabricV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_1_1/EfiFabricV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_1_2/EfiFabricV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_2_0/EfiFabricV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_2_1/EfiFabricV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/FabricAdapter/v1_0_0/EfiFabricAdapterV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/FabricAdapterCollection/EfiFabricAdapterCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/FabricCollection/EfiFabricCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Facility/v1_0_0/EfiFacilityV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Facility/v1_0_1/EfiFacilityV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Facility/v1_1_0/EfiFacilityV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/FacilityCollection/EfiFacilityCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Fan/v1_0_0/EfiFanV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/FanCollection/EfiFanCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_0_0/EfiHostInterfaceV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_0_1/EfiHostInterfaceV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_0_2/EfiHostInterfaceV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_0_3/EfiHostInterfaceV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_0_4/EfiHostInterfaceV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_0_5/EfiHostInterfaceV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_1_0/EfiHostInterfaceV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_1_1/EfiHostInterfaceV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_1_2/EfiHostInterfaceV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_1_3/EfiHostInterfaceV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_1_4/EfiHostInterfaceV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_1_5/EfiHostInterfaceV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_2_0/EfiHostInterfaceV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_2_1/EfiHostInterfaceV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_2_2/EfiHostInterfaceV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_3_0/EfiHostInterfaceV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/HostInterfaceCollection/EfiHostInterfaceCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_0/EfiJobV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_1/EfiJobV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_2/EfiJobV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_3/EfiJobV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_4/EfiJobV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_5/EfiJobV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_6/EfiJobV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/JobCollection/EfiJobCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/JobService/v1_0_0/EfiJobServiceV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/JobService/v1_0_1/EfiJobServiceV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/JobService/v1_0_2/EfiJobServiceV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/JobService/v1_0_3/EfiJobServiceV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/JobService/v1_0_4/EfiJobServiceV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_0/EfiJsonSchemaFileV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_2/EfiJsonSchemaFileV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_3/EfiJsonSchemaFileV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_4/EfiJsonSchemaFileV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_5/EfiJsonSchemaFileV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_6/EfiJsonSchemaFileV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_7/EfiJsonSchemaFileV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_8/EfiJsonSchemaFileV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_1_0/EfiJsonSchemaFileV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_1_1/EfiJsonSchemaFileV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_1_2/EfiJsonSchemaFileV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_1_3/EfiJsonSchemaFileV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_1_4/EfiJsonSchemaFileV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFileCollection/EfiJsonSchemaFileCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_0/EfiLogEntryV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_10/EfiLogEntryV1_0_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_11/EfiLogEntryV1_0_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_12/EfiLogEntryV1_0_12.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_13/EfiLogEntryV1_0_13.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_14/EfiLogEntryV1_0_14.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_2/EfiLogEntryV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_3/EfiLogEntryV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_4/EfiLogEntryV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_5/EfiLogEntryV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_6/EfiLogEntryV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_7/EfiLogEntryV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_8/EfiLogEntryV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_9/EfiLogEntryV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_0/EfiLogEntryV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_1/EfiLogEntryV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_10/EfiLogEntryV1_1_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_11/EfiLogEntryV1_1_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_12/EfiLogEntryV1_1_12.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_2/EfiLogEntryV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_3/EfiLogEntryV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_4/EfiLogEntryV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_5/EfiLogEntryV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_6/EfiLogEntryV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_7/EfiLogEntryV1_1_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_8/EfiLogEntryV1_1_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_9/EfiLogEntryV1_1_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_0/EfiLogEntryV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_1/EfiLogEntryV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_10/EfiLogEntryV1_2_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_2/EfiLogEntryV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_3/EfiLogEntryV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_4/EfiLogEntryV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_5/EfiLogEntryV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_6/EfiLogEntryV1_2_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_7/EfiLogEntryV1_2_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_8/EfiLogEntryV1_2_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_9/EfiLogEntryV1_2_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_0/EfiLogEntryV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_1/EfiLogEntryV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_2/EfiLogEntryV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_3/EfiLogEntryV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_4/EfiLogEntryV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_5/EfiLogEntryV1_3_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_6/EfiLogEntryV1_3_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_7/EfiLogEntryV1_3_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_8/EfiLogEntryV1_3_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_9/EfiLogEntryV1_3_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_0/EfiLogEntryV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_1/EfiLogEntryV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_2/EfiLogEntryV1_4_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_3/EfiLogEntryV1_4_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_4/EfiLogEntryV1_4_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_5/EfiLogEntryV1_4_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_6/EfiLogEntryV1_4_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_7/EfiLogEntryV1_4_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_8/EfiLogEntryV1_4_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_5_0/EfiLogEntryV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_5_1/EfiLogEntryV1_5_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_5_2/EfiLogEntryV1_5_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_5_3/EfiLogEntryV1_5_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_5_4/EfiLogEntryV1_5_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_6_0/EfiLogEntryV1_6_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_6_1/EfiLogEntryV1_6_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_6_2/EfiLogEntryV1_6_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_6_3/EfiLogEntryV1_6_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_7_0/EfiLogEntryV1_7_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_7_1/EfiLogEntryV1_7_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_8_0/EfiLogEntryV1_8_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogEntryCollection/EfiLogEntryCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_0/EfiLogServiceV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_2/EfiLogServiceV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_3/EfiLogServiceV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_4/EfiLogServiceV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_5/EfiLogServiceV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_6/EfiLogServiceV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_7/EfiLogServiceV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_8/EfiLogServiceV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_1_0/EfiLogServiceV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_1_1/EfiLogServiceV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_1_2/EfiLogServiceV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_1_3/EfiLogServiceV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_2_0/EfiLogServiceV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/LogServiceCollection/EfiLogServiceCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_0/EfiManagerV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_1/EfiManagerV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_10/EfiManagerV1_0_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_11/EfiManagerV1_0_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_12/EfiManagerV1_0_12.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_13/EfiManagerV1_0_13.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_14/EfiManagerV1_0_14.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_2/EfiManagerV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_3/EfiManagerV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_4/EfiManagerV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_5/EfiManagerV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_6/EfiManagerV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_7/EfiManagerV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_8/EfiManagerV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_9/EfiManagerV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_10_0/EfiManagerV1_10_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_10_1/EfiManagerV1_10_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_11_0/EfiManagerV1_11_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_0/EfiManagerV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_1/EfiManagerV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_10/EfiManagerV1_1_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_11/EfiManagerV1_1_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_12/EfiManagerV1_1_12.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_2/EfiManagerV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_3/EfiManagerV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_4/EfiManagerV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_5/EfiManagerV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_6/EfiManagerV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_7/EfiManagerV1_1_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_8/EfiManagerV1_1_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_9/EfiManagerV1_1_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_0/EfiManagerV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_1/EfiManagerV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_10/EfiManagerV1_2_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_11/EfiManagerV1_2_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_12/EfiManagerV1_2_12.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_2/EfiManagerV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_3/EfiManagerV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_4/EfiManagerV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_5/EfiManagerV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_6/EfiManagerV1_2_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_7/EfiManagerV1_2_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_8/EfiManagerV1_2_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_9/EfiManagerV1_2_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_0/EfiManagerV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_1/EfiManagerV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_10/EfiManagerV1_3_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_11/EfiManagerV1_3_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_2/EfiManagerV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_3/EfiManagerV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_4/EfiManagerV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_5/EfiManagerV1_3_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_6/EfiManagerV1_3_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_7/EfiManagerV1_3_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_8/EfiManagerV1_3_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_9/EfiManagerV1_3_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_0/EfiManagerV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_1/EfiManagerV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_2/EfiManagerV1_4_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_3/EfiManagerV1_4_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_4/EfiManagerV1_4_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_5/EfiManagerV1_4_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_6/EfiManagerV1_4_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_7/EfiManagerV1_4_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_8/EfiManagerV1_4_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_0/EfiManagerV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_1/EfiManagerV1_5_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_2/EfiManagerV1_5_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_3/EfiManagerV1_5_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_4/EfiManagerV1_5_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_5/EfiManagerV1_5_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_6/EfiManagerV1_5_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_7/EfiManagerV1_5_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_6_0/EfiManagerV1_6_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_6_1/EfiManagerV1_6_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_6_2/EfiManagerV1_6_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_6_3/EfiManagerV1_6_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_6_4/EfiManagerV1_6_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_7_0/EfiManagerV1_7_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_7_1/EfiManagerV1_7_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_7_2/EfiManagerV1_7_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_7_3/EfiManagerV1_7_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_7_4/EfiManagerV1_7_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_8_0/EfiManagerV1_8_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_8_1/EfiManagerV1_8_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_8_2/EfiManagerV1_8_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_8_3/EfiManagerV1_8_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_9_0/EfiManagerV1_9_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_9_1/EfiManagerV1_9_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_9_2/EfiManagerV1_9_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_0/EfiManagerAccountV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_10/EfiManagerAccountV1_0_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_11/EfiManagerAccountV1_0_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_2/EfiManagerAccountV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_3/EfiManagerAccountV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_4/EfiManagerAccountV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_5/EfiManagerAccountV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_6/EfiManagerAccountV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_7/EfiManagerAccountV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_8/EfiManagerAccountV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_9/EfiManagerAccountV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_0/EfiManagerAccountV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_1/EfiManagerAccountV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_2/EfiManagerAccountV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_3/EfiManagerAccountV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_4/EfiManagerAccountV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_5/EfiManagerAccountV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_6/EfiManagerAccountV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_7/EfiManagerAccountV1_1_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_2_0/EfiManagerAccountV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_2_1/EfiManagerAccountV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_2_2/EfiManagerAccountV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_2_3/EfiManagerAccountV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_2_4/EfiManagerAccountV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_3_0/EfiManagerAccountV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_3_1/EfiManagerAccountV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_3_2/EfiManagerAccountV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_3_3/EfiManagerAccountV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_4_0/EfiManagerAccountV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_4_1/EfiManagerAccountV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_4_2/EfiManagerAccountV1_4_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_4_3/EfiManagerAccountV1_4_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_4_4/EfiManagerAccountV1_4_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_5_0/EfiManagerAccountV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_5_1/EfiManagerAccountV1_5_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_5_2/EfiManagerAccountV1_5_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_5_3/EfiManagerAccountV1_5_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_6_0/EfiManagerAccountV1_6_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_6_1/EfiManagerAccountV1_6_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_6_2/EfiManagerAccountV1_6_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_7_0/EfiManagerAccountV1_7_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccountCollection/EfiManagerAccountCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerCollection/EfiManagerCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_0/EfiManagerNetworkProtocolV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_2/EfiManagerNetworkProtocolV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_3/EfiManagerNetworkProtocolV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_4/EfiManagerNetworkProtocolV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_5/EfiManagerNetworkProtocolV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_6/EfiManagerNetworkProtocolV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_7/EfiManagerNetworkProtocolV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_8/EfiManagerNetworkProtocolV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_9/EfiManagerNetworkProtocolV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_0/EfiManagerNetworkProtocolV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_1/EfiManagerNetworkProtocolV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_2/EfiManagerNetworkProtocolV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_3/EfiManagerNetworkProtocolV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_4/EfiManagerNetworkProtocolV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_5/EfiManagerNetworkProtocolV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_6/EfiManagerNetworkProtocolV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_2_0/EfiManagerNetworkProtocolV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_2_1/EfiManagerNetworkProtocolV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_2_2/EfiManagerNetworkProtocolV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_2_3/EfiManagerNetworkProtocolV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_2_4/EfiManagerNetworkProtocolV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_2_5/EfiManagerNetworkProtocolV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_3_0/EfiManagerNetworkProtocolV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_3_1/EfiManagerNetworkProtocolV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_3_2/EfiManagerNetworkProtocolV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_3_3/EfiManagerNetworkProtocolV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_3_4/EfiManagerNetworkProtocolV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_4_0/EfiManagerNetworkProtocolV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_4_1/EfiManagerNetworkProtocolV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_4_2/EfiManagerNetworkProtocolV1_4_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_4_3/EfiManagerNetworkProtocolV1_4_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_4_4/EfiManagerNetworkProtocolV1_4_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_5_0/EfiManagerNetworkProtocolV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_5_1/EfiManagerNetworkProtocolV1_5_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_5_2/EfiManagerNetworkProtocolV1_5_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_5_3/EfiManagerNetworkProtocolV1_5_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_6_0/EfiManagerNetworkProtocolV1_6_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_6_1/EfiManagerNetworkProtocolV1_6_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_6_2/EfiManagerNetworkProtocolV1_6_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_7_0/EfiManagerNetworkProtocolV1_7_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MediaController/v1_0_0/EfiMediaControllerV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MediaController/v1_0_1/EfiMediaControllerV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MediaController/v1_1_0/EfiMediaControllerV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MediaControllerCollection/EfiMediaControllerCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_0/EfiMemoryV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_1/EfiMemoryV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_10/EfiMemoryV1_0_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_11/EfiMemoryV1_0_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_2/EfiMemoryV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_3/EfiMemoryV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_4/EfiMemoryV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_5/EfiMemoryV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_6/EfiMemoryV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_7/EfiMemoryV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_8/EfiMemoryV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_9/EfiMemoryV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_10_0/EfiMemoryV1_10_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_10_1/EfiMemoryV1_10_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_11_0/EfiMemoryV1_11_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_0/EfiMemoryV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_1/EfiMemoryV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_10/EfiMemoryV1_1_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_2/EfiMemoryV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_3/EfiMemoryV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_4/EfiMemoryV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_5/EfiMemoryV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_6/EfiMemoryV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_7/EfiMemoryV1_1_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_8/EfiMemoryV1_1_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_9/EfiMemoryV1_1_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_0/EfiMemoryV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_1/EfiMemoryV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_2/EfiMemoryV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_3/EfiMemoryV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_4/EfiMemoryV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_5/EfiMemoryV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_6/EfiMemoryV1_2_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_7/EfiMemoryV1_2_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_8/EfiMemoryV1_2_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_9/EfiMemoryV1_2_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_0/EfiMemoryV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_1/EfiMemoryV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_2/EfiMemoryV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_3/EfiMemoryV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_4/EfiMemoryV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_5/EfiMemoryV1_3_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_6/EfiMemoryV1_3_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_7/EfiMemoryV1_3_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_8/EfiMemoryV1_3_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_9/EfiMemoryV1_3_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_0/EfiMemoryV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_1/EfiMemoryV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_2/EfiMemoryV1_4_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_3/EfiMemoryV1_4_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_4/EfiMemoryV1_4_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_5/EfiMemoryV1_4_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_6/EfiMemoryV1_4_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_7/EfiMemoryV1_4_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_8/EfiMemoryV1_4_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_9/EfiMemoryV1_4_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_0/EfiMemoryV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_1/EfiMemoryV1_5_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_2/EfiMemoryV1_5_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_3/EfiMemoryV1_5_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_4/EfiMemoryV1_5_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_5/EfiMemoryV1_5_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_6/EfiMemoryV1_5_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_7/EfiMemoryV1_5_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_8/EfiMemoryV1_5_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_0/EfiMemoryV1_6_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_1/EfiMemoryV1_6_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_2/EfiMemoryV1_6_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_3/EfiMemoryV1_6_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_4/EfiMemoryV1_6_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_5/EfiMemoryV1_6_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_6/EfiMemoryV1_6_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_7/EfiMemoryV1_6_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_0/EfiMemoryV1_7_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_1/EfiMemoryV1_7_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_2/EfiMemoryV1_7_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_3/EfiMemoryV1_7_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_4/EfiMemoryV1_7_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_5/EfiMemoryV1_7_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_6/EfiMemoryV1_7_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_8_0/EfiMemoryV1_8_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_8_1/EfiMemoryV1_8_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_8_2/EfiMemoryV1_8_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_8_3/EfiMemoryV1_8_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_8_4/EfiMemoryV1_8_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_9_0/EfiMemoryV1_9_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_9_1/EfiMemoryV1_9_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_9_2/EfiMemoryV1_9_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_9_3/EfiMemoryV1_9_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_9_4/EfiMemoryV1_9_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_0/EfiMemoryChunksV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_1/EfiMemoryChunksV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_2/EfiMemoryChunksV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_3/EfiMemoryChunksV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_4/EfiMemoryChunksV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_5/EfiMemoryChunksV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_6/EfiMemoryChunksV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_7/EfiMemoryChunksV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_1_0/EfiMemoryChunksV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_1_1/EfiMemoryChunksV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_1_2/EfiMemoryChunksV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_1_3/EfiMemoryChunksV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_1_4/EfiMemoryChunksV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_1_5/EfiMemoryChunksV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_0/EfiMemoryChunksV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_1/EfiMemoryChunksV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_2/EfiMemoryChunksV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_3/EfiMemoryChunksV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_4/EfiMemoryChunksV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_5/EfiMemoryChunksV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_6/EfiMemoryChunksV1_2_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_3_0/EfiMemoryChunksV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_3_1/EfiMemoryChunksV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_3_2/EfiMemoryChunksV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_4_0/EfiMemoryChunksV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_4_1/EfiMemoryChunksV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunksCollection/EfiMemoryChunksCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryCollection/EfiMemoryCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_0_0/EfiMemoryDomainV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_0_1/EfiMemoryDomainV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_0_2/EfiMemoryDomainV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_0_3/EfiMemoryDomainV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_0_4/EfiMemoryDomainV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_0_5/EfiMemoryDomainV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_1_0/EfiMemoryDomainV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_1_1/EfiMemoryDomainV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_1_2/EfiMemoryDomainV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_1_3/EfiMemoryDomainV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_1_4/EfiMemoryDomainV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_2_0/EfiMemoryDomainV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_2_1/EfiMemoryDomainV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_2_2/EfiMemoryDomainV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_2_3/EfiMemoryDomainV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_3_0/EfiMemoryDomainV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomainCollection/EfiMemoryDomainCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_0/EfiMemoryMetricsV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_1/EfiMemoryMetricsV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_2/EfiMemoryMetricsV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_3/EfiMemoryMetricsV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_4/EfiMemoryMetricsV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_5/EfiMemoryMetricsV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_6/EfiMemoryMetricsV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_7/EfiMemoryMetricsV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_8/EfiMemoryMetricsV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_1/EfiMemoryMetricsV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_2/EfiMemoryMetricsV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_3/EfiMemoryMetricsV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_4/EfiMemoryMetricsV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_5/EfiMemoryMetricsV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_6/EfiMemoryMetricsV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_7/EfiMemoryMetricsV1_1_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_8/EfiMemoryMetricsV1_1_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_2_0/EfiMemoryMetricsV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_2_1/EfiMemoryMetricsV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_2_2/EfiMemoryMetricsV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_3_0/EfiMemoryMetricsV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_3_1/EfiMemoryMetricsV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_4_0/EfiMemoryMetricsV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_4_1/EfiMemoryMetricsV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_0/EfiMessageRegistryV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_10/EfiMessageRegistryV1_0_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_2/EfiMessageRegistryV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_3/EfiMessageRegistryV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_4/EfiMessageRegistryV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_5/EfiMessageRegistryV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_6/EfiMessageRegistryV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_7/EfiMessageRegistryV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_8/EfiMessageRegistryV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_9/EfiMessageRegistryV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_0/EfiMessageRegistryV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_1/EfiMessageRegistryV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_2/EfiMessageRegistryV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_3/EfiMessageRegistryV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_4/EfiMessageRegistryV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_5/EfiMessageRegistryV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_6/EfiMessageRegistryV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_2_0/EfiMessageRegistryV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_2_1/EfiMessageRegistryV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_2_2/EfiMessageRegistryV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_2_3/EfiMessageRegistryV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_2_4/EfiMessageRegistryV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_3_0/EfiMessageRegistryV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_3_1/EfiMessageRegistryV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_3_2/EfiMessageRegistryV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_3_3/EfiMessageRegistryV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_4_0/EfiMessageRegistryV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_4_1/EfiMessageRegistryV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_4_2/EfiMessageRegistryV1_4_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryCollection/EfiMessageRegistryCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_0/EfiMessageRegistryFileV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_2/EfiMessageRegistryFileV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_3/EfiMessageRegistryFileV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_4/EfiMessageRegistryFileV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_5/EfiMessageRegistryFileV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_6/EfiMessageRegistryFileV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_7/EfiMessageRegistryFileV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_1_0/EfiMessageRegistryFileV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_1_1/EfiMessageRegistryFileV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_1_2/EfiMessageRegistryFileV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_1_3/EfiMessageRegistryFileV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFileCollection/EfiMessageRegistryFileCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_0/EfiMetricDefinitionV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_1/EfiMetricDefinitionV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_2/EfiMetricDefinitionV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_3/EfiMetricDefinitionV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_4/EfiMetricDefinitionV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_5/EfiMetricDefinitionV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_6/EfiMetricDefinitionV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_1_0/EfiMetricDefinitionV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_1_1/EfiMetricDefinitionV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinitionCollection/EfiMetricDefinitionCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_0/EfiMetricReportV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_1/EfiMetricReportV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_2/EfiMetricReportV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_3/EfiMetricReportV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_4/EfiMetricReportV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_5/EfiMetricReportV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_6/EfiMetricReportV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_1_0/EfiMetricReportV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_1_1/EfiMetricReportV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_1_2/EfiMetricReportV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_1_3/EfiMetricReportV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_1_4/EfiMetricReportV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_1_5/EfiMetricReportV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_2_0/EfiMetricReportV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_2_1/EfiMetricReportV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_2_2/EfiMetricReportV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_2_3/EfiMetricReportV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_3_0/EfiMetricReportV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_3_1/EfiMetricReportV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_3_2/EfiMetricReportV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_4_0/EfiMetricReportV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_4_1/EfiMetricReportV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportCollection/EfiMetricReportCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_0/EfiMetricReportDefinitionV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_1/EfiMetricReportDefinitionV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_2/EfiMetricReportDefinitionV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_3/EfiMetricReportDefinitionV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_4/EfiMetricReportDefinitionV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_5/EfiMetricReportDefinitionV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_6/EfiMetricReportDefinitionV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_7/EfiMetricReportDefinitionV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_0/EfiMetricReportDefinitionV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_1/EfiMetricReportDefinitionV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_2/EfiMetricReportDefinitionV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_3/EfiMetricReportDefinitionV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_4/EfiMetricReportDefinitionV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_5/EfiMetricReportDefinitionV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_6/EfiMetricReportDefinitionV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_2_0/EfiMetricReportDefinitionV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_2_1/EfiMetricReportDefinitionV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_2_2/EfiMetricReportDefinitionV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_2_3/EfiMetricReportDefinitionV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_2_4/EfiMetricReportDefinitionV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_2_5/EfiMetricReportDefinitionV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_3_0/EfiMetricReportDefinitionV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_3_1/EfiMetricReportDefinitionV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_3_2/EfiMetricReportDefinitionV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_3_3/EfiMetricReportDefinitionV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_3_4/EfiMetricReportDefinitionV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_4_0/EfiMetricReportDefinitionV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinitionCollection/EfiMetricReportDefinitionCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_0/EfiNetworkAdapterV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_1/EfiNetworkAdapterV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_2/EfiNetworkAdapterV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_3/EfiNetworkAdapterV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_4/EfiNetworkAdapterV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_5/EfiNetworkAdapterV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_6/EfiNetworkAdapterV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_7/EfiNetworkAdapterV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_0/EfiNetworkAdapterV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_1/EfiNetworkAdapterV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_2/EfiNetworkAdapterV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_3/EfiNetworkAdapterV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_4/EfiNetworkAdapterV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_5/EfiNetworkAdapterV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_6/EfiNetworkAdapterV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_2_0/EfiNetworkAdapterV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_2_1/EfiNetworkAdapterV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_2_2/EfiNetworkAdapterV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_2_3/EfiNetworkAdapterV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_2_4/EfiNetworkAdapterV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_2_5/EfiNetworkAdapterV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_3_0/EfiNetworkAdapterV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_3_1/EfiNetworkAdapterV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_3_2/EfiNetworkAdapterV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_3_3/EfiNetworkAdapterV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_3_4/EfiNetworkAdapterV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_4_0/EfiNetworkAdapterV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_4_1/EfiNetworkAdapterV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_5_0/EfiNetworkAdapterV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_5_1/EfiNetworkAdapterV1_5_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_6_0/EfiNetworkAdapterV1_6_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapterCollection/EfiNetworkAdapterCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_0/EfiNetworkDeviceFunctionV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_1/EfiNetworkDeviceFunctionV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_2/EfiNetworkDeviceFunctionV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_3/EfiNetworkDeviceFunctionV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_4/EfiNetworkDeviceFunctionV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_5/EfiNetworkDeviceFunctionV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_6/EfiNetworkDeviceFunctionV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_7/EfiNetworkDeviceFunctionV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_8/EfiNetworkDeviceFunctionV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_0/EfiNetworkDeviceFunctionV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_1/EfiNetworkDeviceFunctionV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_2/EfiNetworkDeviceFunctionV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_3/EfiNetworkDeviceFunctionV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_4/EfiNetworkDeviceFunctionV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_5/EfiNetworkDeviceFunctionV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_6/EfiNetworkDeviceFunctionV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_7/EfiNetworkDeviceFunctionV1_1_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_0/EfiNetworkDeviceFunctionV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_1/EfiNetworkDeviceFunctionV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_2/EfiNetworkDeviceFunctionV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_3/EfiNetworkDeviceFunctionV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_4/EfiNetworkDeviceFunctionV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_5/EfiNetworkDeviceFunctionV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_6/EfiNetworkDeviceFunctionV1_2_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_7/EfiNetworkDeviceFunctionV1_2_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_3_0/EfiNetworkDeviceFunctionV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_3_1/EfiNetworkDeviceFunctionV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_3_2/EfiNetworkDeviceFunctionV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_3_3/EfiNetworkDeviceFunctionV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_3_4/EfiNetworkDeviceFunctionV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_3_5/EfiNetworkDeviceFunctionV1_3_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_4_0/EfiNetworkDeviceFunctionV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_4_1/EfiNetworkDeviceFunctionV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_4_2/EfiNetworkDeviceFunctionV1_4_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_5_0/EfiNetworkDeviceFunctionV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_5_1/EfiNetworkDeviceFunctionV1_5_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunctionCollection/EfiNetworkDeviceFunctionCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_0/EfiNetworkInterfaceV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_1/EfiNetworkInterfaceV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_2/EfiNetworkInterfaceV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_3/EfiNetworkInterfaceV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_4/EfiNetworkInterfaceV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_5/EfiNetworkInterfaceV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_6/EfiNetworkInterfaceV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_1_0/EfiNetworkInterfaceV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_1_1/EfiNetworkInterfaceV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_1_2/EfiNetworkInterfaceV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_1_3/EfiNetworkInterfaceV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_1_4/EfiNetworkInterfaceV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_1_5/EfiNetworkInterfaceV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_2_0/EfiNetworkInterfaceV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_2_1/EfiNetworkInterfaceV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterfaceCollection/EfiNetworkInterfaceCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_0/EfiNetworkPortV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_1/EfiNetworkPortV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_2/EfiNetworkPortV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_3/EfiNetworkPortV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_4/EfiNetworkPortV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_5/EfiNetworkPortV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_6/EfiNetworkPortV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_7/EfiNetworkPortV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_8/EfiNetworkPortV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_0/EfiNetworkPortV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_1/EfiNetworkPortV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_2/EfiNetworkPortV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_3/EfiNetworkPortV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_4/EfiNetworkPortV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_5/EfiNetworkPortV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_6/EfiNetworkPortV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_7/EfiNetworkPortV1_1_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_0/EfiNetworkPortV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_1/EfiNetworkPortV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_2/EfiNetworkPortV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_3/EfiNetworkPortV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_4/EfiNetworkPortV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_5/EfiNetworkPortV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_6/EfiNetworkPortV1_2_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_3_0/EfiNetworkPortV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_3_1/EfiNetworkPortV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_4_0/EfiNetworkPortV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/NetworkPortCollection/EfiNetworkPortCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/OperatingConfig/v1_0_0/EfiOperatingConfigV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/OperatingConfig/v1_0_1/EfiOperatingConfigV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/OperatingConfig/v1_0_2/EfiOperatingConfigV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/OperatingConfigCollection/EfiOperatingConfigCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Outlet/v1_0_0/EfiOutletV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Outlet/v1_0_1/EfiOutletV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Outlet/v1_0_2/EfiOutletV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Outlet/v1_1_0/EfiOutletV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Outlet/v1_1_1/EfiOutletV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/OutletCollection/EfiOutletCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/OutletGroup/v1_0_0/EfiOutletGroupV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/OutletGroup/v1_0_1/EfiOutletGroupV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/OutletGroupCollection/EfiOutletGroupCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_0_0/EfiPCIeDeviceV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_0_1/EfiPCIeDeviceV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_0_2/EfiPCIeDeviceV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_0_3/EfiPCIeDeviceV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_0_4/EfiPCIeDeviceV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_0_5/EfiPCIeDeviceV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_1_0/EfiPCIeDeviceV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_1_1/EfiPCIeDeviceV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_1_2/EfiPCIeDeviceV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_1_3/EfiPCIeDeviceV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_2_0/EfiPCIeDeviceV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_2_1/EfiPCIeDeviceV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_2_2/EfiPCIeDeviceV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_2_3/EfiPCIeDeviceV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_3_0/EfiPCIeDeviceV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_3_1/EfiPCIeDeviceV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_3_2/EfiPCIeDeviceV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_4_0/EfiPCIeDeviceV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_5_0/EfiPCIeDeviceV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_6_0/EfiPCIeDeviceV1_6_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeDeviceCollection/EfiPCIeDeviceCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_0/EfiPCIeFunctionV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_1/EfiPCIeFunctionV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_2/EfiPCIeFunctionV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_3/EfiPCIeFunctionV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_4/EfiPCIeFunctionV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_5/EfiPCIeFunctionV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_6/EfiPCIeFunctionV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_1_0/EfiPCIeFunctionV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_1_1/EfiPCIeFunctionV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_1_2/EfiPCIeFunctionV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_1_3/EfiPCIeFunctionV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_1_4/EfiPCIeFunctionV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_2_0/EfiPCIeFunctionV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_2_1/EfiPCIeFunctionV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_2_2/EfiPCIeFunctionV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_2_3/EfiPCIeFunctionV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunctionCollection/EfiPCIeFunctionCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_0_0/EfiPCIeSlotsV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_0_1/EfiPCIeSlotsV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_0_2/EfiPCIeSlotsV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_0_3/EfiPCIeSlotsV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_1_0/EfiPCIeSlotsV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_1_1/EfiPCIeSlotsV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_1_2/EfiPCIeSlotsV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_2_0/EfiPCIeSlotsV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_3_0/EfiPCIeSlotsV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_4_0/EfiPCIeSlotsV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_4_1/EfiPCIeSlotsV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_0/EfiPortV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_1/EfiPortV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_2/EfiPortV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_3/EfiPortV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_4/EfiPortV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_5/EfiPortV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_6/EfiPortV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_7/EfiPortV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_8/EfiPortV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_1_0/EfiPortV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_1_1/EfiPortV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_1_2/EfiPortV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_1_3/EfiPortV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_1_4/EfiPortV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_1_5/EfiPortV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_2_0/EfiPortV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_2_1/EfiPortV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_2_2/EfiPortV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_2_3/EfiPortV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_3_0/EfiPortV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_3_1/EfiPortV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PortCollection/EfiPortCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PortMetrics/v1_0_0/EfiPortMetricsV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PortMetrics/v1_0_1/EfiPortMetricsV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_0/EfiPowerV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_1/EfiPowerV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_10/EfiPowerV1_0_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_11/EfiPowerV1_0_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_12/EfiPowerV1_0_12.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_2/EfiPowerV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_3/EfiPowerV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_4/EfiPowerV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_5/EfiPowerV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_6/EfiPowerV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_7/EfiPowerV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_8/EfiPowerV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_9/EfiPowerV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_0/EfiPowerV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_1/EfiPowerV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_10/EfiPowerV1_1_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_2/EfiPowerV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_3/EfiPowerV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_4/EfiPowerV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_5/EfiPowerV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_6/EfiPowerV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_7/EfiPowerV1_1_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_8/EfiPowerV1_1_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_9/EfiPowerV1_1_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_0/EfiPowerV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_1/EfiPowerV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_10/EfiPowerV1_2_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_2/EfiPowerV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_3/EfiPowerV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_4/EfiPowerV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_5/EfiPowerV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_6/EfiPowerV1_2_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_7/EfiPowerV1_2_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_8/EfiPowerV1_2_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_9/EfiPowerV1_2_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_0/EfiPowerV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_1/EfiPowerV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_2/EfiPowerV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_3/EfiPowerV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_4/EfiPowerV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_5/EfiPowerV1_3_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_6/EfiPowerV1_3_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_7/EfiPowerV1_3_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_8/EfiPowerV1_3_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_0/EfiPowerV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_1/EfiPowerV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_2/EfiPowerV1_4_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_3/EfiPowerV1_4_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_4/EfiPowerV1_4_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_5/EfiPowerV1_4_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_6/EfiPowerV1_4_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_7/EfiPowerV1_4_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_0/EfiPowerV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_1/EfiPowerV1_5_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_2/EfiPowerV1_5_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_3/EfiPowerV1_5_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_4/EfiPowerV1_5_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_5/EfiPowerV1_5_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_6/EfiPowerV1_5_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_6_0/EfiPowerV1_6_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_6_1/EfiPowerV1_6_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_6_2/EfiPowerV1_6_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_7_0/EfiPowerV1_7_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PowerDistribution/v1_0_0/EfiPowerDistributionV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PowerDistribution/v1_0_1/EfiPowerDistributionV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PowerDistribution/v1_0_2/EfiPowerDistributionV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PowerDistributionCollection/EfiPowerDistributionCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PowerDistributionMetrics/v1_0_0/EfiPowerDistributionMetricsV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PowerDomain/v1_0_0/EfiPowerDomainV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PowerDomain/v1_0_1/EfiPowerDomainV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PowerDomainCollection/EfiPowerDomainCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PowerEquipment/v1_0_0/EfiPowerEquipmentV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PowerSubsystem/v1_0_0/EfiPowerSubsystemV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PowerSupply/v1_0_0/EfiPowerSupplyV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PowerSupplyCollection/EfiPowerSupplyCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PowerSupplyMetrics/v1_0_0/EfiPowerSupplyMetricsV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_0_0/EfiPrivilegeRegistryV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_0_1/EfiPrivilegeRegistryV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_0_2/EfiPrivilegeRegistryV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_0_3/EfiPrivilegeRegistryV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_0_4/EfiPrivilegeRegistryV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_0_5/EfiPrivilegeRegistryV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_1_0/EfiPrivilegeRegistryV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_1_1/EfiPrivilegeRegistryV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_1_2/EfiPrivilegeRegistryV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_1_3/EfiPrivilegeRegistryV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_1_4/EfiPrivilegeRegistryV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_0/EfiProcessorV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_10/EfiProcessorV1_0_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_11/EfiProcessorV1_0_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_12/EfiProcessorV1_0_12.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_2/EfiProcessorV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_3/EfiProcessorV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_4/EfiProcessorV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_5/EfiProcessorV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_6/EfiProcessorV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_7/EfiProcessorV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_8/EfiProcessorV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_9/EfiProcessorV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_10_0/EfiProcessorV1_10_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_10_1/EfiProcessorV1_10_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_11_0/EfiProcessorV1_11_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_0/EfiProcessorV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_1/EfiProcessorV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_2/EfiProcessorV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_3/EfiProcessorV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_4/EfiProcessorV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_5/EfiProcessorV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_6/EfiProcessorV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_7/EfiProcessorV1_1_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_8/EfiProcessorV1_1_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_0/EfiProcessorV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_1/EfiProcessorV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_2/EfiProcessorV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_3/EfiProcessorV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_4/EfiProcessorV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_5/EfiProcessorV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_6/EfiProcessorV1_2_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_7/EfiProcessorV1_2_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_8/EfiProcessorV1_2_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_0/EfiProcessorV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_1/EfiProcessorV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_2/EfiProcessorV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_3/EfiProcessorV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_4/EfiProcessorV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_5/EfiProcessorV1_3_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_6/EfiProcessorV1_3_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_7/EfiProcessorV1_3_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_8/EfiProcessorV1_3_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_0/EfiProcessorV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_1/EfiProcessorV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_2/EfiProcessorV1_4_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_3/EfiProcessorV1_4_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_4/EfiProcessorV1_4_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_5/EfiProcessorV1_4_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_6/EfiProcessorV1_4_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_7/EfiProcessorV1_4_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_0/EfiProcessorV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_1/EfiProcessorV1_5_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_2/EfiProcessorV1_5_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_3/EfiProcessorV1_5_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_4/EfiProcessorV1_5_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_5/EfiProcessorV1_5_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_6/EfiProcessorV1_5_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_6_0/EfiProcessorV1_6_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_6_1/EfiProcessorV1_6_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_6_2/EfiProcessorV1_6_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_6_3/EfiProcessorV1_6_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_6_4/EfiProcessorV1_6_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_7_0/EfiProcessorV1_7_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_7_1/EfiProcessorV1_7_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_7_2/EfiProcessorV1_7_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_7_3/EfiProcessorV1_7_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_8_0/EfiProcessorV1_8_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_8_1/EfiProcessorV1_8_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_8_2/EfiProcessorV1_8_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_9_0/EfiProcessorV1_9_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_9_1/EfiProcessorV1_9_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ProcessorCollection/EfiProcessorCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_0_0/EfiProcessorMetricsV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_0_1/EfiProcessorMetricsV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_0_2/EfiProcessorMetricsV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_0_3/EfiProcessorMetricsV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_0_4/EfiProcessorMetricsV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_1_0/EfiProcessorMetricsV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_1_1/EfiProcessorMetricsV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_1_2/EfiProcessorMetricsV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_2_0/EfiProcessorMetricsV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_0/EfiResourceBlockV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_1/EfiResourceBlockV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_2/EfiResourceBlockV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_3/EfiResourceBlockV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_4/EfiResourceBlockV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_5/EfiResourceBlockV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_6/EfiResourceBlockV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_0/EfiResourceBlockV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_1/EfiResourceBlockV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_2/EfiResourceBlockV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_3/EfiResourceBlockV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_4/EfiResourceBlockV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_5/EfiResourceBlockV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_6/EfiResourceBlockV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_2_0/EfiResourceBlockV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_2_1/EfiResourceBlockV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_2_2/EfiResourceBlockV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_2_3/EfiResourceBlockV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_2_4/EfiResourceBlockV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_2_5/EfiResourceBlockV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_3_0/EfiResourceBlockV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_3_1/EfiResourceBlockV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_3_2/EfiResourceBlockV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_3_3/EfiResourceBlockV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_3_4/EfiResourceBlockV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlockCollection/EfiResourceBlockCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_0/EfiRoleV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_2/EfiRoleV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_3/EfiRoleV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_4/EfiRoleV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_5/EfiRoleV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_6/EfiRoleV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_7/EfiRoleV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_1_0/EfiRoleV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_1_1/EfiRoleV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_1_2/EfiRoleV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_1_3/EfiRoleV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_1_4/EfiRoleV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_1_5/EfiRoleV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_2_0/EfiRoleV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_2_1/EfiRoleV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_2_2/EfiRoleV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_2_3/EfiRoleV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_2_4/EfiRoleV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_2_5/EfiRoleV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_3_0/EfiRoleV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/RoleCollection/EfiRoleCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/RouteEntry/v1_0_0/EfiRouteEntryV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/RouteEntry/v1_0_1/EfiRouteEntryV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/RouteEntryCollection/EfiRouteEntryCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/RouteSetEntry/v1_0_0/EfiRouteSetEntryV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/RouteSetEntry/v1_0_1/EfiRouteSetEntryV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/RouteSetEntryCollection/EfiRouteSetEntryCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_0/EfiSecureBootV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_1/EfiSecureBootV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_2/EfiSecureBootV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_3/EfiSecureBootV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_4/EfiSecureBootV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_5/EfiSecureBootV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_6/EfiSecureBootV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_7/EfiSecureBootV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_1_0/EfiSecureBootV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SecureBootDatabase/v1_0_0/EfiSecureBootDatabaseV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SecureBootDatabaseCollection/EfiSecureBootDatabaseCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_0/EfiSensorV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_1/EfiSensorV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_2/EfiSensorV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_3/EfiSensorV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_4/EfiSensorV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_5/EfiSensorV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_6/EfiSensorV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_1_0/EfiSensorV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_1_1/EfiSensorV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_1_2/EfiSensorV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_2_0/EfiSensorV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SensorCollection/EfiSensorCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_0/EfiSerialInterfaceV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_10/EfiSerialInterfaceV1_0_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_2/EfiSerialInterfaceV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_3/EfiSerialInterfaceV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_4/EfiSerialInterfaceV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_5/EfiSerialInterfaceV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_6/EfiSerialInterfaceV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_7/EfiSerialInterfaceV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_8/EfiSerialInterfaceV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_9/EfiSerialInterfaceV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_0/EfiSerialInterfaceV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_1/EfiSerialInterfaceV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_2/EfiSerialInterfaceV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_3/EfiSerialInterfaceV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_4/EfiSerialInterfaceV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_5/EfiSerialInterfaceV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_6/EfiSerialInterfaceV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_7/EfiSerialInterfaceV1_1_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SerialInterfaceCollection/EfiSerialInterfaceCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_0/EfiServiceRootV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_2/EfiServiceRootV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_3/EfiServiceRootV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_4/EfiServiceRootV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_5/EfiServiceRootV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_6/EfiServiceRootV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_7/EfiServiceRootV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_8/EfiServiceRootV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_9/EfiServiceRootV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_0/EfiServiceRootV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_1/EfiServiceRootV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_2/EfiServiceRootV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_3/EfiServiceRootV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_4/EfiServiceRootV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_5/EfiServiceRootV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_6/EfiServiceRootV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_2_0/EfiServiceRootV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_2_1/EfiServiceRootV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_2_2/EfiServiceRootV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_2_3/EfiServiceRootV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_2_4/EfiServiceRootV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_3_0/EfiServiceRootV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_3_1/EfiServiceRootV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_3_2/EfiServiceRootV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_3_3/EfiServiceRootV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_3_4/EfiServiceRootV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_3_5/EfiServiceRootV1_3_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_4_0/EfiServiceRootV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_4_1/EfiServiceRootV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_4_2/EfiServiceRootV1_4_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_4_3/EfiServiceRootV1_4_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_5_0/EfiServiceRootV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_5_1/EfiServiceRootV1_5_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_5_2/EfiServiceRootV1_5_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_6_0/EfiServiceRootV1_6_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_7_0/EfiServiceRootV1_7_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_8_0/EfiServiceRootV1_8_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_9_0/EfiServiceRootV1_9_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_0_0/EfiSessionV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_0_2/EfiSessionV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_0_3/EfiSessionV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_0_4/EfiSessionV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_0_5/EfiSessionV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_0_6/EfiSessionV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_1_0/EfiSessionV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_1_1/EfiSessionV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_1_2/EfiSessionV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_1_3/EfiSessionV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_2_0/EfiSessionV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_2_1/EfiSessionV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_3_0/EfiSessionV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SessionCollection/EfiSessionCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_0/EfiSessionServiceV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_2/EfiSessionServiceV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_3/EfiSessionServiceV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_4/EfiSessionServiceV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_5/EfiSessionServiceV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_6/EfiSessionServiceV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_7/EfiSessionServiceV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_8/EfiSessionServiceV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_9/EfiSessionServiceV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_0/EfiSessionServiceV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_1/EfiSessionServiceV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_2/EfiSessionServiceV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_3/EfiSessionServiceV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_4/EfiSessionServiceV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_5/EfiSessionServiceV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_6/EfiSessionServiceV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_7/EfiSessionServiceV1_1_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_8/EfiSessionServiceV1_1_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Signature/v1_0_0/EfiSignatureV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Signature/v1_0_1/EfiSignatureV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Signature/v1_0_2/EfiSignatureV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SignatureCollection/EfiSignatureCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_0/EfiSimpleStorageV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_2/EfiSimpleStorageV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_3/EfiSimpleStorageV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_4/EfiSimpleStorageV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_5/EfiSimpleStorageV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_6/EfiSimpleStorageV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_7/EfiSimpleStorageV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_8/EfiSimpleStorageV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_0/EfiSimpleStorageV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_1/EfiSimpleStorageV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_2/EfiSimpleStorageV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_3/EfiSimpleStorageV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_4/EfiSimpleStorageV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_5/EfiSimpleStorageV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_6/EfiSimpleStorageV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_2_0/EfiSimpleStorageV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_2_1/EfiSimpleStorageV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_2_2/EfiSimpleStorageV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_2_3/EfiSimpleStorageV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_2_4/EfiSimpleStorageV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_3_0/EfiSimpleStorageV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_3_1/EfiSimpleStorageV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorageCollection/EfiSimpleStorageCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_0_0/EfiSoftwareInventoryV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_0_1/EfiSoftwareInventoryV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_0_2/EfiSoftwareInventoryV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_0_3/EfiSoftwareInventoryV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_0_4/EfiSoftwareInventoryV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_0_5/EfiSoftwareInventoryV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_1_0/EfiSoftwareInventoryV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_1_1/EfiSoftwareInventoryV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_1_2/EfiSoftwareInventoryV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_1_3/EfiSoftwareInventoryV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_1_4/EfiSoftwareInventoryV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_2_0/EfiSoftwareInventoryV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_2_1/EfiSoftwareInventoryV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_2_2/EfiSoftwareInventoryV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_2_3/EfiSoftwareInventoryV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_3_0/EfiSoftwareInventoryV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_4_0/EfiSoftwareInventoryV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventoryCollection/EfiSoftwareInventoryCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_1/EfiStorageV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_10/EfiStorageV1_0_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_2/EfiStorageV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_3/EfiStorageV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_4/EfiStorageV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_5/EfiStorageV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_6/EfiStorageV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_7/EfiStorageV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_8/EfiStorageV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_9/EfiStorageV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_10_0/EfiStorageV1_10_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_1/EfiStorageV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_2/EfiStorageV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_3/EfiStorageV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_4/EfiStorageV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_5/EfiStorageV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_6/EfiStorageV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_7/EfiStorageV1_1_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_8/EfiStorageV1_1_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_9/EfiStorageV1_1_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_0/EfiStorageV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_1/EfiStorageV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_2/EfiStorageV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_3/EfiStorageV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_4/EfiStorageV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_5/EfiStorageV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_6/EfiStorageV1_2_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_7/EfiStorageV1_2_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_0/EfiStorageV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_1/EfiStorageV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_2/EfiStorageV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_3/EfiStorageV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_4/EfiStorageV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_5/EfiStorageV1_3_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_6/EfiStorageV1_3_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_7/EfiStorageV1_3_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_0/EfiStorageV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_1/EfiStorageV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_2/EfiStorageV1_4_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_3/EfiStorageV1_4_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_4/EfiStorageV1_4_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_5/EfiStorageV1_4_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_6/EfiStorageV1_4_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_5_0/EfiStorageV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_5_1/EfiStorageV1_5_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_5_2/EfiStorageV1_5_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_5_3/EfiStorageV1_5_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_5_4/EfiStorageV1_5_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_5_5/EfiStorageV1_5_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_6_0/EfiStorageV1_6_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_6_1/EfiStorageV1_6_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_6_2/EfiStorageV1_6_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_6_3/EfiStorageV1_6_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_6_4/EfiStorageV1_6_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_7_0/EfiStorageV1_7_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_7_1/EfiStorageV1_7_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_7_2/EfiStorageV1_7_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_7_3/EfiStorageV1_7_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_8_0/EfiStorageV1_8_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_8_1/EfiStorageV1_8_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_8_2/EfiStorageV1_8_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_9_0/EfiStorageV1_9_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_9_1/EfiStorageV1_9_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/StorageCollection/EfiStorageCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/StorageController/v1_0_0/EfiStorageControllerV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/StorageController/v1_0_1/EfiStorageControllerV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/StorageController/v1_1_0/EfiStorageControllerV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/StorageControllerCollection/EfiStorageControllerCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_0/EfiSwitchV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_1/EfiSwitchV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_2/EfiSwitchV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_3/EfiSwitchV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_4/EfiSwitchV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_5/EfiSwitchV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_6/EfiSwitchV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_7/EfiSwitchV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_8/EfiSwitchV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_1_0/EfiSwitchV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_1_1/EfiSwitchV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_1_2/EfiSwitchV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_1_3/EfiSwitchV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_1_4/EfiSwitchV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_1_5/EfiSwitchV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_2_0/EfiSwitchV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_2_1/EfiSwitchV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_2_2/EfiSwitchV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_3_0/EfiSwitchV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_3_1/EfiSwitchV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_3_2/EfiSwitchV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_4_0/EfiSwitchV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_4_1/EfiSwitchV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_5_0/EfiSwitchV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/SwitchCollection/EfiSwitchCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_0/EfiTaskV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_2/EfiTaskV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_3/EfiTaskV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_4/EfiTaskV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_5/EfiTaskV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_6/EfiTaskV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_7/EfiTaskV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_8/EfiTaskV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_9/EfiTaskV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_0/EfiTaskV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_1/EfiTaskV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_2/EfiTaskV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_3/EfiTaskV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_4/EfiTaskV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_5/EfiTaskV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_6/EfiTaskV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_2_0/EfiTaskV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_2_1/EfiTaskV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_2_2/EfiTaskV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_2_3/EfiTaskV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_2_4/EfiTaskV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_2_5/EfiTaskV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_3_0/EfiTaskV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_3_1/EfiTaskV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_3_2/EfiTaskV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_3_3/EfiTaskV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_3_4/EfiTaskV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_3_5/EfiTaskV1_3_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_4_0/EfiTaskV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_4_1/EfiTaskV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_4_2/EfiTaskV1_4_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_4_3/EfiTaskV1_4_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_4_4/EfiTaskV1_4_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_5_0/EfiTaskV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_5_1/EfiTaskV1_5_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TaskCollection/EfiTaskCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_0/EfiTaskServiceV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_2/EfiTaskServiceV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_3/EfiTaskServiceV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_4/EfiTaskServiceV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_5/EfiTaskServiceV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_6/EfiTaskServiceV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_7/EfiTaskServiceV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_8/EfiTaskServiceV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_9/EfiTaskServiceV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_0/EfiTaskServiceV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_1/EfiTaskServiceV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_2/EfiTaskServiceV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_3/EfiTaskServiceV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_4/EfiTaskServiceV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_5/EfiTaskServiceV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_6/EfiTaskServiceV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_0_0/EfiTelemetryServiceV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_0_1/EfiTelemetryServiceV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_0_2/EfiTelemetryServiceV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_0_3/EfiTelemetryServiceV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_0_4/EfiTelemetryServiceV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_1_0/EfiTelemetryServiceV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_1_1/EfiTelemetryServiceV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_1_2/EfiTelemetryServiceV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_1_3/EfiTelemetryServiceV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_1_4/EfiTelemetryServiceV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_2_0/EfiTelemetryServiceV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_2_1/EfiTelemetryServiceV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_2_2/EfiTelemetryServiceV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_3_0/EfiTelemetryServiceV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_0/EfiThermalV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_1/EfiThermalV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_10/EfiThermalV1_0_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_11/EfiThermalV1_0_11.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_2/EfiThermalV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_3/EfiThermalV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_4/EfiThermalV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_5/EfiThermalV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_6/EfiThermalV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_7/EfiThermalV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_8/EfiThermalV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_9/EfiThermalV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_0/EfiThermalV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_1/EfiThermalV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_2/EfiThermalV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_3/EfiThermalV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_4/EfiThermalV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_5/EfiThermalV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_6/EfiThermalV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_7/EfiThermalV1_1_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_8/EfiThermalV1_1_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_9/EfiThermalV1_1_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_0/EfiThermalV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_1/EfiThermalV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_2/EfiThermalV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_3/EfiThermalV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_4/EfiThermalV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_5/EfiThermalV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_6/EfiThermalV1_2_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_7/EfiThermalV1_2_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_8/EfiThermalV1_2_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_0/EfiThermalV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_1/EfiThermalV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_2/EfiThermalV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_3/EfiThermalV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_4/EfiThermalV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_5/EfiThermalV1_3_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_6/EfiThermalV1_3_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_7/EfiThermalV1_3_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_0/EfiThermalV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_1/EfiThermalV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_2/EfiThermalV1_4_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_3/EfiThermalV1_4_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_4/EfiThermalV1_4_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_5/EfiThermalV1_4_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_6/EfiThermalV1_4_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_5_0/EfiThermalV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_5_1/EfiThermalV1_5_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_5_2/EfiThermalV1_5_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_5_3/EfiThermalV1_5_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_5_4/EfiThermalV1_5_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_5_5/EfiThermalV1_5_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_6_0/EfiThermalV1_6_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_6_1/EfiThermalV1_6_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_6_2/EfiThermalV1_6_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_7_0/EfiThermalV1_7_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ThermalMetrics/v1_0_0/EfiThermalMetricsV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ThermalSubsystem/v1_0_0/EfiThermalSubsystemV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_0_0/EfiTriggersV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_0_1/EfiTriggersV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_0_2/EfiTriggersV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_0_3/EfiTriggersV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_0_4/EfiTriggersV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_0_5/EfiTriggersV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_1_0/EfiTriggersV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_1_1/EfiTriggersV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_1_2/EfiTriggersV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_1_3/EfiTriggersV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/TriggersCollection/EfiTriggersCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_0/EfiUpdateServiceV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_1/EfiUpdateServiceV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_10/EfiUpdateServiceV1_0_10.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_2/EfiUpdateServiceV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_3/EfiUpdateServiceV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_4/EfiUpdateServiceV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_5/EfiUpdateServiceV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_6/EfiUpdateServiceV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_7/EfiUpdateServiceV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_8/EfiUpdateServiceV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_9/EfiUpdateServiceV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_0/EfiUpdateServiceV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_1/EfiUpdateServiceV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_2/EfiUpdateServiceV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_3/EfiUpdateServiceV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_4/EfiUpdateServiceV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_5/EfiUpdateServiceV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_6/EfiUpdateServiceV1_1_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_7/EfiUpdateServiceV1_1_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_8/EfiUpdateServiceV1_1_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_9/EfiUpdateServiceV1_1_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_0/EfiUpdateServiceV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_1/EfiUpdateServiceV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_2/EfiUpdateServiceV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_3/EfiUpdateServiceV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_4/EfiUpdateServiceV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_5/EfiUpdateServiceV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_6/EfiUpdateServiceV1_2_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_7/EfiUpdateServiceV1_2_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_8/EfiUpdateServiceV1_2_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_0/EfiUpdateServiceV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_1/EfiUpdateServiceV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_2/EfiUpdateServiceV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_3/EfiUpdateServiceV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_4/EfiUpdateServiceV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_5/EfiUpdateServiceV1_3_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_6/EfiUpdateServiceV1_3_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_4_0/EfiUpdateServiceV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_4_1/EfiUpdateServiceV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_4_2/EfiUpdateServiceV1_4_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_4_3/EfiUpdateServiceV1_4_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_4_4/EfiUpdateServiceV1_4_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_4_5/EfiUpdateServiceV1_4_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_5_0/EfiUpdateServiceV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_5_1/EfiUpdateServiceV1_5_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_5_2/EfiUpdateServiceV1_5_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_5_3/EfiUpdateServiceV1_5_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_5_4/EfiUpdateServiceV1_5_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_6_0/EfiUpdateServiceV1_6_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_6_1/EfiUpdateServiceV1_6_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_6_2/EfiUpdateServiceV1_6_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_6_3/EfiUpdateServiceV1_6_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_7_0/EfiUpdateServiceV1_7_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_7_1/EfiUpdateServiceV1_7_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_7_2/EfiUpdateServiceV1_7_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_7_3/EfiUpdateServiceV1_7_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_8_0/EfiUpdateServiceV1_8_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_8_1/EfiUpdateServiceV1_8_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_8_2/EfiUpdateServiceV1_8_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_8_3/EfiUpdateServiceV1_8_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VCATEntry/v1_0_0/EfiVCATEntryV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VCATEntry/v1_0_1/EfiVCATEntryV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VCATEntryCollection/EfiVCATEntryCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_0/EfiVLanNetworkInterfaceV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_1/EfiVLanNetworkInterfaceV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_2/EfiVLanNetworkInterfaceV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_3/EfiVLanNetworkInterfaceV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_4/EfiVLanNetworkInterfaceV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_5/EfiVLanNetworkInterfaceV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_6/EfiVLanNetworkInterfaceV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_7/EfiVLanNetworkInterfaceV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_8/EfiVLanNetworkInterfaceV1_0_8.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_9/EfiVLanNetworkInterfaceV1_0_9.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_1_0/EfiVLanNetworkInterfaceV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_1_1/EfiVLanNetworkInterfaceV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_1_2/EfiVLanNetworkInterfaceV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_1_3/EfiVLanNetworkInterfaceV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_1_4/EfiVLanNetworkInterfaceV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_1_5/EfiVLanNetworkInterfaceV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_2_0/EfiVLanNetworkInterfaceV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterfaceCollection/EfiVLanNetworkInterfaceCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_0/EfiVirtualMediaV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_2/EfiVirtualMediaV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_3/EfiVirtualMediaV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_4/EfiVirtualMediaV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_5/EfiVirtualMediaV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_6/EfiVirtualMediaV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_7/EfiVirtualMediaV1_0_7.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_1_0/EfiVirtualMediaV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_1_1/EfiVirtualMediaV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_1_2/EfiVirtualMediaV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_1_3/EfiVirtualMediaV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_1_4/EfiVirtualMediaV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_1_5/EfiVirtualMediaV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_2_0/EfiVirtualMediaV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_2_1/EfiVirtualMediaV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_2_2/EfiVirtualMediaV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_2_3/EfiVirtualMediaV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_2_4/EfiVirtualMediaV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_3_0/EfiVirtualMediaV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_3_1/EfiVirtualMediaV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_3_2/EfiVirtualMediaV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VirtualMediaCollection/EfiVirtualMediaCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_0_0/EfiVolumeV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_0_1/EfiVolumeV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_0_2/EfiVolumeV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_0_3/EfiVolumeV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_0_4/EfiVolumeV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_1_0/EfiVolumeV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_1_1/EfiVolumeV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_1_2/EfiVolumeV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_1_3/EfiVolumeV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_1_4/EfiVolumeV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_1_5/EfiVolumeV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_2_0/EfiVolumeV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_2_1/EfiVolumeV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_2_2/EfiVolumeV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_2_3/EfiVolumeV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_2_4/EfiVolumeV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_2_5/EfiVolumeV1_2_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_3_0/EfiVolumeV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_3_1/EfiVolumeV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_3_2/EfiVolumeV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_3_3/EfiVolumeV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_3_4/EfiVolumeV1_3_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_4_0/EfiVolumeV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_4_1/EfiVolumeV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_4_2/EfiVolumeV1_4_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_4_3/EfiVolumeV1_4_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_5_0/EfiVolumeV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_5_1/EfiVolumeV1_5_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_6_0/EfiVolumeV1_6_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_6_1/EfiVolumeV1_6_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/VolumeCollection/EfiVolumeCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_0/EfiZoneV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_1/EfiZoneV1_0_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_2/EfiZoneV1_0_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_3/EfiZoneV1_0_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_4/EfiZoneV1_0_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_5/EfiZoneV1_0_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_6/EfiZoneV1_0_6.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_1_0/EfiZoneV1_1_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_1_1/EfiZoneV1_1_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_1_2/EfiZoneV1_1_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_1_3/EfiZoneV1_1_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_1_4/EfiZoneV1_1_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_1_5/EfiZoneV1_1_5.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_2_0/EfiZoneV1_2_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_2_1/EfiZoneV1_2_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_2_2/EfiZoneV1_2_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_2_3/EfiZoneV1_2_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_2_4/EfiZoneV1_2_4.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_3_0/EfiZoneV1_3_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_3_1/EfiZoneV1_3_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_3_2/EfiZoneV1_3_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_3_3/EfiZoneV1_3_3.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_4_0/EfiZoneV1_4_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_4_1/EfiZoneV1_4_1.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_4_2/EfiZoneV1_4_2.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_5_0/EfiZoneV1_5_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_6_0/EfiZoneV1_6_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/ZoneCollection/EfiZoneCollection.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/redfisherror/v1_0_0/EfiredfisherrorV1_0_0.h create mode 100644 RedfishClientPkg/Include/RedfishJsonStructure/redfisherror/v1_0_1/EfiredfisherrorV1_0_1.h diff --git a/RedfishClientPkg/Converter/AccelerationFunction/v1_0_0/AccelerationFunction_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/AccelerationFunction/v1_0_0/AccelerationFunction_V1_0_0_Dxe.c new file mode 100644 index 00000000000..673bb8410ed --- /dev/null +++ b/RedfishClientPkg/Converter/AccelerationFunction/v1_0_0/AccelerationFunction_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccelerationFunction.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccelerationFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccelerationFunction V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccelerationFunction", + "1", + "0", + "0" + }, + "AccelerationFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccelerationFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_0 *AccelerationFunctionV1_0_0; + EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_0_CS *AccelerationFunctionV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccelerationFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccelerationFunction_V1_0_0_To_CS (ResoruceRaw, &AccelerationFunctionV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccelerationFunctionV1_0_0 = (EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_0)); + if (AccelerationFunctionV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccelerationFunctionV1_0_0; + AccelerationFunctionV1_0_0->AccelerationFunction = AccelerationFunctionV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccelerationFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccelerationFunction"), "AccelerationFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccelerationFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccelerationFunction"), "AccelerationFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccelerationFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccelerationFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccelerationFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccelerationFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccelerationFunction_V1_0_0_JSON (*((EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccelerationFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccelerationFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_0 *AccelerationFunctionV1_0_0; + + AccelerationFunctionV1_0_0 = (EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_0 *)InterpProp; + DestroyAccelerationFunction_V1_0_0_CS (AccelerationFunctionV1_0_0->AccelerationFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccelerationFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccelerationFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccelerationFunction_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccelerationFunction_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccelerationFunctionToStructWrapper, + AccelerationFunctionToJson, + AccelerationFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccelerationFunction_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccelerationFunction/v1_0_0/RedfishAccelerationFunction_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/AccelerationFunction/v1_0_0/RedfishAccelerationFunction_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..90db58e01e2 --- /dev/null +++ b/RedfishClientPkg/Converter/AccelerationFunction/v1_0_0/RedfishAccelerationFunction_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccelerationFunction.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccelerationFunction_V1_0_0_Dxe + FILE_GUID = d7e2f8bb-417c-47e2-b045-035a6e091ad9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccelerationFunction_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishAccelerationFunction_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccelerationFunction_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccelerationFunctionV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccelerationFunction/v1_0_1/AccelerationFunction_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/AccelerationFunction/v1_0_1/AccelerationFunction_V1_0_1_Dxe.c new file mode 100644 index 00000000000..3d98d0f7cf9 --- /dev/null +++ b/RedfishClientPkg/Converter/AccelerationFunction/v1_0_1/AccelerationFunction_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccelerationFunction.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccelerationFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccelerationFunction V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccelerationFunction", + "1", + "0", + "1" + }, + "AccelerationFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccelerationFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_1 *AccelerationFunctionV1_0_1; + EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_1_CS *AccelerationFunctionV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccelerationFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccelerationFunction_V1_0_1_To_CS (ResoruceRaw, &AccelerationFunctionV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccelerationFunctionV1_0_1 = (EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_1)); + if (AccelerationFunctionV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccelerationFunctionV1_0_1; + AccelerationFunctionV1_0_1->AccelerationFunction = AccelerationFunctionV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccelerationFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccelerationFunction"), "AccelerationFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccelerationFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccelerationFunction"), "AccelerationFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccelerationFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccelerationFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccelerationFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccelerationFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccelerationFunction_V1_0_1_JSON (*((EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccelerationFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccelerationFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_1 *AccelerationFunctionV1_0_1; + + AccelerationFunctionV1_0_1 = (EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_1 *)InterpProp; + DestroyAccelerationFunction_V1_0_1_CS (AccelerationFunctionV1_0_1->AccelerationFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccelerationFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccelerationFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccelerationFunction_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccelerationFunction_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccelerationFunctionToStructWrapper, + AccelerationFunctionToJson, + AccelerationFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccelerationFunction_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccelerationFunction/v1_0_1/RedfishAccelerationFunction_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/AccelerationFunction/v1_0_1/RedfishAccelerationFunction_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..063c7242ff5 --- /dev/null +++ b/RedfishClientPkg/Converter/AccelerationFunction/v1_0_1/RedfishAccelerationFunction_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccelerationFunction.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccelerationFunction_V1_0_1_Dxe + FILE_GUID = 794ad4ed-4303-4dd1-ad56-977f2daadd99 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccelerationFunction_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishAccelerationFunction_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccelerationFunction_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccelerationFunctionV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccelerationFunction/v1_0_2/AccelerationFunction_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/AccelerationFunction/v1_0_2/AccelerationFunction_V1_0_2_Dxe.c new file mode 100644 index 00000000000..b2ddda0cb82 --- /dev/null +++ b/RedfishClientPkg/Converter/AccelerationFunction/v1_0_2/AccelerationFunction_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccelerationFunction.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccelerationFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccelerationFunction V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccelerationFunction", + "1", + "0", + "2" + }, + "AccelerationFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccelerationFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_2 *AccelerationFunctionV1_0_2; + EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_2_CS *AccelerationFunctionV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccelerationFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccelerationFunction_V1_0_2_To_CS (ResoruceRaw, &AccelerationFunctionV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccelerationFunctionV1_0_2 = (EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_2)); + if (AccelerationFunctionV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccelerationFunctionV1_0_2; + AccelerationFunctionV1_0_2->AccelerationFunction = AccelerationFunctionV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccelerationFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccelerationFunction"), "AccelerationFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccelerationFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccelerationFunction"), "AccelerationFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccelerationFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccelerationFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccelerationFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccelerationFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccelerationFunction_V1_0_2_JSON (*((EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccelerationFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccelerationFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_2 *AccelerationFunctionV1_0_2; + + AccelerationFunctionV1_0_2 = (EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_2 *)InterpProp; + DestroyAccelerationFunction_V1_0_2_CS (AccelerationFunctionV1_0_2->AccelerationFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccelerationFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccelerationFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccelerationFunction_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccelerationFunction_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccelerationFunctionToStructWrapper, + AccelerationFunctionToJson, + AccelerationFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccelerationFunction_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccelerationFunction/v1_0_2/RedfishAccelerationFunction_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/AccelerationFunction/v1_0_2/RedfishAccelerationFunction_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..e3ea31acfe2 --- /dev/null +++ b/RedfishClientPkg/Converter/AccelerationFunction/v1_0_2/RedfishAccelerationFunction_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccelerationFunction.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccelerationFunction_V1_0_2_Dxe + FILE_GUID = 9f952a08-5dde-4980-b936-f5a7cae20f6e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccelerationFunction_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishAccelerationFunction_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccelerationFunction_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccelerationFunctionV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccelerationFunction/v1_0_3/AccelerationFunction_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/AccelerationFunction/v1_0_3/AccelerationFunction_V1_0_3_Dxe.c new file mode 100644 index 00000000000..f3783f337c1 --- /dev/null +++ b/RedfishClientPkg/Converter/AccelerationFunction/v1_0_3/AccelerationFunction_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccelerationFunction.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccelerationFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccelerationFunction V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccelerationFunction", + "1", + "0", + "3" + }, + "AccelerationFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccelerationFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_3 *AccelerationFunctionV1_0_3; + EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_3_CS *AccelerationFunctionV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccelerationFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccelerationFunction_V1_0_3_To_CS (ResoruceRaw, &AccelerationFunctionV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccelerationFunctionV1_0_3 = (EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_3)); + if (AccelerationFunctionV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccelerationFunctionV1_0_3; + AccelerationFunctionV1_0_3->AccelerationFunction = AccelerationFunctionV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccelerationFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccelerationFunction"), "AccelerationFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccelerationFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccelerationFunction"), "AccelerationFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccelerationFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccelerationFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccelerationFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccelerationFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccelerationFunction_V1_0_3_JSON (*((EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccelerationFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccelerationFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_3 *AccelerationFunctionV1_0_3; + + AccelerationFunctionV1_0_3 = (EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_3 *)InterpProp; + DestroyAccelerationFunction_V1_0_3_CS (AccelerationFunctionV1_0_3->AccelerationFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccelerationFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccelerationFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccelerationFunction_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccelerationFunction_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccelerationFunctionToStructWrapper, + AccelerationFunctionToJson, + AccelerationFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccelerationFunction_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccelerationFunction/v1_0_3/RedfishAccelerationFunction_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/AccelerationFunction/v1_0_3/RedfishAccelerationFunction_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..638e32f24ae --- /dev/null +++ b/RedfishClientPkg/Converter/AccelerationFunction/v1_0_3/RedfishAccelerationFunction_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccelerationFunction.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccelerationFunction_V1_0_3_Dxe + FILE_GUID = 2ab01ca2-e73c-4e39-846f-6af8eba9963f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccelerationFunction_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishAccelerationFunction_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccelerationFunction_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccelerationFunctionV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccelerationFunctionCollection/AccelerationFunctionCollection_Dxe.c b/RedfishClientPkg/Converter/AccelerationFunctionCollection/AccelerationFunctionCollection_Dxe.c new file mode 100644 index 00000000000..c3ff8609910 --- /dev/null +++ b/RedfishClientPkg/Converter/AccelerationFunctionCollection/AccelerationFunctionCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccelerationFunctionCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccelerationFunctionCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support AccelerationFunctionCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccelerationFunctionCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "AccelerationFunctionCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccelerationFunctionCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCELERATIONFUNCTIONCOLLECTION *AccelerationFunctionCollection; + EFI_REDFISH_ACCELERATIONFUNCTIONCOLLECTION_CS *AccelerationFunctionCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccelerationFunctionCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccelerationFunctionCollection_To_CS (ResoruceRaw, &AccelerationFunctionCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + AccelerationFunctionCollection = (EFI_REDFISH_ACCELERATIONFUNCTIONCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCELERATIONFUNCTIONCOLLECTION)); + if (AccelerationFunctionCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccelerationFunctionCollection; + AccelerationFunctionCollection->AccelerationFunctionCollection = AccelerationFunctionCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccelerationFunctionCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccelerationFunctionCollection"), "AccelerationFunctionCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccelerationFunctionCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccelerationFunctionCollection"), "AccelerationFunctionCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccelerationFunctionCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccelerationFunctionCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccelerationFunctionCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccelerationFunctionCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccelerationFunctionCollection_JSON (*((EFI_REDFISH_ACCELERATIONFUNCTIONCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccelerationFunctionCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccelerationFunctionCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCELERATIONFUNCTIONCOLLECTION *AccelerationFunctionCollection; + + AccelerationFunctionCollection = (EFI_REDFISH_ACCELERATIONFUNCTIONCOLLECTION *)InterpProp; + DestroyAccelerationFunctionCollection_CS (AccelerationFunctionCollection->AccelerationFunctionCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccelerationFunctionCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccelerationFunctionCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccelerationFunctionCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccelerationFunctionCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccelerationFunctionCollectionToStructWrapper, + AccelerationFunctionCollectionToJson, + AccelerationFunctionCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccelerationFunctionCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccelerationFunctionCollection/RedfishAccelerationFunctionCollection_Dxe.inf b/RedfishClientPkg/Converter/AccelerationFunctionCollection/RedfishAccelerationFunctionCollection_Dxe.inf new file mode 100644 index 00000000000..202008b4086 --- /dev/null +++ b/RedfishClientPkg/Converter/AccelerationFunctionCollection/RedfishAccelerationFunctionCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccelerationFunctionCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccelerationFunctionCollection_Dxe + FILE_GUID = 10e20ec3-da03-4f19-995f-7a8c4abd736f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccelerationFunctionCollectionEntryPoint + UNLOAD_IMAGE = RedfishAccelerationFunctionCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccelerationFunctionCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccelerationFunctionCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_0_0/AccountService_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_0_0/AccountService_V1_0_0_Dxe.c new file mode 100644 index 00000000000..e573674b70f --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_0_0/AccountService_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "0", + "0" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_0_0 *AccountServiceV1_0_0; + EFI_REDFISH_ACCOUNTSERVICE_V1_0_0_CS *AccountServiceV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_0_0_To_CS (ResoruceRaw, &AccountServiceV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_0_0 = (EFI_REDFISH_ACCOUNTSERVICE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_0_0)); + if (AccountServiceV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_0_0; + AccountServiceV1_0_0->AccountService = AccountServiceV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_0_0_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_0_0 *AccountServiceV1_0_0; + + AccountServiceV1_0_0 = (EFI_REDFISH_ACCOUNTSERVICE_V1_0_0 *)InterpProp; + DestroyAccountService_V1_0_0_CS (AccountServiceV1_0_0->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_0_0/RedfishAccountService_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_0_0/RedfishAccountService_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..cd1a00e0438 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_0_0/RedfishAccountService_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_0_0_Dxe + FILE_GUID = fbf0fa46-64e9-4684-98ab-d21a69f5d3ac + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_0_10/AccountService_V1_0_10_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_0_10/AccountService_V1_0_10_Dxe.c new file mode 100644 index 00000000000..57f9f3ebe30 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_0_10/AccountService_V1_0_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_0_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "0", + "10" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_0_10 *AccountServiceV1_0_10; + EFI_REDFISH_ACCOUNTSERVICE_V1_0_10_CS *AccountServiceV1_0_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_0_10_To_CS (ResoruceRaw, &AccountServiceV1_0_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_0_10 = (EFI_REDFISH_ACCOUNTSERVICE_V1_0_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_0_10)); + if (AccountServiceV1_0_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_0_10; + AccountServiceV1_0_10->AccountService = AccountServiceV1_0_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_0_10_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_0_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_0_10 *AccountServiceV1_0_10; + + AccountServiceV1_0_10 = (EFI_REDFISH_ACCOUNTSERVICE_V1_0_10 *)InterpProp; + DestroyAccountService_V1_0_10_CS (AccountServiceV1_0_10->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_0_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_0_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_0_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_0_10/RedfishAccountService_V1_0_10_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_0_10/RedfishAccountService_V1_0_10_Dxe.inf new file mode 100644 index 00000000000..348353bf89a --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_0_10/RedfishAccountService_V1_0_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_0_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_0_10_Dxe + FILE_GUID = c1682a8b-9f4f-4614-b3ce-f1fa1126c7b5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_0_10EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_0_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_0_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_0_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_0_11/AccountService_V1_0_11_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_0_11/AccountService_V1_0_11_Dxe.c new file mode 100644 index 00000000000..ebc353aff31 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_0_11/AccountService_V1_0_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_0_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "0", + "11" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_0_11 *AccountServiceV1_0_11; + EFI_REDFISH_ACCOUNTSERVICE_V1_0_11_CS *AccountServiceV1_0_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_0_11_To_CS (ResoruceRaw, &AccountServiceV1_0_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_0_11 = (EFI_REDFISH_ACCOUNTSERVICE_V1_0_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_0_11)); + if (AccountServiceV1_0_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_0_11; + AccountServiceV1_0_11->AccountService = AccountServiceV1_0_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_0_11_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_0_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_0_11 *AccountServiceV1_0_11; + + AccountServiceV1_0_11 = (EFI_REDFISH_ACCOUNTSERVICE_V1_0_11 *)InterpProp; + DestroyAccountService_V1_0_11_CS (AccountServiceV1_0_11->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_0_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_0_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_0_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_0_11/RedfishAccountService_V1_0_11_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_0_11/RedfishAccountService_V1_0_11_Dxe.inf new file mode 100644 index 00000000000..f8da4793686 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_0_11/RedfishAccountService_V1_0_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_0_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_0_11_Dxe + FILE_GUID = e394c583-d578-4f72-bd5b-bbc36224f535 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_0_11EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_0_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_0_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_0_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_0_2/AccountService_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_0_2/AccountService_V1_0_2_Dxe.c new file mode 100644 index 00000000000..41620a49824 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_0_2/AccountService_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "0", + "2" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_0_2 *AccountServiceV1_0_2; + EFI_REDFISH_ACCOUNTSERVICE_V1_0_2_CS *AccountServiceV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_0_2_To_CS (ResoruceRaw, &AccountServiceV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_0_2 = (EFI_REDFISH_ACCOUNTSERVICE_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_0_2)); + if (AccountServiceV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_0_2; + AccountServiceV1_0_2->AccountService = AccountServiceV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_0_2_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_0_2 *AccountServiceV1_0_2; + + AccountServiceV1_0_2 = (EFI_REDFISH_ACCOUNTSERVICE_V1_0_2 *)InterpProp; + DestroyAccountService_V1_0_2_CS (AccountServiceV1_0_2->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_0_2/RedfishAccountService_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_0_2/RedfishAccountService_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..e96cc345a59 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_0_2/RedfishAccountService_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_0_2_Dxe + FILE_GUID = a24a932a-5785-4808-afdb-5ece5e6f8597 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_0_3/AccountService_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_0_3/AccountService_V1_0_3_Dxe.c new file mode 100644 index 00000000000..ca88928a3db --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_0_3/AccountService_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "0", + "3" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_0_3 *AccountServiceV1_0_3; + EFI_REDFISH_ACCOUNTSERVICE_V1_0_3_CS *AccountServiceV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_0_3_To_CS (ResoruceRaw, &AccountServiceV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_0_3 = (EFI_REDFISH_ACCOUNTSERVICE_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_0_3)); + if (AccountServiceV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_0_3; + AccountServiceV1_0_3->AccountService = AccountServiceV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_0_3_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_0_3 *AccountServiceV1_0_3; + + AccountServiceV1_0_3 = (EFI_REDFISH_ACCOUNTSERVICE_V1_0_3 *)InterpProp; + DestroyAccountService_V1_0_3_CS (AccountServiceV1_0_3->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_0_3/RedfishAccountService_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_0_3/RedfishAccountService_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..1a7d9c97a96 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_0_3/RedfishAccountService_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_0_3_Dxe + FILE_GUID = b7221dde-cef9-416a-aaf3-34a31d205dfe + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_0_4/AccountService_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_0_4/AccountService_V1_0_4_Dxe.c new file mode 100644 index 00000000000..63cad9c87e3 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_0_4/AccountService_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "0", + "4" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_0_4 *AccountServiceV1_0_4; + EFI_REDFISH_ACCOUNTSERVICE_V1_0_4_CS *AccountServiceV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_0_4_To_CS (ResoruceRaw, &AccountServiceV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_0_4 = (EFI_REDFISH_ACCOUNTSERVICE_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_0_4)); + if (AccountServiceV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_0_4; + AccountServiceV1_0_4->AccountService = AccountServiceV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_0_4_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_0_4 *AccountServiceV1_0_4; + + AccountServiceV1_0_4 = (EFI_REDFISH_ACCOUNTSERVICE_V1_0_4 *)InterpProp; + DestroyAccountService_V1_0_4_CS (AccountServiceV1_0_4->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_0_4/RedfishAccountService_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_0_4/RedfishAccountService_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..dbe05c0d76d --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_0_4/RedfishAccountService_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_0_4_Dxe + FILE_GUID = b95dd737-21c2-42a6-9a4f-de8839147ae2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_0_5/AccountService_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_0_5/AccountService_V1_0_5_Dxe.c new file mode 100644 index 00000000000..93f7c495d78 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_0_5/AccountService_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "0", + "5" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_0_5 *AccountServiceV1_0_5; + EFI_REDFISH_ACCOUNTSERVICE_V1_0_5_CS *AccountServiceV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_0_5_To_CS (ResoruceRaw, &AccountServiceV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_0_5 = (EFI_REDFISH_ACCOUNTSERVICE_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_0_5)); + if (AccountServiceV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_0_5; + AccountServiceV1_0_5->AccountService = AccountServiceV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_0_5_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_0_5 *AccountServiceV1_0_5; + + AccountServiceV1_0_5 = (EFI_REDFISH_ACCOUNTSERVICE_V1_0_5 *)InterpProp; + DestroyAccountService_V1_0_5_CS (AccountServiceV1_0_5->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_0_5/RedfishAccountService_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_0_5/RedfishAccountService_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..c1a508150f6 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_0_5/RedfishAccountService_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_0_5_Dxe + FILE_GUID = a1bc3d35-cd6c-4555-8993-bd27da9767ed + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_0_6/AccountService_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_0_6/AccountService_V1_0_6_Dxe.c new file mode 100644 index 00000000000..b66e292ea0f --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_0_6/AccountService_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "0", + "6" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_0_6 *AccountServiceV1_0_6; + EFI_REDFISH_ACCOUNTSERVICE_V1_0_6_CS *AccountServiceV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_0_6_To_CS (ResoruceRaw, &AccountServiceV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_0_6 = (EFI_REDFISH_ACCOUNTSERVICE_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_0_6)); + if (AccountServiceV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_0_6; + AccountServiceV1_0_6->AccountService = AccountServiceV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_0_6_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_0_6 *AccountServiceV1_0_6; + + AccountServiceV1_0_6 = (EFI_REDFISH_ACCOUNTSERVICE_V1_0_6 *)InterpProp; + DestroyAccountService_V1_0_6_CS (AccountServiceV1_0_6->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_0_6/RedfishAccountService_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_0_6/RedfishAccountService_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..51437b251a7 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_0_6/RedfishAccountService_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_0_6_Dxe + FILE_GUID = 920e3619-d39e-470e-a875-fdf9f8316a97 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_0_7/AccountService_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_0_7/AccountService_V1_0_7_Dxe.c new file mode 100644 index 00000000000..1dfab0b4722 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_0_7/AccountService_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "0", + "7" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_0_7 *AccountServiceV1_0_7; + EFI_REDFISH_ACCOUNTSERVICE_V1_0_7_CS *AccountServiceV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_0_7_To_CS (ResoruceRaw, &AccountServiceV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_0_7 = (EFI_REDFISH_ACCOUNTSERVICE_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_0_7)); + if (AccountServiceV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_0_7; + AccountServiceV1_0_7->AccountService = AccountServiceV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_0_7_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_0_7 *AccountServiceV1_0_7; + + AccountServiceV1_0_7 = (EFI_REDFISH_ACCOUNTSERVICE_V1_0_7 *)InterpProp; + DestroyAccountService_V1_0_7_CS (AccountServiceV1_0_7->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_0_7/RedfishAccountService_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_0_7/RedfishAccountService_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..40203d6e2bd --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_0_7/RedfishAccountService_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_0_7_Dxe + FILE_GUID = d2899a96-a8f1-4d26-99fa-f0a7f75cba60 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_0_8/AccountService_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_0_8/AccountService_V1_0_8_Dxe.c new file mode 100644 index 00000000000..ae27d94d316 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_0_8/AccountService_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "0", + "8" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_0_8 *AccountServiceV1_0_8; + EFI_REDFISH_ACCOUNTSERVICE_V1_0_8_CS *AccountServiceV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_0_8_To_CS (ResoruceRaw, &AccountServiceV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_0_8 = (EFI_REDFISH_ACCOUNTSERVICE_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_0_8)); + if (AccountServiceV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_0_8; + AccountServiceV1_0_8->AccountService = AccountServiceV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_0_8_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_0_8 *AccountServiceV1_0_8; + + AccountServiceV1_0_8 = (EFI_REDFISH_ACCOUNTSERVICE_V1_0_8 *)InterpProp; + DestroyAccountService_V1_0_8_CS (AccountServiceV1_0_8->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_0_8/RedfishAccountService_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_0_8/RedfishAccountService_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..5f684b19d49 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_0_8/RedfishAccountService_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_0_8_Dxe + FILE_GUID = 2914badb-bba0-4ef5-99fe-37df48272cec + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_0_9/AccountService_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_0_9/AccountService_V1_0_9_Dxe.c new file mode 100644 index 00000000000..044a2626415 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_0_9/AccountService_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "0", + "9" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_0_9 *AccountServiceV1_0_9; + EFI_REDFISH_ACCOUNTSERVICE_V1_0_9_CS *AccountServiceV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_0_9_To_CS (ResoruceRaw, &AccountServiceV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_0_9 = (EFI_REDFISH_ACCOUNTSERVICE_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_0_9)); + if (AccountServiceV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_0_9; + AccountServiceV1_0_9->AccountService = AccountServiceV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_0_9_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_0_9 *AccountServiceV1_0_9; + + AccountServiceV1_0_9 = (EFI_REDFISH_ACCOUNTSERVICE_V1_0_9 *)InterpProp; + DestroyAccountService_V1_0_9_CS (AccountServiceV1_0_9->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_0_9/RedfishAccountService_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_0_9/RedfishAccountService_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..49f1be1b934 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_0_9/RedfishAccountService_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_0_9_Dxe + FILE_GUID = a499bc54-8f24-4755-812b-7a0d515f4463 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_1_0/AccountService_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_1_0/AccountService_V1_1_0_Dxe.c new file mode 100644 index 00000000000..7d4bae9fe0d --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_1_0/AccountService_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "1", + "0" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_1_0 *AccountServiceV1_1_0; + EFI_REDFISH_ACCOUNTSERVICE_V1_1_0_CS *AccountServiceV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_1_0_To_CS (ResoruceRaw, &AccountServiceV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_1_0 = (EFI_REDFISH_ACCOUNTSERVICE_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_1_0)); + if (AccountServiceV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_1_0; + AccountServiceV1_1_0->AccountService = AccountServiceV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_1_0_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_1_0 *AccountServiceV1_1_0; + + AccountServiceV1_1_0 = (EFI_REDFISH_ACCOUNTSERVICE_V1_1_0 *)InterpProp; + DestroyAccountService_V1_1_0_CS (AccountServiceV1_1_0->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_1_0/RedfishAccountService_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_1_0/RedfishAccountService_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..66fce8e05d2 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_1_0/RedfishAccountService_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_1_0_Dxe + FILE_GUID = 5a5bf578-6ea2-4972-a34e-3e55742d79fc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_1_1/AccountService_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_1_1/AccountService_V1_1_1_Dxe.c new file mode 100644 index 00000000000..38b17abd763 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_1_1/AccountService_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "1", + "1" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_1_1 *AccountServiceV1_1_1; + EFI_REDFISH_ACCOUNTSERVICE_V1_1_1_CS *AccountServiceV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_1_1_To_CS (ResoruceRaw, &AccountServiceV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_1_1 = (EFI_REDFISH_ACCOUNTSERVICE_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_1_1)); + if (AccountServiceV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_1_1; + AccountServiceV1_1_1->AccountService = AccountServiceV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_1_1_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_1_1 *AccountServiceV1_1_1; + + AccountServiceV1_1_1 = (EFI_REDFISH_ACCOUNTSERVICE_V1_1_1 *)InterpProp; + DestroyAccountService_V1_1_1_CS (AccountServiceV1_1_1->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_1_1/RedfishAccountService_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_1_1/RedfishAccountService_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..47756f1f87f --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_1_1/RedfishAccountService_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_1_1_Dxe + FILE_GUID = ffd84a64-af18-4cd4-a12f-ddf3068231d0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_1_2/AccountService_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_1_2/AccountService_V1_1_2_Dxe.c new file mode 100644 index 00000000000..86d1bc4065c --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_1_2/AccountService_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "1", + "2" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_1_2 *AccountServiceV1_1_2; + EFI_REDFISH_ACCOUNTSERVICE_V1_1_2_CS *AccountServiceV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_1_2_To_CS (ResoruceRaw, &AccountServiceV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_1_2 = (EFI_REDFISH_ACCOUNTSERVICE_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_1_2)); + if (AccountServiceV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_1_2; + AccountServiceV1_1_2->AccountService = AccountServiceV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_1_2_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_1_2 *AccountServiceV1_1_2; + + AccountServiceV1_1_2 = (EFI_REDFISH_ACCOUNTSERVICE_V1_1_2 *)InterpProp; + DestroyAccountService_V1_1_2_CS (AccountServiceV1_1_2->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_1_2/RedfishAccountService_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_1_2/RedfishAccountService_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..f24f595c526 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_1_2/RedfishAccountService_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_1_2_Dxe + FILE_GUID = eabf30c8-9ab8-482e-a938-e1f5f654bb34 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_1_3/AccountService_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_1_3/AccountService_V1_1_3_Dxe.c new file mode 100644 index 00000000000..0dcc391e49d --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_1_3/AccountService_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "1", + "3" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_1_3 *AccountServiceV1_1_3; + EFI_REDFISH_ACCOUNTSERVICE_V1_1_3_CS *AccountServiceV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_1_3_To_CS (ResoruceRaw, &AccountServiceV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_1_3 = (EFI_REDFISH_ACCOUNTSERVICE_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_1_3)); + if (AccountServiceV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_1_3; + AccountServiceV1_1_3->AccountService = AccountServiceV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_1_3_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_1_3 *AccountServiceV1_1_3; + + AccountServiceV1_1_3 = (EFI_REDFISH_ACCOUNTSERVICE_V1_1_3 *)InterpProp; + DestroyAccountService_V1_1_3_CS (AccountServiceV1_1_3->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_1_3/RedfishAccountService_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_1_3/RedfishAccountService_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..e42964571d7 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_1_3/RedfishAccountService_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_1_3_Dxe + FILE_GUID = 43ba30ad-016f-4d40-b8c5-82ded25c2173 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_1_4/AccountService_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_1_4/AccountService_V1_1_4_Dxe.c new file mode 100644 index 00000000000..fe564cd5e73 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_1_4/AccountService_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "1", + "4" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_1_4 *AccountServiceV1_1_4; + EFI_REDFISH_ACCOUNTSERVICE_V1_1_4_CS *AccountServiceV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_1_4_To_CS (ResoruceRaw, &AccountServiceV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_1_4 = (EFI_REDFISH_ACCOUNTSERVICE_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_1_4)); + if (AccountServiceV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_1_4; + AccountServiceV1_1_4->AccountService = AccountServiceV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_1_4_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_1_4 *AccountServiceV1_1_4; + + AccountServiceV1_1_4 = (EFI_REDFISH_ACCOUNTSERVICE_V1_1_4 *)InterpProp; + DestroyAccountService_V1_1_4_CS (AccountServiceV1_1_4->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_1_4/RedfishAccountService_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_1_4/RedfishAccountService_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..d8ed8d4cce3 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_1_4/RedfishAccountService_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_1_4_Dxe + FILE_GUID = 187b16d8-51b0-4fc4-bee1-ca505c8fc904 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_1_5/AccountService_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_1_5/AccountService_V1_1_5_Dxe.c new file mode 100644 index 00000000000..421ec2b684d --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_1_5/AccountService_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "1", + "5" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_1_5 *AccountServiceV1_1_5; + EFI_REDFISH_ACCOUNTSERVICE_V1_1_5_CS *AccountServiceV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_1_5_To_CS (ResoruceRaw, &AccountServiceV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_1_5 = (EFI_REDFISH_ACCOUNTSERVICE_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_1_5)); + if (AccountServiceV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_1_5; + AccountServiceV1_1_5->AccountService = AccountServiceV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_1_5_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_1_5 *AccountServiceV1_1_5; + + AccountServiceV1_1_5 = (EFI_REDFISH_ACCOUNTSERVICE_V1_1_5 *)InterpProp; + DestroyAccountService_V1_1_5_CS (AccountServiceV1_1_5->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_1_5/RedfishAccountService_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_1_5/RedfishAccountService_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..c6cd17deeec --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_1_5/RedfishAccountService_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_1_5_Dxe + FILE_GUID = b73258fd-5513-4aa1-92ec-7362d4e9cef1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_1_6/AccountService_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_1_6/AccountService_V1_1_6_Dxe.c new file mode 100644 index 00000000000..f327249ca47 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_1_6/AccountService_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "1", + "6" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_1_6 *AccountServiceV1_1_6; + EFI_REDFISH_ACCOUNTSERVICE_V1_1_6_CS *AccountServiceV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_1_6_To_CS (ResoruceRaw, &AccountServiceV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_1_6 = (EFI_REDFISH_ACCOUNTSERVICE_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_1_6)); + if (AccountServiceV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_1_6; + AccountServiceV1_1_6->AccountService = AccountServiceV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_1_6_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_1_6 *AccountServiceV1_1_6; + + AccountServiceV1_1_6 = (EFI_REDFISH_ACCOUNTSERVICE_V1_1_6 *)InterpProp; + DestroyAccountService_V1_1_6_CS (AccountServiceV1_1_6->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_1_6/RedfishAccountService_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_1_6/RedfishAccountService_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..83a70caad89 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_1_6/RedfishAccountService_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_1_6_Dxe + FILE_GUID = e0064b69-f368-4d4b-954c-c7c06f20499e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_1_7/AccountService_V1_1_7_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_1_7/AccountService_V1_1_7_Dxe.c new file mode 100644 index 00000000000..b8bdf070669 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_1_7/AccountService_V1_1_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_1_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "1", + "7" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_1_7 *AccountServiceV1_1_7; + EFI_REDFISH_ACCOUNTSERVICE_V1_1_7_CS *AccountServiceV1_1_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_1_7_To_CS (ResoruceRaw, &AccountServiceV1_1_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_1_7 = (EFI_REDFISH_ACCOUNTSERVICE_V1_1_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_1_7)); + if (AccountServiceV1_1_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_1_7; + AccountServiceV1_1_7->AccountService = AccountServiceV1_1_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_1_7_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_1_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_1_7 *AccountServiceV1_1_7; + + AccountServiceV1_1_7 = (EFI_REDFISH_ACCOUNTSERVICE_V1_1_7 *)InterpProp; + DestroyAccountService_V1_1_7_CS (AccountServiceV1_1_7->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_1_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_1_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_1_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_1_7/RedfishAccountService_V1_1_7_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_1_7/RedfishAccountService_V1_1_7_Dxe.inf new file mode 100644 index 00000000000..c4d17d2d994 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_1_7/RedfishAccountService_V1_1_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_1_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_1_7_Dxe + FILE_GUID = 8d5fae24-69ef-4a7b-ae63-6d8b0d7efc5d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_1_7EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_1_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_1_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_1_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_1_8/AccountService_V1_1_8_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_1_8/AccountService_V1_1_8_Dxe.c new file mode 100644 index 00000000000..f9dc0e4d483 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_1_8/AccountService_V1_1_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_1_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "1", + "8" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_1_8 *AccountServiceV1_1_8; + EFI_REDFISH_ACCOUNTSERVICE_V1_1_8_CS *AccountServiceV1_1_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_1_8_To_CS (ResoruceRaw, &AccountServiceV1_1_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_1_8 = (EFI_REDFISH_ACCOUNTSERVICE_V1_1_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_1_8)); + if (AccountServiceV1_1_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_1_8; + AccountServiceV1_1_8->AccountService = AccountServiceV1_1_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_1_8_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_1_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_1_8 *AccountServiceV1_1_8; + + AccountServiceV1_1_8 = (EFI_REDFISH_ACCOUNTSERVICE_V1_1_8 *)InterpProp; + DestroyAccountService_V1_1_8_CS (AccountServiceV1_1_8->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_1_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_1_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_1_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_1_8/RedfishAccountService_V1_1_8_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_1_8/RedfishAccountService_V1_1_8_Dxe.inf new file mode 100644 index 00000000000..35694274bab --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_1_8/RedfishAccountService_V1_1_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_1_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_1_8_Dxe + FILE_GUID = 8fe54ae4-8580-459c-a2ff-f887cfc435a6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_1_8EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_1_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_1_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_1_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_2_0/AccountService_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_2_0/AccountService_V1_2_0_Dxe.c new file mode 100644 index 00000000000..311897438bf --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_2_0/AccountService_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "2", + "0" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_2_0 *AccountServiceV1_2_0; + EFI_REDFISH_ACCOUNTSERVICE_V1_2_0_CS *AccountServiceV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_2_0_To_CS (ResoruceRaw, &AccountServiceV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_2_0 = (EFI_REDFISH_ACCOUNTSERVICE_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_2_0)); + if (AccountServiceV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_2_0; + AccountServiceV1_2_0->AccountService = AccountServiceV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_2_0_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_2_0 *AccountServiceV1_2_0; + + AccountServiceV1_2_0 = (EFI_REDFISH_ACCOUNTSERVICE_V1_2_0 *)InterpProp; + DestroyAccountService_V1_2_0_CS (AccountServiceV1_2_0->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_2_0/RedfishAccountService_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_2_0/RedfishAccountService_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..6b863bb79d4 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_2_0/RedfishAccountService_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_2_0_Dxe + FILE_GUID = 3621bce0-6b65-48f3-9769-d4f4a2ff644b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_2_1/AccountService_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_2_1/AccountService_V1_2_1_Dxe.c new file mode 100644 index 00000000000..b47e96499c8 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_2_1/AccountService_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "2", + "1" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_2_1 *AccountServiceV1_2_1; + EFI_REDFISH_ACCOUNTSERVICE_V1_2_1_CS *AccountServiceV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_2_1_To_CS (ResoruceRaw, &AccountServiceV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_2_1 = (EFI_REDFISH_ACCOUNTSERVICE_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_2_1)); + if (AccountServiceV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_2_1; + AccountServiceV1_2_1->AccountService = AccountServiceV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_2_1_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_2_1 *AccountServiceV1_2_1; + + AccountServiceV1_2_1 = (EFI_REDFISH_ACCOUNTSERVICE_V1_2_1 *)InterpProp; + DestroyAccountService_V1_2_1_CS (AccountServiceV1_2_1->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_2_1/RedfishAccountService_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_2_1/RedfishAccountService_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..9271ed88795 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_2_1/RedfishAccountService_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_2_1_Dxe + FILE_GUID = 4c29f40b-22de-4aa9-bb1f-ac3208a6c0f3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_2_2/AccountService_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_2_2/AccountService_V1_2_2_Dxe.c new file mode 100644 index 00000000000..5b4a8cf7561 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_2_2/AccountService_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "2", + "2" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_2_2 *AccountServiceV1_2_2; + EFI_REDFISH_ACCOUNTSERVICE_V1_2_2_CS *AccountServiceV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_2_2_To_CS (ResoruceRaw, &AccountServiceV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_2_2 = (EFI_REDFISH_ACCOUNTSERVICE_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_2_2)); + if (AccountServiceV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_2_2; + AccountServiceV1_2_2->AccountService = AccountServiceV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_2_2_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_2_2 *AccountServiceV1_2_2; + + AccountServiceV1_2_2 = (EFI_REDFISH_ACCOUNTSERVICE_V1_2_2 *)InterpProp; + DestroyAccountService_V1_2_2_CS (AccountServiceV1_2_2->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_2_2/RedfishAccountService_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_2_2/RedfishAccountService_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..7b1c8f58c04 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_2_2/RedfishAccountService_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_2_2_Dxe + FILE_GUID = f61ec831-e052-4ae7-8326-ff3c9e1532fe + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_2_3/AccountService_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_2_3/AccountService_V1_2_3_Dxe.c new file mode 100644 index 00000000000..d2a1b3b4ab2 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_2_3/AccountService_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "2", + "3" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_2_3 *AccountServiceV1_2_3; + EFI_REDFISH_ACCOUNTSERVICE_V1_2_3_CS *AccountServiceV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_2_3_To_CS (ResoruceRaw, &AccountServiceV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_2_3 = (EFI_REDFISH_ACCOUNTSERVICE_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_2_3)); + if (AccountServiceV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_2_3; + AccountServiceV1_2_3->AccountService = AccountServiceV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_2_3_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_2_3 *AccountServiceV1_2_3; + + AccountServiceV1_2_3 = (EFI_REDFISH_ACCOUNTSERVICE_V1_2_3 *)InterpProp; + DestroyAccountService_V1_2_3_CS (AccountServiceV1_2_3->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_2_3/RedfishAccountService_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_2_3/RedfishAccountService_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..a9fe50d3e19 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_2_3/RedfishAccountService_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_2_3_Dxe + FILE_GUID = 1911b9f4-89fa-497d-95b2-c9b5cdb11829 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_2_4/AccountService_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_2_4/AccountService_V1_2_4_Dxe.c new file mode 100644 index 00000000000..e67d6f1e546 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_2_4/AccountService_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "2", + "4" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_2_4 *AccountServiceV1_2_4; + EFI_REDFISH_ACCOUNTSERVICE_V1_2_4_CS *AccountServiceV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_2_4_To_CS (ResoruceRaw, &AccountServiceV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_2_4 = (EFI_REDFISH_ACCOUNTSERVICE_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_2_4)); + if (AccountServiceV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_2_4; + AccountServiceV1_2_4->AccountService = AccountServiceV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_2_4_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_2_4 *AccountServiceV1_2_4; + + AccountServiceV1_2_4 = (EFI_REDFISH_ACCOUNTSERVICE_V1_2_4 *)InterpProp; + DestroyAccountService_V1_2_4_CS (AccountServiceV1_2_4->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_2_4/RedfishAccountService_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_2_4/RedfishAccountService_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..cfd25969289 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_2_4/RedfishAccountService_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_2_4_Dxe + FILE_GUID = c397ee53-bbf1-4a67-a001-0acdefc64a18 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_2_5/AccountService_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_2_5/AccountService_V1_2_5_Dxe.c new file mode 100644 index 00000000000..ade6d8d30e1 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_2_5/AccountService_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "2", + "5" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_2_5 *AccountServiceV1_2_5; + EFI_REDFISH_ACCOUNTSERVICE_V1_2_5_CS *AccountServiceV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_2_5_To_CS (ResoruceRaw, &AccountServiceV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_2_5 = (EFI_REDFISH_ACCOUNTSERVICE_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_2_5)); + if (AccountServiceV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_2_5; + AccountServiceV1_2_5->AccountService = AccountServiceV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_2_5_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_2_5 *AccountServiceV1_2_5; + + AccountServiceV1_2_5 = (EFI_REDFISH_ACCOUNTSERVICE_V1_2_5 *)InterpProp; + DestroyAccountService_V1_2_5_CS (AccountServiceV1_2_5->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_2_5/RedfishAccountService_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_2_5/RedfishAccountService_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..153db668164 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_2_5/RedfishAccountService_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_2_5_Dxe + FILE_GUID = bc5012a7-870b-4860-bc36-77b124a29039 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_2_6/AccountService_V1_2_6_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_2_6/AccountService_V1_2_6_Dxe.c new file mode 100644 index 00000000000..75fa2fcd238 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_2_6/AccountService_V1_2_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_2_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "2", + "6" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_2_6 *AccountServiceV1_2_6; + EFI_REDFISH_ACCOUNTSERVICE_V1_2_6_CS *AccountServiceV1_2_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_2_6_To_CS (ResoruceRaw, &AccountServiceV1_2_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_2_6 = (EFI_REDFISH_ACCOUNTSERVICE_V1_2_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_2_6)); + if (AccountServiceV1_2_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_2_6; + AccountServiceV1_2_6->AccountService = AccountServiceV1_2_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_2_6_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_2_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_2_6 *AccountServiceV1_2_6; + + AccountServiceV1_2_6 = (EFI_REDFISH_ACCOUNTSERVICE_V1_2_6 *)InterpProp; + DestroyAccountService_V1_2_6_CS (AccountServiceV1_2_6->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_2_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_2_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_2_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_2_6/RedfishAccountService_V1_2_6_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_2_6/RedfishAccountService_V1_2_6_Dxe.inf new file mode 100644 index 00000000000..928d1efd70d --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_2_6/RedfishAccountService_V1_2_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_2_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_2_6_Dxe + FILE_GUID = eb405a63-a918-437f-8781-735efc12a3a9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_2_6EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_2_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_2_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_2_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_2_7/AccountService_V1_2_7_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_2_7/AccountService_V1_2_7_Dxe.c new file mode 100644 index 00000000000..b6143febf33 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_2_7/AccountService_V1_2_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_2_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "2", + "7" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_2_7 *AccountServiceV1_2_7; + EFI_REDFISH_ACCOUNTSERVICE_V1_2_7_CS *AccountServiceV1_2_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_2_7_To_CS (ResoruceRaw, &AccountServiceV1_2_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_2_7 = (EFI_REDFISH_ACCOUNTSERVICE_V1_2_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_2_7)); + if (AccountServiceV1_2_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_2_7; + AccountServiceV1_2_7->AccountService = AccountServiceV1_2_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_2_7_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_2_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_2_7 *AccountServiceV1_2_7; + + AccountServiceV1_2_7 = (EFI_REDFISH_ACCOUNTSERVICE_V1_2_7 *)InterpProp; + DestroyAccountService_V1_2_7_CS (AccountServiceV1_2_7->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_2_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_2_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_2_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_2_7/RedfishAccountService_V1_2_7_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_2_7/RedfishAccountService_V1_2_7_Dxe.inf new file mode 100644 index 00000000000..8b1f88ce52e --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_2_7/RedfishAccountService_V1_2_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_2_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_2_7_Dxe + FILE_GUID = 373e6c0e-d258-42c2-a991-ca8cc47004cb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_2_7EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_2_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_2_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_2_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_2_8/AccountService_V1_2_8_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_2_8/AccountService_V1_2_8_Dxe.c new file mode 100644 index 00000000000..bf1acf10662 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_2_8/AccountService_V1_2_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_2_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "2", + "8" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_2_8 *AccountServiceV1_2_8; + EFI_REDFISH_ACCOUNTSERVICE_V1_2_8_CS *AccountServiceV1_2_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_2_8_To_CS (ResoruceRaw, &AccountServiceV1_2_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_2_8 = (EFI_REDFISH_ACCOUNTSERVICE_V1_2_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_2_8)); + if (AccountServiceV1_2_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_2_8; + AccountServiceV1_2_8->AccountService = AccountServiceV1_2_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_2_8_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_2_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_2_8 *AccountServiceV1_2_8; + + AccountServiceV1_2_8 = (EFI_REDFISH_ACCOUNTSERVICE_V1_2_8 *)InterpProp; + DestroyAccountService_V1_2_8_CS (AccountServiceV1_2_8->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_2_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_2_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_2_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_2_8/RedfishAccountService_V1_2_8_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_2_8/RedfishAccountService_V1_2_8_Dxe.inf new file mode 100644 index 00000000000..aadf26bc500 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_2_8/RedfishAccountService_V1_2_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_2_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_2_8_Dxe + FILE_GUID = c3063e1b-b2a0-4ab8-9001-ea75e5ebfe41 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_2_8EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_2_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_2_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_2_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_3_0/AccountService_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_3_0/AccountService_V1_3_0_Dxe.c new file mode 100644 index 00000000000..b3bd4d8a416 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_3_0/AccountService_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "3", + "0" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_3_0 *AccountServiceV1_3_0; + EFI_REDFISH_ACCOUNTSERVICE_V1_3_0_CS *AccountServiceV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_3_0_To_CS (ResoruceRaw, &AccountServiceV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_3_0 = (EFI_REDFISH_ACCOUNTSERVICE_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_3_0)); + if (AccountServiceV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_3_0; + AccountServiceV1_3_0->AccountService = AccountServiceV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_3_0_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_3_0 *AccountServiceV1_3_0; + + AccountServiceV1_3_0 = (EFI_REDFISH_ACCOUNTSERVICE_V1_3_0 *)InterpProp; + DestroyAccountService_V1_3_0_CS (AccountServiceV1_3_0->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_3_0/RedfishAccountService_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_3_0/RedfishAccountService_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..6e17c46f18b --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_3_0/RedfishAccountService_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_3_0_Dxe + FILE_GUID = ea554654-444c-4e18-bd28-5b52796c88a3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_3_1/AccountService_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_3_1/AccountService_V1_3_1_Dxe.c new file mode 100644 index 00000000000..f6382f33852 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_3_1/AccountService_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "3", + "1" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_3_1 *AccountServiceV1_3_1; + EFI_REDFISH_ACCOUNTSERVICE_V1_3_1_CS *AccountServiceV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_3_1_To_CS (ResoruceRaw, &AccountServiceV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_3_1 = (EFI_REDFISH_ACCOUNTSERVICE_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_3_1)); + if (AccountServiceV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_3_1; + AccountServiceV1_3_1->AccountService = AccountServiceV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_3_1_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_3_1 *AccountServiceV1_3_1; + + AccountServiceV1_3_1 = (EFI_REDFISH_ACCOUNTSERVICE_V1_3_1 *)InterpProp; + DestroyAccountService_V1_3_1_CS (AccountServiceV1_3_1->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_3_1/RedfishAccountService_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_3_1/RedfishAccountService_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..fbf2842c534 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_3_1/RedfishAccountService_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_3_1_Dxe + FILE_GUID = f49d0c2d-6157-4e23-9432-61098dae9418 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_3_2/AccountService_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_3_2/AccountService_V1_3_2_Dxe.c new file mode 100644 index 00000000000..748eeec0d6d --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_3_2/AccountService_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "3", + "2" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_3_2 *AccountServiceV1_3_2; + EFI_REDFISH_ACCOUNTSERVICE_V1_3_2_CS *AccountServiceV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_3_2_To_CS (ResoruceRaw, &AccountServiceV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_3_2 = (EFI_REDFISH_ACCOUNTSERVICE_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_3_2)); + if (AccountServiceV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_3_2; + AccountServiceV1_3_2->AccountService = AccountServiceV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_3_2_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_3_2 *AccountServiceV1_3_2; + + AccountServiceV1_3_2 = (EFI_REDFISH_ACCOUNTSERVICE_V1_3_2 *)InterpProp; + DestroyAccountService_V1_3_2_CS (AccountServiceV1_3_2->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_3_2/RedfishAccountService_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_3_2/RedfishAccountService_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..37d14f1af5f --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_3_2/RedfishAccountService_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_3_2_Dxe + FILE_GUID = 82d2b900-9fe7-46db-a06d-42ef8d19ae86 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_3_3/AccountService_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_3_3/AccountService_V1_3_3_Dxe.c new file mode 100644 index 00000000000..4d6f18a4e7d --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_3_3/AccountService_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "3", + "3" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_3_3 *AccountServiceV1_3_3; + EFI_REDFISH_ACCOUNTSERVICE_V1_3_3_CS *AccountServiceV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_3_3_To_CS (ResoruceRaw, &AccountServiceV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_3_3 = (EFI_REDFISH_ACCOUNTSERVICE_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_3_3)); + if (AccountServiceV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_3_3; + AccountServiceV1_3_3->AccountService = AccountServiceV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_3_3_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_3_3 *AccountServiceV1_3_3; + + AccountServiceV1_3_3 = (EFI_REDFISH_ACCOUNTSERVICE_V1_3_3 *)InterpProp; + DestroyAccountService_V1_3_3_CS (AccountServiceV1_3_3->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_3_3/RedfishAccountService_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_3_3/RedfishAccountService_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..fc59bbc2f9c --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_3_3/RedfishAccountService_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_3_3_Dxe + FILE_GUID = 279ff17b-6498-4f26-a4ab-fafc6c2ca783 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_3_4/AccountService_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_3_4/AccountService_V1_3_4_Dxe.c new file mode 100644 index 00000000000..20e7e011747 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_3_4/AccountService_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "3", + "4" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_3_4 *AccountServiceV1_3_4; + EFI_REDFISH_ACCOUNTSERVICE_V1_3_4_CS *AccountServiceV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_3_4_To_CS (ResoruceRaw, &AccountServiceV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_3_4 = (EFI_REDFISH_ACCOUNTSERVICE_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_3_4)); + if (AccountServiceV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_3_4; + AccountServiceV1_3_4->AccountService = AccountServiceV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_3_4_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_3_4 *AccountServiceV1_3_4; + + AccountServiceV1_3_4 = (EFI_REDFISH_ACCOUNTSERVICE_V1_3_4 *)InterpProp; + DestroyAccountService_V1_3_4_CS (AccountServiceV1_3_4->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_3_4/RedfishAccountService_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_3_4/RedfishAccountService_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..30fd17beca5 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_3_4/RedfishAccountService_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_3_4_Dxe + FILE_GUID = 91733920-5c68-4bac-85cc-3094a545653e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_3_5/AccountService_V1_3_5_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_3_5/AccountService_V1_3_5_Dxe.c new file mode 100644 index 00000000000..70a9d2de7ba --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_3_5/AccountService_V1_3_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_3_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "3", + "5" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_3_5 *AccountServiceV1_3_5; + EFI_REDFISH_ACCOUNTSERVICE_V1_3_5_CS *AccountServiceV1_3_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_3_5_To_CS (ResoruceRaw, &AccountServiceV1_3_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_3_5 = (EFI_REDFISH_ACCOUNTSERVICE_V1_3_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_3_5)); + if (AccountServiceV1_3_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_3_5; + AccountServiceV1_3_5->AccountService = AccountServiceV1_3_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_3_5_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_3_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_3_5 *AccountServiceV1_3_5; + + AccountServiceV1_3_5 = (EFI_REDFISH_ACCOUNTSERVICE_V1_3_5 *)InterpProp; + DestroyAccountService_V1_3_5_CS (AccountServiceV1_3_5->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_3_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_3_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_3_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_3_5/RedfishAccountService_V1_3_5_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_3_5/RedfishAccountService_V1_3_5_Dxe.inf new file mode 100644 index 00000000000..47843cfd557 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_3_5/RedfishAccountService_V1_3_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_3_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_3_5_Dxe + FILE_GUID = 5701e5e4-2f8e-40c8-84d8-51dd5dddd5cd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_3_5EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_3_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_3_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_3_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_3_6/AccountService_V1_3_6_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_3_6/AccountService_V1_3_6_Dxe.c new file mode 100644 index 00000000000..871a9327a41 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_3_6/AccountService_V1_3_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_3_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "3", + "6" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_3_6 *AccountServiceV1_3_6; + EFI_REDFISH_ACCOUNTSERVICE_V1_3_6_CS *AccountServiceV1_3_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_3_6_To_CS (ResoruceRaw, &AccountServiceV1_3_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_3_6 = (EFI_REDFISH_ACCOUNTSERVICE_V1_3_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_3_6)); + if (AccountServiceV1_3_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_3_6; + AccountServiceV1_3_6->AccountService = AccountServiceV1_3_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_3_6_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_3_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_3_6 *AccountServiceV1_3_6; + + AccountServiceV1_3_6 = (EFI_REDFISH_ACCOUNTSERVICE_V1_3_6 *)InterpProp; + DestroyAccountService_V1_3_6_CS (AccountServiceV1_3_6->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_3_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_3_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_3_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_3_6/RedfishAccountService_V1_3_6_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_3_6/RedfishAccountService_V1_3_6_Dxe.inf new file mode 100644 index 00000000000..5ff22c9a644 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_3_6/RedfishAccountService_V1_3_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_3_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_3_6_Dxe + FILE_GUID = 2ff2c83c-8688-4d9d-9c44-2de50e856956 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_3_6EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_3_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_3_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_3_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_3_7/AccountService_V1_3_7_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_3_7/AccountService_V1_3_7_Dxe.c new file mode 100644 index 00000000000..75ca59791d8 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_3_7/AccountService_V1_3_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_3_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_3_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "3", + "7" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_3_7 *AccountServiceV1_3_7; + EFI_REDFISH_ACCOUNTSERVICE_V1_3_7_CS *AccountServiceV1_3_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_3_7_To_CS (ResoruceRaw, &AccountServiceV1_3_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_3_7 = (EFI_REDFISH_ACCOUNTSERVICE_V1_3_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_3_7)); + if (AccountServiceV1_3_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_3_7; + AccountServiceV1_3_7->AccountService = AccountServiceV1_3_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_3_7_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_3_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_3_7 *AccountServiceV1_3_7; + + AccountServiceV1_3_7 = (EFI_REDFISH_ACCOUNTSERVICE_V1_3_7 *)InterpProp; + DestroyAccountService_V1_3_7_CS (AccountServiceV1_3_7->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_3_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_3_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_3_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_3_7/RedfishAccountService_V1_3_7_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_3_7/RedfishAccountService_V1_3_7_Dxe.inf new file mode 100644 index 00000000000..2ff4a33348a --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_3_7/RedfishAccountService_V1_3_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_3_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_3_7_Dxe + FILE_GUID = 0552a5a6-a1a3-4a60-b3bc-f331e892476a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_3_7EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_3_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_3_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_3_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_4_0/AccountService_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_4_0/AccountService_V1_4_0_Dxe.c new file mode 100644 index 00000000000..a715e1b1c10 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_4_0/AccountService_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "4", + "0" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_4_0 *AccountServiceV1_4_0; + EFI_REDFISH_ACCOUNTSERVICE_V1_4_0_CS *AccountServiceV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_4_0_To_CS (ResoruceRaw, &AccountServiceV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_4_0 = (EFI_REDFISH_ACCOUNTSERVICE_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_4_0)); + if (AccountServiceV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_4_0; + AccountServiceV1_4_0->AccountService = AccountServiceV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_4_0_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_4_0 *AccountServiceV1_4_0; + + AccountServiceV1_4_0 = (EFI_REDFISH_ACCOUNTSERVICE_V1_4_0 *)InterpProp; + DestroyAccountService_V1_4_0_CS (AccountServiceV1_4_0->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_4_0/RedfishAccountService_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_4_0/RedfishAccountService_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..d8c01ec2481 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_4_0/RedfishAccountService_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_4_0_Dxe + FILE_GUID = addf63c8-415d-4d9e-b379-5b4a591ab66e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_4_1/AccountService_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_4_1/AccountService_V1_4_1_Dxe.c new file mode 100644 index 00000000000..a1240c4fa22 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_4_1/AccountService_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "4", + "1" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_4_1 *AccountServiceV1_4_1; + EFI_REDFISH_ACCOUNTSERVICE_V1_4_1_CS *AccountServiceV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_4_1_To_CS (ResoruceRaw, &AccountServiceV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_4_1 = (EFI_REDFISH_ACCOUNTSERVICE_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_4_1)); + if (AccountServiceV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_4_1; + AccountServiceV1_4_1->AccountService = AccountServiceV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_4_1_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_4_1 *AccountServiceV1_4_1; + + AccountServiceV1_4_1 = (EFI_REDFISH_ACCOUNTSERVICE_V1_4_1 *)InterpProp; + DestroyAccountService_V1_4_1_CS (AccountServiceV1_4_1->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_4_1/RedfishAccountService_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_4_1/RedfishAccountService_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..843ea02e610 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_4_1/RedfishAccountService_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_4_1_Dxe + FILE_GUID = cd4d92d4-8103-41f7-9600-8daac452730e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_4_2/AccountService_V1_4_2_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_4_2/AccountService_V1_4_2_Dxe.c new file mode 100644 index 00000000000..ceba965b571 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_4_2/AccountService_V1_4_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_4_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "4", + "2" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_4_2 *AccountServiceV1_4_2; + EFI_REDFISH_ACCOUNTSERVICE_V1_4_2_CS *AccountServiceV1_4_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_4_2_To_CS (ResoruceRaw, &AccountServiceV1_4_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_4_2 = (EFI_REDFISH_ACCOUNTSERVICE_V1_4_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_4_2)); + if (AccountServiceV1_4_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_4_2; + AccountServiceV1_4_2->AccountService = AccountServiceV1_4_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_4_2_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_4_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_4_2 *AccountServiceV1_4_2; + + AccountServiceV1_4_2 = (EFI_REDFISH_ACCOUNTSERVICE_V1_4_2 *)InterpProp; + DestroyAccountService_V1_4_2_CS (AccountServiceV1_4_2->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_4_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_4_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_4_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_4_2/RedfishAccountService_V1_4_2_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_4_2/RedfishAccountService_V1_4_2_Dxe.inf new file mode 100644 index 00000000000..7a782696f03 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_4_2/RedfishAccountService_V1_4_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_4_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_4_2_Dxe + FILE_GUID = 6b293d4b-141b-428d-8899-1031d26d8a5f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_4_2EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_4_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_4_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_4_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_4_3/AccountService_V1_4_3_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_4_3/AccountService_V1_4_3_Dxe.c new file mode 100644 index 00000000000..d6c255edfd5 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_4_3/AccountService_V1_4_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_4_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "4", + "3" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_4_3 *AccountServiceV1_4_3; + EFI_REDFISH_ACCOUNTSERVICE_V1_4_3_CS *AccountServiceV1_4_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_4_3_To_CS (ResoruceRaw, &AccountServiceV1_4_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_4_3 = (EFI_REDFISH_ACCOUNTSERVICE_V1_4_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_4_3)); + if (AccountServiceV1_4_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_4_3; + AccountServiceV1_4_3->AccountService = AccountServiceV1_4_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_4_3_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_4_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_4_3 *AccountServiceV1_4_3; + + AccountServiceV1_4_3 = (EFI_REDFISH_ACCOUNTSERVICE_V1_4_3 *)InterpProp; + DestroyAccountService_V1_4_3_CS (AccountServiceV1_4_3->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_4_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_4_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_4_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_4_3/RedfishAccountService_V1_4_3_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_4_3/RedfishAccountService_V1_4_3_Dxe.inf new file mode 100644 index 00000000000..5a4e771c40a --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_4_3/RedfishAccountService_V1_4_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_4_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_4_3_Dxe + FILE_GUID = 36c3e826-7d91-48f9-9e3f-3ab4552ae5f1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_4_3EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_4_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_4_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_4_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_4_4/AccountService_V1_4_4_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_4_4/AccountService_V1_4_4_Dxe.c new file mode 100644 index 00000000000..a49157db4b2 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_4_4/AccountService_V1_4_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_4_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "4", + "4" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_4_4 *AccountServiceV1_4_4; + EFI_REDFISH_ACCOUNTSERVICE_V1_4_4_CS *AccountServiceV1_4_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_4_4_To_CS (ResoruceRaw, &AccountServiceV1_4_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_4_4 = (EFI_REDFISH_ACCOUNTSERVICE_V1_4_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_4_4)); + if (AccountServiceV1_4_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_4_4; + AccountServiceV1_4_4->AccountService = AccountServiceV1_4_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_4_4_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_4_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_4_4 *AccountServiceV1_4_4; + + AccountServiceV1_4_4 = (EFI_REDFISH_ACCOUNTSERVICE_V1_4_4 *)InterpProp; + DestroyAccountService_V1_4_4_CS (AccountServiceV1_4_4->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_4_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_4_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_4_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_4_4/RedfishAccountService_V1_4_4_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_4_4/RedfishAccountService_V1_4_4_Dxe.inf new file mode 100644 index 00000000000..77a7da2abc5 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_4_4/RedfishAccountService_V1_4_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_4_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_4_4_Dxe + FILE_GUID = acd75fd9-884b-428f-b837-3817fa80d680 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_4_4EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_4_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_4_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_4_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_4_5/AccountService_V1_4_5_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_4_5/AccountService_V1_4_5_Dxe.c new file mode 100644 index 00000000000..7219770bd9d --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_4_5/AccountService_V1_4_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_4_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "4", + "5" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_4_5 *AccountServiceV1_4_5; + EFI_REDFISH_ACCOUNTSERVICE_V1_4_5_CS *AccountServiceV1_4_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_4_5_To_CS (ResoruceRaw, &AccountServiceV1_4_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_4_5 = (EFI_REDFISH_ACCOUNTSERVICE_V1_4_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_4_5)); + if (AccountServiceV1_4_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_4_5; + AccountServiceV1_4_5->AccountService = AccountServiceV1_4_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_4_5_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_4_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_4_5 *AccountServiceV1_4_5; + + AccountServiceV1_4_5 = (EFI_REDFISH_ACCOUNTSERVICE_V1_4_5 *)InterpProp; + DestroyAccountService_V1_4_5_CS (AccountServiceV1_4_5->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_4_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_4_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_4_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_4_5/RedfishAccountService_V1_4_5_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_4_5/RedfishAccountService_V1_4_5_Dxe.inf new file mode 100644 index 00000000000..2c1980dc629 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_4_5/RedfishAccountService_V1_4_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_4_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_4_5_Dxe + FILE_GUID = 5cbee5cc-70f9-498a-bc93-8873527af6c5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_4_5EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_4_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_4_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_4_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_5_0/AccountService_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_5_0/AccountService_V1_5_0_Dxe.c new file mode 100644 index 00000000000..b3a183c2ab6 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_5_0/AccountService_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "5", + "0" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_5_0 *AccountServiceV1_5_0; + EFI_REDFISH_ACCOUNTSERVICE_V1_5_0_CS *AccountServiceV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_5_0_To_CS (ResoruceRaw, &AccountServiceV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_5_0 = (EFI_REDFISH_ACCOUNTSERVICE_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_5_0)); + if (AccountServiceV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_5_0; + AccountServiceV1_5_0->AccountService = AccountServiceV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_5_0_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_5_0 *AccountServiceV1_5_0; + + AccountServiceV1_5_0 = (EFI_REDFISH_ACCOUNTSERVICE_V1_5_0 *)InterpProp; + DestroyAccountService_V1_5_0_CS (AccountServiceV1_5_0->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_5_0/RedfishAccountService_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_5_0/RedfishAccountService_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..f3d3b2d72ad --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_5_0/RedfishAccountService_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_5_0_Dxe + FILE_GUID = 0666341b-bc6c-4113-9a65-65afc26ff98b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_5_1/AccountService_V1_5_1_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_5_1/AccountService_V1_5_1_Dxe.c new file mode 100644 index 00000000000..8c2d6d1378a --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_5_1/AccountService_V1_5_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_5_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "5", + "1" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_5_1 *AccountServiceV1_5_1; + EFI_REDFISH_ACCOUNTSERVICE_V1_5_1_CS *AccountServiceV1_5_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_5_1_To_CS (ResoruceRaw, &AccountServiceV1_5_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_5_1 = (EFI_REDFISH_ACCOUNTSERVICE_V1_5_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_5_1)); + if (AccountServiceV1_5_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_5_1; + AccountServiceV1_5_1->AccountService = AccountServiceV1_5_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_5_1_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_5_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_5_1 *AccountServiceV1_5_1; + + AccountServiceV1_5_1 = (EFI_REDFISH_ACCOUNTSERVICE_V1_5_1 *)InterpProp; + DestroyAccountService_V1_5_1_CS (AccountServiceV1_5_1->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_5_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_5_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_5_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_5_1/RedfishAccountService_V1_5_1_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_5_1/RedfishAccountService_V1_5_1_Dxe.inf new file mode 100644 index 00000000000..f1b58c4ea18 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_5_1/RedfishAccountService_V1_5_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_5_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_5_1_Dxe + FILE_GUID = bb99a82a-c8d9-4853-a479-d480a9a8054e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_5_1EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_5_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_5_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_5_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_5_2/AccountService_V1_5_2_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_5_2/AccountService_V1_5_2_Dxe.c new file mode 100644 index 00000000000..32bf8d541c4 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_5_2/AccountService_V1_5_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_5_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "5", + "2" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_5_2 *AccountServiceV1_5_2; + EFI_REDFISH_ACCOUNTSERVICE_V1_5_2_CS *AccountServiceV1_5_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_5_2_To_CS (ResoruceRaw, &AccountServiceV1_5_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_5_2 = (EFI_REDFISH_ACCOUNTSERVICE_V1_5_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_5_2)); + if (AccountServiceV1_5_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_5_2; + AccountServiceV1_5_2->AccountService = AccountServiceV1_5_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_5_2_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_5_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_5_2 *AccountServiceV1_5_2; + + AccountServiceV1_5_2 = (EFI_REDFISH_ACCOUNTSERVICE_V1_5_2 *)InterpProp; + DestroyAccountService_V1_5_2_CS (AccountServiceV1_5_2->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_5_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_5_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_5_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_5_2/RedfishAccountService_V1_5_2_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_5_2/RedfishAccountService_V1_5_2_Dxe.inf new file mode 100644 index 00000000000..60c3834ca67 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_5_2/RedfishAccountService_V1_5_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_5_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_5_2_Dxe + FILE_GUID = 92ef52b4-cf29-4848-a405-621c5b9a8a9a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_5_2EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_5_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_5_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_5_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_5_3/AccountService_V1_5_3_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_5_3/AccountService_V1_5_3_Dxe.c new file mode 100644 index 00000000000..8493720630a --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_5_3/AccountService_V1_5_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_5_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "5", + "3" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_5_3 *AccountServiceV1_5_3; + EFI_REDFISH_ACCOUNTSERVICE_V1_5_3_CS *AccountServiceV1_5_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_5_3_To_CS (ResoruceRaw, &AccountServiceV1_5_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_5_3 = (EFI_REDFISH_ACCOUNTSERVICE_V1_5_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_5_3)); + if (AccountServiceV1_5_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_5_3; + AccountServiceV1_5_3->AccountService = AccountServiceV1_5_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_5_3_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_5_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_5_3 *AccountServiceV1_5_3; + + AccountServiceV1_5_3 = (EFI_REDFISH_ACCOUNTSERVICE_V1_5_3 *)InterpProp; + DestroyAccountService_V1_5_3_CS (AccountServiceV1_5_3->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_5_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_5_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_5_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_5_3/RedfishAccountService_V1_5_3_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_5_3/RedfishAccountService_V1_5_3_Dxe.inf new file mode 100644 index 00000000000..43456c7428d --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_5_3/RedfishAccountService_V1_5_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_5_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_5_3_Dxe + FILE_GUID = c06790c1-e910-439f-8d6b-443e05143fe6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_5_3EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_5_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_5_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_5_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_5_4/AccountService_V1_5_4_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_5_4/AccountService_V1_5_4_Dxe.c new file mode 100644 index 00000000000..98f3b652657 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_5_4/AccountService_V1_5_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_5_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "5", + "4" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_5_4 *AccountServiceV1_5_4; + EFI_REDFISH_ACCOUNTSERVICE_V1_5_4_CS *AccountServiceV1_5_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_5_4_To_CS (ResoruceRaw, &AccountServiceV1_5_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_5_4 = (EFI_REDFISH_ACCOUNTSERVICE_V1_5_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_5_4)); + if (AccountServiceV1_5_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_5_4; + AccountServiceV1_5_4->AccountService = AccountServiceV1_5_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_5_4_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_5_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_5_4 *AccountServiceV1_5_4; + + AccountServiceV1_5_4 = (EFI_REDFISH_ACCOUNTSERVICE_V1_5_4 *)InterpProp; + DestroyAccountService_V1_5_4_CS (AccountServiceV1_5_4->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_5_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_5_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_5_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_5_4/RedfishAccountService_V1_5_4_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_5_4/RedfishAccountService_V1_5_4_Dxe.inf new file mode 100644 index 00000000000..aeaefcda939 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_5_4/RedfishAccountService_V1_5_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_5_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_5_4_Dxe + FILE_GUID = 01b50736-0419-4030-9407-bb3ce5e2013b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_5_4EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_5_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_5_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_5_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_6_0/AccountService_V1_6_0_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_6_0/AccountService_V1_6_0_Dxe.c new file mode 100644 index 00000000000..d561fb8d55d --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_6_0/AccountService_V1_6_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_6_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "6", + "0" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_6_0 *AccountServiceV1_6_0; + EFI_REDFISH_ACCOUNTSERVICE_V1_6_0_CS *AccountServiceV1_6_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_6_0_To_CS (ResoruceRaw, &AccountServiceV1_6_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_6_0 = (EFI_REDFISH_ACCOUNTSERVICE_V1_6_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_6_0)); + if (AccountServiceV1_6_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_6_0; + AccountServiceV1_6_0->AccountService = AccountServiceV1_6_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_6_0_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_6_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_6_0 *AccountServiceV1_6_0; + + AccountServiceV1_6_0 = (EFI_REDFISH_ACCOUNTSERVICE_V1_6_0 *)InterpProp; + DestroyAccountService_V1_6_0_CS (AccountServiceV1_6_0->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_6_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_6_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_6_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_6_0/RedfishAccountService_V1_6_0_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_6_0/RedfishAccountService_V1_6_0_Dxe.inf new file mode 100644 index 00000000000..5563d889aa3 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_6_0/RedfishAccountService_V1_6_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_6_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_6_0_Dxe + FILE_GUID = fa8c32f8-a594-442f-9ce6-be0c9af06839 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_6_0EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_6_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_6_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_6_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_6_1/AccountService_V1_6_1_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_6_1/AccountService_V1_6_1_Dxe.c new file mode 100644 index 00000000000..bd33d30ce3d --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_6_1/AccountService_V1_6_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_6_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "6", + "1" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_6_1 *AccountServiceV1_6_1; + EFI_REDFISH_ACCOUNTSERVICE_V1_6_1_CS *AccountServiceV1_6_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_6_1_To_CS (ResoruceRaw, &AccountServiceV1_6_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_6_1 = (EFI_REDFISH_ACCOUNTSERVICE_V1_6_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_6_1)); + if (AccountServiceV1_6_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_6_1; + AccountServiceV1_6_1->AccountService = AccountServiceV1_6_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_6_1_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_6_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_6_1 *AccountServiceV1_6_1; + + AccountServiceV1_6_1 = (EFI_REDFISH_ACCOUNTSERVICE_V1_6_1 *)InterpProp; + DestroyAccountService_V1_6_1_CS (AccountServiceV1_6_1->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_6_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_6_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_6_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_6_1/RedfishAccountService_V1_6_1_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_6_1/RedfishAccountService_V1_6_1_Dxe.inf new file mode 100644 index 00000000000..b4df3c98c17 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_6_1/RedfishAccountService_V1_6_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_6_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_6_1_Dxe + FILE_GUID = e043c02a-fe50-475a-969b-71ad30198b3a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_6_1EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_6_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_6_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_6_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_6_2/AccountService_V1_6_2_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_6_2/AccountService_V1_6_2_Dxe.c new file mode 100644 index 00000000000..0e2a8a99f08 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_6_2/AccountService_V1_6_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_6_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "6", + "2" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_6_2 *AccountServiceV1_6_2; + EFI_REDFISH_ACCOUNTSERVICE_V1_6_2_CS *AccountServiceV1_6_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_6_2_To_CS (ResoruceRaw, &AccountServiceV1_6_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_6_2 = (EFI_REDFISH_ACCOUNTSERVICE_V1_6_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_6_2)); + if (AccountServiceV1_6_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_6_2; + AccountServiceV1_6_2->AccountService = AccountServiceV1_6_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_6_2_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_6_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_6_2 *AccountServiceV1_6_2; + + AccountServiceV1_6_2 = (EFI_REDFISH_ACCOUNTSERVICE_V1_6_2 *)InterpProp; + DestroyAccountService_V1_6_2_CS (AccountServiceV1_6_2->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_6_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_6_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_6_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_6_2/RedfishAccountService_V1_6_2_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_6_2/RedfishAccountService_V1_6_2_Dxe.inf new file mode 100644 index 00000000000..7643a0df3a5 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_6_2/RedfishAccountService_V1_6_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_6_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_6_2_Dxe + FILE_GUID = 274bf2ea-296d-4f27-8ae7-cf2f67f7aac6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_6_2EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_6_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_6_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_6_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_6_3/AccountService_V1_6_3_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_6_3/AccountService_V1_6_3_Dxe.c new file mode 100644 index 00000000000..9490ba78591 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_6_3/AccountService_V1_6_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_6_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_6_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "6", + "3" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_6_3 *AccountServiceV1_6_3; + EFI_REDFISH_ACCOUNTSERVICE_V1_6_3_CS *AccountServiceV1_6_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_6_3_To_CS (ResoruceRaw, &AccountServiceV1_6_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_6_3 = (EFI_REDFISH_ACCOUNTSERVICE_V1_6_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_6_3)); + if (AccountServiceV1_6_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_6_3; + AccountServiceV1_6_3->AccountService = AccountServiceV1_6_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_6_3_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_6_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_6_3 *AccountServiceV1_6_3; + + AccountServiceV1_6_3 = (EFI_REDFISH_ACCOUNTSERVICE_V1_6_3 *)InterpProp; + DestroyAccountService_V1_6_3_CS (AccountServiceV1_6_3->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_6_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_6_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_6_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_6_3/RedfishAccountService_V1_6_3_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_6_3/RedfishAccountService_V1_6_3_Dxe.inf new file mode 100644 index 00000000000..5ae3bb9ac51 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_6_3/RedfishAccountService_V1_6_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_6_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_6_3_Dxe + FILE_GUID = dbd2d690-3b02-4ac5-afd5-f93cea64ad4a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_6_3EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_6_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_6_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_6_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_7_0/AccountService_V1_7_0_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_7_0/AccountService_V1_7_0_Dxe.c new file mode 100644 index 00000000000..83915127862 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_7_0/AccountService_V1_7_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_7_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "7", + "0" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_7_0 *AccountServiceV1_7_0; + EFI_REDFISH_ACCOUNTSERVICE_V1_7_0_CS *AccountServiceV1_7_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_7_0_To_CS (ResoruceRaw, &AccountServiceV1_7_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_7_0 = (EFI_REDFISH_ACCOUNTSERVICE_V1_7_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_7_0)); + if (AccountServiceV1_7_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_7_0; + AccountServiceV1_7_0->AccountService = AccountServiceV1_7_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_7_0_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_7_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_7_0 *AccountServiceV1_7_0; + + AccountServiceV1_7_0 = (EFI_REDFISH_ACCOUNTSERVICE_V1_7_0 *)InterpProp; + DestroyAccountService_V1_7_0_CS (AccountServiceV1_7_0->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_7_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_7_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_7_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_7_0/RedfishAccountService_V1_7_0_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_7_0/RedfishAccountService_V1_7_0_Dxe.inf new file mode 100644 index 00000000000..b6d4c49bf38 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_7_0/RedfishAccountService_V1_7_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_7_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_7_0_Dxe + FILE_GUID = bb8cec81-afb9-4479-bebb-48b0105a4505 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_7_0EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_7_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_7_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_7_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_7_1/AccountService_V1_7_1_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_7_1/AccountService_V1_7_1_Dxe.c new file mode 100644 index 00000000000..7506fcd95f3 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_7_1/AccountService_V1_7_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_7_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_7_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "7", + "1" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_7_1 *AccountServiceV1_7_1; + EFI_REDFISH_ACCOUNTSERVICE_V1_7_1_CS *AccountServiceV1_7_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_7_1_To_CS (ResoruceRaw, &AccountServiceV1_7_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_7_1 = (EFI_REDFISH_ACCOUNTSERVICE_V1_7_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_7_1)); + if (AccountServiceV1_7_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_7_1; + AccountServiceV1_7_1->AccountService = AccountServiceV1_7_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_7_1_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_7_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_7_1 *AccountServiceV1_7_1; + + AccountServiceV1_7_1 = (EFI_REDFISH_ACCOUNTSERVICE_V1_7_1 *)InterpProp; + DestroyAccountService_V1_7_1_CS (AccountServiceV1_7_1->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_7_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_7_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_7_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_7_1/RedfishAccountService_V1_7_1_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_7_1/RedfishAccountService_V1_7_1_Dxe.inf new file mode 100644 index 00000000000..a0f3416ba74 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_7_1/RedfishAccountService_V1_7_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_7_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_7_1_Dxe + FILE_GUID = 83889dd7-164e-4f1e-ac4c-ce37e20179d0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_7_1EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_7_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_7_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_7_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_7_2/AccountService_V1_7_2_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_7_2/AccountService_V1_7_2_Dxe.c new file mode 100644 index 00000000000..655e575834c --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_7_2/AccountService_V1_7_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_7_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_7_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "7", + "2" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_7_2 *AccountServiceV1_7_2; + EFI_REDFISH_ACCOUNTSERVICE_V1_7_2_CS *AccountServiceV1_7_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_7_2_To_CS (ResoruceRaw, &AccountServiceV1_7_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_7_2 = (EFI_REDFISH_ACCOUNTSERVICE_V1_7_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_7_2)); + if (AccountServiceV1_7_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_7_2; + AccountServiceV1_7_2->AccountService = AccountServiceV1_7_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_7_2_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_7_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_7_2 *AccountServiceV1_7_2; + + AccountServiceV1_7_2 = (EFI_REDFISH_ACCOUNTSERVICE_V1_7_2 *)InterpProp; + DestroyAccountService_V1_7_2_CS (AccountServiceV1_7_2->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_7_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_7_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_7_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_7_2/RedfishAccountService_V1_7_2_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_7_2/RedfishAccountService_V1_7_2_Dxe.inf new file mode 100644 index 00000000000..b1a857ceb5e --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_7_2/RedfishAccountService_V1_7_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_7_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_7_2_Dxe + FILE_GUID = cef48ff0-ef95-4984-bba7-1bcb4156361d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_7_2EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_7_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_7_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_7_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_7_3/AccountService_V1_7_3_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_7_3/AccountService_V1_7_3_Dxe.c new file mode 100644 index 00000000000..cb20dbbe6e4 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_7_3/AccountService_V1_7_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_7_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_7_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "7", + "3" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_7_3 *AccountServiceV1_7_3; + EFI_REDFISH_ACCOUNTSERVICE_V1_7_3_CS *AccountServiceV1_7_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_7_3_To_CS (ResoruceRaw, &AccountServiceV1_7_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_7_3 = (EFI_REDFISH_ACCOUNTSERVICE_V1_7_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_7_3)); + if (AccountServiceV1_7_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_7_3; + AccountServiceV1_7_3->AccountService = AccountServiceV1_7_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_7_3_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_7_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_7_3 *AccountServiceV1_7_3; + + AccountServiceV1_7_3 = (EFI_REDFISH_ACCOUNTSERVICE_V1_7_3 *)InterpProp; + DestroyAccountService_V1_7_3_CS (AccountServiceV1_7_3->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_7_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_7_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_7_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_7_3/RedfishAccountService_V1_7_3_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_7_3/RedfishAccountService_V1_7_3_Dxe.inf new file mode 100644 index 00000000000..8faf3c00c1c --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_7_3/RedfishAccountService_V1_7_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_7_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_7_3_Dxe + FILE_GUID = 7c0aba66-d62e-4b0a-83bf-f937523e02e7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_7_3EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_7_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_7_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_7_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AccountService/v1_8_0/AccountService_V1_8_0_Dxe.c b/RedfishClientPkg/Converter/AccountService/v1_8_0/AccountService_V1_8_0_Dxe.c new file mode 100644 index 00000000000..ad2cf73f2b3 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_8_0/AccountService_V1_8_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AccountService.v1_8_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AccountService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AccountService V1_8_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AccountService", + "1", + "8", + "0" + }, + "AccountService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_8_0 *AccountServiceV1_8_0; + EFI_REDFISH_ACCOUNTSERVICE_V1_8_0_CS *AccountServiceV1_8_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AccountService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AccountService_V1_8_0_To_CS (ResoruceRaw, &AccountServiceV1_8_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AccountServiceV1_8_0 = (EFI_REDFISH_ACCOUNTSERVICE_V1_8_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACCOUNTSERVICE_V1_8_0)); + if (AccountServiceV1_8_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AccountServiceV1_8_0; + AccountServiceV1_8_0->AccountService = AccountServiceV1_8_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AccountService"), "AccountService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AccountService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AccountService"), "AccountService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AccountServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AccountServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AccountService_V1_8_0_JSON (*((EFI_REDFISH_ACCOUNTSERVICE_V1_8_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AccountServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACCOUNTSERVICE_V1_8_0 *AccountServiceV1_8_0; + + AccountServiceV1_8_0 = (EFI_REDFISH_ACCOUNTSERVICE_V1_8_0 *)InterpProp; + DestroyAccountService_V1_8_0_CS (AccountServiceV1_8_0->AccountService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AccountServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AccountServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAccountService_V1_8_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_8_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AccountServiceToStructWrapper, + AccountServiceToJson, + AccountServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAccountService_V1_8_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AccountService/v1_8_0/RedfishAccountService_V1_8_0_Dxe.inf b/RedfishClientPkg/Converter/AccountService/v1_8_0/RedfishAccountService_V1_8_0_Dxe.inf new file mode 100644 index 00000000000..1c56fd4b505 --- /dev/null +++ b/RedfishClientPkg/Converter/AccountService/v1_8_0/RedfishAccountService_V1_8_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AccountService.v1_8_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAccountService_V1_8_0_Dxe + FILE_GUID = 843de43a-1d4c-4849-a0ea-7d88f6af1c0c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAccountService_V1_8_0EntryPoint + UNLOAD_IMAGE = RedfishAccountService_V1_8_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AccountService_V1_8_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AccountServiceV1_8_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ActionInfo/v1_0_0/ActionInfo_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/ActionInfo/v1_0_0/ActionInfo_V1_0_0_Dxe.c new file mode 100644 index 00000000000..a22aa5d2349 --- /dev/null +++ b/RedfishClientPkg/Converter/ActionInfo/v1_0_0/ActionInfo_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ActionInfo.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ActionInfo"; +BOOLEAN IsRevisonController = TRUE; + +// Support ActionInfo V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ActionInfo", + "1", + "0", + "0" + }, + "ActionInfo" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACTIONINFO_V1_0_0 *ActionInfoV1_0_0; + EFI_REDFISH_ACTIONINFO_V1_0_0_CS *ActionInfoV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ActionInfo") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ActionInfo_V1_0_0_To_CS (ResoruceRaw, &ActionInfoV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ActionInfoV1_0_0 = (EFI_REDFISH_ACTIONINFO_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACTIONINFO_V1_0_0)); + if (ActionInfoV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ActionInfoV1_0_0; + ActionInfoV1_0_0->ActionInfo = ActionInfoV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ActionInfo")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ActionInfo"), "ActionInfo"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ActionInfo")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ActionInfo"), "ActionInfo"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ActionInfoToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ActionInfoToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ActionInfo_V1_0_0_JSON (*((EFI_REDFISH_ACTIONINFO_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ActionInfoToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACTIONINFO_V1_0_0 *ActionInfoV1_0_0; + + ActionInfoV1_0_0 = (EFI_REDFISH_ACTIONINFO_V1_0_0 *)InterpProp; + DestroyActionInfo_V1_0_0_CS (ActionInfoV1_0_0->ActionInfo); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ActionInfoFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyActionInfo_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishActionInfo_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ActionInfoToStructWrapper, + ActionInfoToJson, + ActionInfoDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishActionInfo_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ActionInfo/v1_0_0/RedfishActionInfo_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/ActionInfo/v1_0_0/RedfishActionInfo_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..1bfc432c830 --- /dev/null +++ b/RedfishClientPkg/Converter/ActionInfo/v1_0_0/RedfishActionInfo_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ActionInfo.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishActionInfo_V1_0_0_Dxe + FILE_GUID = 503c9c69-7de2-4ebd-9191-cf7db5243448 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishActionInfo_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishActionInfo_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ActionInfo_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ActionInfoV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ActionInfo/v1_0_1/ActionInfo_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/ActionInfo/v1_0_1/ActionInfo_V1_0_1_Dxe.c new file mode 100644 index 00000000000..dba3f521372 --- /dev/null +++ b/RedfishClientPkg/Converter/ActionInfo/v1_0_1/ActionInfo_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ActionInfo.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ActionInfo"; +BOOLEAN IsRevisonController = TRUE; + +// Support ActionInfo V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ActionInfo", + "1", + "0", + "1" + }, + "ActionInfo" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACTIONINFO_V1_0_1 *ActionInfoV1_0_1; + EFI_REDFISH_ACTIONINFO_V1_0_1_CS *ActionInfoV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ActionInfo") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ActionInfo_V1_0_1_To_CS (ResoruceRaw, &ActionInfoV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ActionInfoV1_0_1 = (EFI_REDFISH_ACTIONINFO_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACTIONINFO_V1_0_1)); + if (ActionInfoV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ActionInfoV1_0_1; + ActionInfoV1_0_1->ActionInfo = ActionInfoV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ActionInfo")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ActionInfo"), "ActionInfo"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ActionInfo")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ActionInfo"), "ActionInfo"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ActionInfoToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ActionInfoToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ActionInfo_V1_0_1_JSON (*((EFI_REDFISH_ACTIONINFO_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ActionInfoToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACTIONINFO_V1_0_1 *ActionInfoV1_0_1; + + ActionInfoV1_0_1 = (EFI_REDFISH_ACTIONINFO_V1_0_1 *)InterpProp; + DestroyActionInfo_V1_0_1_CS (ActionInfoV1_0_1->ActionInfo); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ActionInfoFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyActionInfo_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishActionInfo_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ActionInfoToStructWrapper, + ActionInfoToJson, + ActionInfoDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishActionInfo_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ActionInfo/v1_0_1/RedfishActionInfo_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/ActionInfo/v1_0_1/RedfishActionInfo_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..d1f623cecd7 --- /dev/null +++ b/RedfishClientPkg/Converter/ActionInfo/v1_0_1/RedfishActionInfo_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ActionInfo.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishActionInfo_V1_0_1_Dxe + FILE_GUID = e0ef70ea-8f84-404e-a6ad-4d0a585b3822 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishActionInfo_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishActionInfo_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ActionInfo_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ActionInfoV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ActionInfo/v1_0_2/ActionInfo_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/ActionInfo/v1_0_2/ActionInfo_V1_0_2_Dxe.c new file mode 100644 index 00000000000..8c552596279 --- /dev/null +++ b/RedfishClientPkg/Converter/ActionInfo/v1_0_2/ActionInfo_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ActionInfo.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ActionInfo"; +BOOLEAN IsRevisonController = TRUE; + +// Support ActionInfo V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ActionInfo", + "1", + "0", + "2" + }, + "ActionInfo" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACTIONINFO_V1_0_2 *ActionInfoV1_0_2; + EFI_REDFISH_ACTIONINFO_V1_0_2_CS *ActionInfoV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ActionInfo") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ActionInfo_V1_0_2_To_CS (ResoruceRaw, &ActionInfoV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ActionInfoV1_0_2 = (EFI_REDFISH_ACTIONINFO_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACTIONINFO_V1_0_2)); + if (ActionInfoV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ActionInfoV1_0_2; + ActionInfoV1_0_2->ActionInfo = ActionInfoV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ActionInfo")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ActionInfo"), "ActionInfo"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ActionInfo")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ActionInfo"), "ActionInfo"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ActionInfoToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ActionInfoToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ActionInfo_V1_0_2_JSON (*((EFI_REDFISH_ACTIONINFO_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ActionInfoToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACTIONINFO_V1_0_2 *ActionInfoV1_0_2; + + ActionInfoV1_0_2 = (EFI_REDFISH_ACTIONINFO_V1_0_2 *)InterpProp; + DestroyActionInfo_V1_0_2_CS (ActionInfoV1_0_2->ActionInfo); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ActionInfoFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyActionInfo_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishActionInfo_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ActionInfoToStructWrapper, + ActionInfoToJson, + ActionInfoDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishActionInfo_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ActionInfo/v1_0_2/RedfishActionInfo_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/ActionInfo/v1_0_2/RedfishActionInfo_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..e8acade6911 --- /dev/null +++ b/RedfishClientPkg/Converter/ActionInfo/v1_0_2/RedfishActionInfo_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ActionInfo.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishActionInfo_V1_0_2_Dxe + FILE_GUID = 4cd85540-ba16-4b8e-ad83-80d9d63e2930 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishActionInfo_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishActionInfo_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ActionInfo_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ActionInfoV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ActionInfo/v1_0_3/ActionInfo_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/ActionInfo/v1_0_3/ActionInfo_V1_0_3_Dxe.c new file mode 100644 index 00000000000..12f45426172 --- /dev/null +++ b/RedfishClientPkg/Converter/ActionInfo/v1_0_3/ActionInfo_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ActionInfo.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ActionInfo"; +BOOLEAN IsRevisonController = TRUE; + +// Support ActionInfo V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ActionInfo", + "1", + "0", + "3" + }, + "ActionInfo" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACTIONINFO_V1_0_3 *ActionInfoV1_0_3; + EFI_REDFISH_ACTIONINFO_V1_0_3_CS *ActionInfoV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ActionInfo") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ActionInfo_V1_0_3_To_CS (ResoruceRaw, &ActionInfoV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ActionInfoV1_0_3 = (EFI_REDFISH_ACTIONINFO_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACTIONINFO_V1_0_3)); + if (ActionInfoV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ActionInfoV1_0_3; + ActionInfoV1_0_3->ActionInfo = ActionInfoV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ActionInfo")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ActionInfo"), "ActionInfo"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ActionInfo")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ActionInfo"), "ActionInfo"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ActionInfoToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ActionInfoToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ActionInfo_V1_0_3_JSON (*((EFI_REDFISH_ACTIONINFO_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ActionInfoToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACTIONINFO_V1_0_3 *ActionInfoV1_0_3; + + ActionInfoV1_0_3 = (EFI_REDFISH_ACTIONINFO_V1_0_3 *)InterpProp; + DestroyActionInfo_V1_0_3_CS (ActionInfoV1_0_3->ActionInfo); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ActionInfoFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyActionInfo_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishActionInfo_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ActionInfoToStructWrapper, + ActionInfoToJson, + ActionInfoDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishActionInfo_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ActionInfo/v1_0_3/RedfishActionInfo_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/ActionInfo/v1_0_3/RedfishActionInfo_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..61b772f4a60 --- /dev/null +++ b/RedfishClientPkg/Converter/ActionInfo/v1_0_3/RedfishActionInfo_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ActionInfo.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishActionInfo_V1_0_3_Dxe + FILE_GUID = 6ae6fa5f-842d-4d4b-b843-7508547c0e0e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishActionInfo_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishActionInfo_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ActionInfo_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ActionInfoV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ActionInfo/v1_0_4/ActionInfo_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/ActionInfo/v1_0_4/ActionInfo_V1_0_4_Dxe.c new file mode 100644 index 00000000000..c2fdb5a1d88 --- /dev/null +++ b/RedfishClientPkg/Converter/ActionInfo/v1_0_4/ActionInfo_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ActionInfo.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ActionInfo"; +BOOLEAN IsRevisonController = TRUE; + +// Support ActionInfo V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ActionInfo", + "1", + "0", + "4" + }, + "ActionInfo" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACTIONINFO_V1_0_4 *ActionInfoV1_0_4; + EFI_REDFISH_ACTIONINFO_V1_0_4_CS *ActionInfoV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ActionInfo") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ActionInfo_V1_0_4_To_CS (ResoruceRaw, &ActionInfoV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ActionInfoV1_0_4 = (EFI_REDFISH_ACTIONINFO_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACTIONINFO_V1_0_4)); + if (ActionInfoV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ActionInfoV1_0_4; + ActionInfoV1_0_4->ActionInfo = ActionInfoV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ActionInfo")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ActionInfo"), "ActionInfo"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ActionInfo")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ActionInfo"), "ActionInfo"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ActionInfoToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ActionInfoToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ActionInfo_V1_0_4_JSON (*((EFI_REDFISH_ACTIONINFO_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ActionInfoToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACTIONINFO_V1_0_4 *ActionInfoV1_0_4; + + ActionInfoV1_0_4 = (EFI_REDFISH_ACTIONINFO_V1_0_4 *)InterpProp; + DestroyActionInfo_V1_0_4_CS (ActionInfoV1_0_4->ActionInfo); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ActionInfoFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyActionInfo_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishActionInfo_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ActionInfoToStructWrapper, + ActionInfoToJson, + ActionInfoDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishActionInfo_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ActionInfo/v1_0_4/RedfishActionInfo_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/ActionInfo/v1_0_4/RedfishActionInfo_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..00e08658655 --- /dev/null +++ b/RedfishClientPkg/Converter/ActionInfo/v1_0_4/RedfishActionInfo_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ActionInfo.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishActionInfo_V1_0_4_Dxe + FILE_GUID = 892b8b5f-4fb0-4511-a11d-a6a17ad57534 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishActionInfo_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishActionInfo_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ActionInfo_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ActionInfoV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ActionInfo/v1_0_5/ActionInfo_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/ActionInfo/v1_0_5/ActionInfo_V1_0_5_Dxe.c new file mode 100644 index 00000000000..5eb3591807d --- /dev/null +++ b/RedfishClientPkg/Converter/ActionInfo/v1_0_5/ActionInfo_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ActionInfo.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ActionInfo"; +BOOLEAN IsRevisonController = TRUE; + +// Support ActionInfo V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ActionInfo", + "1", + "0", + "5" + }, + "ActionInfo" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACTIONINFO_V1_0_5 *ActionInfoV1_0_5; + EFI_REDFISH_ACTIONINFO_V1_0_5_CS *ActionInfoV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ActionInfo") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ActionInfo_V1_0_5_To_CS (ResoruceRaw, &ActionInfoV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ActionInfoV1_0_5 = (EFI_REDFISH_ACTIONINFO_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACTIONINFO_V1_0_5)); + if (ActionInfoV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ActionInfoV1_0_5; + ActionInfoV1_0_5->ActionInfo = ActionInfoV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ActionInfo")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ActionInfo"), "ActionInfo"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ActionInfo")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ActionInfo"), "ActionInfo"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ActionInfoToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ActionInfoToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ActionInfo_V1_0_5_JSON (*((EFI_REDFISH_ACTIONINFO_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ActionInfoToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACTIONINFO_V1_0_5 *ActionInfoV1_0_5; + + ActionInfoV1_0_5 = (EFI_REDFISH_ACTIONINFO_V1_0_5 *)InterpProp; + DestroyActionInfo_V1_0_5_CS (ActionInfoV1_0_5->ActionInfo); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ActionInfoFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyActionInfo_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishActionInfo_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ActionInfoToStructWrapper, + ActionInfoToJson, + ActionInfoDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishActionInfo_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ActionInfo/v1_0_5/RedfishActionInfo_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/ActionInfo/v1_0_5/RedfishActionInfo_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..83800bf2c9f --- /dev/null +++ b/RedfishClientPkg/Converter/ActionInfo/v1_0_5/RedfishActionInfo_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ActionInfo.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishActionInfo_V1_0_5_Dxe + FILE_GUID = 0d2d3e09-3524-4eff-8150-f9268304ae8f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishActionInfo_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishActionInfo_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ActionInfo_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ActionInfoV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ActionInfo/v1_0_6/ActionInfo_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/ActionInfo/v1_0_6/ActionInfo_V1_0_6_Dxe.c new file mode 100644 index 00000000000..d94ed60b50b --- /dev/null +++ b/RedfishClientPkg/Converter/ActionInfo/v1_0_6/ActionInfo_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ActionInfo.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ActionInfo"; +BOOLEAN IsRevisonController = TRUE; + +// Support ActionInfo V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ActionInfo", + "1", + "0", + "6" + }, + "ActionInfo" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACTIONINFO_V1_0_6 *ActionInfoV1_0_6; + EFI_REDFISH_ACTIONINFO_V1_0_6_CS *ActionInfoV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ActionInfo") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ActionInfo_V1_0_6_To_CS (ResoruceRaw, &ActionInfoV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ActionInfoV1_0_6 = (EFI_REDFISH_ACTIONINFO_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACTIONINFO_V1_0_6)); + if (ActionInfoV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ActionInfoV1_0_6; + ActionInfoV1_0_6->ActionInfo = ActionInfoV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ActionInfo")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ActionInfo"), "ActionInfo"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ActionInfo")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ActionInfo"), "ActionInfo"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ActionInfoToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ActionInfoToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ActionInfo_V1_0_6_JSON (*((EFI_REDFISH_ACTIONINFO_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ActionInfoToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACTIONINFO_V1_0_6 *ActionInfoV1_0_6; + + ActionInfoV1_0_6 = (EFI_REDFISH_ACTIONINFO_V1_0_6 *)InterpProp; + DestroyActionInfo_V1_0_6_CS (ActionInfoV1_0_6->ActionInfo); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ActionInfoFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyActionInfo_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishActionInfo_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ActionInfoToStructWrapper, + ActionInfoToJson, + ActionInfoDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishActionInfo_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ActionInfo/v1_0_6/RedfishActionInfo_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/ActionInfo/v1_0_6/RedfishActionInfo_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..22041730416 --- /dev/null +++ b/RedfishClientPkg/Converter/ActionInfo/v1_0_6/RedfishActionInfo_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ActionInfo.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishActionInfo_V1_0_6_Dxe + FILE_GUID = 58669db2-bca5-4195-a11d-1202c61da881 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishActionInfo_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishActionInfo_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ActionInfo_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ActionInfoV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ActionInfo/v1_1_0/ActionInfo_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/ActionInfo/v1_1_0/ActionInfo_V1_1_0_Dxe.c new file mode 100644 index 00000000000..b1f5013b017 --- /dev/null +++ b/RedfishClientPkg/Converter/ActionInfo/v1_1_0/ActionInfo_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ActionInfo.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ActionInfo"; +BOOLEAN IsRevisonController = TRUE; + +// Support ActionInfo V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ActionInfo", + "1", + "1", + "0" + }, + "ActionInfo" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACTIONINFO_V1_1_0 *ActionInfoV1_1_0; + EFI_REDFISH_ACTIONINFO_V1_1_0_CS *ActionInfoV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ActionInfo") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ActionInfo_V1_1_0_To_CS (ResoruceRaw, &ActionInfoV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ActionInfoV1_1_0 = (EFI_REDFISH_ACTIONINFO_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACTIONINFO_V1_1_0)); + if (ActionInfoV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ActionInfoV1_1_0; + ActionInfoV1_1_0->ActionInfo = ActionInfoV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ActionInfo")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ActionInfo"), "ActionInfo"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ActionInfo")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ActionInfo"), "ActionInfo"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ActionInfoToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ActionInfoToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ActionInfo_V1_1_0_JSON (*((EFI_REDFISH_ACTIONINFO_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ActionInfoToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACTIONINFO_V1_1_0 *ActionInfoV1_1_0; + + ActionInfoV1_1_0 = (EFI_REDFISH_ACTIONINFO_V1_1_0 *)InterpProp; + DestroyActionInfo_V1_1_0_CS (ActionInfoV1_1_0->ActionInfo); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ActionInfoFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyActionInfo_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishActionInfo_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ActionInfoToStructWrapper, + ActionInfoToJson, + ActionInfoDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishActionInfo_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ActionInfo/v1_1_0/RedfishActionInfo_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/ActionInfo/v1_1_0/RedfishActionInfo_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..b5fd8cab57b --- /dev/null +++ b/RedfishClientPkg/Converter/ActionInfo/v1_1_0/RedfishActionInfo_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ActionInfo.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishActionInfo_V1_1_0_Dxe + FILE_GUID = 531b3084-84d8-474d-a0e5-2e4380de1d81 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishActionInfo_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishActionInfo_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ActionInfo_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ActionInfoV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ActionInfo/v1_1_1/ActionInfo_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/ActionInfo/v1_1_1/ActionInfo_V1_1_1_Dxe.c new file mode 100644 index 00000000000..ff534dc1fc3 --- /dev/null +++ b/RedfishClientPkg/Converter/ActionInfo/v1_1_1/ActionInfo_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ActionInfo.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ActionInfo"; +BOOLEAN IsRevisonController = TRUE; + +// Support ActionInfo V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ActionInfo", + "1", + "1", + "1" + }, + "ActionInfo" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACTIONINFO_V1_1_1 *ActionInfoV1_1_1; + EFI_REDFISH_ACTIONINFO_V1_1_1_CS *ActionInfoV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ActionInfo") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ActionInfo_V1_1_1_To_CS (ResoruceRaw, &ActionInfoV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ActionInfoV1_1_1 = (EFI_REDFISH_ACTIONINFO_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACTIONINFO_V1_1_1)); + if (ActionInfoV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ActionInfoV1_1_1; + ActionInfoV1_1_1->ActionInfo = ActionInfoV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ActionInfo")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ActionInfo"), "ActionInfo"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ActionInfo")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ActionInfo"), "ActionInfo"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ActionInfoToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ActionInfoToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ActionInfo_V1_1_1_JSON (*((EFI_REDFISH_ACTIONINFO_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ActionInfoToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACTIONINFO_V1_1_1 *ActionInfoV1_1_1; + + ActionInfoV1_1_1 = (EFI_REDFISH_ACTIONINFO_V1_1_1 *)InterpProp; + DestroyActionInfo_V1_1_1_CS (ActionInfoV1_1_1->ActionInfo); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ActionInfoFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyActionInfo_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishActionInfo_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ActionInfoToStructWrapper, + ActionInfoToJson, + ActionInfoDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishActionInfo_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ActionInfo/v1_1_1/RedfishActionInfo_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/ActionInfo/v1_1_1/RedfishActionInfo_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..396f121b17c --- /dev/null +++ b/RedfishClientPkg/Converter/ActionInfo/v1_1_1/RedfishActionInfo_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ActionInfo.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishActionInfo_V1_1_1_Dxe + FILE_GUID = 1fd1074c-137c-40ff-ab19-0a9611a92589 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishActionInfo_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishActionInfo_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ActionInfo_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ActionInfoV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ActionInfo/v1_1_2/ActionInfo_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/ActionInfo/v1_1_2/ActionInfo_V1_1_2_Dxe.c new file mode 100644 index 00000000000..c421f27a817 --- /dev/null +++ b/RedfishClientPkg/Converter/ActionInfo/v1_1_2/ActionInfo_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ActionInfo.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ActionInfo"; +BOOLEAN IsRevisonController = TRUE; + +// Support ActionInfo V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ActionInfo", + "1", + "1", + "2" + }, + "ActionInfo" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ACTIONINFO_V1_1_2 *ActionInfoV1_1_2; + EFI_REDFISH_ACTIONINFO_V1_1_2_CS *ActionInfoV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ActionInfo") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ActionInfo_V1_1_2_To_CS (ResoruceRaw, &ActionInfoV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ActionInfoV1_1_2 = (EFI_REDFISH_ACTIONINFO_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ACTIONINFO_V1_1_2)); + if (ActionInfoV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ActionInfoV1_1_2; + ActionInfoV1_1_2->ActionInfo = ActionInfoV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ActionInfo")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ActionInfo"), "ActionInfo"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ActionInfo")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ActionInfo"), "ActionInfo"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ActionInfoToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ActionInfoToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ActionInfo_V1_1_2_JSON (*((EFI_REDFISH_ACTIONINFO_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ActionInfoToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ACTIONINFO_V1_1_2 *ActionInfoV1_1_2; + + ActionInfoV1_1_2 = (EFI_REDFISH_ACTIONINFO_V1_1_2 *)InterpProp; + DestroyActionInfo_V1_1_2_CS (ActionInfoV1_1_2->ActionInfo); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ActionInfoFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ActionInfoDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyActionInfo_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishActionInfo_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ActionInfoToStructWrapper, + ActionInfoToJson, + ActionInfoDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishActionInfo_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ActionInfo/v1_1_2/RedfishActionInfo_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/ActionInfo/v1_1_2/RedfishActionInfo_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..ff04cc2a3e2 --- /dev/null +++ b/RedfishClientPkg/Converter/ActionInfo/v1_1_2/RedfishActionInfo_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ActionInfo.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishActionInfo_V1_1_2_Dxe + FILE_GUID = 823f4644-9a8d-4bac-a9fc-7258bc7b12cc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishActionInfo_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishActionInfo_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ActionInfo_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ActionInfoV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AddressPool/v1_0_0/AddressPool_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/AddressPool/v1_0_0/AddressPool_V1_0_0_Dxe.c new file mode 100644 index 00000000000..955152b275b --- /dev/null +++ b/RedfishClientPkg/Converter/AddressPool/v1_0_0/AddressPool_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AddressPool.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AddressPool"; +BOOLEAN IsRevisonController = TRUE; + +// Support AddressPool V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AddressPool", + "1", + "0", + "0" + }, + "AddressPool" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ADDRESSPOOL_V1_0_0 *AddressPoolV1_0_0; + EFI_REDFISH_ADDRESSPOOL_V1_0_0_CS *AddressPoolV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AddressPool") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AddressPool_V1_0_0_To_CS (ResoruceRaw, &AddressPoolV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AddressPoolV1_0_0 = (EFI_REDFISH_ADDRESSPOOL_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ADDRESSPOOL_V1_0_0)); + if (AddressPoolV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AddressPoolV1_0_0; + AddressPoolV1_0_0->AddressPool = AddressPoolV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AddressPool")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AddressPool"), "AddressPool"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AddressPool")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AddressPool"), "AddressPool"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AddressPoolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AddressPoolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AddressPool_V1_0_0_JSON (*((EFI_REDFISH_ADDRESSPOOL_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AddressPoolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ADDRESSPOOL_V1_0_0 *AddressPoolV1_0_0; + + AddressPoolV1_0_0 = (EFI_REDFISH_ADDRESSPOOL_V1_0_0 *)InterpProp; + DestroyAddressPool_V1_0_0_CS (AddressPoolV1_0_0->AddressPool); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AddressPoolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAddressPool_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAddressPool_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AddressPoolToStructWrapper, + AddressPoolToJson, + AddressPoolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAddressPool_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AddressPool/v1_0_0/RedfishAddressPool_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/AddressPool/v1_0_0/RedfishAddressPool_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..373ec8a32f0 --- /dev/null +++ b/RedfishClientPkg/Converter/AddressPool/v1_0_0/RedfishAddressPool_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AddressPool.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAddressPool_V1_0_0_Dxe + FILE_GUID = 30c91ffd-34a0-484a-8c15-382b6edf1ba8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAddressPool_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishAddressPool_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AddressPool_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AddressPoolV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AddressPool/v1_0_1/AddressPool_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/AddressPool/v1_0_1/AddressPool_V1_0_1_Dxe.c new file mode 100644 index 00000000000..4406c977fab --- /dev/null +++ b/RedfishClientPkg/Converter/AddressPool/v1_0_1/AddressPool_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AddressPool.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AddressPool"; +BOOLEAN IsRevisonController = TRUE; + +// Support AddressPool V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AddressPool", + "1", + "0", + "1" + }, + "AddressPool" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ADDRESSPOOL_V1_0_1 *AddressPoolV1_0_1; + EFI_REDFISH_ADDRESSPOOL_V1_0_1_CS *AddressPoolV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AddressPool") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AddressPool_V1_0_1_To_CS (ResoruceRaw, &AddressPoolV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AddressPoolV1_0_1 = (EFI_REDFISH_ADDRESSPOOL_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ADDRESSPOOL_V1_0_1)); + if (AddressPoolV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AddressPoolV1_0_1; + AddressPoolV1_0_1->AddressPool = AddressPoolV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AddressPool")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AddressPool"), "AddressPool"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AddressPool")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AddressPool"), "AddressPool"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AddressPoolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AddressPoolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AddressPool_V1_0_1_JSON (*((EFI_REDFISH_ADDRESSPOOL_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AddressPoolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ADDRESSPOOL_V1_0_1 *AddressPoolV1_0_1; + + AddressPoolV1_0_1 = (EFI_REDFISH_ADDRESSPOOL_V1_0_1 *)InterpProp; + DestroyAddressPool_V1_0_1_CS (AddressPoolV1_0_1->AddressPool); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AddressPoolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAddressPool_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAddressPool_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AddressPoolToStructWrapper, + AddressPoolToJson, + AddressPoolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAddressPool_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AddressPool/v1_0_1/RedfishAddressPool_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/AddressPool/v1_0_1/RedfishAddressPool_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..35e19b242c2 --- /dev/null +++ b/RedfishClientPkg/Converter/AddressPool/v1_0_1/RedfishAddressPool_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AddressPool.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAddressPool_V1_0_1_Dxe + FILE_GUID = 58668fed-4e32-448c-a3be-663dfd11a5d8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAddressPool_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishAddressPool_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AddressPool_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AddressPoolV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AddressPool/v1_0_2/AddressPool_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/AddressPool/v1_0_2/AddressPool_V1_0_2_Dxe.c new file mode 100644 index 00000000000..dcf4d738810 --- /dev/null +++ b/RedfishClientPkg/Converter/AddressPool/v1_0_2/AddressPool_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AddressPool.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AddressPool"; +BOOLEAN IsRevisonController = TRUE; + +// Support AddressPool V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AddressPool", + "1", + "0", + "2" + }, + "AddressPool" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ADDRESSPOOL_V1_0_2 *AddressPoolV1_0_2; + EFI_REDFISH_ADDRESSPOOL_V1_0_2_CS *AddressPoolV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AddressPool") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AddressPool_V1_0_2_To_CS (ResoruceRaw, &AddressPoolV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AddressPoolV1_0_2 = (EFI_REDFISH_ADDRESSPOOL_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ADDRESSPOOL_V1_0_2)); + if (AddressPoolV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AddressPoolV1_0_2; + AddressPoolV1_0_2->AddressPool = AddressPoolV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AddressPool")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AddressPool"), "AddressPool"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AddressPool")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AddressPool"), "AddressPool"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AddressPoolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AddressPoolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AddressPool_V1_0_2_JSON (*((EFI_REDFISH_ADDRESSPOOL_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AddressPoolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ADDRESSPOOL_V1_0_2 *AddressPoolV1_0_2; + + AddressPoolV1_0_2 = (EFI_REDFISH_ADDRESSPOOL_V1_0_2 *)InterpProp; + DestroyAddressPool_V1_0_2_CS (AddressPoolV1_0_2->AddressPool); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AddressPoolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAddressPool_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAddressPool_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AddressPoolToStructWrapper, + AddressPoolToJson, + AddressPoolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAddressPool_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AddressPool/v1_0_2/RedfishAddressPool_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/AddressPool/v1_0_2/RedfishAddressPool_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..79572c374fe --- /dev/null +++ b/RedfishClientPkg/Converter/AddressPool/v1_0_2/RedfishAddressPool_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AddressPool.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAddressPool_V1_0_2_Dxe + FILE_GUID = 5f894c12-840b-42b3-8a39-33f9e3418a11 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAddressPool_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishAddressPool_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AddressPool_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AddressPoolV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AddressPool/v1_1_0/AddressPool_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/AddressPool/v1_1_0/AddressPool_V1_1_0_Dxe.c new file mode 100644 index 00000000000..cf5c274039b --- /dev/null +++ b/RedfishClientPkg/Converter/AddressPool/v1_1_0/AddressPool_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AddressPool.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AddressPool"; +BOOLEAN IsRevisonController = TRUE; + +// Support AddressPool V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AddressPool", + "1", + "1", + "0" + }, + "AddressPool" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ADDRESSPOOL_V1_1_0 *AddressPoolV1_1_0; + EFI_REDFISH_ADDRESSPOOL_V1_1_0_CS *AddressPoolV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AddressPool") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AddressPool_V1_1_0_To_CS (ResoruceRaw, &AddressPoolV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AddressPoolV1_1_0 = (EFI_REDFISH_ADDRESSPOOL_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ADDRESSPOOL_V1_1_0)); + if (AddressPoolV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AddressPoolV1_1_0; + AddressPoolV1_1_0->AddressPool = AddressPoolV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AddressPool")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AddressPool"), "AddressPool"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AddressPool")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AddressPool"), "AddressPool"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AddressPoolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AddressPoolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AddressPool_V1_1_0_JSON (*((EFI_REDFISH_ADDRESSPOOL_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AddressPoolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ADDRESSPOOL_V1_1_0 *AddressPoolV1_1_0; + + AddressPoolV1_1_0 = (EFI_REDFISH_ADDRESSPOOL_V1_1_0 *)InterpProp; + DestroyAddressPool_V1_1_0_CS (AddressPoolV1_1_0->AddressPool); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AddressPoolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAddressPool_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAddressPool_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AddressPoolToStructWrapper, + AddressPoolToJson, + AddressPoolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAddressPool_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AddressPool/v1_1_0/RedfishAddressPool_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/AddressPool/v1_1_0/RedfishAddressPool_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..b82de95a617 --- /dev/null +++ b/RedfishClientPkg/Converter/AddressPool/v1_1_0/RedfishAddressPool_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AddressPool.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAddressPool_V1_1_0_Dxe + FILE_GUID = 5fd6c00c-f856-4393-b0ec-079c7ddf33b3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAddressPool_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishAddressPool_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AddressPool_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AddressPoolV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AddressPool/v1_1_1/AddressPool_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/AddressPool/v1_1_1/AddressPool_V1_1_1_Dxe.c new file mode 100644 index 00000000000..d18e7f3203b --- /dev/null +++ b/RedfishClientPkg/Converter/AddressPool/v1_1_1/AddressPool_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AddressPool.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AddressPool"; +BOOLEAN IsRevisonController = TRUE; + +// Support AddressPool V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AddressPool", + "1", + "1", + "1" + }, + "AddressPool" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ADDRESSPOOL_V1_1_1 *AddressPoolV1_1_1; + EFI_REDFISH_ADDRESSPOOL_V1_1_1_CS *AddressPoolV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AddressPool") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AddressPool_V1_1_1_To_CS (ResoruceRaw, &AddressPoolV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AddressPoolV1_1_1 = (EFI_REDFISH_ADDRESSPOOL_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ADDRESSPOOL_V1_1_1)); + if (AddressPoolV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AddressPoolV1_1_1; + AddressPoolV1_1_1->AddressPool = AddressPoolV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AddressPool")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AddressPool"), "AddressPool"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AddressPool")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AddressPool"), "AddressPool"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AddressPoolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AddressPoolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AddressPool_V1_1_1_JSON (*((EFI_REDFISH_ADDRESSPOOL_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AddressPoolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ADDRESSPOOL_V1_1_1 *AddressPoolV1_1_1; + + AddressPoolV1_1_1 = (EFI_REDFISH_ADDRESSPOOL_V1_1_1 *)InterpProp; + DestroyAddressPool_V1_1_1_CS (AddressPoolV1_1_1->AddressPool); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AddressPoolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAddressPool_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAddressPool_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AddressPoolToStructWrapper, + AddressPoolToJson, + AddressPoolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAddressPool_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AddressPool/v1_1_1/RedfishAddressPool_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/AddressPool/v1_1_1/RedfishAddressPool_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..709113eb153 --- /dev/null +++ b/RedfishClientPkg/Converter/AddressPool/v1_1_1/RedfishAddressPool_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AddressPool.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAddressPool_V1_1_1_Dxe + FILE_GUID = e8fcef52-4a59-4d6c-afc9-022e0fa3f56c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAddressPool_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishAddressPool_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AddressPool_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AddressPoolV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AddressPoolCollection/AddressPoolCollection_Dxe.c b/RedfishClientPkg/Converter/AddressPoolCollection/AddressPoolCollection_Dxe.c new file mode 100644 index 00000000000..1167e26988c --- /dev/null +++ b/RedfishClientPkg/Converter/AddressPoolCollection/AddressPoolCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AddressPoolCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AddressPoolCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support AddressPoolCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AddressPoolCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "AddressPoolCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ADDRESSPOOLCOLLECTION *AddressPoolCollection; + EFI_REDFISH_ADDRESSPOOLCOLLECTION_CS *AddressPoolCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AddressPoolCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AddressPoolCollection_To_CS (ResoruceRaw, &AddressPoolCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + AddressPoolCollection = (EFI_REDFISH_ADDRESSPOOLCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ADDRESSPOOLCOLLECTION)); + if (AddressPoolCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AddressPoolCollection; + AddressPoolCollection->AddressPoolCollection = AddressPoolCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AddressPoolCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AddressPoolCollection"), "AddressPoolCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AddressPoolCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AddressPoolCollection"), "AddressPoolCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AddressPoolCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AddressPoolCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AddressPoolCollection_JSON (*((EFI_REDFISH_ADDRESSPOOLCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AddressPoolCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ADDRESSPOOLCOLLECTION *AddressPoolCollection; + + AddressPoolCollection = (EFI_REDFISH_ADDRESSPOOLCOLLECTION *)InterpProp; + DestroyAddressPoolCollection_CS (AddressPoolCollection->AddressPoolCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AddressPoolCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AddressPoolCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAddressPoolCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAddressPoolCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AddressPoolCollectionToStructWrapper, + AddressPoolCollectionToJson, + AddressPoolCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAddressPoolCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AddressPoolCollection/RedfishAddressPoolCollection_Dxe.inf b/RedfishClientPkg/Converter/AddressPoolCollection/RedfishAddressPoolCollection_Dxe.inf new file mode 100644 index 00000000000..21304872c4d --- /dev/null +++ b/RedfishClientPkg/Converter/AddressPoolCollection/RedfishAddressPoolCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AddressPoolCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAddressPoolCollection_Dxe + FILE_GUID = 2068f370-6e5c-488c-9b2e-8d151314c615 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAddressPoolCollectionEntryPoint + UNLOAD_IMAGE = RedfishAddressPoolCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AddressPoolCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AddressPoolCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Aggregate/v1_0_0/Aggregate_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Aggregate/v1_0_0/Aggregate_V1_0_0_Dxe.c new file mode 100644 index 00000000000..19ac8e1901f --- /dev/null +++ b/RedfishClientPkg/Converter/Aggregate/v1_0_0/Aggregate_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Aggregate.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Aggregate"; +BOOLEAN IsRevisonController = TRUE; + +// Support Aggregate V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Aggregate", + "1", + "0", + "0" + }, + "Aggregate" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregateToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_AGGREGATE_V1_0_0 *AggregateV1_0_0; + EFI_REDFISH_AGGREGATE_V1_0_0_CS *AggregateV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Aggregate") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Aggregate_V1_0_0_To_CS (ResoruceRaw, &AggregateV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AggregateV1_0_0 = (EFI_REDFISH_AGGREGATE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_AGGREGATE_V1_0_0)); + if (AggregateV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AggregateV1_0_0; + AggregateV1_0_0->Aggregate = AggregateV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Aggregate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Aggregate"), "Aggregate"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Aggregate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Aggregate"), "Aggregate"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AggregateToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregateToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AggregateToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregateToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Aggregate_V1_0_0_JSON (*((EFI_REDFISH_AGGREGATE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AggregateToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregateDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_AGGREGATE_V1_0_0 *AggregateV1_0_0; + + AggregateV1_0_0 = (EFI_REDFISH_AGGREGATE_V1_0_0 *)InterpProp; + DestroyAggregate_V1_0_0_CS (AggregateV1_0_0->Aggregate); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AggregateFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregateDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAggregate_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAggregate_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AggregateToStructWrapper, + AggregateToJson, + AggregateDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAggregate_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Aggregate/v1_0_0/RedfishAggregate_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Aggregate/v1_0_0/RedfishAggregate_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..9490ae364c0 --- /dev/null +++ b/RedfishClientPkg/Converter/Aggregate/v1_0_0/RedfishAggregate_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Aggregate.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAggregate_V1_0_0_Dxe + FILE_GUID = 148602b7-b6c7-44d2-a20f-89c9c5c36478 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAggregate_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishAggregate_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Aggregate_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AggregateV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Aggregate/v1_0_1/Aggregate_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/Aggregate/v1_0_1/Aggregate_V1_0_1_Dxe.c new file mode 100644 index 00000000000..55da07808db --- /dev/null +++ b/RedfishClientPkg/Converter/Aggregate/v1_0_1/Aggregate_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Aggregate.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Aggregate"; +BOOLEAN IsRevisonController = TRUE; + +// Support Aggregate V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Aggregate", + "1", + "0", + "1" + }, + "Aggregate" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregateToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_AGGREGATE_V1_0_1 *AggregateV1_0_1; + EFI_REDFISH_AGGREGATE_V1_0_1_CS *AggregateV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Aggregate") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Aggregate_V1_0_1_To_CS (ResoruceRaw, &AggregateV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AggregateV1_0_1 = (EFI_REDFISH_AGGREGATE_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_AGGREGATE_V1_0_1)); + if (AggregateV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AggregateV1_0_1; + AggregateV1_0_1->Aggregate = AggregateV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Aggregate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Aggregate"), "Aggregate"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Aggregate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Aggregate"), "Aggregate"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AggregateToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregateToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AggregateToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregateToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Aggregate_V1_0_1_JSON (*((EFI_REDFISH_AGGREGATE_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AggregateToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregateDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_AGGREGATE_V1_0_1 *AggregateV1_0_1; + + AggregateV1_0_1 = (EFI_REDFISH_AGGREGATE_V1_0_1 *)InterpProp; + DestroyAggregate_V1_0_1_CS (AggregateV1_0_1->Aggregate); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AggregateFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregateDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAggregate_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAggregate_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AggregateToStructWrapper, + AggregateToJson, + AggregateDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAggregate_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Aggregate/v1_0_1/RedfishAggregate_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/Aggregate/v1_0_1/RedfishAggregate_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..9074de7b8f9 --- /dev/null +++ b/RedfishClientPkg/Converter/Aggregate/v1_0_1/RedfishAggregate_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Aggregate.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAggregate_V1_0_1_Dxe + FILE_GUID = 68f88cfa-9965-4bae-8d5c-6493080ed1f5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAggregate_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishAggregate_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Aggregate_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AggregateV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AggregateCollection/AggregateCollection_Dxe.c b/RedfishClientPkg/Converter/AggregateCollection/AggregateCollection_Dxe.c new file mode 100644 index 00000000000..1feb7daeb0d --- /dev/null +++ b/RedfishClientPkg/Converter/AggregateCollection/AggregateCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AggregateCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AggregateCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support AggregateCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AggregateCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "AggregateCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregateCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_AGGREGATECOLLECTION *AggregateCollection; + EFI_REDFISH_AGGREGATECOLLECTION_CS *AggregateCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AggregateCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AggregateCollection_To_CS (ResoruceRaw, &AggregateCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + AggregateCollection = (EFI_REDFISH_AGGREGATECOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_AGGREGATECOLLECTION)); + if (AggregateCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AggregateCollection; + AggregateCollection->AggregateCollection = AggregateCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AggregateCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AggregateCollection"), "AggregateCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AggregateCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AggregateCollection"), "AggregateCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AggregateCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregateCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AggregateCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregateCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AggregateCollection_JSON (*((EFI_REDFISH_AGGREGATECOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AggregateCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregateCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_AGGREGATECOLLECTION *AggregateCollection; + + AggregateCollection = (EFI_REDFISH_AGGREGATECOLLECTION *)InterpProp; + DestroyAggregateCollection_CS (AggregateCollection->AggregateCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AggregateCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregateCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAggregateCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAggregateCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AggregateCollectionToStructWrapper, + AggregateCollectionToJson, + AggregateCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAggregateCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AggregateCollection/RedfishAggregateCollection_Dxe.inf b/RedfishClientPkg/Converter/AggregateCollection/RedfishAggregateCollection_Dxe.inf new file mode 100644 index 00000000000..3145c682e84 --- /dev/null +++ b/RedfishClientPkg/Converter/AggregateCollection/RedfishAggregateCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AggregateCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAggregateCollection_Dxe + FILE_GUID = df7d27e9-943a-4e01-83e2-394037634ab1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAggregateCollectionEntryPoint + UNLOAD_IMAGE = RedfishAggregateCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AggregateCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AggregateCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AggregationService/v1_0_0/AggregationService_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/AggregationService/v1_0_0/AggregationService_V1_0_0_Dxe.c new file mode 100644 index 00000000000..31c2429cfae --- /dev/null +++ b/RedfishClientPkg/Converter/AggregationService/v1_0_0/AggregationService_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AggregationService.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AggregationService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AggregationService V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AggregationService", + "1", + "0", + "0" + }, + "AggregationService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregationServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_AGGREGATIONSERVICE_V1_0_0 *AggregationServiceV1_0_0; + EFI_REDFISH_AGGREGATIONSERVICE_V1_0_0_CS *AggregationServiceV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AggregationService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AggregationService_V1_0_0_To_CS (ResoruceRaw, &AggregationServiceV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AggregationServiceV1_0_0 = (EFI_REDFISH_AGGREGATIONSERVICE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_AGGREGATIONSERVICE_V1_0_0)); + if (AggregationServiceV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AggregationServiceV1_0_0; + AggregationServiceV1_0_0->AggregationService = AggregationServiceV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AggregationService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AggregationService"), "AggregationService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AggregationService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AggregationService"), "AggregationService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AggregationServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregationServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AggregationServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregationServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AggregationService_V1_0_0_JSON (*((EFI_REDFISH_AGGREGATIONSERVICE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AggregationServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregationServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_AGGREGATIONSERVICE_V1_0_0 *AggregationServiceV1_0_0; + + AggregationServiceV1_0_0 = (EFI_REDFISH_AGGREGATIONSERVICE_V1_0_0 *)InterpProp; + DestroyAggregationService_V1_0_0_CS (AggregationServiceV1_0_0->AggregationService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AggregationServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregationServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAggregationService_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAggregationService_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AggregationServiceToStructWrapper, + AggregationServiceToJson, + AggregationServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAggregationService_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AggregationService/v1_0_0/RedfishAggregationService_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/AggregationService/v1_0_0/RedfishAggregationService_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..9a2e418eaab --- /dev/null +++ b/RedfishClientPkg/Converter/AggregationService/v1_0_0/RedfishAggregationService_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AggregationService.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAggregationService_V1_0_0_Dxe + FILE_GUID = e9ec78e0-ec0a-4d15-9a0a-2c272d40dabd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAggregationService_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishAggregationService_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AggregationService_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AggregationServiceV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AggregationService/v1_0_1/AggregationService_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/AggregationService/v1_0_1/AggregationService_V1_0_1_Dxe.c new file mode 100644 index 00000000000..6cf33a1e2ae --- /dev/null +++ b/RedfishClientPkg/Converter/AggregationService/v1_0_1/AggregationService_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AggregationService.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AggregationService"; +BOOLEAN IsRevisonController = TRUE; + +// Support AggregationService V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AggregationService", + "1", + "0", + "1" + }, + "AggregationService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregationServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_AGGREGATIONSERVICE_V1_0_1 *AggregationServiceV1_0_1; + EFI_REDFISH_AGGREGATIONSERVICE_V1_0_1_CS *AggregationServiceV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AggregationService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AggregationService_V1_0_1_To_CS (ResoruceRaw, &AggregationServiceV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AggregationServiceV1_0_1 = (EFI_REDFISH_AGGREGATIONSERVICE_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_AGGREGATIONSERVICE_V1_0_1)); + if (AggregationServiceV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AggregationServiceV1_0_1; + AggregationServiceV1_0_1->AggregationService = AggregationServiceV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AggregationService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AggregationService"), "AggregationService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AggregationService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AggregationService"), "AggregationService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AggregationServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregationServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AggregationServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregationServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AggregationService_V1_0_1_JSON (*((EFI_REDFISH_AGGREGATIONSERVICE_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AggregationServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregationServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_AGGREGATIONSERVICE_V1_0_1 *AggregationServiceV1_0_1; + + AggregationServiceV1_0_1 = (EFI_REDFISH_AGGREGATIONSERVICE_V1_0_1 *)InterpProp; + DestroyAggregationService_V1_0_1_CS (AggregationServiceV1_0_1->AggregationService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AggregationServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregationServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAggregationService_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAggregationService_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AggregationServiceToStructWrapper, + AggregationServiceToJson, + AggregationServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAggregationService_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AggregationService/v1_0_1/RedfishAggregationService_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/AggregationService/v1_0_1/RedfishAggregationService_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..1177158723e --- /dev/null +++ b/RedfishClientPkg/Converter/AggregationService/v1_0_1/RedfishAggregationService_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AggregationService.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAggregationService_V1_0_1_Dxe + FILE_GUID = 6f41813e-a7c6-4eb6-ad11-67f9f1213b93 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAggregationService_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishAggregationService_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AggregationService_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AggregationServiceV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AggregationSource/v1_0_0/AggregationSource_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/AggregationSource/v1_0_0/AggregationSource_V1_0_0_Dxe.c new file mode 100644 index 00000000000..90267a79478 --- /dev/null +++ b/RedfishClientPkg/Converter/AggregationSource/v1_0_0/AggregationSource_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AggregationSource.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AggregationSource"; +BOOLEAN IsRevisonController = TRUE; + +// Support AggregationSource V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AggregationSource", + "1", + "0", + "0" + }, + "AggregationSource" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregationSourceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_AGGREGATIONSOURCE_V1_0_0 *AggregationSourceV1_0_0; + EFI_REDFISH_AGGREGATIONSOURCE_V1_0_0_CS *AggregationSourceV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AggregationSource") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AggregationSource_V1_0_0_To_CS (ResoruceRaw, &AggregationSourceV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AggregationSourceV1_0_0 = (EFI_REDFISH_AGGREGATIONSOURCE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_AGGREGATIONSOURCE_V1_0_0)); + if (AggregationSourceV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AggregationSourceV1_0_0; + AggregationSourceV1_0_0->AggregationSource = AggregationSourceV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AggregationSource")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AggregationSource"), "AggregationSource"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AggregationSource")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AggregationSource"), "AggregationSource"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AggregationSourceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregationSourceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AggregationSourceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregationSourceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AggregationSource_V1_0_0_JSON (*((EFI_REDFISH_AGGREGATIONSOURCE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AggregationSourceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregationSourceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_AGGREGATIONSOURCE_V1_0_0 *AggregationSourceV1_0_0; + + AggregationSourceV1_0_0 = (EFI_REDFISH_AGGREGATIONSOURCE_V1_0_0 *)InterpProp; + DestroyAggregationSource_V1_0_0_CS (AggregationSourceV1_0_0->AggregationSource); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AggregationSourceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregationSourceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAggregationSource_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAggregationSource_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AggregationSourceToStructWrapper, + AggregationSourceToJson, + AggregationSourceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAggregationSource_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AggregationSource/v1_0_0/RedfishAggregationSource_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/AggregationSource/v1_0_0/RedfishAggregationSource_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..e408e7bf074 --- /dev/null +++ b/RedfishClientPkg/Converter/AggregationSource/v1_0_0/RedfishAggregationSource_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AggregationSource.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAggregationSource_V1_0_0_Dxe + FILE_GUID = b2b5b1a2-e4e9-4f78-837c-c74b4f648d32 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAggregationSource_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishAggregationSource_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AggregationSource_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AggregationSourceV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AggregationSource/v1_1_0/AggregationSource_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/AggregationSource/v1_1_0/AggregationSource_V1_1_0_Dxe.c new file mode 100644 index 00000000000..c7a43ab1825 --- /dev/null +++ b/RedfishClientPkg/Converter/AggregationSource/v1_1_0/AggregationSource_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AggregationSource.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AggregationSource"; +BOOLEAN IsRevisonController = TRUE; + +// Support AggregationSource V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AggregationSource", + "1", + "1", + "0" + }, + "AggregationSource" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregationSourceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_AGGREGATIONSOURCE_V1_1_0 *AggregationSourceV1_1_0; + EFI_REDFISH_AGGREGATIONSOURCE_V1_1_0_CS *AggregationSourceV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AggregationSource") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AggregationSource_V1_1_0_To_CS (ResoruceRaw, &AggregationSourceV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AggregationSourceV1_1_0 = (EFI_REDFISH_AGGREGATIONSOURCE_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_AGGREGATIONSOURCE_V1_1_0)); + if (AggregationSourceV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AggregationSourceV1_1_0; + AggregationSourceV1_1_0->AggregationSource = AggregationSourceV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AggregationSource")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AggregationSource"), "AggregationSource"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AggregationSource")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AggregationSource"), "AggregationSource"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AggregationSourceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregationSourceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AggregationSourceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregationSourceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AggregationSource_V1_1_0_JSON (*((EFI_REDFISH_AGGREGATIONSOURCE_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AggregationSourceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregationSourceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_AGGREGATIONSOURCE_V1_1_0 *AggregationSourceV1_1_0; + + AggregationSourceV1_1_0 = (EFI_REDFISH_AGGREGATIONSOURCE_V1_1_0 *)InterpProp; + DestroyAggregationSource_V1_1_0_CS (AggregationSourceV1_1_0->AggregationSource); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AggregationSourceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregationSourceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAggregationSource_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAggregationSource_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AggregationSourceToStructWrapper, + AggregationSourceToJson, + AggregationSourceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAggregationSource_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AggregationSource/v1_1_0/RedfishAggregationSource_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/AggregationSource/v1_1_0/RedfishAggregationSource_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..c8aa62dcabd --- /dev/null +++ b/RedfishClientPkg/Converter/AggregationSource/v1_1_0/RedfishAggregationSource_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AggregationSource.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAggregationSource_V1_1_0_Dxe + FILE_GUID = 87127623-ad43-48ed-909d-a20e2f91a43d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAggregationSource_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishAggregationSource_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AggregationSource_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AggregationSourceV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AggregationSourceCollection/AggregationSourceCollection_Dxe.c b/RedfishClientPkg/Converter/AggregationSourceCollection/AggregationSourceCollection_Dxe.c new file mode 100644 index 00000000000..6ea0a7b65a9 --- /dev/null +++ b/RedfishClientPkg/Converter/AggregationSourceCollection/AggregationSourceCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AggregationSourceCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AggregationSourceCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support AggregationSourceCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AggregationSourceCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "AggregationSourceCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregationSourceCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_AGGREGATIONSOURCECOLLECTION *AggregationSourceCollection; + EFI_REDFISH_AGGREGATIONSOURCECOLLECTION_CS *AggregationSourceCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AggregationSourceCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AggregationSourceCollection_To_CS (ResoruceRaw, &AggregationSourceCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + AggregationSourceCollection = (EFI_REDFISH_AGGREGATIONSOURCECOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_AGGREGATIONSOURCECOLLECTION)); + if (AggregationSourceCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AggregationSourceCollection; + AggregationSourceCollection->AggregationSourceCollection = AggregationSourceCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AggregationSourceCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AggregationSourceCollection"), "AggregationSourceCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AggregationSourceCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AggregationSourceCollection"), "AggregationSourceCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AggregationSourceCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregationSourceCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AggregationSourceCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregationSourceCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AggregationSourceCollection_JSON (*((EFI_REDFISH_AGGREGATIONSOURCECOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AggregationSourceCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregationSourceCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_AGGREGATIONSOURCECOLLECTION *AggregationSourceCollection; + + AggregationSourceCollection = (EFI_REDFISH_AGGREGATIONSOURCECOLLECTION *)InterpProp; + DestroyAggregationSourceCollection_CS (AggregationSourceCollection->AggregationSourceCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AggregationSourceCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AggregationSourceCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAggregationSourceCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAggregationSourceCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AggregationSourceCollectionToStructWrapper, + AggregationSourceCollectionToJson, + AggregationSourceCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAggregationSourceCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AggregationSourceCollection/RedfishAggregationSourceCollection_Dxe.inf b/RedfishClientPkg/Converter/AggregationSourceCollection/RedfishAggregationSourceCollection_Dxe.inf new file mode 100644 index 00000000000..a32cf84b0fd --- /dev/null +++ b/RedfishClientPkg/Converter/AggregationSourceCollection/RedfishAggregationSourceCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AggregationSourceCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAggregationSourceCollection_Dxe + FILE_GUID = fc8307c8-1d0b-4963-b57d-4cedd128eaa6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAggregationSourceCollectionEntryPoint + UNLOAD_IMAGE = RedfishAggregationSourceCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AggregationSourceCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AggregationSourceCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Assembly/v1_0_0/Assembly_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Assembly/v1_0_0/Assembly_V1_0_0_Dxe.c new file mode 100644 index 00000000000..9283278a50c --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_0_0/Assembly_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Assembly.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Assembly"; +BOOLEAN IsRevisonController = TRUE; + +// Support Assembly V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Assembly", + "1", + "0", + "0" + }, + "Assembly" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_0_0 *AssemblyV1_0_0; + EFI_REDFISH_ASSEMBLY_V1_0_0_CS *AssemblyV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Assembly") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Assembly_V1_0_0_To_CS (ResoruceRaw, &AssemblyV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AssemblyV1_0_0 = (EFI_REDFISH_ASSEMBLY_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ASSEMBLY_V1_0_0)); + if (AssemblyV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AssemblyV1_0_0; + AssemblyV1_0_0->Assembly = AssemblyV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Assembly"), "Assembly"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Assembly"), "Assembly"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AssemblyToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AssemblyToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Assembly_V1_0_0_JSON (*((EFI_REDFISH_ASSEMBLY_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AssemblyToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_0_0 *AssemblyV1_0_0; + + AssemblyV1_0_0 = (EFI_REDFISH_ASSEMBLY_V1_0_0 *)InterpProp; + DestroyAssembly_V1_0_0_CS (AssemblyV1_0_0->Assembly); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AssemblyFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAssembly_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AssemblyToStructWrapper, + AssemblyToJson, + AssemblyDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Assembly/v1_0_0/RedfishAssembly_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Assembly/v1_0_0/RedfishAssembly_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..13c9b1c7089 --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_0_0/RedfishAssembly_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Assembly.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAssembly_V1_0_0_Dxe + FILE_GUID = 416465de-9dab-4e35-ac9a-01c87682d988 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAssembly_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishAssembly_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Assembly_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AssemblyV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Assembly/v1_0_1/Assembly_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/Assembly/v1_0_1/Assembly_V1_0_1_Dxe.c new file mode 100644 index 00000000000..552e5d2ff8b --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_0_1/Assembly_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Assembly.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Assembly"; +BOOLEAN IsRevisonController = TRUE; + +// Support Assembly V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Assembly", + "1", + "0", + "1" + }, + "Assembly" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_0_1 *AssemblyV1_0_1; + EFI_REDFISH_ASSEMBLY_V1_0_1_CS *AssemblyV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Assembly") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Assembly_V1_0_1_To_CS (ResoruceRaw, &AssemblyV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AssemblyV1_0_1 = (EFI_REDFISH_ASSEMBLY_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ASSEMBLY_V1_0_1)); + if (AssemblyV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AssemblyV1_0_1; + AssemblyV1_0_1->Assembly = AssemblyV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Assembly"), "Assembly"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Assembly"), "Assembly"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AssemblyToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AssemblyToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Assembly_V1_0_1_JSON (*((EFI_REDFISH_ASSEMBLY_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AssemblyToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_0_1 *AssemblyV1_0_1; + + AssemblyV1_0_1 = (EFI_REDFISH_ASSEMBLY_V1_0_1 *)InterpProp; + DestroyAssembly_V1_0_1_CS (AssemblyV1_0_1->Assembly); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AssemblyFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAssembly_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AssemblyToStructWrapper, + AssemblyToJson, + AssemblyDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Assembly/v1_0_1/RedfishAssembly_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/Assembly/v1_0_1/RedfishAssembly_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..44f6be0912c --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_0_1/RedfishAssembly_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Assembly.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAssembly_V1_0_1_Dxe + FILE_GUID = 1fa8b33f-a30f-419a-a1e7-fa03c7b7b727 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAssembly_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishAssembly_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Assembly_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AssemblyV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Assembly/v1_0_2/Assembly_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Assembly/v1_0_2/Assembly_V1_0_2_Dxe.c new file mode 100644 index 00000000000..897b99a4174 --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_0_2/Assembly_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Assembly.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Assembly"; +BOOLEAN IsRevisonController = TRUE; + +// Support Assembly V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Assembly", + "1", + "0", + "2" + }, + "Assembly" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_0_2 *AssemblyV1_0_2; + EFI_REDFISH_ASSEMBLY_V1_0_2_CS *AssemblyV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Assembly") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Assembly_V1_0_2_To_CS (ResoruceRaw, &AssemblyV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AssemblyV1_0_2 = (EFI_REDFISH_ASSEMBLY_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ASSEMBLY_V1_0_2)); + if (AssemblyV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AssemblyV1_0_2; + AssemblyV1_0_2->Assembly = AssemblyV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Assembly"), "Assembly"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Assembly"), "Assembly"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AssemblyToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AssemblyToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Assembly_V1_0_2_JSON (*((EFI_REDFISH_ASSEMBLY_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AssemblyToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_0_2 *AssemblyV1_0_2; + + AssemblyV1_0_2 = (EFI_REDFISH_ASSEMBLY_V1_0_2 *)InterpProp; + DestroyAssembly_V1_0_2_CS (AssemblyV1_0_2->Assembly); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AssemblyFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAssembly_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AssemblyToStructWrapper, + AssemblyToJson, + AssemblyDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Assembly/v1_0_2/RedfishAssembly_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Assembly/v1_0_2/RedfishAssembly_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..5c1c5b470d0 --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_0_2/RedfishAssembly_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Assembly.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAssembly_V1_0_2_Dxe + FILE_GUID = 2d8f35b4-5565-4fd0-935e-4e5e8b845a1f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAssembly_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishAssembly_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Assembly_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AssemblyV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Assembly/v1_0_3/Assembly_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/Assembly/v1_0_3/Assembly_V1_0_3_Dxe.c new file mode 100644 index 00000000000..53bc71edac6 --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_0_3/Assembly_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Assembly.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Assembly"; +BOOLEAN IsRevisonController = TRUE; + +// Support Assembly V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Assembly", + "1", + "0", + "3" + }, + "Assembly" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_0_3 *AssemblyV1_0_3; + EFI_REDFISH_ASSEMBLY_V1_0_3_CS *AssemblyV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Assembly") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Assembly_V1_0_3_To_CS (ResoruceRaw, &AssemblyV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AssemblyV1_0_3 = (EFI_REDFISH_ASSEMBLY_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ASSEMBLY_V1_0_3)); + if (AssemblyV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AssemblyV1_0_3; + AssemblyV1_0_3->Assembly = AssemblyV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Assembly"), "Assembly"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Assembly"), "Assembly"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AssemblyToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AssemblyToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Assembly_V1_0_3_JSON (*((EFI_REDFISH_ASSEMBLY_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AssemblyToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_0_3 *AssemblyV1_0_3; + + AssemblyV1_0_3 = (EFI_REDFISH_ASSEMBLY_V1_0_3 *)InterpProp; + DestroyAssembly_V1_0_3_CS (AssemblyV1_0_3->Assembly); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AssemblyFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAssembly_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AssemblyToStructWrapper, + AssemblyToJson, + AssemblyDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Assembly/v1_0_3/RedfishAssembly_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/Assembly/v1_0_3/RedfishAssembly_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..65abcdf219d --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_0_3/RedfishAssembly_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Assembly.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAssembly_V1_0_3_Dxe + FILE_GUID = 3278c8a0-a414-4160-bdbb-e843c96fa691 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAssembly_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishAssembly_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Assembly_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AssemblyV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Assembly/v1_0_4/Assembly_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/Assembly/v1_0_4/Assembly_V1_0_4_Dxe.c new file mode 100644 index 00000000000..29362186296 --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_0_4/Assembly_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Assembly.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Assembly"; +BOOLEAN IsRevisonController = TRUE; + +// Support Assembly V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Assembly", + "1", + "0", + "4" + }, + "Assembly" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_0_4 *AssemblyV1_0_4; + EFI_REDFISH_ASSEMBLY_V1_0_4_CS *AssemblyV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Assembly") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Assembly_V1_0_4_To_CS (ResoruceRaw, &AssemblyV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AssemblyV1_0_4 = (EFI_REDFISH_ASSEMBLY_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ASSEMBLY_V1_0_4)); + if (AssemblyV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AssemblyV1_0_4; + AssemblyV1_0_4->Assembly = AssemblyV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Assembly"), "Assembly"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Assembly"), "Assembly"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AssemblyToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AssemblyToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Assembly_V1_0_4_JSON (*((EFI_REDFISH_ASSEMBLY_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AssemblyToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_0_4 *AssemblyV1_0_4; + + AssemblyV1_0_4 = (EFI_REDFISH_ASSEMBLY_V1_0_4 *)InterpProp; + DestroyAssembly_V1_0_4_CS (AssemblyV1_0_4->Assembly); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AssemblyFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAssembly_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AssemblyToStructWrapper, + AssemblyToJson, + AssemblyDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Assembly/v1_0_4/RedfishAssembly_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/Assembly/v1_0_4/RedfishAssembly_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..d6057ce5dec --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_0_4/RedfishAssembly_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Assembly.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAssembly_V1_0_4_Dxe + FILE_GUID = 80afaec7-07f4-4fad-8233-549c4c869850 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAssembly_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishAssembly_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Assembly_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AssemblyV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Assembly/v1_1_0/Assembly_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/Assembly/v1_1_0/Assembly_V1_1_0_Dxe.c new file mode 100644 index 00000000000..66e2157061e --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_1_0/Assembly_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Assembly.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Assembly"; +BOOLEAN IsRevisonController = TRUE; + +// Support Assembly V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Assembly", + "1", + "1", + "0" + }, + "Assembly" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_1_0 *AssemblyV1_1_0; + EFI_REDFISH_ASSEMBLY_V1_1_0_CS *AssemblyV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Assembly") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Assembly_V1_1_0_To_CS (ResoruceRaw, &AssemblyV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AssemblyV1_1_0 = (EFI_REDFISH_ASSEMBLY_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ASSEMBLY_V1_1_0)); + if (AssemblyV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AssemblyV1_1_0; + AssemblyV1_1_0->Assembly = AssemblyV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Assembly"), "Assembly"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Assembly"), "Assembly"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AssemblyToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AssemblyToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Assembly_V1_1_0_JSON (*((EFI_REDFISH_ASSEMBLY_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AssemblyToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_1_0 *AssemblyV1_1_0; + + AssemblyV1_1_0 = (EFI_REDFISH_ASSEMBLY_V1_1_0 *)InterpProp; + DestroyAssembly_V1_1_0_CS (AssemblyV1_1_0->Assembly); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AssemblyFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAssembly_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AssemblyToStructWrapper, + AssemblyToJson, + AssemblyDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Assembly/v1_1_0/RedfishAssembly_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/Assembly/v1_1_0/RedfishAssembly_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..b69497b7c22 --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_1_0/RedfishAssembly_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Assembly.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAssembly_V1_1_0_Dxe + FILE_GUID = dfbf9b07-fa63-497d-9a89-20f298aedd66 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAssembly_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishAssembly_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Assembly_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AssemblyV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Assembly/v1_1_1/Assembly_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/Assembly/v1_1_1/Assembly_V1_1_1_Dxe.c new file mode 100644 index 00000000000..d4f263007c7 --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_1_1/Assembly_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Assembly.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Assembly"; +BOOLEAN IsRevisonController = TRUE; + +// Support Assembly V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Assembly", + "1", + "1", + "1" + }, + "Assembly" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_1_1 *AssemblyV1_1_1; + EFI_REDFISH_ASSEMBLY_V1_1_1_CS *AssemblyV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Assembly") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Assembly_V1_1_1_To_CS (ResoruceRaw, &AssemblyV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AssemblyV1_1_1 = (EFI_REDFISH_ASSEMBLY_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ASSEMBLY_V1_1_1)); + if (AssemblyV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AssemblyV1_1_1; + AssemblyV1_1_1->Assembly = AssemblyV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Assembly"), "Assembly"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Assembly"), "Assembly"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AssemblyToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AssemblyToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Assembly_V1_1_1_JSON (*((EFI_REDFISH_ASSEMBLY_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AssemblyToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_1_1 *AssemblyV1_1_1; + + AssemblyV1_1_1 = (EFI_REDFISH_ASSEMBLY_V1_1_1 *)InterpProp; + DestroyAssembly_V1_1_1_CS (AssemblyV1_1_1->Assembly); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AssemblyFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAssembly_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AssemblyToStructWrapper, + AssemblyToJson, + AssemblyDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Assembly/v1_1_1/RedfishAssembly_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/Assembly/v1_1_1/RedfishAssembly_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..b698985da54 --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_1_1/RedfishAssembly_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Assembly.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAssembly_V1_1_1_Dxe + FILE_GUID = 89926c72-0b54-4e4a-8be8-e0eb5c405bcf + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAssembly_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishAssembly_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Assembly_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AssemblyV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Assembly/v1_1_2/Assembly_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/Assembly/v1_1_2/Assembly_V1_1_2_Dxe.c new file mode 100644 index 00000000000..0219d7537c8 --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_1_2/Assembly_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Assembly.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Assembly"; +BOOLEAN IsRevisonController = TRUE; + +// Support Assembly V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Assembly", + "1", + "1", + "2" + }, + "Assembly" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_1_2 *AssemblyV1_1_2; + EFI_REDFISH_ASSEMBLY_V1_1_2_CS *AssemblyV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Assembly") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Assembly_V1_1_2_To_CS (ResoruceRaw, &AssemblyV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AssemblyV1_1_2 = (EFI_REDFISH_ASSEMBLY_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ASSEMBLY_V1_1_2)); + if (AssemblyV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AssemblyV1_1_2; + AssemblyV1_1_2->Assembly = AssemblyV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Assembly"), "Assembly"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Assembly"), "Assembly"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AssemblyToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AssemblyToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Assembly_V1_1_2_JSON (*((EFI_REDFISH_ASSEMBLY_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AssemblyToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_1_2 *AssemblyV1_1_2; + + AssemblyV1_1_2 = (EFI_REDFISH_ASSEMBLY_V1_1_2 *)InterpProp; + DestroyAssembly_V1_1_2_CS (AssemblyV1_1_2->Assembly); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AssemblyFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAssembly_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AssemblyToStructWrapper, + AssemblyToJson, + AssemblyDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Assembly/v1_1_2/RedfishAssembly_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/Assembly/v1_1_2/RedfishAssembly_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..ef6a503565d --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_1_2/RedfishAssembly_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Assembly.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAssembly_V1_1_2_Dxe + FILE_GUID = f14f2fdc-9016-40db-981e-8ba796f91979 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAssembly_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishAssembly_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Assembly_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AssemblyV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Assembly/v1_1_3/Assembly_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/Assembly/v1_1_3/Assembly_V1_1_3_Dxe.c new file mode 100644 index 00000000000..9072d838f03 --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_1_3/Assembly_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Assembly.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Assembly"; +BOOLEAN IsRevisonController = TRUE; + +// Support Assembly V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Assembly", + "1", + "1", + "3" + }, + "Assembly" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_1_3 *AssemblyV1_1_3; + EFI_REDFISH_ASSEMBLY_V1_1_3_CS *AssemblyV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Assembly") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Assembly_V1_1_3_To_CS (ResoruceRaw, &AssemblyV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AssemblyV1_1_3 = (EFI_REDFISH_ASSEMBLY_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ASSEMBLY_V1_1_3)); + if (AssemblyV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AssemblyV1_1_3; + AssemblyV1_1_3->Assembly = AssemblyV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Assembly"), "Assembly"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Assembly"), "Assembly"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AssemblyToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AssemblyToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Assembly_V1_1_3_JSON (*((EFI_REDFISH_ASSEMBLY_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AssemblyToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_1_3 *AssemblyV1_1_3; + + AssemblyV1_1_3 = (EFI_REDFISH_ASSEMBLY_V1_1_3 *)InterpProp; + DestroyAssembly_V1_1_3_CS (AssemblyV1_1_3->Assembly); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AssemblyFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAssembly_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AssemblyToStructWrapper, + AssemblyToJson, + AssemblyDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Assembly/v1_1_3/RedfishAssembly_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/Assembly/v1_1_3/RedfishAssembly_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..53e81442311 --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_1_3/RedfishAssembly_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Assembly.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAssembly_V1_1_3_Dxe + FILE_GUID = 537dce4b-51a1-4e10-b023-d1aa055d371a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAssembly_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishAssembly_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Assembly_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AssemblyV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Assembly/v1_1_4/Assembly_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/Assembly/v1_1_4/Assembly_V1_1_4_Dxe.c new file mode 100644 index 00000000000..4689dd696b6 --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_1_4/Assembly_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Assembly.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Assembly"; +BOOLEAN IsRevisonController = TRUE; + +// Support Assembly V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Assembly", + "1", + "1", + "4" + }, + "Assembly" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_1_4 *AssemblyV1_1_4; + EFI_REDFISH_ASSEMBLY_V1_1_4_CS *AssemblyV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Assembly") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Assembly_V1_1_4_To_CS (ResoruceRaw, &AssemblyV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AssemblyV1_1_4 = (EFI_REDFISH_ASSEMBLY_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ASSEMBLY_V1_1_4)); + if (AssemblyV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AssemblyV1_1_4; + AssemblyV1_1_4->Assembly = AssemblyV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Assembly"), "Assembly"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Assembly"), "Assembly"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AssemblyToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AssemblyToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Assembly_V1_1_4_JSON (*((EFI_REDFISH_ASSEMBLY_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AssemblyToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_1_4 *AssemblyV1_1_4; + + AssemblyV1_1_4 = (EFI_REDFISH_ASSEMBLY_V1_1_4 *)InterpProp; + DestroyAssembly_V1_1_4_CS (AssemblyV1_1_4->Assembly); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AssemblyFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAssembly_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AssemblyToStructWrapper, + AssemblyToJson, + AssemblyDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Assembly/v1_1_4/RedfishAssembly_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/Assembly/v1_1_4/RedfishAssembly_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..578ab058ae5 --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_1_4/RedfishAssembly_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Assembly.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAssembly_V1_1_4_Dxe + FILE_GUID = b863ffe5-02b2-46a4-abbc-7b1eef00d046 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAssembly_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishAssembly_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Assembly_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AssemblyV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Assembly/v1_2_0/Assembly_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/Assembly/v1_2_0/Assembly_V1_2_0_Dxe.c new file mode 100644 index 00000000000..bc35dde5135 --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_2_0/Assembly_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Assembly.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Assembly"; +BOOLEAN IsRevisonController = TRUE; + +// Support Assembly V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Assembly", + "1", + "2", + "0" + }, + "Assembly" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_2_0 *AssemblyV1_2_0; + EFI_REDFISH_ASSEMBLY_V1_2_0_CS *AssemblyV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Assembly") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Assembly_V1_2_0_To_CS (ResoruceRaw, &AssemblyV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AssemblyV1_2_0 = (EFI_REDFISH_ASSEMBLY_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ASSEMBLY_V1_2_0)); + if (AssemblyV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AssemblyV1_2_0; + AssemblyV1_2_0->Assembly = AssemblyV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Assembly"), "Assembly"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Assembly"), "Assembly"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AssemblyToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AssemblyToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Assembly_V1_2_0_JSON (*((EFI_REDFISH_ASSEMBLY_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AssemblyToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_2_0 *AssemblyV1_2_0; + + AssemblyV1_2_0 = (EFI_REDFISH_ASSEMBLY_V1_2_0 *)InterpProp; + DestroyAssembly_V1_2_0_CS (AssemblyV1_2_0->Assembly); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AssemblyFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAssembly_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AssemblyToStructWrapper, + AssemblyToJson, + AssemblyDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Assembly/v1_2_0/RedfishAssembly_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/Assembly/v1_2_0/RedfishAssembly_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..e5c8b4c7672 --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_2_0/RedfishAssembly_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Assembly.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAssembly_V1_2_0_Dxe + FILE_GUID = 58b9fe30-e847-47f5-b048-93ae7b5cfd1a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAssembly_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishAssembly_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Assembly_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AssemblyV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Assembly/v1_2_1/Assembly_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/Assembly/v1_2_1/Assembly_V1_2_1_Dxe.c new file mode 100644 index 00000000000..8d2cbda528e --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_2_1/Assembly_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Assembly.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Assembly"; +BOOLEAN IsRevisonController = TRUE; + +// Support Assembly V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Assembly", + "1", + "2", + "1" + }, + "Assembly" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_2_1 *AssemblyV1_2_1; + EFI_REDFISH_ASSEMBLY_V1_2_1_CS *AssemblyV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Assembly") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Assembly_V1_2_1_To_CS (ResoruceRaw, &AssemblyV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AssemblyV1_2_1 = (EFI_REDFISH_ASSEMBLY_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ASSEMBLY_V1_2_1)); + if (AssemblyV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AssemblyV1_2_1; + AssemblyV1_2_1->Assembly = AssemblyV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Assembly"), "Assembly"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Assembly"), "Assembly"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AssemblyToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AssemblyToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Assembly_V1_2_1_JSON (*((EFI_REDFISH_ASSEMBLY_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AssemblyToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_2_1 *AssemblyV1_2_1; + + AssemblyV1_2_1 = (EFI_REDFISH_ASSEMBLY_V1_2_1 *)InterpProp; + DestroyAssembly_V1_2_1_CS (AssemblyV1_2_1->Assembly); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AssemblyFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAssembly_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AssemblyToStructWrapper, + AssemblyToJson, + AssemblyDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Assembly/v1_2_1/RedfishAssembly_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/Assembly/v1_2_1/RedfishAssembly_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..be330bde76a --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_2_1/RedfishAssembly_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Assembly.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAssembly_V1_2_1_Dxe + FILE_GUID = 73a47230-ad1e-4946-8f10-ac2ab5a42031 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAssembly_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishAssembly_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Assembly_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AssemblyV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Assembly/v1_2_2/Assembly_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/Assembly/v1_2_2/Assembly_V1_2_2_Dxe.c new file mode 100644 index 00000000000..1256c834f67 --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_2_2/Assembly_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Assembly.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Assembly"; +BOOLEAN IsRevisonController = TRUE; + +// Support Assembly V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Assembly", + "1", + "2", + "2" + }, + "Assembly" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_2_2 *AssemblyV1_2_2; + EFI_REDFISH_ASSEMBLY_V1_2_2_CS *AssemblyV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Assembly") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Assembly_V1_2_2_To_CS (ResoruceRaw, &AssemblyV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AssemblyV1_2_2 = (EFI_REDFISH_ASSEMBLY_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ASSEMBLY_V1_2_2)); + if (AssemblyV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AssemblyV1_2_2; + AssemblyV1_2_2->Assembly = AssemblyV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Assembly"), "Assembly"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Assembly"), "Assembly"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AssemblyToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AssemblyToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Assembly_V1_2_2_JSON (*((EFI_REDFISH_ASSEMBLY_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AssemblyToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_2_2 *AssemblyV1_2_2; + + AssemblyV1_2_2 = (EFI_REDFISH_ASSEMBLY_V1_2_2 *)InterpProp; + DestroyAssembly_V1_2_2_CS (AssemblyV1_2_2->Assembly); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AssemblyFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAssembly_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AssemblyToStructWrapper, + AssemblyToJson, + AssemblyDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Assembly/v1_2_2/RedfishAssembly_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/Assembly/v1_2_2/RedfishAssembly_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..9e9ec607898 --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_2_2/RedfishAssembly_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Assembly.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAssembly_V1_2_2_Dxe + FILE_GUID = 8247faaa-21f5-4809-b210-6bc4626057f5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAssembly_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishAssembly_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Assembly_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AssemblyV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Assembly/v1_2_3/Assembly_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/Assembly/v1_2_3/Assembly_V1_2_3_Dxe.c new file mode 100644 index 00000000000..45dbeb275d0 --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_2_3/Assembly_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Assembly.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Assembly"; +BOOLEAN IsRevisonController = TRUE; + +// Support Assembly V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Assembly", + "1", + "2", + "3" + }, + "Assembly" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_2_3 *AssemblyV1_2_3; + EFI_REDFISH_ASSEMBLY_V1_2_3_CS *AssemblyV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Assembly") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Assembly_V1_2_3_To_CS (ResoruceRaw, &AssemblyV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AssemblyV1_2_3 = (EFI_REDFISH_ASSEMBLY_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ASSEMBLY_V1_2_3)); + if (AssemblyV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AssemblyV1_2_3; + AssemblyV1_2_3->Assembly = AssemblyV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Assembly"), "Assembly"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Assembly"), "Assembly"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AssemblyToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AssemblyToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Assembly_V1_2_3_JSON (*((EFI_REDFISH_ASSEMBLY_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AssemblyToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_2_3 *AssemblyV1_2_3; + + AssemblyV1_2_3 = (EFI_REDFISH_ASSEMBLY_V1_2_3 *)InterpProp; + DestroyAssembly_V1_2_3_CS (AssemblyV1_2_3->Assembly); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AssemblyFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAssembly_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AssemblyToStructWrapper, + AssemblyToJson, + AssemblyDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Assembly/v1_2_3/RedfishAssembly_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/Assembly/v1_2_3/RedfishAssembly_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..e47baa059c0 --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_2_3/RedfishAssembly_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Assembly.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAssembly_V1_2_3_Dxe + FILE_GUID = 66b02267-3f9c-47a8-91b1-00803632964e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAssembly_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishAssembly_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Assembly_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AssemblyV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Assembly/v1_3_0/Assembly_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/Assembly/v1_3_0/Assembly_V1_3_0_Dxe.c new file mode 100644 index 00000000000..7a9496d18d5 --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_3_0/Assembly_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Assembly.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Assembly"; +BOOLEAN IsRevisonController = TRUE; + +// Support Assembly V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Assembly", + "1", + "3", + "0" + }, + "Assembly" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_3_0 *AssemblyV1_3_0; + EFI_REDFISH_ASSEMBLY_V1_3_0_CS *AssemblyV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Assembly") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Assembly_V1_3_0_To_CS (ResoruceRaw, &AssemblyV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AssemblyV1_3_0 = (EFI_REDFISH_ASSEMBLY_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ASSEMBLY_V1_3_0)); + if (AssemblyV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AssemblyV1_3_0; + AssemblyV1_3_0->Assembly = AssemblyV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Assembly"), "Assembly"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Assembly")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Assembly"), "Assembly"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AssemblyToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AssemblyToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Assembly_V1_3_0_JSON (*((EFI_REDFISH_ASSEMBLY_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AssemblyToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ASSEMBLY_V1_3_0 *AssemblyV1_3_0; + + AssemblyV1_3_0 = (EFI_REDFISH_ASSEMBLY_V1_3_0 *)InterpProp; + DestroyAssembly_V1_3_0_CS (AssemblyV1_3_0->Assembly); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AssemblyFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AssemblyDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAssembly_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AssemblyToStructWrapper, + AssemblyToJson, + AssemblyDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAssembly_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Assembly/v1_3_0/RedfishAssembly_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/Assembly/v1_3_0/RedfishAssembly_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..ae45543f962 --- /dev/null +++ b/RedfishClientPkg/Converter/Assembly/v1_3_0/RedfishAssembly_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Assembly.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAssembly_V1_3_0_Dxe + FILE_GUID = 7cb4234a-dbaf-42db-b8c5-4ad18f54c773 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAssembly_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishAssembly_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Assembly_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AssemblyV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_0_0/AttributeRegistry_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_0/AttributeRegistry_V1_0_0_Dxe.c new file mode 100644 index 00000000000..0454ce46fb4 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_0/AttributeRegistry_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "0", + "0" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_0 *AttributeRegistryV1_0_0; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_0_CS *AttributeRegistryV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_0_0_To_CS (ResoruceRaw, &AttributeRegistryV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_0_0 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_0)); + if (AttributeRegistryV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_0_0; + AttributeRegistryV1_0_0->AttributeRegistry = AttributeRegistryV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_0_0_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_0 *AttributeRegistryV1_0_0; + + AttributeRegistryV1_0_0 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_0 *)InterpProp; + DestroyAttributeRegistry_V1_0_0_CS (AttributeRegistryV1_0_0->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_0_0/RedfishAttributeRegistry_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_0/RedfishAttributeRegistry_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..43dcac0e8f4 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_0/RedfishAttributeRegistry_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_0_0_Dxe + FILE_GUID = 96054a69-d119-41e2-9b52-83d3912ca94c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_0_1/AttributeRegistry_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_1/AttributeRegistry_V1_0_1_Dxe.c new file mode 100644 index 00000000000..db687869cdc --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_1/AttributeRegistry_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "0", + "1" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_1 *AttributeRegistryV1_0_1; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_1_CS *AttributeRegistryV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_0_1_To_CS (ResoruceRaw, &AttributeRegistryV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_0_1 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_1)); + if (AttributeRegistryV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_0_1; + AttributeRegistryV1_0_1->AttributeRegistry = AttributeRegistryV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_0_1_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_1 *AttributeRegistryV1_0_1; + + AttributeRegistryV1_0_1 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_1 *)InterpProp; + DestroyAttributeRegistry_V1_0_1_CS (AttributeRegistryV1_0_1->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_0_1/RedfishAttributeRegistry_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_1/RedfishAttributeRegistry_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..83184db72df --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_1/RedfishAttributeRegistry_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_0_1_Dxe + FILE_GUID = bd64e80f-4f7e-4198-a87e-ed4732f17d54 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_0_10/AttributeRegistry_V1_0_10_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_10/AttributeRegistry_V1_0_10_Dxe.c new file mode 100644 index 00000000000..80934bb672b --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_10/AttributeRegistry_V1_0_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_0_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "0", + "10" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_10 *AttributeRegistryV1_0_10; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_10_CS *AttributeRegistryV1_0_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_0_10_To_CS (ResoruceRaw, &AttributeRegistryV1_0_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_0_10 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_10)); + if (AttributeRegistryV1_0_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_0_10; + AttributeRegistryV1_0_10->AttributeRegistry = AttributeRegistryV1_0_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_0_10_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_10 *AttributeRegistryV1_0_10; + + AttributeRegistryV1_0_10 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_10 *)InterpProp; + DestroyAttributeRegistry_V1_0_10_CS (AttributeRegistryV1_0_10->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_0_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_0_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_0_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_0_10/RedfishAttributeRegistry_V1_0_10_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_10/RedfishAttributeRegistry_V1_0_10_Dxe.inf new file mode 100644 index 00000000000..a9326f31c1c --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_10/RedfishAttributeRegistry_V1_0_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_0_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_0_10_Dxe + FILE_GUID = 418c0eba-acbe-4cc8-838c-4957c75cc4c7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_0_10EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_0_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_0_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_0_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_0_2/AttributeRegistry_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_2/AttributeRegistry_V1_0_2_Dxe.c new file mode 100644 index 00000000000..a0743fa8239 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_2/AttributeRegistry_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "0", + "2" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_2 *AttributeRegistryV1_0_2; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_2_CS *AttributeRegistryV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_0_2_To_CS (ResoruceRaw, &AttributeRegistryV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_0_2 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_2)); + if (AttributeRegistryV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_0_2; + AttributeRegistryV1_0_2->AttributeRegistry = AttributeRegistryV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_0_2_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_2 *AttributeRegistryV1_0_2; + + AttributeRegistryV1_0_2 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_2 *)InterpProp; + DestroyAttributeRegistry_V1_0_2_CS (AttributeRegistryV1_0_2->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_0_2/RedfishAttributeRegistry_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_2/RedfishAttributeRegistry_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..1cb8af047b3 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_2/RedfishAttributeRegistry_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_0_2_Dxe + FILE_GUID = 9e7b335b-10c7-42bd-8bd2-5c69ef1da64c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_0_3/AttributeRegistry_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_3/AttributeRegistry_V1_0_3_Dxe.c new file mode 100644 index 00000000000..5947efde4ce --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_3/AttributeRegistry_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "0", + "3" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_3 *AttributeRegistryV1_0_3; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_3_CS *AttributeRegistryV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_0_3_To_CS (ResoruceRaw, &AttributeRegistryV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_0_3 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_3)); + if (AttributeRegistryV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_0_3; + AttributeRegistryV1_0_3->AttributeRegistry = AttributeRegistryV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_0_3_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_3 *AttributeRegistryV1_0_3; + + AttributeRegistryV1_0_3 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_3 *)InterpProp; + DestroyAttributeRegistry_V1_0_3_CS (AttributeRegistryV1_0_3->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_0_3/RedfishAttributeRegistry_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_3/RedfishAttributeRegistry_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..8629b8a3561 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_3/RedfishAttributeRegistry_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_0_3_Dxe + FILE_GUID = e85274d2-08ea-4afe-8f65-403df3e475ac + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_0_4/AttributeRegistry_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_4/AttributeRegistry_V1_0_4_Dxe.c new file mode 100644 index 00000000000..afc35d77728 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_4/AttributeRegistry_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "0", + "4" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_4 *AttributeRegistryV1_0_4; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_4_CS *AttributeRegistryV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_0_4_To_CS (ResoruceRaw, &AttributeRegistryV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_0_4 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_4)); + if (AttributeRegistryV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_0_4; + AttributeRegistryV1_0_4->AttributeRegistry = AttributeRegistryV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_0_4_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_4 *AttributeRegistryV1_0_4; + + AttributeRegistryV1_0_4 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_4 *)InterpProp; + DestroyAttributeRegistry_V1_0_4_CS (AttributeRegistryV1_0_4->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_0_4/RedfishAttributeRegistry_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_4/RedfishAttributeRegistry_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..44a4cca03ef --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_4/RedfishAttributeRegistry_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_0_4_Dxe + FILE_GUID = 888c363b-474b-46fa-8d14-29455f88679b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_0_5/AttributeRegistry_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_5/AttributeRegistry_V1_0_5_Dxe.c new file mode 100644 index 00000000000..d00cfecd183 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_5/AttributeRegistry_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "0", + "5" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_5 *AttributeRegistryV1_0_5; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_5_CS *AttributeRegistryV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_0_5_To_CS (ResoruceRaw, &AttributeRegistryV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_0_5 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_5)); + if (AttributeRegistryV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_0_5; + AttributeRegistryV1_0_5->AttributeRegistry = AttributeRegistryV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_0_5_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_5 *AttributeRegistryV1_0_5; + + AttributeRegistryV1_0_5 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_5 *)InterpProp; + DestroyAttributeRegistry_V1_0_5_CS (AttributeRegistryV1_0_5->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_0_5/RedfishAttributeRegistry_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_5/RedfishAttributeRegistry_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..0e9147b8233 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_5/RedfishAttributeRegistry_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_0_5_Dxe + FILE_GUID = 1a361994-2c48-46b3-8530-b51fea0f33b4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_0_6/AttributeRegistry_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_6/AttributeRegistry_V1_0_6_Dxe.c new file mode 100644 index 00000000000..a92b6b4e17f --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_6/AttributeRegistry_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "0", + "6" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_6 *AttributeRegistryV1_0_6; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_6_CS *AttributeRegistryV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_0_6_To_CS (ResoruceRaw, &AttributeRegistryV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_0_6 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_6)); + if (AttributeRegistryV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_0_6; + AttributeRegistryV1_0_6->AttributeRegistry = AttributeRegistryV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_0_6_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_6 *AttributeRegistryV1_0_6; + + AttributeRegistryV1_0_6 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_6 *)InterpProp; + DestroyAttributeRegistry_V1_0_6_CS (AttributeRegistryV1_0_6->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_0_6/RedfishAttributeRegistry_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_6/RedfishAttributeRegistry_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..08df86e00f5 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_6/RedfishAttributeRegistry_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_0_6_Dxe + FILE_GUID = 5b586b2c-a40c-4717-aa95-347c80dced19 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_0_7/AttributeRegistry_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_7/AttributeRegistry_V1_0_7_Dxe.c new file mode 100644 index 00000000000..83bc96fa9e3 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_7/AttributeRegistry_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "0", + "7" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_7 *AttributeRegistryV1_0_7; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_7_CS *AttributeRegistryV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_0_7_To_CS (ResoruceRaw, &AttributeRegistryV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_0_7 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_7)); + if (AttributeRegistryV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_0_7; + AttributeRegistryV1_0_7->AttributeRegistry = AttributeRegistryV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_0_7_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_7 *AttributeRegistryV1_0_7; + + AttributeRegistryV1_0_7 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_7 *)InterpProp; + DestroyAttributeRegistry_V1_0_7_CS (AttributeRegistryV1_0_7->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_0_7/RedfishAttributeRegistry_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_7/RedfishAttributeRegistry_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..9d3018f2e74 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_7/RedfishAttributeRegistry_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_0_7_Dxe + FILE_GUID = 94d7c669-b4bd-45c8-bac1-d17b1ca65bcc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_0_8/AttributeRegistry_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_8/AttributeRegistry_V1_0_8_Dxe.c new file mode 100644 index 00000000000..027379c4f81 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_8/AttributeRegistry_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "0", + "8" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_8 *AttributeRegistryV1_0_8; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_8_CS *AttributeRegistryV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_0_8_To_CS (ResoruceRaw, &AttributeRegistryV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_0_8 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_8)); + if (AttributeRegistryV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_0_8; + AttributeRegistryV1_0_8->AttributeRegistry = AttributeRegistryV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_0_8_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_8 *AttributeRegistryV1_0_8; + + AttributeRegistryV1_0_8 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_8 *)InterpProp; + DestroyAttributeRegistry_V1_0_8_CS (AttributeRegistryV1_0_8->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_0_8/RedfishAttributeRegistry_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_8/RedfishAttributeRegistry_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..203d97ec3b6 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_8/RedfishAttributeRegistry_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_0_8_Dxe + FILE_GUID = 5852140a-85a1-460a-b8a2-0da215c293a0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_0_9/AttributeRegistry_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_9/AttributeRegistry_V1_0_9_Dxe.c new file mode 100644 index 00000000000..0063af4693d --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_9/AttributeRegistry_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "0", + "9" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_9 *AttributeRegistryV1_0_9; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_9_CS *AttributeRegistryV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_0_9_To_CS (ResoruceRaw, &AttributeRegistryV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_0_9 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_9)); + if (AttributeRegistryV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_0_9; + AttributeRegistryV1_0_9->AttributeRegistry = AttributeRegistryV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_0_9_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_9 *AttributeRegistryV1_0_9; + + AttributeRegistryV1_0_9 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_9 *)InterpProp; + DestroyAttributeRegistry_V1_0_9_CS (AttributeRegistryV1_0_9->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_0_9/RedfishAttributeRegistry_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_9/RedfishAttributeRegistry_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..fc68731704f --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_0_9/RedfishAttributeRegistry_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_0_9_Dxe + FILE_GUID = 24953974-9ce9-44b8-8c69-f04654f24f76 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_1_0/AttributeRegistry_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_0/AttributeRegistry_V1_1_0_Dxe.c new file mode 100644 index 00000000000..07b3c0e5b99 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_0/AttributeRegistry_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "1", + "0" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_0 *AttributeRegistryV1_1_0; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_0_CS *AttributeRegistryV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_1_0_To_CS (ResoruceRaw, &AttributeRegistryV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_1_0 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_0)); + if (AttributeRegistryV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_1_0; + AttributeRegistryV1_1_0->AttributeRegistry = AttributeRegistryV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_1_0_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_0 *AttributeRegistryV1_1_0; + + AttributeRegistryV1_1_0 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_0 *)InterpProp; + DestroyAttributeRegistry_V1_1_0_CS (AttributeRegistryV1_1_0->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_1_0/RedfishAttributeRegistry_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_0/RedfishAttributeRegistry_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..00f52c3b4c3 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_0/RedfishAttributeRegistry_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_1_0_Dxe + FILE_GUID = 79407199-5b50-4fe5-92fd-7d66c6f39eac + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_1_1/AttributeRegistry_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_1/AttributeRegistry_V1_1_1_Dxe.c new file mode 100644 index 00000000000..f928f8cd424 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_1/AttributeRegistry_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "1", + "1" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_1 *AttributeRegistryV1_1_1; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_1_CS *AttributeRegistryV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_1_1_To_CS (ResoruceRaw, &AttributeRegistryV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_1_1 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_1)); + if (AttributeRegistryV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_1_1; + AttributeRegistryV1_1_1->AttributeRegistry = AttributeRegistryV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_1_1_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_1 *AttributeRegistryV1_1_1; + + AttributeRegistryV1_1_1 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_1 *)InterpProp; + DestroyAttributeRegistry_V1_1_1_CS (AttributeRegistryV1_1_1->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_1_1/RedfishAttributeRegistry_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_1/RedfishAttributeRegistry_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..a4351439672 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_1/RedfishAttributeRegistry_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_1_1_Dxe + FILE_GUID = a35739ea-ea62-4dc2-ae01-914c7bb815fb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_1_2/AttributeRegistry_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_2/AttributeRegistry_V1_1_2_Dxe.c new file mode 100644 index 00000000000..42f80722855 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_2/AttributeRegistry_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "1", + "2" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_2 *AttributeRegistryV1_1_2; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_2_CS *AttributeRegistryV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_1_2_To_CS (ResoruceRaw, &AttributeRegistryV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_1_2 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_2)); + if (AttributeRegistryV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_1_2; + AttributeRegistryV1_1_2->AttributeRegistry = AttributeRegistryV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_1_2_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_2 *AttributeRegistryV1_1_2; + + AttributeRegistryV1_1_2 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_2 *)InterpProp; + DestroyAttributeRegistry_V1_1_2_CS (AttributeRegistryV1_1_2->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_1_2/RedfishAttributeRegistry_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_2/RedfishAttributeRegistry_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..f859c4ac294 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_2/RedfishAttributeRegistry_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_1_2_Dxe + FILE_GUID = 20645df0-ada0-4241-967d-823e1f219f84 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_1_3/AttributeRegistry_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_3/AttributeRegistry_V1_1_3_Dxe.c new file mode 100644 index 00000000000..a82a93f9329 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_3/AttributeRegistry_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "1", + "3" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_3 *AttributeRegistryV1_1_3; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_3_CS *AttributeRegistryV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_1_3_To_CS (ResoruceRaw, &AttributeRegistryV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_1_3 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_3)); + if (AttributeRegistryV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_1_3; + AttributeRegistryV1_1_3->AttributeRegistry = AttributeRegistryV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_1_3_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_3 *AttributeRegistryV1_1_3; + + AttributeRegistryV1_1_3 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_3 *)InterpProp; + DestroyAttributeRegistry_V1_1_3_CS (AttributeRegistryV1_1_3->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_1_3/RedfishAttributeRegistry_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_3/RedfishAttributeRegistry_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..98959059c9c --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_3/RedfishAttributeRegistry_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_1_3_Dxe + FILE_GUID = 2462c0d7-d5fd-4830-8d46-af78be780442 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_1_4/AttributeRegistry_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_4/AttributeRegistry_V1_1_4_Dxe.c new file mode 100644 index 00000000000..f7553dc4fbd --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_4/AttributeRegistry_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "1", + "4" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_4 *AttributeRegistryV1_1_4; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_4_CS *AttributeRegistryV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_1_4_To_CS (ResoruceRaw, &AttributeRegistryV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_1_4 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_4)); + if (AttributeRegistryV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_1_4; + AttributeRegistryV1_1_4->AttributeRegistry = AttributeRegistryV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_1_4_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_4 *AttributeRegistryV1_1_4; + + AttributeRegistryV1_1_4 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_4 *)InterpProp; + DestroyAttributeRegistry_V1_1_4_CS (AttributeRegistryV1_1_4->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_1_4/RedfishAttributeRegistry_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_4/RedfishAttributeRegistry_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..25a86caed3f --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_4/RedfishAttributeRegistry_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_1_4_Dxe + FILE_GUID = 82aa0c12-3614-4335-a96a-675c027f7344 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_1_5/AttributeRegistry_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_5/AttributeRegistry_V1_1_5_Dxe.c new file mode 100644 index 00000000000..d6b24e10894 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_5/AttributeRegistry_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "1", + "5" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_5 *AttributeRegistryV1_1_5; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_5_CS *AttributeRegistryV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_1_5_To_CS (ResoruceRaw, &AttributeRegistryV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_1_5 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_5)); + if (AttributeRegistryV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_1_5; + AttributeRegistryV1_1_5->AttributeRegistry = AttributeRegistryV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_1_5_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_5 *AttributeRegistryV1_1_5; + + AttributeRegistryV1_1_5 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_5 *)InterpProp; + DestroyAttributeRegistry_V1_1_5_CS (AttributeRegistryV1_1_5->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_1_5/RedfishAttributeRegistry_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_5/RedfishAttributeRegistry_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..e4a89691f97 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_5/RedfishAttributeRegistry_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_1_5_Dxe + FILE_GUID = 996e8ba2-cf94-4d05-87f2-8921d35c1e2d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_1_6/AttributeRegistry_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_6/AttributeRegistry_V1_1_6_Dxe.c new file mode 100644 index 00000000000..1a6234db4b2 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_6/AttributeRegistry_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "1", + "6" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_6 *AttributeRegistryV1_1_6; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_6_CS *AttributeRegistryV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_1_6_To_CS (ResoruceRaw, &AttributeRegistryV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_1_6 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_6)); + if (AttributeRegistryV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_1_6; + AttributeRegistryV1_1_6->AttributeRegistry = AttributeRegistryV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_1_6_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_6 *AttributeRegistryV1_1_6; + + AttributeRegistryV1_1_6 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_6 *)InterpProp; + DestroyAttributeRegistry_V1_1_6_CS (AttributeRegistryV1_1_6->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_1_6/RedfishAttributeRegistry_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_6/RedfishAttributeRegistry_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..45e48cb368e --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_6/RedfishAttributeRegistry_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_1_6_Dxe + FILE_GUID = 3135fe29-c00b-473a-b3cd-64e7501d176f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_1_7/AttributeRegistry_V1_1_7_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_7/AttributeRegistry_V1_1_7_Dxe.c new file mode 100644 index 00000000000..fbc6ae26d21 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_7/AttributeRegistry_V1_1_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_1_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "1", + "7" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_7 *AttributeRegistryV1_1_7; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_7_CS *AttributeRegistryV1_1_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_1_7_To_CS (ResoruceRaw, &AttributeRegistryV1_1_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_1_7 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_7)); + if (AttributeRegistryV1_1_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_1_7; + AttributeRegistryV1_1_7->AttributeRegistry = AttributeRegistryV1_1_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_1_7_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_7 *AttributeRegistryV1_1_7; + + AttributeRegistryV1_1_7 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_7 *)InterpProp; + DestroyAttributeRegistry_V1_1_7_CS (AttributeRegistryV1_1_7->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_1_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_1_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_1_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_1_7/RedfishAttributeRegistry_V1_1_7_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_7/RedfishAttributeRegistry_V1_1_7_Dxe.inf new file mode 100644 index 00000000000..5445bf3a92c --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_7/RedfishAttributeRegistry_V1_1_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_1_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_1_7_Dxe + FILE_GUID = 31ef9bf7-bd8c-4de9-9818-9f37cc6cc0fb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_1_7EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_1_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_1_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_1_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_1_8/AttributeRegistry_V1_1_8_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_8/AttributeRegistry_V1_1_8_Dxe.c new file mode 100644 index 00000000000..a2db1ba7b73 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_8/AttributeRegistry_V1_1_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_1_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "1", + "8" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_8 *AttributeRegistryV1_1_8; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_8_CS *AttributeRegistryV1_1_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_1_8_To_CS (ResoruceRaw, &AttributeRegistryV1_1_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_1_8 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_8)); + if (AttributeRegistryV1_1_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_1_8; + AttributeRegistryV1_1_8->AttributeRegistry = AttributeRegistryV1_1_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_1_8_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_8 *AttributeRegistryV1_1_8; + + AttributeRegistryV1_1_8 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_8 *)InterpProp; + DestroyAttributeRegistry_V1_1_8_CS (AttributeRegistryV1_1_8->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_1_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_1_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_1_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_1_8/RedfishAttributeRegistry_V1_1_8_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_8/RedfishAttributeRegistry_V1_1_8_Dxe.inf new file mode 100644 index 00000000000..f67b6aa2ba7 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_8/RedfishAttributeRegistry_V1_1_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_1_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_1_8_Dxe + FILE_GUID = 6db56088-52af-42ab-92ea-c1ac013aa744 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_1_8EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_1_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_1_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_1_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_1_9/AttributeRegistry_V1_1_9_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_9/AttributeRegistry_V1_1_9_Dxe.c new file mode 100644 index 00000000000..50815bc7226 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_9/AttributeRegistry_V1_1_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_1_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "1", + "9" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_9 *AttributeRegistryV1_1_9; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_9_CS *AttributeRegistryV1_1_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_1_9_To_CS (ResoruceRaw, &AttributeRegistryV1_1_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_1_9 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_9)); + if (AttributeRegistryV1_1_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_1_9; + AttributeRegistryV1_1_9->AttributeRegistry = AttributeRegistryV1_1_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_1_9_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_9 *AttributeRegistryV1_1_9; + + AttributeRegistryV1_1_9 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_9 *)InterpProp; + DestroyAttributeRegistry_V1_1_9_CS (AttributeRegistryV1_1_9->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_1_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_1_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_1_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_1_9/RedfishAttributeRegistry_V1_1_9_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_9/RedfishAttributeRegistry_V1_1_9_Dxe.inf new file mode 100644 index 00000000000..695e64ddcf6 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_1_9/RedfishAttributeRegistry_V1_1_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_1_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_1_9_Dxe + FILE_GUID = 500bb1b7-4f19-418e-b6fb-3d9929bdba94 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_1_9EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_1_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_1_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_1_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_2_0/AttributeRegistry_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_0/AttributeRegistry_V1_2_0_Dxe.c new file mode 100644 index 00000000000..89740f34a64 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_0/AttributeRegistry_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "2", + "0" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_0 *AttributeRegistryV1_2_0; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_0_CS *AttributeRegistryV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_2_0_To_CS (ResoruceRaw, &AttributeRegistryV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_2_0 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_0)); + if (AttributeRegistryV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_2_0; + AttributeRegistryV1_2_0->AttributeRegistry = AttributeRegistryV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_2_0_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_0 *AttributeRegistryV1_2_0; + + AttributeRegistryV1_2_0 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_0 *)InterpProp; + DestroyAttributeRegistry_V1_2_0_CS (AttributeRegistryV1_2_0->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_2_0/RedfishAttributeRegistry_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_0/RedfishAttributeRegistry_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..83068152b25 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_0/RedfishAttributeRegistry_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_2_0_Dxe + FILE_GUID = e088131a-f315-4573-a61e-5245d4d336a4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_2_1/AttributeRegistry_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_1/AttributeRegistry_V1_2_1_Dxe.c new file mode 100644 index 00000000000..c8261dd37d5 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_1/AttributeRegistry_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "2", + "1" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_1 *AttributeRegistryV1_2_1; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_1_CS *AttributeRegistryV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_2_1_To_CS (ResoruceRaw, &AttributeRegistryV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_2_1 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_1)); + if (AttributeRegistryV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_2_1; + AttributeRegistryV1_2_1->AttributeRegistry = AttributeRegistryV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_2_1_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_1 *AttributeRegistryV1_2_1; + + AttributeRegistryV1_2_1 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_1 *)InterpProp; + DestroyAttributeRegistry_V1_2_1_CS (AttributeRegistryV1_2_1->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_2_1/RedfishAttributeRegistry_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_1/RedfishAttributeRegistry_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..a66fc8b59a9 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_1/RedfishAttributeRegistry_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_2_1_Dxe + FILE_GUID = e7353d79-e1b2-494b-948d-77d4a149b4f9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_2_2/AttributeRegistry_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_2/AttributeRegistry_V1_2_2_Dxe.c new file mode 100644 index 00000000000..0efbae01009 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_2/AttributeRegistry_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "2", + "2" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_2 *AttributeRegistryV1_2_2; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_2_CS *AttributeRegistryV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_2_2_To_CS (ResoruceRaw, &AttributeRegistryV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_2_2 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_2)); + if (AttributeRegistryV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_2_2; + AttributeRegistryV1_2_2->AttributeRegistry = AttributeRegistryV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_2_2_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_2 *AttributeRegistryV1_2_2; + + AttributeRegistryV1_2_2 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_2 *)InterpProp; + DestroyAttributeRegistry_V1_2_2_CS (AttributeRegistryV1_2_2->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_2_2/RedfishAttributeRegistry_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_2/RedfishAttributeRegistry_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..3059d5b6117 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_2/RedfishAttributeRegistry_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_2_2_Dxe + FILE_GUID = b6293c7f-91b6-4e52-9186-a802362d8db1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_2_3/AttributeRegistry_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_3/AttributeRegistry_V1_2_3_Dxe.c new file mode 100644 index 00000000000..66d8c89716c --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_3/AttributeRegistry_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "2", + "3" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_3 *AttributeRegistryV1_2_3; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_3_CS *AttributeRegistryV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_2_3_To_CS (ResoruceRaw, &AttributeRegistryV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_2_3 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_3)); + if (AttributeRegistryV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_2_3; + AttributeRegistryV1_2_3->AttributeRegistry = AttributeRegistryV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_2_3_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_3 *AttributeRegistryV1_2_3; + + AttributeRegistryV1_2_3 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_3 *)InterpProp; + DestroyAttributeRegistry_V1_2_3_CS (AttributeRegistryV1_2_3->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_2_3/RedfishAttributeRegistry_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_3/RedfishAttributeRegistry_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..26838fb2087 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_3/RedfishAttributeRegistry_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_2_3_Dxe + FILE_GUID = cd29dccc-4baa-4c87-8c4e-93fa1c8109a4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_2_4/AttributeRegistry_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_4/AttributeRegistry_V1_2_4_Dxe.c new file mode 100644 index 00000000000..03686cdfbe8 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_4/AttributeRegistry_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "2", + "4" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_4 *AttributeRegistryV1_2_4; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_4_CS *AttributeRegistryV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_2_4_To_CS (ResoruceRaw, &AttributeRegistryV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_2_4 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_4)); + if (AttributeRegistryV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_2_4; + AttributeRegistryV1_2_4->AttributeRegistry = AttributeRegistryV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_2_4_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_4 *AttributeRegistryV1_2_4; + + AttributeRegistryV1_2_4 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_4 *)InterpProp; + DestroyAttributeRegistry_V1_2_4_CS (AttributeRegistryV1_2_4->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_2_4/RedfishAttributeRegistry_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_4/RedfishAttributeRegistry_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..4115f43c415 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_4/RedfishAttributeRegistry_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_2_4_Dxe + FILE_GUID = d318bdb0-da50-4c0a-9c0a-169752d30acc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_2_5/AttributeRegistry_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_5/AttributeRegistry_V1_2_5_Dxe.c new file mode 100644 index 00000000000..5be4262a0d7 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_5/AttributeRegistry_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "2", + "5" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_5 *AttributeRegistryV1_2_5; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_5_CS *AttributeRegistryV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_2_5_To_CS (ResoruceRaw, &AttributeRegistryV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_2_5 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_5)); + if (AttributeRegistryV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_2_5; + AttributeRegistryV1_2_5->AttributeRegistry = AttributeRegistryV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_2_5_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_5 *AttributeRegistryV1_2_5; + + AttributeRegistryV1_2_5 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_5 *)InterpProp; + DestroyAttributeRegistry_V1_2_5_CS (AttributeRegistryV1_2_5->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_2_5/RedfishAttributeRegistry_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_5/RedfishAttributeRegistry_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..30b10ba2d51 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_5/RedfishAttributeRegistry_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_2_5_Dxe + FILE_GUID = dfee152e-6812-4629-a3b3-2be4bd56f193 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_2_6/AttributeRegistry_V1_2_6_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_6/AttributeRegistry_V1_2_6_Dxe.c new file mode 100644 index 00000000000..c01e5186f3b --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_6/AttributeRegistry_V1_2_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_2_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "2", + "6" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_6 *AttributeRegistryV1_2_6; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_6_CS *AttributeRegistryV1_2_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_2_6_To_CS (ResoruceRaw, &AttributeRegistryV1_2_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_2_6 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_6)); + if (AttributeRegistryV1_2_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_2_6; + AttributeRegistryV1_2_6->AttributeRegistry = AttributeRegistryV1_2_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_2_6_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_6 *AttributeRegistryV1_2_6; + + AttributeRegistryV1_2_6 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_6 *)InterpProp; + DestroyAttributeRegistry_V1_2_6_CS (AttributeRegistryV1_2_6->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_2_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_2_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_2_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_2_6/RedfishAttributeRegistry_V1_2_6_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_6/RedfishAttributeRegistry_V1_2_6_Dxe.inf new file mode 100644 index 00000000000..e0166e87b65 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_6/RedfishAttributeRegistry_V1_2_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_2_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_2_6_Dxe + FILE_GUID = 58df85ad-5c57-453d-839e-c20f49db31ed + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_2_6EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_2_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_2_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_2_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_2_7/AttributeRegistry_V1_2_7_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_7/AttributeRegistry_V1_2_7_Dxe.c new file mode 100644 index 00000000000..6500af1ec8f --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_7/AttributeRegistry_V1_2_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_2_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "2", + "7" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_7 *AttributeRegistryV1_2_7; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_7_CS *AttributeRegistryV1_2_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_2_7_To_CS (ResoruceRaw, &AttributeRegistryV1_2_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_2_7 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_7)); + if (AttributeRegistryV1_2_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_2_7; + AttributeRegistryV1_2_7->AttributeRegistry = AttributeRegistryV1_2_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_2_7_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_7 *AttributeRegistryV1_2_7; + + AttributeRegistryV1_2_7 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_7 *)InterpProp; + DestroyAttributeRegistry_V1_2_7_CS (AttributeRegistryV1_2_7->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_2_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_2_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_2_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_2_7/RedfishAttributeRegistry_V1_2_7_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_7/RedfishAttributeRegistry_V1_2_7_Dxe.inf new file mode 100644 index 00000000000..82f52bf9b1b --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_2_7/RedfishAttributeRegistry_V1_2_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_2_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_2_7_Dxe + FILE_GUID = 181d4087-f752-4da2-845b-e88d776501c2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_2_7EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_2_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_2_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_2_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_3_0/AttributeRegistry_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_3_0/AttributeRegistry_V1_3_0_Dxe.c new file mode 100644 index 00000000000..fd6da88f6b9 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_3_0/AttributeRegistry_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "3", + "0" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_0 *AttributeRegistryV1_3_0; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_0_CS *AttributeRegistryV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_3_0_To_CS (ResoruceRaw, &AttributeRegistryV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_3_0 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_0)); + if (AttributeRegistryV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_3_0; + AttributeRegistryV1_3_0->AttributeRegistry = AttributeRegistryV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_3_0_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_0 *AttributeRegistryV1_3_0; + + AttributeRegistryV1_3_0 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_0 *)InterpProp; + DestroyAttributeRegistry_V1_3_0_CS (AttributeRegistryV1_3_0->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_3_0/RedfishAttributeRegistry_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_3_0/RedfishAttributeRegistry_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..65108be15ef --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_3_0/RedfishAttributeRegistry_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_3_0_Dxe + FILE_GUID = ade5caf0-f524-4b01-a4fa-cf8adbb52332 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_3_1/AttributeRegistry_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_3_1/AttributeRegistry_V1_3_1_Dxe.c new file mode 100644 index 00000000000..0c25b4ac592 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_3_1/AttributeRegistry_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "3", + "1" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_1 *AttributeRegistryV1_3_1; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_1_CS *AttributeRegistryV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_3_1_To_CS (ResoruceRaw, &AttributeRegistryV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_3_1 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_1)); + if (AttributeRegistryV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_3_1; + AttributeRegistryV1_3_1->AttributeRegistry = AttributeRegistryV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_3_1_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_1 *AttributeRegistryV1_3_1; + + AttributeRegistryV1_3_1 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_1 *)InterpProp; + DestroyAttributeRegistry_V1_3_1_CS (AttributeRegistryV1_3_1->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_3_1/RedfishAttributeRegistry_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_3_1/RedfishAttributeRegistry_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..4ae5bdda5d1 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_3_1/RedfishAttributeRegistry_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_3_1_Dxe + FILE_GUID = 07cb4c30-2c45-4f4a-bd2e-bb14023ee6ed + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_3_2/AttributeRegistry_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_3_2/AttributeRegistry_V1_3_2_Dxe.c new file mode 100644 index 00000000000..0364af6ad94 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_3_2/AttributeRegistry_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "3", + "2" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_2 *AttributeRegistryV1_3_2; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_2_CS *AttributeRegistryV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_3_2_To_CS (ResoruceRaw, &AttributeRegistryV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_3_2 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_2)); + if (AttributeRegistryV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_3_2; + AttributeRegistryV1_3_2->AttributeRegistry = AttributeRegistryV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_3_2_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_2 *AttributeRegistryV1_3_2; + + AttributeRegistryV1_3_2 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_2 *)InterpProp; + DestroyAttributeRegistry_V1_3_2_CS (AttributeRegistryV1_3_2->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_3_2/RedfishAttributeRegistry_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_3_2/RedfishAttributeRegistry_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..7b97a475cf7 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_3_2/RedfishAttributeRegistry_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_3_2_Dxe + FILE_GUID = 87430002-9386-474f-86e1-6f0caf8f6f48 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_3_3/AttributeRegistry_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_3_3/AttributeRegistry_V1_3_3_Dxe.c new file mode 100644 index 00000000000..331fb0e2a33 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_3_3/AttributeRegistry_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "3", + "3" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_3 *AttributeRegistryV1_3_3; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_3_CS *AttributeRegistryV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_3_3_To_CS (ResoruceRaw, &AttributeRegistryV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_3_3 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_3)); + if (AttributeRegistryV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_3_3; + AttributeRegistryV1_3_3->AttributeRegistry = AttributeRegistryV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_3_3_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_3 *AttributeRegistryV1_3_3; + + AttributeRegistryV1_3_3 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_3 *)InterpProp; + DestroyAttributeRegistry_V1_3_3_CS (AttributeRegistryV1_3_3->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_3_3/RedfishAttributeRegistry_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_3_3/RedfishAttributeRegistry_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..9f9e84113e8 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_3_3/RedfishAttributeRegistry_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_3_3_Dxe + FILE_GUID = ed2a6976-e96b-4734-86ee-916c24cc48f5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_3_4/AttributeRegistry_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_3_4/AttributeRegistry_V1_3_4_Dxe.c new file mode 100644 index 00000000000..0698374ee12 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_3_4/AttributeRegistry_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "3", + "4" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_4 *AttributeRegistryV1_3_4; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_4_CS *AttributeRegistryV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_3_4_To_CS (ResoruceRaw, &AttributeRegistryV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_3_4 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_4)); + if (AttributeRegistryV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_3_4; + AttributeRegistryV1_3_4->AttributeRegistry = AttributeRegistryV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_3_4_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_4 *AttributeRegistryV1_3_4; + + AttributeRegistryV1_3_4 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_4 *)InterpProp; + DestroyAttributeRegistry_V1_3_4_CS (AttributeRegistryV1_3_4->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_3_4/RedfishAttributeRegistry_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_3_4/RedfishAttributeRegistry_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..bb4327b9d64 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_3_4/RedfishAttributeRegistry_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_3_4_Dxe + FILE_GUID = 99b2de41-dba7-46d2-a7a3-911e0211ff38 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_3_5/AttributeRegistry_V1_3_5_Dxe.c b/RedfishClientPkg/Converter/AttributeRegistry/v1_3_5/AttributeRegistry_V1_3_5_Dxe.c new file mode 100644 index 00000000000..95ee6c2b385 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_3_5/AttributeRegistry_V1_3_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - AttributeRegistry.v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#AttributeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support AttributeRegistry V1_3_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "AttributeRegistry", + "1", + "3", + "5" + }, + "AttributeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_5 *AttributeRegistryV1_3_5; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_5_CS *AttributeRegistryV1_3_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "AttributeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_AttributeRegistry_V1_3_5_To_CS (ResoruceRaw, &AttributeRegistryV1_3_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + AttributeRegistryV1_3_5 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_5)); + if (AttributeRegistryV1_3_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)AttributeRegistryV1_3_5; + AttributeRegistryV1_3_5->AttributeRegistry = AttributeRegistryV1_3_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("AttributeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("AttributeRegistry"), "AttributeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of AttributeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return AttributeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_AttributeRegistry_V1_3_5_JSON (*((EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in AttributeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_5 *AttributeRegistryV1_3_5; + + AttributeRegistryV1_3_5 = (EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_5 *)InterpProp; + DestroyAttributeRegistry_V1_3_5_CS (AttributeRegistryV1_3_5->AttributeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from AttributeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +AttributeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyAttributeRegistry_V1_3_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_3_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + AttributeRegistryToStructWrapper, + AttributeRegistryToJson, + AttributeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishAttributeRegistry_V1_3_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/AttributeRegistry/v1_3_5/RedfishAttributeRegistry_V1_3_5_Dxe.inf b/RedfishClientPkg/Converter/AttributeRegistry/v1_3_5/RedfishAttributeRegistry_V1_3_5_Dxe.inf new file mode 100644 index 00000000000..765caf192b7 --- /dev/null +++ b/RedfishClientPkg/Converter/AttributeRegistry/v1_3_5/RedfishAttributeRegistry_V1_3_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of AttributeRegistry.v1_3_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishAttributeRegistry_V1_3_5_Dxe + FILE_GUID = 6ede3db0-b717-4cdc-a8d9-37ddf1a2b8fd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishAttributeRegistry_V1_3_5EntryPoint + UNLOAD_IMAGE = RedfishAttributeRegistry_V1_3_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + AttributeRegistry_V1_3_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + AttributeRegistryV1_3_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Bios/v1_0_0/Bios_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Bios/v1_0_0/Bios_V1_0_0_Dxe.c new file mode 100644 index 00000000000..d672228fb18 --- /dev/null +++ b/RedfishClientPkg/Converter/Bios/v1_0_0/Bios_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Bios.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Bios"; +BOOLEAN IsRevisonController = TRUE; + +// Support Bios V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Bios", + "1", + "0", + "0" + }, + "Bios" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_BIOS_V1_0_0 *BiosV1_0_0; + EFI_REDFISH_BIOS_V1_0_0_CS *BiosV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Bios") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Bios_V1_0_0_To_CS (ResoruceRaw, &BiosV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + BiosV1_0_0 = (EFI_REDFISH_BIOS_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_BIOS_V1_0_0)); + if (BiosV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)BiosV1_0_0; + BiosV1_0_0->Bios = BiosV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Bios")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Bios"), "Bios"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Bios")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Bios"), "Bios"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of BiosToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return BiosToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Bios_V1_0_0_JSON (*((EFI_REDFISH_BIOS_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in BiosToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_BIOS_V1_0_0 *BiosV1_0_0; + + BiosV1_0_0 = (EFI_REDFISH_BIOS_V1_0_0 *)InterpProp; + DestroyBios_V1_0_0_CS (BiosV1_0_0->Bios); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from BiosFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyBios_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishBios_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + BiosToStructWrapper, + BiosToJson, + BiosDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishBios_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Bios/v1_0_0/RedfishBios_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Bios/v1_0_0/RedfishBios_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..24675aca63c --- /dev/null +++ b/RedfishClientPkg/Converter/Bios/v1_0_0/RedfishBios_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Bios.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishBios_V1_0_0_Dxe + FILE_GUID = 972898f8-5a43-43fa-afa9-a975917e1e06 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishBios_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishBios_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Bios_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + BiosV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Bios/v1_0_1/Bios_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/Bios/v1_0_1/Bios_V1_0_1_Dxe.c new file mode 100644 index 00000000000..5f003cba305 --- /dev/null +++ b/RedfishClientPkg/Converter/Bios/v1_0_1/Bios_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Bios.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Bios"; +BOOLEAN IsRevisonController = TRUE; + +// Support Bios V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Bios", + "1", + "0", + "1" + }, + "Bios" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_BIOS_V1_0_1 *BiosV1_0_1; + EFI_REDFISH_BIOS_V1_0_1_CS *BiosV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Bios") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Bios_V1_0_1_To_CS (ResoruceRaw, &BiosV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + BiosV1_0_1 = (EFI_REDFISH_BIOS_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_BIOS_V1_0_1)); + if (BiosV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)BiosV1_0_1; + BiosV1_0_1->Bios = BiosV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Bios")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Bios"), "Bios"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Bios")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Bios"), "Bios"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of BiosToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return BiosToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Bios_V1_0_1_JSON (*((EFI_REDFISH_BIOS_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in BiosToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_BIOS_V1_0_1 *BiosV1_0_1; + + BiosV1_0_1 = (EFI_REDFISH_BIOS_V1_0_1 *)InterpProp; + DestroyBios_V1_0_1_CS (BiosV1_0_1->Bios); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from BiosFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyBios_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishBios_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + BiosToStructWrapper, + BiosToJson, + BiosDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishBios_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Bios/v1_0_1/RedfishBios_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/Bios/v1_0_1/RedfishBios_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..1505d900d73 --- /dev/null +++ b/RedfishClientPkg/Converter/Bios/v1_0_1/RedfishBios_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Bios.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishBios_V1_0_1_Dxe + FILE_GUID = 91542da1-ce34-4dc1-b434-5c14ca56c3b5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishBios_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishBios_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Bios_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + BiosV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Bios/v1_0_2/Bios_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Bios/v1_0_2/Bios_V1_0_2_Dxe.c new file mode 100644 index 00000000000..23035f684cc --- /dev/null +++ b/RedfishClientPkg/Converter/Bios/v1_0_2/Bios_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Bios.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Bios"; +BOOLEAN IsRevisonController = TRUE; + +// Support Bios V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Bios", + "1", + "0", + "2" + }, + "Bios" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_BIOS_V1_0_2 *BiosV1_0_2; + EFI_REDFISH_BIOS_V1_0_2_CS *BiosV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Bios") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Bios_V1_0_2_To_CS (ResoruceRaw, &BiosV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + BiosV1_0_2 = (EFI_REDFISH_BIOS_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_BIOS_V1_0_2)); + if (BiosV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)BiosV1_0_2; + BiosV1_0_2->Bios = BiosV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Bios")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Bios"), "Bios"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Bios")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Bios"), "Bios"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of BiosToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return BiosToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Bios_V1_0_2_JSON (*((EFI_REDFISH_BIOS_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in BiosToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_BIOS_V1_0_2 *BiosV1_0_2; + + BiosV1_0_2 = (EFI_REDFISH_BIOS_V1_0_2 *)InterpProp; + DestroyBios_V1_0_2_CS (BiosV1_0_2->Bios); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from BiosFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyBios_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishBios_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + BiosToStructWrapper, + BiosToJson, + BiosDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishBios_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Bios/v1_0_2/RedfishBios_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Bios/v1_0_2/RedfishBios_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..c2955813c27 --- /dev/null +++ b/RedfishClientPkg/Converter/Bios/v1_0_2/RedfishBios_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Bios.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishBios_V1_0_2_Dxe + FILE_GUID = 3f074b6f-0aab-4bf6-8ee7-7d02faea4a40 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishBios_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishBios_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Bios_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + BiosV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Bios/v1_0_3/Bios_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/Bios/v1_0_3/Bios_V1_0_3_Dxe.c new file mode 100644 index 00000000000..e2f5954385a --- /dev/null +++ b/RedfishClientPkg/Converter/Bios/v1_0_3/Bios_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Bios.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Bios"; +BOOLEAN IsRevisonController = TRUE; + +// Support Bios V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Bios", + "1", + "0", + "3" + }, + "Bios" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_BIOS_V1_0_3 *BiosV1_0_3; + EFI_REDFISH_BIOS_V1_0_3_CS *BiosV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Bios") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Bios_V1_0_3_To_CS (ResoruceRaw, &BiosV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + BiosV1_0_3 = (EFI_REDFISH_BIOS_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_BIOS_V1_0_3)); + if (BiosV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)BiosV1_0_3; + BiosV1_0_3->Bios = BiosV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Bios")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Bios"), "Bios"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Bios")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Bios"), "Bios"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of BiosToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return BiosToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Bios_V1_0_3_JSON (*((EFI_REDFISH_BIOS_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in BiosToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_BIOS_V1_0_3 *BiosV1_0_3; + + BiosV1_0_3 = (EFI_REDFISH_BIOS_V1_0_3 *)InterpProp; + DestroyBios_V1_0_3_CS (BiosV1_0_3->Bios); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from BiosFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyBios_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishBios_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + BiosToStructWrapper, + BiosToJson, + BiosDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishBios_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Bios/v1_0_3/RedfishBios_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/Bios/v1_0_3/RedfishBios_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..894e27ac6d8 --- /dev/null +++ b/RedfishClientPkg/Converter/Bios/v1_0_3/RedfishBios_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Bios.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishBios_V1_0_3_Dxe + FILE_GUID = 19ba30d9-a672-4583-a40d-592749e4b04d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishBios_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishBios_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Bios_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + BiosV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Bios/v1_0_4/Bios_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/Bios/v1_0_4/Bios_V1_0_4_Dxe.c new file mode 100644 index 00000000000..4d46b1608c4 --- /dev/null +++ b/RedfishClientPkg/Converter/Bios/v1_0_4/Bios_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Bios.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Bios"; +BOOLEAN IsRevisonController = TRUE; + +// Support Bios V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Bios", + "1", + "0", + "4" + }, + "Bios" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_BIOS_V1_0_4 *BiosV1_0_4; + EFI_REDFISH_BIOS_V1_0_4_CS *BiosV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Bios") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Bios_V1_0_4_To_CS (ResoruceRaw, &BiosV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + BiosV1_0_4 = (EFI_REDFISH_BIOS_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_BIOS_V1_0_4)); + if (BiosV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)BiosV1_0_4; + BiosV1_0_4->Bios = BiosV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Bios")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Bios"), "Bios"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Bios")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Bios"), "Bios"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of BiosToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return BiosToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Bios_V1_0_4_JSON (*((EFI_REDFISH_BIOS_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in BiosToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_BIOS_V1_0_4 *BiosV1_0_4; + + BiosV1_0_4 = (EFI_REDFISH_BIOS_V1_0_4 *)InterpProp; + DestroyBios_V1_0_4_CS (BiosV1_0_4->Bios); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from BiosFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyBios_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishBios_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + BiosToStructWrapper, + BiosToJson, + BiosDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishBios_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Bios/v1_0_4/RedfishBios_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/Bios/v1_0_4/RedfishBios_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..5852ecf0108 --- /dev/null +++ b/RedfishClientPkg/Converter/Bios/v1_0_4/RedfishBios_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Bios.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishBios_V1_0_4_Dxe + FILE_GUID = b5350086-cc85-4850-9889-7a53be118e6c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishBios_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishBios_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Bios_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + BiosV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Bios/v1_0_5/Bios_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/Bios/v1_0_5/Bios_V1_0_5_Dxe.c new file mode 100644 index 00000000000..1f2f3430b62 --- /dev/null +++ b/RedfishClientPkg/Converter/Bios/v1_0_5/Bios_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Bios.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Bios"; +BOOLEAN IsRevisonController = TRUE; + +// Support Bios V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Bios", + "1", + "0", + "5" + }, + "Bios" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_BIOS_V1_0_5 *BiosV1_0_5; + EFI_REDFISH_BIOS_V1_0_5_CS *BiosV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Bios") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Bios_V1_0_5_To_CS (ResoruceRaw, &BiosV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + BiosV1_0_5 = (EFI_REDFISH_BIOS_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_BIOS_V1_0_5)); + if (BiosV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)BiosV1_0_5; + BiosV1_0_5->Bios = BiosV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Bios")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Bios"), "Bios"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Bios")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Bios"), "Bios"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of BiosToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return BiosToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Bios_V1_0_5_JSON (*((EFI_REDFISH_BIOS_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in BiosToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_BIOS_V1_0_5 *BiosV1_0_5; + + BiosV1_0_5 = (EFI_REDFISH_BIOS_V1_0_5 *)InterpProp; + DestroyBios_V1_0_5_CS (BiosV1_0_5->Bios); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from BiosFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyBios_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishBios_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + BiosToStructWrapper, + BiosToJson, + BiosDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishBios_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Bios/v1_0_5/RedfishBios_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/Bios/v1_0_5/RedfishBios_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..c40b3abe225 --- /dev/null +++ b/RedfishClientPkg/Converter/Bios/v1_0_5/RedfishBios_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Bios.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishBios_V1_0_5_Dxe + FILE_GUID = 4e9c1f20-0533-4dc4-854c-d395273d441b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishBios_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishBios_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Bios_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + BiosV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Bios/v1_0_6/Bios_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/Bios/v1_0_6/Bios_V1_0_6_Dxe.c new file mode 100644 index 00000000000..687f2901d9b --- /dev/null +++ b/RedfishClientPkg/Converter/Bios/v1_0_6/Bios_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Bios.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Bios"; +BOOLEAN IsRevisonController = TRUE; + +// Support Bios V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Bios", + "1", + "0", + "6" + }, + "Bios" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_BIOS_V1_0_6 *BiosV1_0_6; + EFI_REDFISH_BIOS_V1_0_6_CS *BiosV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Bios") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Bios_V1_0_6_To_CS (ResoruceRaw, &BiosV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + BiosV1_0_6 = (EFI_REDFISH_BIOS_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_BIOS_V1_0_6)); + if (BiosV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)BiosV1_0_6; + BiosV1_0_6->Bios = BiosV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Bios")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Bios"), "Bios"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Bios")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Bios"), "Bios"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of BiosToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return BiosToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Bios_V1_0_6_JSON (*((EFI_REDFISH_BIOS_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in BiosToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_BIOS_V1_0_6 *BiosV1_0_6; + + BiosV1_0_6 = (EFI_REDFISH_BIOS_V1_0_6 *)InterpProp; + DestroyBios_V1_0_6_CS (BiosV1_0_6->Bios); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from BiosFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyBios_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishBios_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + BiosToStructWrapper, + BiosToJson, + BiosDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishBios_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Bios/v1_0_6/RedfishBios_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/Bios/v1_0_6/RedfishBios_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..0b94ec5e653 --- /dev/null +++ b/RedfishClientPkg/Converter/Bios/v1_0_6/RedfishBios_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Bios.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishBios_V1_0_6_Dxe + FILE_GUID = 2cc24b55-8c16-432f-959b-3a37522e6dc5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishBios_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishBios_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Bios_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + BiosV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Bios/v1_0_7/Bios_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/Bios/v1_0_7/Bios_V1_0_7_Dxe.c new file mode 100644 index 00000000000..d67d49d0ffc --- /dev/null +++ b/RedfishClientPkg/Converter/Bios/v1_0_7/Bios_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Bios.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Bios"; +BOOLEAN IsRevisonController = TRUE; + +// Support Bios V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Bios", + "1", + "0", + "7" + }, + "Bios" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_BIOS_V1_0_7 *BiosV1_0_7; + EFI_REDFISH_BIOS_V1_0_7_CS *BiosV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Bios") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Bios_V1_0_7_To_CS (ResoruceRaw, &BiosV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + BiosV1_0_7 = (EFI_REDFISH_BIOS_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_BIOS_V1_0_7)); + if (BiosV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)BiosV1_0_7; + BiosV1_0_7->Bios = BiosV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Bios")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Bios"), "Bios"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Bios")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Bios"), "Bios"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of BiosToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return BiosToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Bios_V1_0_7_JSON (*((EFI_REDFISH_BIOS_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in BiosToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_BIOS_V1_0_7 *BiosV1_0_7; + + BiosV1_0_7 = (EFI_REDFISH_BIOS_V1_0_7 *)InterpProp; + DestroyBios_V1_0_7_CS (BiosV1_0_7->Bios); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from BiosFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyBios_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishBios_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + BiosToStructWrapper, + BiosToJson, + BiosDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishBios_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Bios/v1_0_7/RedfishBios_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/Bios/v1_0_7/RedfishBios_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..48f7b0cdc4a --- /dev/null +++ b/RedfishClientPkg/Converter/Bios/v1_0_7/RedfishBios_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Bios.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishBios_V1_0_7_Dxe + FILE_GUID = bdb8c460-c222-4ab0-b0bf-ccbc802deaf8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishBios_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishBios_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Bios_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + BiosV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Bios/v1_0_8/Bios_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/Bios/v1_0_8/Bios_V1_0_8_Dxe.c new file mode 100644 index 00000000000..2791708ca7b --- /dev/null +++ b/RedfishClientPkg/Converter/Bios/v1_0_8/Bios_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Bios.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Bios"; +BOOLEAN IsRevisonController = TRUE; + +// Support Bios V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Bios", + "1", + "0", + "8" + }, + "Bios" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_BIOS_V1_0_8 *BiosV1_0_8; + EFI_REDFISH_BIOS_V1_0_8_CS *BiosV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Bios") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Bios_V1_0_8_To_CS (ResoruceRaw, &BiosV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + BiosV1_0_8 = (EFI_REDFISH_BIOS_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_BIOS_V1_0_8)); + if (BiosV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)BiosV1_0_8; + BiosV1_0_8->Bios = BiosV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Bios")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Bios"), "Bios"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Bios")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Bios"), "Bios"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of BiosToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return BiosToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Bios_V1_0_8_JSON (*((EFI_REDFISH_BIOS_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in BiosToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_BIOS_V1_0_8 *BiosV1_0_8; + + BiosV1_0_8 = (EFI_REDFISH_BIOS_V1_0_8 *)InterpProp; + DestroyBios_V1_0_8_CS (BiosV1_0_8->Bios); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from BiosFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyBios_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishBios_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + BiosToStructWrapper, + BiosToJson, + BiosDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishBios_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Bios/v1_0_8/RedfishBios_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/Bios/v1_0_8/RedfishBios_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..4338a89b75e --- /dev/null +++ b/RedfishClientPkg/Converter/Bios/v1_0_8/RedfishBios_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Bios.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishBios_V1_0_8_Dxe + FILE_GUID = 8448822b-2ddf-4cd7-b780-a5b895e163a0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishBios_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishBios_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Bios_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + BiosV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Bios/v1_1_0/Bios_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/Bios/v1_1_0/Bios_V1_1_0_Dxe.c new file mode 100644 index 00000000000..ea58a081540 --- /dev/null +++ b/RedfishClientPkg/Converter/Bios/v1_1_0/Bios_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Bios.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Bios"; +BOOLEAN IsRevisonController = TRUE; + +// Support Bios V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Bios", + "1", + "1", + "0" + }, + "Bios" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_BIOS_V1_1_0 *BiosV1_1_0; + EFI_REDFISH_BIOS_V1_1_0_CS *BiosV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Bios") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Bios_V1_1_0_To_CS (ResoruceRaw, &BiosV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + BiosV1_1_0 = (EFI_REDFISH_BIOS_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_BIOS_V1_1_0)); + if (BiosV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)BiosV1_1_0; + BiosV1_1_0->Bios = BiosV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Bios")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Bios"), "Bios"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Bios")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Bios"), "Bios"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of BiosToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return BiosToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Bios_V1_1_0_JSON (*((EFI_REDFISH_BIOS_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in BiosToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_BIOS_V1_1_0 *BiosV1_1_0; + + BiosV1_1_0 = (EFI_REDFISH_BIOS_V1_1_0 *)InterpProp; + DestroyBios_V1_1_0_CS (BiosV1_1_0->Bios); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from BiosFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyBios_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishBios_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + BiosToStructWrapper, + BiosToJson, + BiosDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishBios_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Bios/v1_1_0/RedfishBios_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/Bios/v1_1_0/RedfishBios_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..4b34aacc45f --- /dev/null +++ b/RedfishClientPkg/Converter/Bios/v1_1_0/RedfishBios_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Bios.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishBios_V1_1_0_Dxe + FILE_GUID = 3692340f-ae13-47a4-9166-d98a553cdb53 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishBios_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishBios_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Bios_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + BiosV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Bios/v1_1_1/Bios_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/Bios/v1_1_1/Bios_V1_1_1_Dxe.c new file mode 100644 index 00000000000..269e138b451 --- /dev/null +++ b/RedfishClientPkg/Converter/Bios/v1_1_1/Bios_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Bios.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Bios"; +BOOLEAN IsRevisonController = TRUE; + +// Support Bios V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Bios", + "1", + "1", + "1" + }, + "Bios" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_BIOS_V1_1_1 *BiosV1_1_1; + EFI_REDFISH_BIOS_V1_1_1_CS *BiosV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Bios") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Bios_V1_1_1_To_CS (ResoruceRaw, &BiosV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + BiosV1_1_1 = (EFI_REDFISH_BIOS_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_BIOS_V1_1_1)); + if (BiosV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)BiosV1_1_1; + BiosV1_1_1->Bios = BiosV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Bios")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Bios"), "Bios"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Bios")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Bios"), "Bios"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of BiosToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return BiosToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Bios_V1_1_1_JSON (*((EFI_REDFISH_BIOS_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in BiosToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_BIOS_V1_1_1 *BiosV1_1_1; + + BiosV1_1_1 = (EFI_REDFISH_BIOS_V1_1_1 *)InterpProp; + DestroyBios_V1_1_1_CS (BiosV1_1_1->Bios); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from BiosFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BiosDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyBios_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishBios_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + BiosToStructWrapper, + BiosToJson, + BiosDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishBios_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Bios/v1_1_1/RedfishBios_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/Bios/v1_1_1/RedfishBios_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..085f7fd8a60 --- /dev/null +++ b/RedfishClientPkg/Converter/Bios/v1_1_1/RedfishBios_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Bios.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishBios_V1_1_1_Dxe + FILE_GUID = eeebeef9-0a13-440f-b868-ce543e4b5c53 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishBios_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishBios_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Bios_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + BiosV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/BootOption/v1_0_0/BootOption_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/BootOption/v1_0_0/BootOption_V1_0_0_Dxe.c new file mode 100644 index 00000000000..e55d1c2bd11 --- /dev/null +++ b/RedfishClientPkg/Converter/BootOption/v1_0_0/BootOption_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - BootOption.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#BootOption"; +BOOLEAN IsRevisonController = TRUE; + +// Support BootOption V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "BootOption", + "1", + "0", + "0" + }, + "BootOption" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_BOOTOPTION_V1_0_0 *BootOptionV1_0_0; + EFI_REDFISH_BOOTOPTION_V1_0_0_CS *BootOptionV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "BootOption") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_BootOption_V1_0_0_To_CS (ResoruceRaw, &BootOptionV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + BootOptionV1_0_0 = (EFI_REDFISH_BOOTOPTION_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_BOOTOPTION_V1_0_0)); + if (BootOptionV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)BootOptionV1_0_0; + BootOptionV1_0_0->BootOption = BootOptionV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("BootOption")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("BootOption"), "BootOption"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("BootOption")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("BootOption"), "BootOption"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of BootOptionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return BootOptionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_BootOption_V1_0_0_JSON (*((EFI_REDFISH_BOOTOPTION_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in BootOptionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_BOOTOPTION_V1_0_0 *BootOptionV1_0_0; + + BootOptionV1_0_0 = (EFI_REDFISH_BOOTOPTION_V1_0_0 *)InterpProp; + DestroyBootOption_V1_0_0_CS (BootOptionV1_0_0->BootOption); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from BootOptionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyBootOption_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishBootOption_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + BootOptionToStructWrapper, + BootOptionToJson, + BootOptionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishBootOption_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/BootOption/v1_0_0/RedfishBootOption_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/BootOption/v1_0_0/RedfishBootOption_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..a0b2ed79d58 --- /dev/null +++ b/RedfishClientPkg/Converter/BootOption/v1_0_0/RedfishBootOption_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of BootOption.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishBootOption_V1_0_0_Dxe + FILE_GUID = cdde2c72-3558-4d20-836d-6f542502bce2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishBootOption_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishBootOption_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + BootOption_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + BootOptionV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/BootOption/v1_0_1/BootOption_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/BootOption/v1_0_1/BootOption_V1_0_1_Dxe.c new file mode 100644 index 00000000000..f8bbcd0ca07 --- /dev/null +++ b/RedfishClientPkg/Converter/BootOption/v1_0_1/BootOption_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - BootOption.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#BootOption"; +BOOLEAN IsRevisonController = TRUE; + +// Support BootOption V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "BootOption", + "1", + "0", + "1" + }, + "BootOption" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_BOOTOPTION_V1_0_1 *BootOptionV1_0_1; + EFI_REDFISH_BOOTOPTION_V1_0_1_CS *BootOptionV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "BootOption") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_BootOption_V1_0_1_To_CS (ResoruceRaw, &BootOptionV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + BootOptionV1_0_1 = (EFI_REDFISH_BOOTOPTION_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_BOOTOPTION_V1_0_1)); + if (BootOptionV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)BootOptionV1_0_1; + BootOptionV1_0_1->BootOption = BootOptionV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("BootOption")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("BootOption"), "BootOption"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("BootOption")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("BootOption"), "BootOption"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of BootOptionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return BootOptionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_BootOption_V1_0_1_JSON (*((EFI_REDFISH_BOOTOPTION_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in BootOptionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_BOOTOPTION_V1_0_1 *BootOptionV1_0_1; + + BootOptionV1_0_1 = (EFI_REDFISH_BOOTOPTION_V1_0_1 *)InterpProp; + DestroyBootOption_V1_0_1_CS (BootOptionV1_0_1->BootOption); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from BootOptionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyBootOption_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishBootOption_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + BootOptionToStructWrapper, + BootOptionToJson, + BootOptionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishBootOption_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/BootOption/v1_0_1/RedfishBootOption_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/BootOption/v1_0_1/RedfishBootOption_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..e63645ee781 --- /dev/null +++ b/RedfishClientPkg/Converter/BootOption/v1_0_1/RedfishBootOption_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of BootOption.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishBootOption_V1_0_1_Dxe + FILE_GUID = 0e959262-f52a-4ba5-8477-c04c1216f8c0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishBootOption_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishBootOption_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + BootOption_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + BootOptionV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/BootOption/v1_0_2/BootOption_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/BootOption/v1_0_2/BootOption_V1_0_2_Dxe.c new file mode 100644 index 00000000000..0dd0ef3c499 --- /dev/null +++ b/RedfishClientPkg/Converter/BootOption/v1_0_2/BootOption_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - BootOption.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#BootOption"; +BOOLEAN IsRevisonController = TRUE; + +// Support BootOption V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "BootOption", + "1", + "0", + "2" + }, + "BootOption" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_BOOTOPTION_V1_0_2 *BootOptionV1_0_2; + EFI_REDFISH_BOOTOPTION_V1_0_2_CS *BootOptionV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "BootOption") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_BootOption_V1_0_2_To_CS (ResoruceRaw, &BootOptionV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + BootOptionV1_0_2 = (EFI_REDFISH_BOOTOPTION_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_BOOTOPTION_V1_0_2)); + if (BootOptionV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)BootOptionV1_0_2; + BootOptionV1_0_2->BootOption = BootOptionV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("BootOption")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("BootOption"), "BootOption"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("BootOption")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("BootOption"), "BootOption"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of BootOptionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return BootOptionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_BootOption_V1_0_2_JSON (*((EFI_REDFISH_BOOTOPTION_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in BootOptionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_BOOTOPTION_V1_0_2 *BootOptionV1_0_2; + + BootOptionV1_0_2 = (EFI_REDFISH_BOOTOPTION_V1_0_2 *)InterpProp; + DestroyBootOption_V1_0_2_CS (BootOptionV1_0_2->BootOption); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from BootOptionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyBootOption_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishBootOption_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + BootOptionToStructWrapper, + BootOptionToJson, + BootOptionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishBootOption_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/BootOption/v1_0_2/RedfishBootOption_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/BootOption/v1_0_2/RedfishBootOption_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..52cc65d2e15 --- /dev/null +++ b/RedfishClientPkg/Converter/BootOption/v1_0_2/RedfishBootOption_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of BootOption.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishBootOption_V1_0_2_Dxe + FILE_GUID = 3e663a91-9136-46e4-9c70-6aa00053f202 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishBootOption_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishBootOption_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + BootOption_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + BootOptionV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/BootOption/v1_0_3/BootOption_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/BootOption/v1_0_3/BootOption_V1_0_3_Dxe.c new file mode 100644 index 00000000000..295eb132b26 --- /dev/null +++ b/RedfishClientPkg/Converter/BootOption/v1_0_3/BootOption_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - BootOption.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#BootOption"; +BOOLEAN IsRevisonController = TRUE; + +// Support BootOption V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "BootOption", + "1", + "0", + "3" + }, + "BootOption" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_BOOTOPTION_V1_0_3 *BootOptionV1_0_3; + EFI_REDFISH_BOOTOPTION_V1_0_3_CS *BootOptionV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "BootOption") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_BootOption_V1_0_3_To_CS (ResoruceRaw, &BootOptionV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + BootOptionV1_0_3 = (EFI_REDFISH_BOOTOPTION_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_BOOTOPTION_V1_0_3)); + if (BootOptionV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)BootOptionV1_0_3; + BootOptionV1_0_3->BootOption = BootOptionV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("BootOption")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("BootOption"), "BootOption"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("BootOption")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("BootOption"), "BootOption"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of BootOptionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return BootOptionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_BootOption_V1_0_3_JSON (*((EFI_REDFISH_BOOTOPTION_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in BootOptionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_BOOTOPTION_V1_0_3 *BootOptionV1_0_3; + + BootOptionV1_0_3 = (EFI_REDFISH_BOOTOPTION_V1_0_3 *)InterpProp; + DestroyBootOption_V1_0_3_CS (BootOptionV1_0_3->BootOption); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from BootOptionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyBootOption_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishBootOption_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + BootOptionToStructWrapper, + BootOptionToJson, + BootOptionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishBootOption_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/BootOption/v1_0_3/RedfishBootOption_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/BootOption/v1_0_3/RedfishBootOption_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..cc593febbdb --- /dev/null +++ b/RedfishClientPkg/Converter/BootOption/v1_0_3/RedfishBootOption_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of BootOption.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishBootOption_V1_0_3_Dxe + FILE_GUID = f451378d-2847-4776-a81b-9864189c5a51 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishBootOption_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishBootOption_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + BootOption_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + BootOptionV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/BootOption/v1_0_4/BootOption_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/BootOption/v1_0_4/BootOption_V1_0_4_Dxe.c new file mode 100644 index 00000000000..3ebf5ad8e17 --- /dev/null +++ b/RedfishClientPkg/Converter/BootOption/v1_0_4/BootOption_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - BootOption.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#BootOption"; +BOOLEAN IsRevisonController = TRUE; + +// Support BootOption V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "BootOption", + "1", + "0", + "4" + }, + "BootOption" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_BOOTOPTION_V1_0_4 *BootOptionV1_0_4; + EFI_REDFISH_BOOTOPTION_V1_0_4_CS *BootOptionV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "BootOption") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_BootOption_V1_0_4_To_CS (ResoruceRaw, &BootOptionV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + BootOptionV1_0_4 = (EFI_REDFISH_BOOTOPTION_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_BOOTOPTION_V1_0_4)); + if (BootOptionV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)BootOptionV1_0_4; + BootOptionV1_0_4->BootOption = BootOptionV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("BootOption")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("BootOption"), "BootOption"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("BootOption")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("BootOption"), "BootOption"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of BootOptionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return BootOptionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_BootOption_V1_0_4_JSON (*((EFI_REDFISH_BOOTOPTION_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in BootOptionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_BOOTOPTION_V1_0_4 *BootOptionV1_0_4; + + BootOptionV1_0_4 = (EFI_REDFISH_BOOTOPTION_V1_0_4 *)InterpProp; + DestroyBootOption_V1_0_4_CS (BootOptionV1_0_4->BootOption); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from BootOptionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyBootOption_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishBootOption_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + BootOptionToStructWrapper, + BootOptionToJson, + BootOptionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishBootOption_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/BootOption/v1_0_4/RedfishBootOption_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/BootOption/v1_0_4/RedfishBootOption_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..0c4ae637086 --- /dev/null +++ b/RedfishClientPkg/Converter/BootOption/v1_0_4/RedfishBootOption_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of BootOption.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishBootOption_V1_0_4_Dxe + FILE_GUID = 3e22418b-1955-45f7-847c-ef3eca204203 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishBootOption_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishBootOption_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + BootOption_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + BootOptionV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/BootOptionCollection/BootOptionCollection_Dxe.c b/RedfishClientPkg/Converter/BootOptionCollection/BootOptionCollection_Dxe.c new file mode 100644 index 00000000000..05a14ad5364 --- /dev/null +++ b/RedfishClientPkg/Converter/BootOptionCollection/BootOptionCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - BootOptionCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#BootOptionCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support BootOptionCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "BootOptionCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "BootOptionCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_BOOTOPTIONCOLLECTION *BootOptionCollection; + EFI_REDFISH_BOOTOPTIONCOLLECTION_CS *BootOptionCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "BootOptionCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_BootOptionCollection_To_CS (ResoruceRaw, &BootOptionCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + BootOptionCollection = (EFI_REDFISH_BOOTOPTIONCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_BOOTOPTIONCOLLECTION)); + if (BootOptionCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)BootOptionCollection; + BootOptionCollection->BootOptionCollection = BootOptionCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("BootOptionCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("BootOptionCollection"), "BootOptionCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("BootOptionCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("BootOptionCollection"), "BootOptionCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of BootOptionCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return BootOptionCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_BootOptionCollection_JSON (*((EFI_REDFISH_BOOTOPTIONCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in BootOptionCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_BOOTOPTIONCOLLECTION *BootOptionCollection; + + BootOptionCollection = (EFI_REDFISH_BOOTOPTIONCOLLECTION *)InterpProp; + DestroyBootOptionCollection_CS (BootOptionCollection->BootOptionCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from BootOptionCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +BootOptionCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyBootOptionCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishBootOptionCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + BootOptionCollectionToStructWrapper, + BootOptionCollectionToJson, + BootOptionCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishBootOptionCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/BootOptionCollection/RedfishBootOptionCollection_Dxe.inf b/RedfishClientPkg/Converter/BootOptionCollection/RedfishBootOptionCollection_Dxe.inf new file mode 100644 index 00000000000..a56477ac398 --- /dev/null +++ b/RedfishClientPkg/Converter/BootOptionCollection/RedfishBootOptionCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of BootOptionCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishBootOptionCollection_Dxe + FILE_GUID = 14a31d78-e7a1-4268-8747-1c93e91ca8f7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishBootOptionCollectionEntryPoint + UNLOAD_IMAGE = RedfishBootOptionCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + BootOptionCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + BootOptionCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Certificate/v1_0_0/Certificate_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Certificate/v1_0_0/Certificate_V1_0_0_Dxe.c new file mode 100644 index 00000000000..ceaa17a698f --- /dev/null +++ b/RedfishClientPkg/Converter/Certificate/v1_0_0/Certificate_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Certificate.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Certificate"; +BOOLEAN IsRevisonController = TRUE; + +// Support Certificate V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Certificate", + "1", + "0", + "0" + }, + "Certificate" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CERTIFICATE_V1_0_0 *CertificateV1_0_0; + EFI_REDFISH_CERTIFICATE_V1_0_0_CS *CertificateV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Certificate") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Certificate_V1_0_0_To_CS (ResoruceRaw, &CertificateV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CertificateV1_0_0 = (EFI_REDFISH_CERTIFICATE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CERTIFICATE_V1_0_0)); + if (CertificateV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CertificateV1_0_0; + CertificateV1_0_0->Certificate = CertificateV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Certificate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Certificate"), "Certificate"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Certificate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Certificate"), "Certificate"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CertificateToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CertificateToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Certificate_V1_0_0_JSON (*((EFI_REDFISH_CERTIFICATE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CertificateToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CERTIFICATE_V1_0_0 *CertificateV1_0_0; + + CertificateV1_0_0 = (EFI_REDFISH_CERTIFICATE_V1_0_0 *)InterpProp; + DestroyCertificate_V1_0_0_CS (CertificateV1_0_0->Certificate); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CertificateFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCertificate_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCertificate_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CertificateToStructWrapper, + CertificateToJson, + CertificateDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCertificate_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Certificate/v1_0_0/RedfishCertificate_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Certificate/v1_0_0/RedfishCertificate_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..2af5ad5fc1d --- /dev/null +++ b/RedfishClientPkg/Converter/Certificate/v1_0_0/RedfishCertificate_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Certificate.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCertificate_V1_0_0_Dxe + FILE_GUID = 23cde48c-f8a2-41ce-b4b9-ff4f79f4c61f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCertificate_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishCertificate_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Certificate_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CertificateV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Certificate/v1_0_1/Certificate_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/Certificate/v1_0_1/Certificate_V1_0_1_Dxe.c new file mode 100644 index 00000000000..9d0185fc151 --- /dev/null +++ b/RedfishClientPkg/Converter/Certificate/v1_0_1/Certificate_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Certificate.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Certificate"; +BOOLEAN IsRevisonController = TRUE; + +// Support Certificate V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Certificate", + "1", + "0", + "1" + }, + "Certificate" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CERTIFICATE_V1_0_1 *CertificateV1_0_1; + EFI_REDFISH_CERTIFICATE_V1_0_1_CS *CertificateV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Certificate") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Certificate_V1_0_1_To_CS (ResoruceRaw, &CertificateV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CertificateV1_0_1 = (EFI_REDFISH_CERTIFICATE_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CERTIFICATE_V1_0_1)); + if (CertificateV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CertificateV1_0_1; + CertificateV1_0_1->Certificate = CertificateV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Certificate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Certificate"), "Certificate"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Certificate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Certificate"), "Certificate"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CertificateToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CertificateToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Certificate_V1_0_1_JSON (*((EFI_REDFISH_CERTIFICATE_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CertificateToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CERTIFICATE_V1_0_1 *CertificateV1_0_1; + + CertificateV1_0_1 = (EFI_REDFISH_CERTIFICATE_V1_0_1 *)InterpProp; + DestroyCertificate_V1_0_1_CS (CertificateV1_0_1->Certificate); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CertificateFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCertificate_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCertificate_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CertificateToStructWrapper, + CertificateToJson, + CertificateDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCertificate_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Certificate/v1_0_1/RedfishCertificate_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/Certificate/v1_0_1/RedfishCertificate_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..71d769a6393 --- /dev/null +++ b/RedfishClientPkg/Converter/Certificate/v1_0_1/RedfishCertificate_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Certificate.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCertificate_V1_0_1_Dxe + FILE_GUID = 24eb7f90-4d83-4223-bcf4-6a2f528d5496 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCertificate_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishCertificate_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Certificate_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CertificateV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Certificate/v1_0_2/Certificate_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Certificate/v1_0_2/Certificate_V1_0_2_Dxe.c new file mode 100644 index 00000000000..59cdc33b756 --- /dev/null +++ b/RedfishClientPkg/Converter/Certificate/v1_0_2/Certificate_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Certificate.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Certificate"; +BOOLEAN IsRevisonController = TRUE; + +// Support Certificate V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Certificate", + "1", + "0", + "2" + }, + "Certificate" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CERTIFICATE_V1_0_2 *CertificateV1_0_2; + EFI_REDFISH_CERTIFICATE_V1_0_2_CS *CertificateV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Certificate") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Certificate_V1_0_2_To_CS (ResoruceRaw, &CertificateV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CertificateV1_0_2 = (EFI_REDFISH_CERTIFICATE_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CERTIFICATE_V1_0_2)); + if (CertificateV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CertificateV1_0_2; + CertificateV1_0_2->Certificate = CertificateV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Certificate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Certificate"), "Certificate"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Certificate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Certificate"), "Certificate"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CertificateToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CertificateToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Certificate_V1_0_2_JSON (*((EFI_REDFISH_CERTIFICATE_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CertificateToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CERTIFICATE_V1_0_2 *CertificateV1_0_2; + + CertificateV1_0_2 = (EFI_REDFISH_CERTIFICATE_V1_0_2 *)InterpProp; + DestroyCertificate_V1_0_2_CS (CertificateV1_0_2->Certificate); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CertificateFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCertificate_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCertificate_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CertificateToStructWrapper, + CertificateToJson, + CertificateDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCertificate_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Certificate/v1_0_2/RedfishCertificate_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Certificate/v1_0_2/RedfishCertificate_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..6aceacb28ab --- /dev/null +++ b/RedfishClientPkg/Converter/Certificate/v1_0_2/RedfishCertificate_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Certificate.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCertificate_V1_0_2_Dxe + FILE_GUID = ed1362f5-cc26-4d94-8399-9037727dddb7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCertificate_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishCertificate_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Certificate_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CertificateV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Certificate/v1_0_3/Certificate_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/Certificate/v1_0_3/Certificate_V1_0_3_Dxe.c new file mode 100644 index 00000000000..7afdc5aa10c --- /dev/null +++ b/RedfishClientPkg/Converter/Certificate/v1_0_3/Certificate_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Certificate.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Certificate"; +BOOLEAN IsRevisonController = TRUE; + +// Support Certificate V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Certificate", + "1", + "0", + "3" + }, + "Certificate" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CERTIFICATE_V1_0_3 *CertificateV1_0_3; + EFI_REDFISH_CERTIFICATE_V1_0_3_CS *CertificateV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Certificate") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Certificate_V1_0_3_To_CS (ResoruceRaw, &CertificateV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CertificateV1_0_3 = (EFI_REDFISH_CERTIFICATE_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CERTIFICATE_V1_0_3)); + if (CertificateV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CertificateV1_0_3; + CertificateV1_0_3->Certificate = CertificateV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Certificate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Certificate"), "Certificate"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Certificate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Certificate"), "Certificate"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CertificateToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CertificateToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Certificate_V1_0_3_JSON (*((EFI_REDFISH_CERTIFICATE_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CertificateToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CERTIFICATE_V1_0_3 *CertificateV1_0_3; + + CertificateV1_0_3 = (EFI_REDFISH_CERTIFICATE_V1_0_3 *)InterpProp; + DestroyCertificate_V1_0_3_CS (CertificateV1_0_3->Certificate); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CertificateFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCertificate_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCertificate_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CertificateToStructWrapper, + CertificateToJson, + CertificateDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCertificate_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Certificate/v1_0_3/RedfishCertificate_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/Certificate/v1_0_3/RedfishCertificate_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..bc8078d1507 --- /dev/null +++ b/RedfishClientPkg/Converter/Certificate/v1_0_3/RedfishCertificate_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Certificate.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCertificate_V1_0_3_Dxe + FILE_GUID = a10ce0ea-2cf3-46ef-9090-34710cd06255 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCertificate_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishCertificate_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Certificate_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CertificateV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Certificate/v1_0_4/Certificate_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/Certificate/v1_0_4/Certificate_V1_0_4_Dxe.c new file mode 100644 index 00000000000..8aacfd8f461 --- /dev/null +++ b/RedfishClientPkg/Converter/Certificate/v1_0_4/Certificate_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Certificate.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Certificate"; +BOOLEAN IsRevisonController = TRUE; + +// Support Certificate V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Certificate", + "1", + "0", + "4" + }, + "Certificate" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CERTIFICATE_V1_0_4 *CertificateV1_0_4; + EFI_REDFISH_CERTIFICATE_V1_0_4_CS *CertificateV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Certificate") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Certificate_V1_0_4_To_CS (ResoruceRaw, &CertificateV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CertificateV1_0_4 = (EFI_REDFISH_CERTIFICATE_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CERTIFICATE_V1_0_4)); + if (CertificateV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CertificateV1_0_4; + CertificateV1_0_4->Certificate = CertificateV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Certificate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Certificate"), "Certificate"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Certificate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Certificate"), "Certificate"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CertificateToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CertificateToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Certificate_V1_0_4_JSON (*((EFI_REDFISH_CERTIFICATE_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CertificateToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CERTIFICATE_V1_0_4 *CertificateV1_0_4; + + CertificateV1_0_4 = (EFI_REDFISH_CERTIFICATE_V1_0_4 *)InterpProp; + DestroyCertificate_V1_0_4_CS (CertificateV1_0_4->Certificate); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CertificateFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCertificate_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCertificate_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CertificateToStructWrapper, + CertificateToJson, + CertificateDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCertificate_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Certificate/v1_0_4/RedfishCertificate_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/Certificate/v1_0_4/RedfishCertificate_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..8e0ff187fe0 --- /dev/null +++ b/RedfishClientPkg/Converter/Certificate/v1_0_4/RedfishCertificate_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Certificate.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCertificate_V1_0_4_Dxe + FILE_GUID = 8de276b9-1dcc-400b-8b88-6e38d6c3f1c4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCertificate_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishCertificate_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Certificate_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CertificateV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Certificate/v1_1_0/Certificate_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/Certificate/v1_1_0/Certificate_V1_1_0_Dxe.c new file mode 100644 index 00000000000..c334f23a2b4 --- /dev/null +++ b/RedfishClientPkg/Converter/Certificate/v1_1_0/Certificate_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Certificate.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Certificate"; +BOOLEAN IsRevisonController = TRUE; + +// Support Certificate V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Certificate", + "1", + "1", + "0" + }, + "Certificate" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CERTIFICATE_V1_1_0 *CertificateV1_1_0; + EFI_REDFISH_CERTIFICATE_V1_1_0_CS *CertificateV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Certificate") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Certificate_V1_1_0_To_CS (ResoruceRaw, &CertificateV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CertificateV1_1_0 = (EFI_REDFISH_CERTIFICATE_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CERTIFICATE_V1_1_0)); + if (CertificateV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CertificateV1_1_0; + CertificateV1_1_0->Certificate = CertificateV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Certificate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Certificate"), "Certificate"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Certificate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Certificate"), "Certificate"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CertificateToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CertificateToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Certificate_V1_1_0_JSON (*((EFI_REDFISH_CERTIFICATE_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CertificateToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CERTIFICATE_V1_1_0 *CertificateV1_1_0; + + CertificateV1_1_0 = (EFI_REDFISH_CERTIFICATE_V1_1_0 *)InterpProp; + DestroyCertificate_V1_1_0_CS (CertificateV1_1_0->Certificate); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CertificateFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCertificate_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCertificate_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CertificateToStructWrapper, + CertificateToJson, + CertificateDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCertificate_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Certificate/v1_1_0/RedfishCertificate_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/Certificate/v1_1_0/RedfishCertificate_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..c71c8ca2044 --- /dev/null +++ b/RedfishClientPkg/Converter/Certificate/v1_1_0/RedfishCertificate_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Certificate.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCertificate_V1_1_0_Dxe + FILE_GUID = 182216ae-817f-4163-85fb-67c03677b0cf + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCertificate_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishCertificate_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Certificate_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CertificateV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Certificate/v1_1_1/Certificate_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/Certificate/v1_1_1/Certificate_V1_1_1_Dxe.c new file mode 100644 index 00000000000..036bf18cf57 --- /dev/null +++ b/RedfishClientPkg/Converter/Certificate/v1_1_1/Certificate_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Certificate.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Certificate"; +BOOLEAN IsRevisonController = TRUE; + +// Support Certificate V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Certificate", + "1", + "1", + "1" + }, + "Certificate" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CERTIFICATE_V1_1_1 *CertificateV1_1_1; + EFI_REDFISH_CERTIFICATE_V1_1_1_CS *CertificateV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Certificate") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Certificate_V1_1_1_To_CS (ResoruceRaw, &CertificateV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CertificateV1_1_1 = (EFI_REDFISH_CERTIFICATE_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CERTIFICATE_V1_1_1)); + if (CertificateV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CertificateV1_1_1; + CertificateV1_1_1->Certificate = CertificateV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Certificate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Certificate"), "Certificate"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Certificate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Certificate"), "Certificate"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CertificateToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CertificateToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Certificate_V1_1_1_JSON (*((EFI_REDFISH_CERTIFICATE_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CertificateToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CERTIFICATE_V1_1_1 *CertificateV1_1_1; + + CertificateV1_1_1 = (EFI_REDFISH_CERTIFICATE_V1_1_1 *)InterpProp; + DestroyCertificate_V1_1_1_CS (CertificateV1_1_1->Certificate); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CertificateFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCertificate_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCertificate_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CertificateToStructWrapper, + CertificateToJson, + CertificateDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCertificate_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Certificate/v1_1_1/RedfishCertificate_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/Certificate/v1_1_1/RedfishCertificate_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..a59dba2dd2f --- /dev/null +++ b/RedfishClientPkg/Converter/Certificate/v1_1_1/RedfishCertificate_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Certificate.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCertificate_V1_1_1_Dxe + FILE_GUID = 51b191f5-a3cb-45d9-bdd5-a068eac8db85 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCertificate_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishCertificate_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Certificate_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CertificateV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Certificate/v1_1_2/Certificate_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/Certificate/v1_1_2/Certificate_V1_1_2_Dxe.c new file mode 100644 index 00000000000..5a59b538cfe --- /dev/null +++ b/RedfishClientPkg/Converter/Certificate/v1_1_2/Certificate_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Certificate.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Certificate"; +BOOLEAN IsRevisonController = TRUE; + +// Support Certificate V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Certificate", + "1", + "1", + "2" + }, + "Certificate" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CERTIFICATE_V1_1_2 *CertificateV1_1_2; + EFI_REDFISH_CERTIFICATE_V1_1_2_CS *CertificateV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Certificate") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Certificate_V1_1_2_To_CS (ResoruceRaw, &CertificateV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CertificateV1_1_2 = (EFI_REDFISH_CERTIFICATE_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CERTIFICATE_V1_1_2)); + if (CertificateV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CertificateV1_1_2; + CertificateV1_1_2->Certificate = CertificateV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Certificate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Certificate"), "Certificate"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Certificate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Certificate"), "Certificate"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CertificateToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CertificateToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Certificate_V1_1_2_JSON (*((EFI_REDFISH_CERTIFICATE_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CertificateToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CERTIFICATE_V1_1_2 *CertificateV1_1_2; + + CertificateV1_1_2 = (EFI_REDFISH_CERTIFICATE_V1_1_2 *)InterpProp; + DestroyCertificate_V1_1_2_CS (CertificateV1_1_2->Certificate); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CertificateFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCertificate_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCertificate_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CertificateToStructWrapper, + CertificateToJson, + CertificateDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCertificate_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Certificate/v1_1_2/RedfishCertificate_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/Certificate/v1_1_2/RedfishCertificate_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..be5ac90b12c --- /dev/null +++ b/RedfishClientPkg/Converter/Certificate/v1_1_2/RedfishCertificate_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Certificate.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCertificate_V1_1_2_Dxe + FILE_GUID = 7dfe72f2-39e8-42b3-be34-ea9e8169122b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCertificate_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishCertificate_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Certificate_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CertificateV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Certificate/v1_1_3/Certificate_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/Certificate/v1_1_3/Certificate_V1_1_3_Dxe.c new file mode 100644 index 00000000000..bec4643d548 --- /dev/null +++ b/RedfishClientPkg/Converter/Certificate/v1_1_3/Certificate_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Certificate.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Certificate"; +BOOLEAN IsRevisonController = TRUE; + +// Support Certificate V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Certificate", + "1", + "1", + "3" + }, + "Certificate" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CERTIFICATE_V1_1_3 *CertificateV1_1_3; + EFI_REDFISH_CERTIFICATE_V1_1_3_CS *CertificateV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Certificate") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Certificate_V1_1_3_To_CS (ResoruceRaw, &CertificateV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CertificateV1_1_3 = (EFI_REDFISH_CERTIFICATE_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CERTIFICATE_V1_1_3)); + if (CertificateV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CertificateV1_1_3; + CertificateV1_1_3->Certificate = CertificateV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Certificate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Certificate"), "Certificate"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Certificate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Certificate"), "Certificate"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CertificateToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CertificateToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Certificate_V1_1_3_JSON (*((EFI_REDFISH_CERTIFICATE_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CertificateToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CERTIFICATE_V1_1_3 *CertificateV1_1_3; + + CertificateV1_1_3 = (EFI_REDFISH_CERTIFICATE_V1_1_3 *)InterpProp; + DestroyCertificate_V1_1_3_CS (CertificateV1_1_3->Certificate); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CertificateFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCertificate_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCertificate_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CertificateToStructWrapper, + CertificateToJson, + CertificateDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCertificate_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Certificate/v1_1_3/RedfishCertificate_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/Certificate/v1_1_3/RedfishCertificate_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..99f6d2f8ffe --- /dev/null +++ b/RedfishClientPkg/Converter/Certificate/v1_1_3/RedfishCertificate_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Certificate.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCertificate_V1_1_3_Dxe + FILE_GUID = 61671c56-ad0a-4a73-b28e-1351a509949e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCertificate_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishCertificate_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Certificate_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CertificateV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Certificate/v1_2_0/Certificate_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/Certificate/v1_2_0/Certificate_V1_2_0_Dxe.c new file mode 100644 index 00000000000..f439c55facc --- /dev/null +++ b/RedfishClientPkg/Converter/Certificate/v1_2_0/Certificate_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Certificate.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Certificate"; +BOOLEAN IsRevisonController = TRUE; + +// Support Certificate V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Certificate", + "1", + "2", + "0" + }, + "Certificate" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CERTIFICATE_V1_2_0 *CertificateV1_2_0; + EFI_REDFISH_CERTIFICATE_V1_2_0_CS *CertificateV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Certificate") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Certificate_V1_2_0_To_CS (ResoruceRaw, &CertificateV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CertificateV1_2_0 = (EFI_REDFISH_CERTIFICATE_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CERTIFICATE_V1_2_0)); + if (CertificateV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CertificateV1_2_0; + CertificateV1_2_0->Certificate = CertificateV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Certificate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Certificate"), "Certificate"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Certificate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Certificate"), "Certificate"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CertificateToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CertificateToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Certificate_V1_2_0_JSON (*((EFI_REDFISH_CERTIFICATE_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CertificateToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CERTIFICATE_V1_2_0 *CertificateV1_2_0; + + CertificateV1_2_0 = (EFI_REDFISH_CERTIFICATE_V1_2_0 *)InterpProp; + DestroyCertificate_V1_2_0_CS (CertificateV1_2_0->Certificate); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CertificateFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCertificate_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCertificate_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CertificateToStructWrapper, + CertificateToJson, + CertificateDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCertificate_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Certificate/v1_2_0/RedfishCertificate_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/Certificate/v1_2_0/RedfishCertificate_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..65591dae129 --- /dev/null +++ b/RedfishClientPkg/Converter/Certificate/v1_2_0/RedfishCertificate_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Certificate.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCertificate_V1_2_0_Dxe + FILE_GUID = a4b2a278-c3ec-4221-9f99-d7eeab58b692 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCertificate_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishCertificate_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Certificate_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CertificateV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Certificate/v1_2_1/Certificate_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/Certificate/v1_2_1/Certificate_V1_2_1_Dxe.c new file mode 100644 index 00000000000..b14faeb24f2 --- /dev/null +++ b/RedfishClientPkg/Converter/Certificate/v1_2_1/Certificate_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Certificate.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Certificate"; +BOOLEAN IsRevisonController = TRUE; + +// Support Certificate V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Certificate", + "1", + "2", + "1" + }, + "Certificate" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CERTIFICATE_V1_2_1 *CertificateV1_2_1; + EFI_REDFISH_CERTIFICATE_V1_2_1_CS *CertificateV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Certificate") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Certificate_V1_2_1_To_CS (ResoruceRaw, &CertificateV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CertificateV1_2_1 = (EFI_REDFISH_CERTIFICATE_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CERTIFICATE_V1_2_1)); + if (CertificateV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CertificateV1_2_1; + CertificateV1_2_1->Certificate = CertificateV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Certificate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Certificate"), "Certificate"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Certificate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Certificate"), "Certificate"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CertificateToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CertificateToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Certificate_V1_2_1_JSON (*((EFI_REDFISH_CERTIFICATE_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CertificateToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CERTIFICATE_V1_2_1 *CertificateV1_2_1; + + CertificateV1_2_1 = (EFI_REDFISH_CERTIFICATE_V1_2_1 *)InterpProp; + DestroyCertificate_V1_2_1_CS (CertificateV1_2_1->Certificate); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CertificateFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCertificate_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCertificate_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CertificateToStructWrapper, + CertificateToJson, + CertificateDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCertificate_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Certificate/v1_2_1/RedfishCertificate_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/Certificate/v1_2_1/RedfishCertificate_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..ec64d676d2b --- /dev/null +++ b/RedfishClientPkg/Converter/Certificate/v1_2_1/RedfishCertificate_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Certificate.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCertificate_V1_2_1_Dxe + FILE_GUID = f390bb6a-b3a2-47f2-bc4b-ebaaf43eecf9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCertificate_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishCertificate_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Certificate_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CertificateV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Certificate/v1_2_2/Certificate_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/Certificate/v1_2_2/Certificate_V1_2_2_Dxe.c new file mode 100644 index 00000000000..569e22dd41b --- /dev/null +++ b/RedfishClientPkg/Converter/Certificate/v1_2_2/Certificate_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Certificate.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Certificate"; +BOOLEAN IsRevisonController = TRUE; + +// Support Certificate V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Certificate", + "1", + "2", + "2" + }, + "Certificate" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CERTIFICATE_V1_2_2 *CertificateV1_2_2; + EFI_REDFISH_CERTIFICATE_V1_2_2_CS *CertificateV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Certificate") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Certificate_V1_2_2_To_CS (ResoruceRaw, &CertificateV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CertificateV1_2_2 = (EFI_REDFISH_CERTIFICATE_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CERTIFICATE_V1_2_2)); + if (CertificateV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CertificateV1_2_2; + CertificateV1_2_2->Certificate = CertificateV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Certificate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Certificate"), "Certificate"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Certificate")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Certificate"), "Certificate"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CertificateToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CertificateToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Certificate_V1_2_2_JSON (*((EFI_REDFISH_CERTIFICATE_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CertificateToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CERTIFICATE_V1_2_2 *CertificateV1_2_2; + + CertificateV1_2_2 = (EFI_REDFISH_CERTIFICATE_V1_2_2 *)InterpProp; + DestroyCertificate_V1_2_2_CS (CertificateV1_2_2->Certificate); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CertificateFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCertificate_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCertificate_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CertificateToStructWrapper, + CertificateToJson, + CertificateDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCertificate_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Certificate/v1_2_2/RedfishCertificate_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/Certificate/v1_2_2/RedfishCertificate_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..a7996bd9709 --- /dev/null +++ b/RedfishClientPkg/Converter/Certificate/v1_2_2/RedfishCertificate_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Certificate.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCertificate_V1_2_2_Dxe + FILE_GUID = 06b8db4d-9809-4842-94b1-897d9d4a6fb3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCertificate_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishCertificate_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Certificate_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CertificateV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/CertificateCollection/CertificateCollection_Dxe.c b/RedfishClientPkg/Converter/CertificateCollection/CertificateCollection_Dxe.c new file mode 100644 index 00000000000..c4c680af2be --- /dev/null +++ b/RedfishClientPkg/Converter/CertificateCollection/CertificateCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - CertificateCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#CertificateCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support CertificateCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "CertificateCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "CertificateCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CERTIFICATECOLLECTION *CertificateCollection; + EFI_REDFISH_CERTIFICATECOLLECTION_CS *CertificateCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "CertificateCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_CertificateCollection_To_CS (ResoruceRaw, &CertificateCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + CertificateCollection = (EFI_REDFISH_CERTIFICATECOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CERTIFICATECOLLECTION)); + if (CertificateCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CertificateCollection; + CertificateCollection->CertificateCollection = CertificateCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("CertificateCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("CertificateCollection"), "CertificateCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("CertificateCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("CertificateCollection"), "CertificateCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CertificateCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CertificateCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_CertificateCollection_JSON (*((EFI_REDFISH_CERTIFICATECOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CertificateCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CERTIFICATECOLLECTION *CertificateCollection; + + CertificateCollection = (EFI_REDFISH_CERTIFICATECOLLECTION *)InterpProp; + DestroyCertificateCollection_CS (CertificateCollection->CertificateCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CertificateCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCertificateCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCertificateCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CertificateCollectionToStructWrapper, + CertificateCollectionToJson, + CertificateCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCertificateCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/CertificateCollection/RedfishCertificateCollection_Dxe.inf b/RedfishClientPkg/Converter/CertificateCollection/RedfishCertificateCollection_Dxe.inf new file mode 100644 index 00000000000..f2ceb53952b --- /dev/null +++ b/RedfishClientPkg/Converter/CertificateCollection/RedfishCertificateCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of CertificateCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCertificateCollection_Dxe + FILE_GUID = 334e8adb-e687-44a9-a692-b6ec7ed49cf9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCertificateCollectionEntryPoint + UNLOAD_IMAGE = RedfishCertificateCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + CertificateCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CertificateCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/CertificateLocations/v1_0_0/CertificateLocations_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/CertificateLocations/v1_0_0/CertificateLocations_V1_0_0_Dxe.c new file mode 100644 index 00000000000..d0ff56b599d --- /dev/null +++ b/RedfishClientPkg/Converter/CertificateLocations/v1_0_0/CertificateLocations_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - CertificateLocations.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#CertificateLocations"; +BOOLEAN IsRevisonController = TRUE; + +// Support CertificateLocations V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "CertificateLocations", + "1", + "0", + "0" + }, + "CertificateLocations" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateLocationsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_0 *CertificateLocationsV1_0_0; + EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_0_CS *CertificateLocationsV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "CertificateLocations") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_CertificateLocations_V1_0_0_To_CS (ResoruceRaw, &CertificateLocationsV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CertificateLocationsV1_0_0 = (EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_0)); + if (CertificateLocationsV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CertificateLocationsV1_0_0; + CertificateLocationsV1_0_0->CertificateLocations = CertificateLocationsV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("CertificateLocations")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("CertificateLocations"), "CertificateLocations"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("CertificateLocations")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("CertificateLocations"), "CertificateLocations"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CertificateLocationsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateLocationsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CertificateLocationsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateLocationsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_CertificateLocations_V1_0_0_JSON (*((EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CertificateLocationsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateLocationsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_0 *CertificateLocationsV1_0_0; + + CertificateLocationsV1_0_0 = (EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_0 *)InterpProp; + DestroyCertificateLocations_V1_0_0_CS (CertificateLocationsV1_0_0->CertificateLocations); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CertificateLocationsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateLocationsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCertificateLocations_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCertificateLocations_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CertificateLocationsToStructWrapper, + CertificateLocationsToJson, + CertificateLocationsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCertificateLocations_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/CertificateLocations/v1_0_0/RedfishCertificateLocations_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/CertificateLocations/v1_0_0/RedfishCertificateLocations_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..6356d0d1fe2 --- /dev/null +++ b/RedfishClientPkg/Converter/CertificateLocations/v1_0_0/RedfishCertificateLocations_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of CertificateLocations.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCertificateLocations_V1_0_0_Dxe + FILE_GUID = d1ba2d3a-c945-4ae0-a216-19e16615ba3f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCertificateLocations_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishCertificateLocations_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + CertificateLocations_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CertificateLocationsV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/CertificateLocations/v1_0_1/CertificateLocations_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/CertificateLocations/v1_0_1/CertificateLocations_V1_0_1_Dxe.c new file mode 100644 index 00000000000..dbb4142373d --- /dev/null +++ b/RedfishClientPkg/Converter/CertificateLocations/v1_0_1/CertificateLocations_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - CertificateLocations.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#CertificateLocations"; +BOOLEAN IsRevisonController = TRUE; + +// Support CertificateLocations V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "CertificateLocations", + "1", + "0", + "1" + }, + "CertificateLocations" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateLocationsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_1 *CertificateLocationsV1_0_1; + EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_1_CS *CertificateLocationsV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "CertificateLocations") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_CertificateLocations_V1_0_1_To_CS (ResoruceRaw, &CertificateLocationsV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CertificateLocationsV1_0_1 = (EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_1)); + if (CertificateLocationsV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CertificateLocationsV1_0_1; + CertificateLocationsV1_0_1->CertificateLocations = CertificateLocationsV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("CertificateLocations")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("CertificateLocations"), "CertificateLocations"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("CertificateLocations")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("CertificateLocations"), "CertificateLocations"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CertificateLocationsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateLocationsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CertificateLocationsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateLocationsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_CertificateLocations_V1_0_1_JSON (*((EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CertificateLocationsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateLocationsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_1 *CertificateLocationsV1_0_1; + + CertificateLocationsV1_0_1 = (EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_1 *)InterpProp; + DestroyCertificateLocations_V1_0_1_CS (CertificateLocationsV1_0_1->CertificateLocations); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CertificateLocationsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateLocationsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCertificateLocations_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCertificateLocations_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CertificateLocationsToStructWrapper, + CertificateLocationsToJson, + CertificateLocationsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCertificateLocations_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/CertificateLocations/v1_0_1/RedfishCertificateLocations_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/CertificateLocations/v1_0_1/RedfishCertificateLocations_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..c25c8b9a173 --- /dev/null +++ b/RedfishClientPkg/Converter/CertificateLocations/v1_0_1/RedfishCertificateLocations_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of CertificateLocations.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCertificateLocations_V1_0_1_Dxe + FILE_GUID = 729676cf-9f66-4094-af00-a9c48876cf4e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCertificateLocations_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishCertificateLocations_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + CertificateLocations_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CertificateLocationsV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/CertificateLocations/v1_0_2/CertificateLocations_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/CertificateLocations/v1_0_2/CertificateLocations_V1_0_2_Dxe.c new file mode 100644 index 00000000000..58f1b0ce8df --- /dev/null +++ b/RedfishClientPkg/Converter/CertificateLocations/v1_0_2/CertificateLocations_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - CertificateLocations.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#CertificateLocations"; +BOOLEAN IsRevisonController = TRUE; + +// Support CertificateLocations V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "CertificateLocations", + "1", + "0", + "2" + }, + "CertificateLocations" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateLocationsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_2 *CertificateLocationsV1_0_2; + EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_2_CS *CertificateLocationsV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "CertificateLocations") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_CertificateLocations_V1_0_2_To_CS (ResoruceRaw, &CertificateLocationsV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CertificateLocationsV1_0_2 = (EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_2)); + if (CertificateLocationsV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CertificateLocationsV1_0_2; + CertificateLocationsV1_0_2->CertificateLocations = CertificateLocationsV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("CertificateLocations")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("CertificateLocations"), "CertificateLocations"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("CertificateLocations")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("CertificateLocations"), "CertificateLocations"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CertificateLocationsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateLocationsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CertificateLocationsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateLocationsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_CertificateLocations_V1_0_2_JSON (*((EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CertificateLocationsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateLocationsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_2 *CertificateLocationsV1_0_2; + + CertificateLocationsV1_0_2 = (EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_2 *)InterpProp; + DestroyCertificateLocations_V1_0_2_CS (CertificateLocationsV1_0_2->CertificateLocations); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CertificateLocationsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateLocationsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCertificateLocations_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCertificateLocations_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CertificateLocationsToStructWrapper, + CertificateLocationsToJson, + CertificateLocationsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCertificateLocations_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/CertificateLocations/v1_0_2/RedfishCertificateLocations_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/CertificateLocations/v1_0_2/RedfishCertificateLocations_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..171825af1c8 --- /dev/null +++ b/RedfishClientPkg/Converter/CertificateLocations/v1_0_2/RedfishCertificateLocations_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of CertificateLocations.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCertificateLocations_V1_0_2_Dxe + FILE_GUID = b7713afc-1523-4ac8-b29a-70a86fe2143f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCertificateLocations_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishCertificateLocations_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + CertificateLocations_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CertificateLocationsV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/CertificateService/v1_0_0/CertificateService_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/CertificateService/v1_0_0/CertificateService_V1_0_0_Dxe.c new file mode 100644 index 00000000000..aea1313b26d --- /dev/null +++ b/RedfishClientPkg/Converter/CertificateService/v1_0_0/CertificateService_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - CertificateService.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#CertificateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support CertificateService V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "CertificateService", + "1", + "0", + "0" + }, + "CertificateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CERTIFICATESERVICE_V1_0_0 *CertificateServiceV1_0_0; + EFI_REDFISH_CERTIFICATESERVICE_V1_0_0_CS *CertificateServiceV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "CertificateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_CertificateService_V1_0_0_To_CS (ResoruceRaw, &CertificateServiceV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CertificateServiceV1_0_0 = (EFI_REDFISH_CERTIFICATESERVICE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CERTIFICATESERVICE_V1_0_0)); + if (CertificateServiceV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CertificateServiceV1_0_0; + CertificateServiceV1_0_0->CertificateService = CertificateServiceV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("CertificateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("CertificateService"), "CertificateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("CertificateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("CertificateService"), "CertificateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CertificateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CertificateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_CertificateService_V1_0_0_JSON (*((EFI_REDFISH_CERTIFICATESERVICE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CertificateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CERTIFICATESERVICE_V1_0_0 *CertificateServiceV1_0_0; + + CertificateServiceV1_0_0 = (EFI_REDFISH_CERTIFICATESERVICE_V1_0_0 *)InterpProp; + DestroyCertificateService_V1_0_0_CS (CertificateServiceV1_0_0->CertificateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CertificateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCertificateService_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCertificateService_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CertificateServiceToStructWrapper, + CertificateServiceToJson, + CertificateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCertificateService_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/CertificateService/v1_0_0/RedfishCertificateService_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/CertificateService/v1_0_0/RedfishCertificateService_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..fffaa625253 --- /dev/null +++ b/RedfishClientPkg/Converter/CertificateService/v1_0_0/RedfishCertificateService_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of CertificateService.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCertificateService_V1_0_0_Dxe + FILE_GUID = 9b8254a7-e1e9-48e3-9e96-1457a5e9138a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCertificateService_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishCertificateService_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + CertificateService_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CertificateServiceV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/CertificateService/v1_0_1/CertificateService_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/CertificateService/v1_0_1/CertificateService_V1_0_1_Dxe.c new file mode 100644 index 00000000000..e20c80cd39b --- /dev/null +++ b/RedfishClientPkg/Converter/CertificateService/v1_0_1/CertificateService_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - CertificateService.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#CertificateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support CertificateService V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "CertificateService", + "1", + "0", + "1" + }, + "CertificateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CERTIFICATESERVICE_V1_0_1 *CertificateServiceV1_0_1; + EFI_REDFISH_CERTIFICATESERVICE_V1_0_1_CS *CertificateServiceV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "CertificateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_CertificateService_V1_0_1_To_CS (ResoruceRaw, &CertificateServiceV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CertificateServiceV1_0_1 = (EFI_REDFISH_CERTIFICATESERVICE_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CERTIFICATESERVICE_V1_0_1)); + if (CertificateServiceV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CertificateServiceV1_0_1; + CertificateServiceV1_0_1->CertificateService = CertificateServiceV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("CertificateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("CertificateService"), "CertificateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("CertificateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("CertificateService"), "CertificateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CertificateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CertificateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_CertificateService_V1_0_1_JSON (*((EFI_REDFISH_CERTIFICATESERVICE_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CertificateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CERTIFICATESERVICE_V1_0_1 *CertificateServiceV1_0_1; + + CertificateServiceV1_0_1 = (EFI_REDFISH_CERTIFICATESERVICE_V1_0_1 *)InterpProp; + DestroyCertificateService_V1_0_1_CS (CertificateServiceV1_0_1->CertificateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CertificateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCertificateService_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCertificateService_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CertificateServiceToStructWrapper, + CertificateServiceToJson, + CertificateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCertificateService_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/CertificateService/v1_0_1/RedfishCertificateService_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/CertificateService/v1_0_1/RedfishCertificateService_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..8443d531be0 --- /dev/null +++ b/RedfishClientPkg/Converter/CertificateService/v1_0_1/RedfishCertificateService_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of CertificateService.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCertificateService_V1_0_1_Dxe + FILE_GUID = 3c7f536d-7635-4e65-a2e3-64ee8b7f2f5f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCertificateService_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishCertificateService_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + CertificateService_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CertificateServiceV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/CertificateService/v1_0_2/CertificateService_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/CertificateService/v1_0_2/CertificateService_V1_0_2_Dxe.c new file mode 100644 index 00000000000..3b6a39d2b4a --- /dev/null +++ b/RedfishClientPkg/Converter/CertificateService/v1_0_2/CertificateService_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - CertificateService.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#CertificateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support CertificateService V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "CertificateService", + "1", + "0", + "2" + }, + "CertificateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CERTIFICATESERVICE_V1_0_2 *CertificateServiceV1_0_2; + EFI_REDFISH_CERTIFICATESERVICE_V1_0_2_CS *CertificateServiceV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "CertificateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_CertificateService_V1_0_2_To_CS (ResoruceRaw, &CertificateServiceV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CertificateServiceV1_0_2 = (EFI_REDFISH_CERTIFICATESERVICE_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CERTIFICATESERVICE_V1_0_2)); + if (CertificateServiceV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CertificateServiceV1_0_2; + CertificateServiceV1_0_2->CertificateService = CertificateServiceV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("CertificateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("CertificateService"), "CertificateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("CertificateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("CertificateService"), "CertificateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CertificateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CertificateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_CertificateService_V1_0_2_JSON (*((EFI_REDFISH_CERTIFICATESERVICE_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CertificateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CERTIFICATESERVICE_V1_0_2 *CertificateServiceV1_0_2; + + CertificateServiceV1_0_2 = (EFI_REDFISH_CERTIFICATESERVICE_V1_0_2 *)InterpProp; + DestroyCertificateService_V1_0_2_CS (CertificateServiceV1_0_2->CertificateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CertificateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCertificateService_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCertificateService_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CertificateServiceToStructWrapper, + CertificateServiceToJson, + CertificateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCertificateService_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/CertificateService/v1_0_2/RedfishCertificateService_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/CertificateService/v1_0_2/RedfishCertificateService_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..2e4a0e27f43 --- /dev/null +++ b/RedfishClientPkg/Converter/CertificateService/v1_0_2/RedfishCertificateService_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of CertificateService.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCertificateService_V1_0_2_Dxe + FILE_GUID = 8f819a13-d5ab-40aa-82b1-952527f6222b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCertificateService_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishCertificateService_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + CertificateService_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CertificateServiceV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/CertificateService/v1_0_3/CertificateService_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/CertificateService/v1_0_3/CertificateService_V1_0_3_Dxe.c new file mode 100644 index 00000000000..5359f4a43dd --- /dev/null +++ b/RedfishClientPkg/Converter/CertificateService/v1_0_3/CertificateService_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - CertificateService.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#CertificateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support CertificateService V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "CertificateService", + "1", + "0", + "3" + }, + "CertificateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CERTIFICATESERVICE_V1_0_3 *CertificateServiceV1_0_3; + EFI_REDFISH_CERTIFICATESERVICE_V1_0_3_CS *CertificateServiceV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "CertificateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_CertificateService_V1_0_3_To_CS (ResoruceRaw, &CertificateServiceV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CertificateServiceV1_0_3 = (EFI_REDFISH_CERTIFICATESERVICE_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CERTIFICATESERVICE_V1_0_3)); + if (CertificateServiceV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CertificateServiceV1_0_3; + CertificateServiceV1_0_3->CertificateService = CertificateServiceV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("CertificateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("CertificateService"), "CertificateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("CertificateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("CertificateService"), "CertificateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CertificateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CertificateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_CertificateService_V1_0_3_JSON (*((EFI_REDFISH_CERTIFICATESERVICE_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CertificateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CERTIFICATESERVICE_V1_0_3 *CertificateServiceV1_0_3; + + CertificateServiceV1_0_3 = (EFI_REDFISH_CERTIFICATESERVICE_V1_0_3 *)InterpProp; + DestroyCertificateService_V1_0_3_CS (CertificateServiceV1_0_3->CertificateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CertificateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCertificateService_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCertificateService_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CertificateServiceToStructWrapper, + CertificateServiceToJson, + CertificateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCertificateService_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/CertificateService/v1_0_3/RedfishCertificateService_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/CertificateService/v1_0_3/RedfishCertificateService_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..e53204e3666 --- /dev/null +++ b/RedfishClientPkg/Converter/CertificateService/v1_0_3/RedfishCertificateService_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of CertificateService.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCertificateService_V1_0_3_Dxe + FILE_GUID = 1a65c925-97a0-491e-8c32-1d21ea094fe7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCertificateService_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishCertificateService_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + CertificateService_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CertificateServiceV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/CertificateService/v1_0_4/CertificateService_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/CertificateService/v1_0_4/CertificateService_V1_0_4_Dxe.c new file mode 100644 index 00000000000..7f6f5f82edd --- /dev/null +++ b/RedfishClientPkg/Converter/CertificateService/v1_0_4/CertificateService_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - CertificateService.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#CertificateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support CertificateService V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "CertificateService", + "1", + "0", + "4" + }, + "CertificateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CERTIFICATESERVICE_V1_0_4 *CertificateServiceV1_0_4; + EFI_REDFISH_CERTIFICATESERVICE_V1_0_4_CS *CertificateServiceV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "CertificateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_CertificateService_V1_0_4_To_CS (ResoruceRaw, &CertificateServiceV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CertificateServiceV1_0_4 = (EFI_REDFISH_CERTIFICATESERVICE_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CERTIFICATESERVICE_V1_0_4)); + if (CertificateServiceV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CertificateServiceV1_0_4; + CertificateServiceV1_0_4->CertificateService = CertificateServiceV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("CertificateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("CertificateService"), "CertificateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("CertificateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("CertificateService"), "CertificateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CertificateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CertificateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_CertificateService_V1_0_4_JSON (*((EFI_REDFISH_CERTIFICATESERVICE_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CertificateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CERTIFICATESERVICE_V1_0_4 *CertificateServiceV1_0_4; + + CertificateServiceV1_0_4 = (EFI_REDFISH_CERTIFICATESERVICE_V1_0_4 *)InterpProp; + DestroyCertificateService_V1_0_4_CS (CertificateServiceV1_0_4->CertificateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CertificateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CertificateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCertificateService_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCertificateService_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CertificateServiceToStructWrapper, + CertificateServiceToJson, + CertificateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCertificateService_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/CertificateService/v1_0_4/RedfishCertificateService_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/CertificateService/v1_0_4/RedfishCertificateService_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..41b29100584 --- /dev/null +++ b/RedfishClientPkg/Converter/CertificateService/v1_0_4/RedfishCertificateService_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of CertificateService.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCertificateService_V1_0_4_Dxe + FILE_GUID = 93e7a9c3-18e1-45c6-a1c7-a8a0bf1b70ca + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCertificateService_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishCertificateService_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + CertificateService_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CertificateServiceV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_0/Chassis_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_0_0/Chassis_V1_0_0_Dxe.c new file mode 100644 index 00000000000..f6c352effc0 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_0/Chassis_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "0", + "0" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_0 *ChassisV1_0_0; + EFI_REDFISH_CHASSIS_V1_0_0_CS *ChassisV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_0_0_To_CS (ResoruceRaw, &ChassisV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_0_0 = (EFI_REDFISH_CHASSIS_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_0_0)); + if (ChassisV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_0_0; + ChassisV1_0_0->Chassis = ChassisV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_0_0_JSON (*((EFI_REDFISH_CHASSIS_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_0 *ChassisV1_0_0; + + ChassisV1_0_0 = (EFI_REDFISH_CHASSIS_V1_0_0 *)InterpProp; + DestroyChassis_V1_0_0_CS (ChassisV1_0_0->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_0/RedfishChassis_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_0_0/RedfishChassis_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..94ba2bd36de --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_0/RedfishChassis_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_0_0_Dxe + FILE_GUID = b9eb8f72-e8d1-4950-b6ef-578493eab809 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_1/Chassis_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_0_1/Chassis_V1_0_1_Dxe.c new file mode 100644 index 00000000000..99a009b57cc --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_1/Chassis_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "0", + "1" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_1 *ChassisV1_0_1; + EFI_REDFISH_CHASSIS_V1_0_1_CS *ChassisV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_0_1_To_CS (ResoruceRaw, &ChassisV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_0_1 = (EFI_REDFISH_CHASSIS_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_0_1)); + if (ChassisV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_0_1; + ChassisV1_0_1->Chassis = ChassisV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_0_1_JSON (*((EFI_REDFISH_CHASSIS_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_1 *ChassisV1_0_1; + + ChassisV1_0_1 = (EFI_REDFISH_CHASSIS_V1_0_1 *)InterpProp; + DestroyChassis_V1_0_1_CS (ChassisV1_0_1->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_1/RedfishChassis_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_0_1/RedfishChassis_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..6c5b7643a2c --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_1/RedfishChassis_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_0_1_Dxe + FILE_GUID = ea772ab6-8646-42fd-adcf-444be2a330ab + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_10/Chassis_V1_0_10_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_0_10/Chassis_V1_0_10_Dxe.c new file mode 100644 index 00000000000..285be66de72 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_10/Chassis_V1_0_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_0_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "0", + "10" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_10 *ChassisV1_0_10; + EFI_REDFISH_CHASSIS_V1_0_10_CS *ChassisV1_0_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_0_10_To_CS (ResoruceRaw, &ChassisV1_0_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_0_10 = (EFI_REDFISH_CHASSIS_V1_0_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_0_10)); + if (ChassisV1_0_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_0_10; + ChassisV1_0_10->Chassis = ChassisV1_0_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_0_10_JSON (*((EFI_REDFISH_CHASSIS_V1_0_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_10 *ChassisV1_0_10; + + ChassisV1_0_10 = (EFI_REDFISH_CHASSIS_V1_0_10 *)InterpProp; + DestroyChassis_V1_0_10_CS (ChassisV1_0_10->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_0_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_10/RedfishChassis_V1_0_10_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_0_10/RedfishChassis_V1_0_10_Dxe.inf new file mode 100644 index 00000000000..fe914ec8fea --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_10/RedfishChassis_V1_0_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_0_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_0_10_Dxe + FILE_GUID = bce2f57c-d66d-455c-96a6-df86ca70ed6f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_0_10EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_0_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_0_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_0_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_11/Chassis_V1_0_11_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_0_11/Chassis_V1_0_11_Dxe.c new file mode 100644 index 00000000000..4381c42807f --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_11/Chassis_V1_0_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_0_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "0", + "11" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_11 *ChassisV1_0_11; + EFI_REDFISH_CHASSIS_V1_0_11_CS *ChassisV1_0_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_0_11_To_CS (ResoruceRaw, &ChassisV1_0_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_0_11 = (EFI_REDFISH_CHASSIS_V1_0_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_0_11)); + if (ChassisV1_0_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_0_11; + ChassisV1_0_11->Chassis = ChassisV1_0_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_0_11_JSON (*((EFI_REDFISH_CHASSIS_V1_0_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_11 *ChassisV1_0_11; + + ChassisV1_0_11 = (EFI_REDFISH_CHASSIS_V1_0_11 *)InterpProp; + DestroyChassis_V1_0_11_CS (ChassisV1_0_11->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_0_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_11/RedfishChassis_V1_0_11_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_0_11/RedfishChassis_V1_0_11_Dxe.inf new file mode 100644 index 00000000000..69ee0e8ffa2 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_11/RedfishChassis_V1_0_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_0_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_0_11_Dxe + FILE_GUID = fe6406ee-dfea-4d6e-9e45-f4b9d9aaca07 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_0_11EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_0_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_0_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_0_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_12/Chassis_V1_0_12_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_0_12/Chassis_V1_0_12_Dxe.c new file mode 100644 index 00000000000..3bc6ad80aaa --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_12/Chassis_V1_0_12_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_0_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_0_12 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "0", + "12" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_12 *ChassisV1_0_12; + EFI_REDFISH_CHASSIS_V1_0_12_CS *ChassisV1_0_12Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "12") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_0_12_To_CS (ResoruceRaw, &ChassisV1_0_12Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_0_12 = (EFI_REDFISH_CHASSIS_V1_0_12 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_0_12)); + if (ChassisV1_0_12 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_0_12; + ChassisV1_0_12->Chassis = ChassisV1_0_12Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "12"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_0_12_JSON (*((EFI_REDFISH_CHASSIS_V1_0_12_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_12 *ChassisV1_0_12; + + ChassisV1_0_12 = (EFI_REDFISH_CHASSIS_V1_0_12 *)InterpProp; + DestroyChassis_V1_0_12_CS (ChassisV1_0_12->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_0_12_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_12EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_12Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_12/RedfishChassis_V1_0_12_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_0_12/RedfishChassis_V1_0_12_Dxe.inf new file mode 100644 index 00000000000..ef53084f055 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_12/RedfishChassis_V1_0_12_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_0_12 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_0_12_Dxe + FILE_GUID = e9099934-5172-4904-8c03-d27850a69eca + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_0_12EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_0_12Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_0_12_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_0_12Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_13/Chassis_V1_0_13_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_0_13/Chassis_V1_0_13_Dxe.c new file mode 100644 index 00000000000..e19dc094015 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_13/Chassis_V1_0_13_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_0_13 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_0_13 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "0", + "13" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_13 *ChassisV1_0_13; + EFI_REDFISH_CHASSIS_V1_0_13_CS *ChassisV1_0_13Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "13") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_0_13_To_CS (ResoruceRaw, &ChassisV1_0_13Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_0_13 = (EFI_REDFISH_CHASSIS_V1_0_13 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_0_13)); + if (ChassisV1_0_13 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_0_13; + ChassisV1_0_13->Chassis = ChassisV1_0_13Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "13"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_0_13_JSON (*((EFI_REDFISH_CHASSIS_V1_0_13_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_13 *ChassisV1_0_13; + + ChassisV1_0_13 = (EFI_REDFISH_CHASSIS_V1_0_13 *)InterpProp; + DestroyChassis_V1_0_13_CS (ChassisV1_0_13->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_0_13_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_13EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_13Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_13/RedfishChassis_V1_0_13_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_0_13/RedfishChassis_V1_0_13_Dxe.inf new file mode 100644 index 00000000000..88748ceed19 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_13/RedfishChassis_V1_0_13_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_0_13 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_0_13_Dxe + FILE_GUID = 6a20e534-12be-497b-8201-e4bd0328bc37 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_0_13EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_0_13Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_0_13_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_0_13Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_2/Chassis_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_0_2/Chassis_V1_0_2_Dxe.c new file mode 100644 index 00000000000..7d0e7251246 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_2/Chassis_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "0", + "2" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_2 *ChassisV1_0_2; + EFI_REDFISH_CHASSIS_V1_0_2_CS *ChassisV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_0_2_To_CS (ResoruceRaw, &ChassisV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_0_2 = (EFI_REDFISH_CHASSIS_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_0_2)); + if (ChassisV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_0_2; + ChassisV1_0_2->Chassis = ChassisV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_0_2_JSON (*((EFI_REDFISH_CHASSIS_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_2 *ChassisV1_0_2; + + ChassisV1_0_2 = (EFI_REDFISH_CHASSIS_V1_0_2 *)InterpProp; + DestroyChassis_V1_0_2_CS (ChassisV1_0_2->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_2/RedfishChassis_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_0_2/RedfishChassis_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..12cd562c348 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_2/RedfishChassis_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_0_2_Dxe + FILE_GUID = fc54ceb4-69df-433c-b728-b7d6f6970e58 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_3/Chassis_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_0_3/Chassis_V1_0_3_Dxe.c new file mode 100644 index 00000000000..2fb0d3bbd24 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_3/Chassis_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "0", + "3" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_3 *ChassisV1_0_3; + EFI_REDFISH_CHASSIS_V1_0_3_CS *ChassisV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_0_3_To_CS (ResoruceRaw, &ChassisV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_0_3 = (EFI_REDFISH_CHASSIS_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_0_3)); + if (ChassisV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_0_3; + ChassisV1_0_3->Chassis = ChassisV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_0_3_JSON (*((EFI_REDFISH_CHASSIS_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_3 *ChassisV1_0_3; + + ChassisV1_0_3 = (EFI_REDFISH_CHASSIS_V1_0_3 *)InterpProp; + DestroyChassis_V1_0_3_CS (ChassisV1_0_3->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_3/RedfishChassis_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_0_3/RedfishChassis_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..04167659a43 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_3/RedfishChassis_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_0_3_Dxe + FILE_GUID = 6e5f6f21-46cb-4639-9db3-710b91894c74 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_4/Chassis_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_0_4/Chassis_V1_0_4_Dxe.c new file mode 100644 index 00000000000..922f5b0e2f7 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_4/Chassis_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "0", + "4" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_4 *ChassisV1_0_4; + EFI_REDFISH_CHASSIS_V1_0_4_CS *ChassisV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_0_4_To_CS (ResoruceRaw, &ChassisV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_0_4 = (EFI_REDFISH_CHASSIS_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_0_4)); + if (ChassisV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_0_4; + ChassisV1_0_4->Chassis = ChassisV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_0_4_JSON (*((EFI_REDFISH_CHASSIS_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_4 *ChassisV1_0_4; + + ChassisV1_0_4 = (EFI_REDFISH_CHASSIS_V1_0_4 *)InterpProp; + DestroyChassis_V1_0_4_CS (ChassisV1_0_4->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_4/RedfishChassis_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_0_4/RedfishChassis_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..00802a42a60 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_4/RedfishChassis_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_0_4_Dxe + FILE_GUID = cd701f84-ec20-420c-a63b-480f0505eee3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_5/Chassis_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_0_5/Chassis_V1_0_5_Dxe.c new file mode 100644 index 00000000000..174791aad51 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_5/Chassis_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "0", + "5" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_5 *ChassisV1_0_5; + EFI_REDFISH_CHASSIS_V1_0_5_CS *ChassisV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_0_5_To_CS (ResoruceRaw, &ChassisV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_0_5 = (EFI_REDFISH_CHASSIS_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_0_5)); + if (ChassisV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_0_5; + ChassisV1_0_5->Chassis = ChassisV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_0_5_JSON (*((EFI_REDFISH_CHASSIS_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_5 *ChassisV1_0_5; + + ChassisV1_0_5 = (EFI_REDFISH_CHASSIS_V1_0_5 *)InterpProp; + DestroyChassis_V1_0_5_CS (ChassisV1_0_5->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_5/RedfishChassis_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_0_5/RedfishChassis_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..82f5f32de07 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_5/RedfishChassis_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_0_5_Dxe + FILE_GUID = b3531d6b-23e1-4f0c-ac32-317b477710be + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_6/Chassis_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_0_6/Chassis_V1_0_6_Dxe.c new file mode 100644 index 00000000000..f6d08ba9760 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_6/Chassis_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "0", + "6" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_6 *ChassisV1_0_6; + EFI_REDFISH_CHASSIS_V1_0_6_CS *ChassisV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_0_6_To_CS (ResoruceRaw, &ChassisV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_0_6 = (EFI_REDFISH_CHASSIS_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_0_6)); + if (ChassisV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_0_6; + ChassisV1_0_6->Chassis = ChassisV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_0_6_JSON (*((EFI_REDFISH_CHASSIS_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_6 *ChassisV1_0_6; + + ChassisV1_0_6 = (EFI_REDFISH_CHASSIS_V1_0_6 *)InterpProp; + DestroyChassis_V1_0_6_CS (ChassisV1_0_6->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_6/RedfishChassis_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_0_6/RedfishChassis_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..d78d7c99f0b --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_6/RedfishChassis_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_0_6_Dxe + FILE_GUID = 58690786-a377-4d88-bde3-2bc523b79aac + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_7/Chassis_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_0_7/Chassis_V1_0_7_Dxe.c new file mode 100644 index 00000000000..db1c8944614 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_7/Chassis_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "0", + "7" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_7 *ChassisV1_0_7; + EFI_REDFISH_CHASSIS_V1_0_7_CS *ChassisV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_0_7_To_CS (ResoruceRaw, &ChassisV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_0_7 = (EFI_REDFISH_CHASSIS_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_0_7)); + if (ChassisV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_0_7; + ChassisV1_0_7->Chassis = ChassisV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_0_7_JSON (*((EFI_REDFISH_CHASSIS_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_7 *ChassisV1_0_7; + + ChassisV1_0_7 = (EFI_REDFISH_CHASSIS_V1_0_7 *)InterpProp; + DestroyChassis_V1_0_7_CS (ChassisV1_0_7->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_7/RedfishChassis_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_0_7/RedfishChassis_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..e979ab2bec6 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_7/RedfishChassis_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_0_7_Dxe + FILE_GUID = 83cfee28-8d64-41df-b3c6-d2a663e81ca5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_8/Chassis_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_0_8/Chassis_V1_0_8_Dxe.c new file mode 100644 index 00000000000..63d36680e56 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_8/Chassis_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "0", + "8" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_8 *ChassisV1_0_8; + EFI_REDFISH_CHASSIS_V1_0_8_CS *ChassisV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_0_8_To_CS (ResoruceRaw, &ChassisV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_0_8 = (EFI_REDFISH_CHASSIS_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_0_8)); + if (ChassisV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_0_8; + ChassisV1_0_8->Chassis = ChassisV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_0_8_JSON (*((EFI_REDFISH_CHASSIS_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_8 *ChassisV1_0_8; + + ChassisV1_0_8 = (EFI_REDFISH_CHASSIS_V1_0_8 *)InterpProp; + DestroyChassis_V1_0_8_CS (ChassisV1_0_8->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_8/RedfishChassis_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_0_8/RedfishChassis_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..93d522eea18 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_8/RedfishChassis_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_0_8_Dxe + FILE_GUID = 0c012ed1-6a62-4b3b-81fe-724927500f97 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_9/Chassis_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_0_9/Chassis_V1_0_9_Dxe.c new file mode 100644 index 00000000000..1c52209c4f6 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_9/Chassis_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "0", + "9" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_9 *ChassisV1_0_9; + EFI_REDFISH_CHASSIS_V1_0_9_CS *ChassisV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_0_9_To_CS (ResoruceRaw, &ChassisV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_0_9 = (EFI_REDFISH_CHASSIS_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_0_9)); + if (ChassisV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_0_9; + ChassisV1_0_9->Chassis = ChassisV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_0_9_JSON (*((EFI_REDFISH_CHASSIS_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_0_9 *ChassisV1_0_9; + + ChassisV1_0_9 = (EFI_REDFISH_CHASSIS_V1_0_9 *)InterpProp; + DestroyChassis_V1_0_9_CS (ChassisV1_0_9->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_0_9/RedfishChassis_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_0_9/RedfishChassis_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..a43246f5b21 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_0_9/RedfishChassis_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_0_9_Dxe + FILE_GUID = 08138347-8402-4870-a5b8-6e02a9c36158 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_10_0/Chassis_V1_10_0_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_10_0/Chassis_V1_10_0_Dxe.c new file mode 100644 index 00000000000..3d91c85ab96 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_10_0/Chassis_V1_10_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_10_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_10_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "10", + "0" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_10_0 *ChassisV1_10_0; + EFI_REDFISH_CHASSIS_V1_10_0_CS *ChassisV1_10_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_10_0_To_CS (ResoruceRaw, &ChassisV1_10_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_10_0 = (EFI_REDFISH_CHASSIS_V1_10_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_10_0)); + if (ChassisV1_10_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_10_0; + ChassisV1_10_0->Chassis = ChassisV1_10_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "10"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_10_0_JSON (*((EFI_REDFISH_CHASSIS_V1_10_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_10_0 *ChassisV1_10_0; + + ChassisV1_10_0 = (EFI_REDFISH_CHASSIS_V1_10_0 *)InterpProp; + DestroyChassis_V1_10_0_CS (ChassisV1_10_0->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_10_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_10_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_10_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_10_0/RedfishChassis_V1_10_0_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_10_0/RedfishChassis_V1_10_0_Dxe.inf new file mode 100644 index 00000000000..404edcca34e --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_10_0/RedfishChassis_V1_10_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_10_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_10_0_Dxe + FILE_GUID = 774e1df7-ef5f-4667-9265-06938eebcf6a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_10_0EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_10_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_10_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_10_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_10_1/Chassis_V1_10_1_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_10_1/Chassis_V1_10_1_Dxe.c new file mode 100644 index 00000000000..c766d603118 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_10_1/Chassis_V1_10_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_10_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_10_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "10", + "1" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_10_1 *ChassisV1_10_1; + EFI_REDFISH_CHASSIS_V1_10_1_CS *ChassisV1_10_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_10_1_To_CS (ResoruceRaw, &ChassisV1_10_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_10_1 = (EFI_REDFISH_CHASSIS_V1_10_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_10_1)); + if (ChassisV1_10_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_10_1; + ChassisV1_10_1->Chassis = ChassisV1_10_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "10"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_10_1_JSON (*((EFI_REDFISH_CHASSIS_V1_10_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_10_1 *ChassisV1_10_1; + + ChassisV1_10_1 = (EFI_REDFISH_CHASSIS_V1_10_1 *)InterpProp; + DestroyChassis_V1_10_1_CS (ChassisV1_10_1->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_10_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_10_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_10_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_10_1/RedfishChassis_V1_10_1_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_10_1/RedfishChassis_V1_10_1_Dxe.inf new file mode 100644 index 00000000000..f7efe99e496 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_10_1/RedfishChassis_V1_10_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_10_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_10_1_Dxe + FILE_GUID = 0b0c4620-a8ec-4104-be1d-0d014bdcdae5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_10_1EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_10_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_10_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_10_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_10_2/Chassis_V1_10_2_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_10_2/Chassis_V1_10_2_Dxe.c new file mode 100644 index 00000000000..1b941087606 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_10_2/Chassis_V1_10_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_10_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_10_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "10", + "2" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_10_2 *ChassisV1_10_2; + EFI_REDFISH_CHASSIS_V1_10_2_CS *ChassisV1_10_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_10_2_To_CS (ResoruceRaw, &ChassisV1_10_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_10_2 = (EFI_REDFISH_CHASSIS_V1_10_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_10_2)); + if (ChassisV1_10_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_10_2; + ChassisV1_10_2->Chassis = ChassisV1_10_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "10"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_10_2_JSON (*((EFI_REDFISH_CHASSIS_V1_10_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_10_2 *ChassisV1_10_2; + + ChassisV1_10_2 = (EFI_REDFISH_CHASSIS_V1_10_2 *)InterpProp; + DestroyChassis_V1_10_2_CS (ChassisV1_10_2->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_10_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_10_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_10_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_10_2/RedfishChassis_V1_10_2_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_10_2/RedfishChassis_V1_10_2_Dxe.inf new file mode 100644 index 00000000000..798dce1bc66 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_10_2/RedfishChassis_V1_10_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_10_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_10_2_Dxe + FILE_GUID = 3db61d00-a434-40f1-9ff2-4f99db8fb73c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_10_2EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_10_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_10_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_10_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_10_3/Chassis_V1_10_3_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_10_3/Chassis_V1_10_3_Dxe.c new file mode 100644 index 00000000000..07c67b034ea --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_10_3/Chassis_V1_10_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_10_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_10_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "10", + "3" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_10_3 *ChassisV1_10_3; + EFI_REDFISH_CHASSIS_V1_10_3_CS *ChassisV1_10_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_10_3_To_CS (ResoruceRaw, &ChassisV1_10_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_10_3 = (EFI_REDFISH_CHASSIS_V1_10_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_10_3)); + if (ChassisV1_10_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_10_3; + ChassisV1_10_3->Chassis = ChassisV1_10_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "10"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_10_3_JSON (*((EFI_REDFISH_CHASSIS_V1_10_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_10_3 *ChassisV1_10_3; + + ChassisV1_10_3 = (EFI_REDFISH_CHASSIS_V1_10_3 *)InterpProp; + DestroyChassis_V1_10_3_CS (ChassisV1_10_3->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_10_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_10_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_10_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_10_3/RedfishChassis_V1_10_3_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_10_3/RedfishChassis_V1_10_3_Dxe.inf new file mode 100644 index 00000000000..1b86704d1e1 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_10_3/RedfishChassis_V1_10_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_10_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_10_3_Dxe + FILE_GUID = 865ed105-7072-4b24-8f4c-ef9a0ba3f696 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_10_3EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_10_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_10_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_10_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_11_0/Chassis_V1_11_0_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_11_0/Chassis_V1_11_0_Dxe.c new file mode 100644 index 00000000000..ee02ad6fc44 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_11_0/Chassis_V1_11_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_11_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_11_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "11", + "0" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_11_0 *ChassisV1_11_0; + EFI_REDFISH_CHASSIS_V1_11_0_CS *ChassisV1_11_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_11_0_To_CS (ResoruceRaw, &ChassisV1_11_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_11_0 = (EFI_REDFISH_CHASSIS_V1_11_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_11_0)); + if (ChassisV1_11_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_11_0; + ChassisV1_11_0->Chassis = ChassisV1_11_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "11"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_11_0_JSON (*((EFI_REDFISH_CHASSIS_V1_11_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_11_0 *ChassisV1_11_0; + + ChassisV1_11_0 = (EFI_REDFISH_CHASSIS_V1_11_0 *)InterpProp; + DestroyChassis_V1_11_0_CS (ChassisV1_11_0->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_11_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_11_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_11_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_11_0/RedfishChassis_V1_11_0_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_11_0/RedfishChassis_V1_11_0_Dxe.inf new file mode 100644 index 00000000000..636c3190504 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_11_0/RedfishChassis_V1_11_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_11_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_11_0_Dxe + FILE_GUID = eb40e292-ae01-4149-8132-932b728eb976 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_11_0EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_11_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_11_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_11_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_11_1/Chassis_V1_11_1_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_11_1/Chassis_V1_11_1_Dxe.c new file mode 100644 index 00000000000..ff7d5fb4fe4 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_11_1/Chassis_V1_11_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_11_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_11_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "11", + "1" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_11_1 *ChassisV1_11_1; + EFI_REDFISH_CHASSIS_V1_11_1_CS *ChassisV1_11_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_11_1_To_CS (ResoruceRaw, &ChassisV1_11_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_11_1 = (EFI_REDFISH_CHASSIS_V1_11_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_11_1)); + if (ChassisV1_11_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_11_1; + ChassisV1_11_1->Chassis = ChassisV1_11_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "11"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_11_1_JSON (*((EFI_REDFISH_CHASSIS_V1_11_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_11_1 *ChassisV1_11_1; + + ChassisV1_11_1 = (EFI_REDFISH_CHASSIS_V1_11_1 *)InterpProp; + DestroyChassis_V1_11_1_CS (ChassisV1_11_1->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_11_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_11_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_11_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_11_1/RedfishChassis_V1_11_1_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_11_1/RedfishChassis_V1_11_1_Dxe.inf new file mode 100644 index 00000000000..3d9ec65c60f --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_11_1/RedfishChassis_V1_11_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_11_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_11_1_Dxe + FILE_GUID = e445c78d-85f5-4d20-ab3a-3db8dd7aff8d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_11_1EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_11_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_11_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_11_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_11_2/Chassis_V1_11_2_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_11_2/Chassis_V1_11_2_Dxe.c new file mode 100644 index 00000000000..0a3a96b3c10 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_11_2/Chassis_V1_11_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_11_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_11_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "11", + "2" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_11_2 *ChassisV1_11_2; + EFI_REDFISH_CHASSIS_V1_11_2_CS *ChassisV1_11_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_11_2_To_CS (ResoruceRaw, &ChassisV1_11_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_11_2 = (EFI_REDFISH_CHASSIS_V1_11_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_11_2)); + if (ChassisV1_11_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_11_2; + ChassisV1_11_2->Chassis = ChassisV1_11_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "11"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_11_2_JSON (*((EFI_REDFISH_CHASSIS_V1_11_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_11_2 *ChassisV1_11_2; + + ChassisV1_11_2 = (EFI_REDFISH_CHASSIS_V1_11_2 *)InterpProp; + DestroyChassis_V1_11_2_CS (ChassisV1_11_2->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_11_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_11_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_11_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_11_2/RedfishChassis_V1_11_2_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_11_2/RedfishChassis_V1_11_2_Dxe.inf new file mode 100644 index 00000000000..ae1e95a297f --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_11_2/RedfishChassis_V1_11_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_11_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_11_2_Dxe + FILE_GUID = 295ac3e6-df2f-414c-9f85-e7f1761b9e6d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_11_2EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_11_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_11_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_11_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_11_3/Chassis_V1_11_3_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_11_3/Chassis_V1_11_3_Dxe.c new file mode 100644 index 00000000000..8562cdb3e15 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_11_3/Chassis_V1_11_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_11_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_11_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "11", + "3" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_11_3 *ChassisV1_11_3; + EFI_REDFISH_CHASSIS_V1_11_3_CS *ChassisV1_11_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_11_3_To_CS (ResoruceRaw, &ChassisV1_11_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_11_3 = (EFI_REDFISH_CHASSIS_V1_11_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_11_3)); + if (ChassisV1_11_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_11_3; + ChassisV1_11_3->Chassis = ChassisV1_11_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "11"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_11_3_JSON (*((EFI_REDFISH_CHASSIS_V1_11_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_11_3 *ChassisV1_11_3; + + ChassisV1_11_3 = (EFI_REDFISH_CHASSIS_V1_11_3 *)InterpProp; + DestroyChassis_V1_11_3_CS (ChassisV1_11_3->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_11_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_11_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_11_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_11_3/RedfishChassis_V1_11_3_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_11_3/RedfishChassis_V1_11_3_Dxe.inf new file mode 100644 index 00000000000..ecfd790c6dc --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_11_3/RedfishChassis_V1_11_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_11_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_11_3_Dxe + FILE_GUID = 49806572-677e-4f44-87a4-2c02cbc4bb6d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_11_3EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_11_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_11_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_11_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_12_0/Chassis_V1_12_0_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_12_0/Chassis_V1_12_0_Dxe.c new file mode 100644 index 00000000000..1ea5f6f9f0a --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_12_0/Chassis_V1_12_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_12_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_12_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "12", + "0" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_12_0 *ChassisV1_12_0; + EFI_REDFISH_CHASSIS_V1_12_0_CS *ChassisV1_12_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "12") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_12_0_To_CS (ResoruceRaw, &ChassisV1_12_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_12_0 = (EFI_REDFISH_CHASSIS_V1_12_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_12_0)); + if (ChassisV1_12_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_12_0; + ChassisV1_12_0->Chassis = ChassisV1_12_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "12"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_12_0_JSON (*((EFI_REDFISH_CHASSIS_V1_12_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_12_0 *ChassisV1_12_0; + + ChassisV1_12_0 = (EFI_REDFISH_CHASSIS_V1_12_0 *)InterpProp; + DestroyChassis_V1_12_0_CS (ChassisV1_12_0->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_12_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_12_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_12_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_12_0/RedfishChassis_V1_12_0_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_12_0/RedfishChassis_V1_12_0_Dxe.inf new file mode 100644 index 00000000000..a92e5864a6e --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_12_0/RedfishChassis_V1_12_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_12_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_12_0_Dxe + FILE_GUID = ca44ec6c-a355-4cf0-abed-8e1560f71750 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_12_0EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_12_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_12_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_12_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_12_1/Chassis_V1_12_1_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_12_1/Chassis_V1_12_1_Dxe.c new file mode 100644 index 00000000000..2c57b02a00a --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_12_1/Chassis_V1_12_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_12_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_12_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "12", + "1" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_12_1 *ChassisV1_12_1; + EFI_REDFISH_CHASSIS_V1_12_1_CS *ChassisV1_12_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "12") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_12_1_To_CS (ResoruceRaw, &ChassisV1_12_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_12_1 = (EFI_REDFISH_CHASSIS_V1_12_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_12_1)); + if (ChassisV1_12_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_12_1; + ChassisV1_12_1->Chassis = ChassisV1_12_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "12"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_12_1_JSON (*((EFI_REDFISH_CHASSIS_V1_12_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_12_1 *ChassisV1_12_1; + + ChassisV1_12_1 = (EFI_REDFISH_CHASSIS_V1_12_1 *)InterpProp; + DestroyChassis_V1_12_1_CS (ChassisV1_12_1->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_12_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_12_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_12_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_12_1/RedfishChassis_V1_12_1_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_12_1/RedfishChassis_V1_12_1_Dxe.inf new file mode 100644 index 00000000000..72a8215ac35 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_12_1/RedfishChassis_V1_12_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_12_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_12_1_Dxe + FILE_GUID = 3c29c2b1-b6e8-497b-98be-b7f42e4ea49e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_12_1EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_12_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_12_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_12_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_12_2/Chassis_V1_12_2_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_12_2/Chassis_V1_12_2_Dxe.c new file mode 100644 index 00000000000..c15dab64886 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_12_2/Chassis_V1_12_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_12_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_12_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "12", + "2" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_12_2 *ChassisV1_12_2; + EFI_REDFISH_CHASSIS_V1_12_2_CS *ChassisV1_12_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "12") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_12_2_To_CS (ResoruceRaw, &ChassisV1_12_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_12_2 = (EFI_REDFISH_CHASSIS_V1_12_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_12_2)); + if (ChassisV1_12_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_12_2; + ChassisV1_12_2->Chassis = ChassisV1_12_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "12"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_12_2_JSON (*((EFI_REDFISH_CHASSIS_V1_12_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_12_2 *ChassisV1_12_2; + + ChassisV1_12_2 = (EFI_REDFISH_CHASSIS_V1_12_2 *)InterpProp; + DestroyChassis_V1_12_2_CS (ChassisV1_12_2->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_12_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_12_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_12_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_12_2/RedfishChassis_V1_12_2_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_12_2/RedfishChassis_V1_12_2_Dxe.inf new file mode 100644 index 00000000000..75bf59ee053 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_12_2/RedfishChassis_V1_12_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_12_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_12_2_Dxe + FILE_GUID = 79a43b86-0afd-4fa5-beef-60bb67d65b1e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_12_2EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_12_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_12_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_12_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_13_0/Chassis_V1_13_0_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_13_0/Chassis_V1_13_0_Dxe.c new file mode 100644 index 00000000000..79eea99ee62 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_13_0/Chassis_V1_13_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_13_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_13_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "13", + "0" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_13_0 *ChassisV1_13_0; + EFI_REDFISH_CHASSIS_V1_13_0_CS *ChassisV1_13_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "13") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_13_0_To_CS (ResoruceRaw, &ChassisV1_13_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_13_0 = (EFI_REDFISH_CHASSIS_V1_13_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_13_0)); + if (ChassisV1_13_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_13_0; + ChassisV1_13_0->Chassis = ChassisV1_13_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "13"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_13_0_JSON (*((EFI_REDFISH_CHASSIS_V1_13_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_13_0 *ChassisV1_13_0; + + ChassisV1_13_0 = (EFI_REDFISH_CHASSIS_V1_13_0 *)InterpProp; + DestroyChassis_V1_13_0_CS (ChassisV1_13_0->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_13_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_13_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_13_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_13_0/RedfishChassis_V1_13_0_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_13_0/RedfishChassis_V1_13_0_Dxe.inf new file mode 100644 index 00000000000..c1df6404943 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_13_0/RedfishChassis_V1_13_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_13_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_13_0_Dxe + FILE_GUID = d9781e76-0e12-4d17-892a-778422c5449b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_13_0EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_13_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_13_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_13_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_13_1/Chassis_V1_13_1_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_13_1/Chassis_V1_13_1_Dxe.c new file mode 100644 index 00000000000..6ad57093a69 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_13_1/Chassis_V1_13_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_13_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_13_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "13", + "1" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_13_1 *ChassisV1_13_1; + EFI_REDFISH_CHASSIS_V1_13_1_CS *ChassisV1_13_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "13") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_13_1_To_CS (ResoruceRaw, &ChassisV1_13_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_13_1 = (EFI_REDFISH_CHASSIS_V1_13_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_13_1)); + if (ChassisV1_13_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_13_1; + ChassisV1_13_1->Chassis = ChassisV1_13_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "13"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_13_1_JSON (*((EFI_REDFISH_CHASSIS_V1_13_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_13_1 *ChassisV1_13_1; + + ChassisV1_13_1 = (EFI_REDFISH_CHASSIS_V1_13_1 *)InterpProp; + DestroyChassis_V1_13_1_CS (ChassisV1_13_1->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_13_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_13_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_13_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_13_1/RedfishChassis_V1_13_1_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_13_1/RedfishChassis_V1_13_1_Dxe.inf new file mode 100644 index 00000000000..f3b267ecd40 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_13_1/RedfishChassis_V1_13_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_13_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_13_1_Dxe + FILE_GUID = 670c79a4-9b79-4245-98ed-af9abbbb0a65 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_13_1EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_13_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_13_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_13_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_14_0/Chassis_V1_14_0_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_14_0/Chassis_V1_14_0_Dxe.c new file mode 100644 index 00000000000..72f3d1f3929 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_14_0/Chassis_V1_14_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_14_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_14_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "14", + "0" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_14_0 *ChassisV1_14_0; + EFI_REDFISH_CHASSIS_V1_14_0_CS *ChassisV1_14_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "14") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_14_0_To_CS (ResoruceRaw, &ChassisV1_14_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_14_0 = (EFI_REDFISH_CHASSIS_V1_14_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_14_0)); + if (ChassisV1_14_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_14_0; + ChassisV1_14_0->Chassis = ChassisV1_14_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "14"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_14_0_JSON (*((EFI_REDFISH_CHASSIS_V1_14_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_14_0 *ChassisV1_14_0; + + ChassisV1_14_0 = (EFI_REDFISH_CHASSIS_V1_14_0 *)InterpProp; + DestroyChassis_V1_14_0_CS (ChassisV1_14_0->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_14_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_14_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_14_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_14_0/RedfishChassis_V1_14_0_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_14_0/RedfishChassis_V1_14_0_Dxe.inf new file mode 100644 index 00000000000..978138f07e1 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_14_0/RedfishChassis_V1_14_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_14_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_14_0_Dxe + FILE_GUID = 3d0a6fd4-d935-4d91-80e8-3b25b7a26d81 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_14_0EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_14_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_14_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_14_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_15_0/Chassis_V1_15_0_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_15_0/Chassis_V1_15_0_Dxe.c new file mode 100644 index 00000000000..4e59c5bee3d --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_15_0/Chassis_V1_15_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_15_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_15_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "15", + "0" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_15_0 *ChassisV1_15_0; + EFI_REDFISH_CHASSIS_V1_15_0_CS *ChassisV1_15_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "15") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_15_0_To_CS (ResoruceRaw, &ChassisV1_15_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_15_0 = (EFI_REDFISH_CHASSIS_V1_15_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_15_0)); + if (ChassisV1_15_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_15_0; + ChassisV1_15_0->Chassis = ChassisV1_15_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "15"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_15_0_JSON (*((EFI_REDFISH_CHASSIS_V1_15_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_15_0 *ChassisV1_15_0; + + ChassisV1_15_0 = (EFI_REDFISH_CHASSIS_V1_15_0 *)InterpProp; + DestroyChassis_V1_15_0_CS (ChassisV1_15_0->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_15_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_15_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_15_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_15_0/RedfishChassis_V1_15_0_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_15_0/RedfishChassis_V1_15_0_Dxe.inf new file mode 100644 index 00000000000..4218246ad1b --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_15_0/RedfishChassis_V1_15_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_15_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_15_0_Dxe + FILE_GUID = b35c83f9-baf8-4b25-a6dd-e06f3e47ac82 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_15_0EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_15_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_15_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_15_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_0/Chassis_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_1_0/Chassis_V1_1_0_Dxe.c new file mode 100644 index 00000000000..3dd6f0509aa --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_0/Chassis_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "1", + "0" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_0 *ChassisV1_1_0; + EFI_REDFISH_CHASSIS_V1_1_0_CS *ChassisV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_1_0_To_CS (ResoruceRaw, &ChassisV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_1_0 = (EFI_REDFISH_CHASSIS_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_1_0)); + if (ChassisV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_1_0; + ChassisV1_1_0->Chassis = ChassisV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_1_0_JSON (*((EFI_REDFISH_CHASSIS_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_0 *ChassisV1_1_0; + + ChassisV1_1_0 = (EFI_REDFISH_CHASSIS_V1_1_0 *)InterpProp; + DestroyChassis_V1_1_0_CS (ChassisV1_1_0->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_0/RedfishChassis_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_1_0/RedfishChassis_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..958007afed7 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_0/RedfishChassis_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_1_0_Dxe + FILE_GUID = 520c6013-d1c9-4120-baeb-bdc384802fb8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_10/Chassis_V1_1_10_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_1_10/Chassis_V1_1_10_Dxe.c new file mode 100644 index 00000000000..b4105046952 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_10/Chassis_V1_1_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_1_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_1_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "1", + "10" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_10 *ChassisV1_1_10; + EFI_REDFISH_CHASSIS_V1_1_10_CS *ChassisV1_1_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_1_10_To_CS (ResoruceRaw, &ChassisV1_1_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_1_10 = (EFI_REDFISH_CHASSIS_V1_1_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_1_10)); + if (ChassisV1_1_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_1_10; + ChassisV1_1_10->Chassis = ChassisV1_1_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_1_10_JSON (*((EFI_REDFISH_CHASSIS_V1_1_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_10 *ChassisV1_1_10; + + ChassisV1_1_10 = (EFI_REDFISH_CHASSIS_V1_1_10 *)InterpProp; + DestroyChassis_V1_1_10_CS (ChassisV1_1_10->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_1_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_10/RedfishChassis_V1_1_10_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_1_10/RedfishChassis_V1_1_10_Dxe.inf new file mode 100644 index 00000000000..00e3e3259a6 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_10/RedfishChassis_V1_1_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_1_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_1_10_Dxe + FILE_GUID = b27d0a41-e243-45fd-82d0-afc8e9b66e50 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_1_10EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_1_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_1_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_1_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_11/Chassis_V1_1_11_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_1_11/Chassis_V1_1_11_Dxe.c new file mode 100644 index 00000000000..0cf18698518 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_11/Chassis_V1_1_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_1_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_1_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "1", + "11" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_11 *ChassisV1_1_11; + EFI_REDFISH_CHASSIS_V1_1_11_CS *ChassisV1_1_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_1_11_To_CS (ResoruceRaw, &ChassisV1_1_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_1_11 = (EFI_REDFISH_CHASSIS_V1_1_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_1_11)); + if (ChassisV1_1_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_1_11; + ChassisV1_1_11->Chassis = ChassisV1_1_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_1_11_JSON (*((EFI_REDFISH_CHASSIS_V1_1_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_11 *ChassisV1_1_11; + + ChassisV1_1_11 = (EFI_REDFISH_CHASSIS_V1_1_11 *)InterpProp; + DestroyChassis_V1_1_11_CS (ChassisV1_1_11->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_1_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_11/RedfishChassis_V1_1_11_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_1_11/RedfishChassis_V1_1_11_Dxe.inf new file mode 100644 index 00000000000..9c20a851da6 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_11/RedfishChassis_V1_1_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_1_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_1_11_Dxe + FILE_GUID = 9c186899-4a03-4010-84cd-26601aa9e6ab + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_1_11EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_1_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_1_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_1_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_12/Chassis_V1_1_12_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_1_12/Chassis_V1_1_12_Dxe.c new file mode 100644 index 00000000000..b457dbee88c --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_12/Chassis_V1_1_12_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_1_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_1_12 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "1", + "12" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_12 *ChassisV1_1_12; + EFI_REDFISH_CHASSIS_V1_1_12_CS *ChassisV1_1_12Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "12") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_1_12_To_CS (ResoruceRaw, &ChassisV1_1_12Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_1_12 = (EFI_REDFISH_CHASSIS_V1_1_12 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_1_12)); + if (ChassisV1_1_12 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_1_12; + ChassisV1_1_12->Chassis = ChassisV1_1_12Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "12"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_1_12_JSON (*((EFI_REDFISH_CHASSIS_V1_1_12_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_12 *ChassisV1_1_12; + + ChassisV1_1_12 = (EFI_REDFISH_CHASSIS_V1_1_12 *)InterpProp; + DestroyChassis_V1_1_12_CS (ChassisV1_1_12->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_1_12_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_12EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_12Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_12/RedfishChassis_V1_1_12_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_1_12/RedfishChassis_V1_1_12_Dxe.inf new file mode 100644 index 00000000000..98e26b4afb7 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_12/RedfishChassis_V1_1_12_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_1_12 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_1_12_Dxe + FILE_GUID = 58bbc3ec-7644-4504-a8d2-8bf787698422 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_1_12EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_1_12Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_1_12_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_1_12Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_13/Chassis_V1_1_13_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_1_13/Chassis_V1_1_13_Dxe.c new file mode 100644 index 00000000000..7a45643deac --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_13/Chassis_V1_1_13_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_1_13 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_1_13 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "1", + "13" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_13 *ChassisV1_1_13; + EFI_REDFISH_CHASSIS_V1_1_13_CS *ChassisV1_1_13Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "13") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_1_13_To_CS (ResoruceRaw, &ChassisV1_1_13Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_1_13 = (EFI_REDFISH_CHASSIS_V1_1_13 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_1_13)); + if (ChassisV1_1_13 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_1_13; + ChassisV1_1_13->Chassis = ChassisV1_1_13Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "13"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_1_13_JSON (*((EFI_REDFISH_CHASSIS_V1_1_13_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_13 *ChassisV1_1_13; + + ChassisV1_1_13 = (EFI_REDFISH_CHASSIS_V1_1_13 *)InterpProp; + DestroyChassis_V1_1_13_CS (ChassisV1_1_13->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_1_13_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_13EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_13Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_13/RedfishChassis_V1_1_13_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_1_13/RedfishChassis_V1_1_13_Dxe.inf new file mode 100644 index 00000000000..cece67b74eb --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_13/RedfishChassis_V1_1_13_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_1_13 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_1_13_Dxe + FILE_GUID = 3ae421c5-121e-4e93-9541-887eff1d3c25 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_1_13EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_1_13Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_1_13_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_1_13Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_2/Chassis_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_1_2/Chassis_V1_1_2_Dxe.c new file mode 100644 index 00000000000..79e33b3a928 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_2/Chassis_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "1", + "2" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_2 *ChassisV1_1_2; + EFI_REDFISH_CHASSIS_V1_1_2_CS *ChassisV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_1_2_To_CS (ResoruceRaw, &ChassisV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_1_2 = (EFI_REDFISH_CHASSIS_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_1_2)); + if (ChassisV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_1_2; + ChassisV1_1_2->Chassis = ChassisV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_1_2_JSON (*((EFI_REDFISH_CHASSIS_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_2 *ChassisV1_1_2; + + ChassisV1_1_2 = (EFI_REDFISH_CHASSIS_V1_1_2 *)InterpProp; + DestroyChassis_V1_1_2_CS (ChassisV1_1_2->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_2/RedfishChassis_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_1_2/RedfishChassis_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..831ce053a48 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_2/RedfishChassis_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_1_2_Dxe + FILE_GUID = 3d7d4f9a-97d4-4df5-b81b-fdf88e9c40b9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_3/Chassis_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_1_3/Chassis_V1_1_3_Dxe.c new file mode 100644 index 00000000000..a7e2fbdd142 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_3/Chassis_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "1", + "3" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_3 *ChassisV1_1_3; + EFI_REDFISH_CHASSIS_V1_1_3_CS *ChassisV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_1_3_To_CS (ResoruceRaw, &ChassisV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_1_3 = (EFI_REDFISH_CHASSIS_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_1_3)); + if (ChassisV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_1_3; + ChassisV1_1_3->Chassis = ChassisV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_1_3_JSON (*((EFI_REDFISH_CHASSIS_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_3 *ChassisV1_1_3; + + ChassisV1_1_3 = (EFI_REDFISH_CHASSIS_V1_1_3 *)InterpProp; + DestroyChassis_V1_1_3_CS (ChassisV1_1_3->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_3/RedfishChassis_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_1_3/RedfishChassis_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..fc56881679c --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_3/RedfishChassis_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_1_3_Dxe + FILE_GUID = 4d11b03c-dd0c-4a1e-b2fa-e2b4812687ad + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_4/Chassis_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_1_4/Chassis_V1_1_4_Dxe.c new file mode 100644 index 00000000000..9b00d8ce2a1 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_4/Chassis_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "1", + "4" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_4 *ChassisV1_1_4; + EFI_REDFISH_CHASSIS_V1_1_4_CS *ChassisV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_1_4_To_CS (ResoruceRaw, &ChassisV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_1_4 = (EFI_REDFISH_CHASSIS_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_1_4)); + if (ChassisV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_1_4; + ChassisV1_1_4->Chassis = ChassisV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_1_4_JSON (*((EFI_REDFISH_CHASSIS_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_4 *ChassisV1_1_4; + + ChassisV1_1_4 = (EFI_REDFISH_CHASSIS_V1_1_4 *)InterpProp; + DestroyChassis_V1_1_4_CS (ChassisV1_1_4->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_4/RedfishChassis_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_1_4/RedfishChassis_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..b719a0dd894 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_4/RedfishChassis_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_1_4_Dxe + FILE_GUID = e6590fae-e87a-4781-ae92-e1e9e5963cb7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_5/Chassis_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_1_5/Chassis_V1_1_5_Dxe.c new file mode 100644 index 00000000000..48c2f1e9243 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_5/Chassis_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "1", + "5" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_5 *ChassisV1_1_5; + EFI_REDFISH_CHASSIS_V1_1_5_CS *ChassisV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_1_5_To_CS (ResoruceRaw, &ChassisV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_1_5 = (EFI_REDFISH_CHASSIS_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_1_5)); + if (ChassisV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_1_5; + ChassisV1_1_5->Chassis = ChassisV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_1_5_JSON (*((EFI_REDFISH_CHASSIS_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_5 *ChassisV1_1_5; + + ChassisV1_1_5 = (EFI_REDFISH_CHASSIS_V1_1_5 *)InterpProp; + DestroyChassis_V1_1_5_CS (ChassisV1_1_5->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_5/RedfishChassis_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_1_5/RedfishChassis_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..c2b899629d8 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_5/RedfishChassis_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_1_5_Dxe + FILE_GUID = 23b586b2-dfd5-4624-99d5-a8407922676e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_6/Chassis_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_1_6/Chassis_V1_1_6_Dxe.c new file mode 100644 index 00000000000..c102dafa2e6 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_6/Chassis_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "1", + "6" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_6 *ChassisV1_1_6; + EFI_REDFISH_CHASSIS_V1_1_6_CS *ChassisV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_1_6_To_CS (ResoruceRaw, &ChassisV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_1_6 = (EFI_REDFISH_CHASSIS_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_1_6)); + if (ChassisV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_1_6; + ChassisV1_1_6->Chassis = ChassisV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_1_6_JSON (*((EFI_REDFISH_CHASSIS_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_6 *ChassisV1_1_6; + + ChassisV1_1_6 = (EFI_REDFISH_CHASSIS_V1_1_6 *)InterpProp; + DestroyChassis_V1_1_6_CS (ChassisV1_1_6->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_6/RedfishChassis_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_1_6/RedfishChassis_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..128176bbfec --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_6/RedfishChassis_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_1_6_Dxe + FILE_GUID = 2ace70cb-1d71-4f89-bb6c-a56c90123029 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_7/Chassis_V1_1_7_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_1_7/Chassis_V1_1_7_Dxe.c new file mode 100644 index 00000000000..c771a36975a --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_7/Chassis_V1_1_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_1_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "1", + "7" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_7 *ChassisV1_1_7; + EFI_REDFISH_CHASSIS_V1_1_7_CS *ChassisV1_1_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_1_7_To_CS (ResoruceRaw, &ChassisV1_1_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_1_7 = (EFI_REDFISH_CHASSIS_V1_1_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_1_7)); + if (ChassisV1_1_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_1_7; + ChassisV1_1_7->Chassis = ChassisV1_1_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_1_7_JSON (*((EFI_REDFISH_CHASSIS_V1_1_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_7 *ChassisV1_1_7; + + ChassisV1_1_7 = (EFI_REDFISH_CHASSIS_V1_1_7 *)InterpProp; + DestroyChassis_V1_1_7_CS (ChassisV1_1_7->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_1_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_7/RedfishChassis_V1_1_7_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_1_7/RedfishChassis_V1_1_7_Dxe.inf new file mode 100644 index 00000000000..93a92b5a199 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_7/RedfishChassis_V1_1_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_1_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_1_7_Dxe + FILE_GUID = 7d728e20-2c8f-49e1-8787-55b02d6b3f09 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_1_7EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_1_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_1_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_1_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_8/Chassis_V1_1_8_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_1_8/Chassis_V1_1_8_Dxe.c new file mode 100644 index 00000000000..03c67ddd67e --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_8/Chassis_V1_1_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_1_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "1", + "8" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_8 *ChassisV1_1_8; + EFI_REDFISH_CHASSIS_V1_1_8_CS *ChassisV1_1_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_1_8_To_CS (ResoruceRaw, &ChassisV1_1_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_1_8 = (EFI_REDFISH_CHASSIS_V1_1_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_1_8)); + if (ChassisV1_1_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_1_8; + ChassisV1_1_8->Chassis = ChassisV1_1_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_1_8_JSON (*((EFI_REDFISH_CHASSIS_V1_1_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_8 *ChassisV1_1_8; + + ChassisV1_1_8 = (EFI_REDFISH_CHASSIS_V1_1_8 *)InterpProp; + DestroyChassis_V1_1_8_CS (ChassisV1_1_8->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_1_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_8/RedfishChassis_V1_1_8_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_1_8/RedfishChassis_V1_1_8_Dxe.inf new file mode 100644 index 00000000000..00ee7b1ac41 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_8/RedfishChassis_V1_1_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_1_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_1_8_Dxe + FILE_GUID = 32e48456-f6a6-4518-9505-322909ed4ac2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_1_8EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_1_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_1_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_1_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_9/Chassis_V1_1_9_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_1_9/Chassis_V1_1_9_Dxe.c new file mode 100644 index 00000000000..9f620183c3f --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_9/Chassis_V1_1_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_1_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "1", + "9" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_9 *ChassisV1_1_9; + EFI_REDFISH_CHASSIS_V1_1_9_CS *ChassisV1_1_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_1_9_To_CS (ResoruceRaw, &ChassisV1_1_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_1_9 = (EFI_REDFISH_CHASSIS_V1_1_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_1_9)); + if (ChassisV1_1_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_1_9; + ChassisV1_1_9->Chassis = ChassisV1_1_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_1_9_JSON (*((EFI_REDFISH_CHASSIS_V1_1_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_1_9 *ChassisV1_1_9; + + ChassisV1_1_9 = (EFI_REDFISH_CHASSIS_V1_1_9 *)InterpProp; + DestroyChassis_V1_1_9_CS (ChassisV1_1_9->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_1_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_1_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_1_9/RedfishChassis_V1_1_9_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_1_9/RedfishChassis_V1_1_9_Dxe.inf new file mode 100644 index 00000000000..dd536924e91 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_1_9/RedfishChassis_V1_1_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_1_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_1_9_Dxe + FILE_GUID = ec97ed76-a97a-4b51-9d93-5b59f21f1a9f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_1_9EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_1_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_1_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_1_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_2_0/Chassis_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_2_0/Chassis_V1_2_0_Dxe.c new file mode 100644 index 00000000000..23062ab204e --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_2_0/Chassis_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "2", + "0" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_2_0 *ChassisV1_2_0; + EFI_REDFISH_CHASSIS_V1_2_0_CS *ChassisV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_2_0_To_CS (ResoruceRaw, &ChassisV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_2_0 = (EFI_REDFISH_CHASSIS_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_2_0)); + if (ChassisV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_2_0; + ChassisV1_2_0->Chassis = ChassisV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_2_0_JSON (*((EFI_REDFISH_CHASSIS_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_2_0 *ChassisV1_2_0; + + ChassisV1_2_0 = (EFI_REDFISH_CHASSIS_V1_2_0 *)InterpProp; + DestroyChassis_V1_2_0_CS (ChassisV1_2_0->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_2_0/RedfishChassis_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_2_0/RedfishChassis_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..ea38b22fcd4 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_2_0/RedfishChassis_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_2_0_Dxe + FILE_GUID = 1d8c25d6-bc56-48e0-91bc-23fdb9831ae3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_2_1/Chassis_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_2_1/Chassis_V1_2_1_Dxe.c new file mode 100644 index 00000000000..b6d71e33fe3 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_2_1/Chassis_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "2", + "1" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_2_1 *ChassisV1_2_1; + EFI_REDFISH_CHASSIS_V1_2_1_CS *ChassisV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_2_1_To_CS (ResoruceRaw, &ChassisV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_2_1 = (EFI_REDFISH_CHASSIS_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_2_1)); + if (ChassisV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_2_1; + ChassisV1_2_1->Chassis = ChassisV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_2_1_JSON (*((EFI_REDFISH_CHASSIS_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_2_1 *ChassisV1_2_1; + + ChassisV1_2_1 = (EFI_REDFISH_CHASSIS_V1_2_1 *)InterpProp; + DestroyChassis_V1_2_1_CS (ChassisV1_2_1->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_2_1/RedfishChassis_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_2_1/RedfishChassis_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..29fb459f908 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_2_1/RedfishChassis_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_2_1_Dxe + FILE_GUID = b38e3237-ba3f-4696-a57b-7fe0c2159410 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_2_10/Chassis_V1_2_10_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_2_10/Chassis_V1_2_10_Dxe.c new file mode 100644 index 00000000000..feead7e6b52 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_2_10/Chassis_V1_2_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_2_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_2_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "2", + "10" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_2_10 *ChassisV1_2_10; + EFI_REDFISH_CHASSIS_V1_2_10_CS *ChassisV1_2_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_2_10_To_CS (ResoruceRaw, &ChassisV1_2_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_2_10 = (EFI_REDFISH_CHASSIS_V1_2_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_2_10)); + if (ChassisV1_2_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_2_10; + ChassisV1_2_10->Chassis = ChassisV1_2_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_2_10_JSON (*((EFI_REDFISH_CHASSIS_V1_2_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_2_10 *ChassisV1_2_10; + + ChassisV1_2_10 = (EFI_REDFISH_CHASSIS_V1_2_10 *)InterpProp; + DestroyChassis_V1_2_10_CS (ChassisV1_2_10->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_2_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_2_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_2_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_2_10/RedfishChassis_V1_2_10_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_2_10/RedfishChassis_V1_2_10_Dxe.inf new file mode 100644 index 00000000000..8e1ca47bb15 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_2_10/RedfishChassis_V1_2_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_2_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_2_10_Dxe + FILE_GUID = 3f3e4632-fd20-418d-9c16-23238ec5f877 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_2_10EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_2_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_2_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_2_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_2_11/Chassis_V1_2_11_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_2_11/Chassis_V1_2_11_Dxe.c new file mode 100644 index 00000000000..32ac55b6c0d --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_2_11/Chassis_V1_2_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_2_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_2_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "2", + "11" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_2_11 *ChassisV1_2_11; + EFI_REDFISH_CHASSIS_V1_2_11_CS *ChassisV1_2_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_2_11_To_CS (ResoruceRaw, &ChassisV1_2_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_2_11 = (EFI_REDFISH_CHASSIS_V1_2_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_2_11)); + if (ChassisV1_2_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_2_11; + ChassisV1_2_11->Chassis = ChassisV1_2_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_2_11_JSON (*((EFI_REDFISH_CHASSIS_V1_2_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_2_11 *ChassisV1_2_11; + + ChassisV1_2_11 = (EFI_REDFISH_CHASSIS_V1_2_11 *)InterpProp; + DestroyChassis_V1_2_11_CS (ChassisV1_2_11->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_2_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_2_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_2_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_2_11/RedfishChassis_V1_2_11_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_2_11/RedfishChassis_V1_2_11_Dxe.inf new file mode 100644 index 00000000000..ae162c2cd52 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_2_11/RedfishChassis_V1_2_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_2_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_2_11_Dxe + FILE_GUID = 4386093c-2577-46c1-a3d7-1b069437dbb8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_2_11EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_2_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_2_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_2_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_2_2/Chassis_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_2_2/Chassis_V1_2_2_Dxe.c new file mode 100644 index 00000000000..f3ed87443e7 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_2_2/Chassis_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "2", + "2" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_2_2 *ChassisV1_2_2; + EFI_REDFISH_CHASSIS_V1_2_2_CS *ChassisV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_2_2_To_CS (ResoruceRaw, &ChassisV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_2_2 = (EFI_REDFISH_CHASSIS_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_2_2)); + if (ChassisV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_2_2; + ChassisV1_2_2->Chassis = ChassisV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_2_2_JSON (*((EFI_REDFISH_CHASSIS_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_2_2 *ChassisV1_2_2; + + ChassisV1_2_2 = (EFI_REDFISH_CHASSIS_V1_2_2 *)InterpProp; + DestroyChassis_V1_2_2_CS (ChassisV1_2_2->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_2_2/RedfishChassis_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_2_2/RedfishChassis_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..edf46414501 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_2_2/RedfishChassis_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_2_2_Dxe + FILE_GUID = 4879713d-d973-4127-836a-a7185b10a858 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_2_3/Chassis_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_2_3/Chassis_V1_2_3_Dxe.c new file mode 100644 index 00000000000..63ab0b61490 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_2_3/Chassis_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "2", + "3" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_2_3 *ChassisV1_2_3; + EFI_REDFISH_CHASSIS_V1_2_3_CS *ChassisV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_2_3_To_CS (ResoruceRaw, &ChassisV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_2_3 = (EFI_REDFISH_CHASSIS_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_2_3)); + if (ChassisV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_2_3; + ChassisV1_2_3->Chassis = ChassisV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_2_3_JSON (*((EFI_REDFISH_CHASSIS_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_2_3 *ChassisV1_2_3; + + ChassisV1_2_3 = (EFI_REDFISH_CHASSIS_V1_2_3 *)InterpProp; + DestroyChassis_V1_2_3_CS (ChassisV1_2_3->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_2_3/RedfishChassis_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_2_3/RedfishChassis_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..6968938b0b6 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_2_3/RedfishChassis_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_2_3_Dxe + FILE_GUID = 86b5398d-3e3a-4380-bf7b-bb1983e9a820 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_2_4/Chassis_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_2_4/Chassis_V1_2_4_Dxe.c new file mode 100644 index 00000000000..ae92d2c35b4 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_2_4/Chassis_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "2", + "4" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_2_4 *ChassisV1_2_4; + EFI_REDFISH_CHASSIS_V1_2_4_CS *ChassisV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_2_4_To_CS (ResoruceRaw, &ChassisV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_2_4 = (EFI_REDFISH_CHASSIS_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_2_4)); + if (ChassisV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_2_4; + ChassisV1_2_4->Chassis = ChassisV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_2_4_JSON (*((EFI_REDFISH_CHASSIS_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_2_4 *ChassisV1_2_4; + + ChassisV1_2_4 = (EFI_REDFISH_CHASSIS_V1_2_4 *)InterpProp; + DestroyChassis_V1_2_4_CS (ChassisV1_2_4->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_2_4/RedfishChassis_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_2_4/RedfishChassis_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..33ae42ac421 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_2_4/RedfishChassis_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_2_4_Dxe + FILE_GUID = 9c39039a-8b22-410f-891d-c74eea86a0a1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_2_5/Chassis_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_2_5/Chassis_V1_2_5_Dxe.c new file mode 100644 index 00000000000..cded1139d27 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_2_5/Chassis_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "2", + "5" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_2_5 *ChassisV1_2_5; + EFI_REDFISH_CHASSIS_V1_2_5_CS *ChassisV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_2_5_To_CS (ResoruceRaw, &ChassisV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_2_5 = (EFI_REDFISH_CHASSIS_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_2_5)); + if (ChassisV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_2_5; + ChassisV1_2_5->Chassis = ChassisV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_2_5_JSON (*((EFI_REDFISH_CHASSIS_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_2_5 *ChassisV1_2_5; + + ChassisV1_2_5 = (EFI_REDFISH_CHASSIS_V1_2_5 *)InterpProp; + DestroyChassis_V1_2_5_CS (ChassisV1_2_5->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_2_5/RedfishChassis_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_2_5/RedfishChassis_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..cbf726beb07 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_2_5/RedfishChassis_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_2_5_Dxe + FILE_GUID = 849208a0-ba03-49f4-a7cf-d03e169d0149 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_2_6/Chassis_V1_2_6_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_2_6/Chassis_V1_2_6_Dxe.c new file mode 100644 index 00000000000..f4aabe872e8 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_2_6/Chassis_V1_2_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_2_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "2", + "6" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_2_6 *ChassisV1_2_6; + EFI_REDFISH_CHASSIS_V1_2_6_CS *ChassisV1_2_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_2_6_To_CS (ResoruceRaw, &ChassisV1_2_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_2_6 = (EFI_REDFISH_CHASSIS_V1_2_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_2_6)); + if (ChassisV1_2_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_2_6; + ChassisV1_2_6->Chassis = ChassisV1_2_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_2_6_JSON (*((EFI_REDFISH_CHASSIS_V1_2_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_2_6 *ChassisV1_2_6; + + ChassisV1_2_6 = (EFI_REDFISH_CHASSIS_V1_2_6 *)InterpProp; + DestroyChassis_V1_2_6_CS (ChassisV1_2_6->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_2_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_2_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_2_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_2_6/RedfishChassis_V1_2_6_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_2_6/RedfishChassis_V1_2_6_Dxe.inf new file mode 100644 index 00000000000..970ae9e2436 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_2_6/RedfishChassis_V1_2_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_2_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_2_6_Dxe + FILE_GUID = e47d0ab5-ec42-4247-b084-d0a566b98b80 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_2_6EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_2_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_2_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_2_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_2_7/Chassis_V1_2_7_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_2_7/Chassis_V1_2_7_Dxe.c new file mode 100644 index 00000000000..d8f15948487 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_2_7/Chassis_V1_2_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_2_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "2", + "7" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_2_7 *ChassisV1_2_7; + EFI_REDFISH_CHASSIS_V1_2_7_CS *ChassisV1_2_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_2_7_To_CS (ResoruceRaw, &ChassisV1_2_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_2_7 = (EFI_REDFISH_CHASSIS_V1_2_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_2_7)); + if (ChassisV1_2_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_2_7; + ChassisV1_2_7->Chassis = ChassisV1_2_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_2_7_JSON (*((EFI_REDFISH_CHASSIS_V1_2_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_2_7 *ChassisV1_2_7; + + ChassisV1_2_7 = (EFI_REDFISH_CHASSIS_V1_2_7 *)InterpProp; + DestroyChassis_V1_2_7_CS (ChassisV1_2_7->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_2_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_2_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_2_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_2_7/RedfishChassis_V1_2_7_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_2_7/RedfishChassis_V1_2_7_Dxe.inf new file mode 100644 index 00000000000..d089aeea902 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_2_7/RedfishChassis_V1_2_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_2_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_2_7_Dxe + FILE_GUID = 868466ea-f00e-4ea4-8c6b-873e114bdb40 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_2_7EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_2_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_2_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_2_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_2_8/Chassis_V1_2_8_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_2_8/Chassis_V1_2_8_Dxe.c new file mode 100644 index 00000000000..b0adf65362d --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_2_8/Chassis_V1_2_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_2_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "2", + "8" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_2_8 *ChassisV1_2_8; + EFI_REDFISH_CHASSIS_V1_2_8_CS *ChassisV1_2_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_2_8_To_CS (ResoruceRaw, &ChassisV1_2_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_2_8 = (EFI_REDFISH_CHASSIS_V1_2_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_2_8)); + if (ChassisV1_2_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_2_8; + ChassisV1_2_8->Chassis = ChassisV1_2_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_2_8_JSON (*((EFI_REDFISH_CHASSIS_V1_2_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_2_8 *ChassisV1_2_8; + + ChassisV1_2_8 = (EFI_REDFISH_CHASSIS_V1_2_8 *)InterpProp; + DestroyChassis_V1_2_8_CS (ChassisV1_2_8->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_2_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_2_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_2_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_2_8/RedfishChassis_V1_2_8_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_2_8/RedfishChassis_V1_2_8_Dxe.inf new file mode 100644 index 00000000000..fbd90e8b3f3 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_2_8/RedfishChassis_V1_2_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_2_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_2_8_Dxe + FILE_GUID = bdb98ca3-f709-4e61-a549-681083d2268c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_2_8EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_2_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_2_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_2_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_2_9/Chassis_V1_2_9_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_2_9/Chassis_V1_2_9_Dxe.c new file mode 100644 index 00000000000..e7a63aacf19 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_2_9/Chassis_V1_2_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_2_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_2_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "2", + "9" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_2_9 *ChassisV1_2_9; + EFI_REDFISH_CHASSIS_V1_2_9_CS *ChassisV1_2_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_2_9_To_CS (ResoruceRaw, &ChassisV1_2_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_2_9 = (EFI_REDFISH_CHASSIS_V1_2_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_2_9)); + if (ChassisV1_2_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_2_9; + ChassisV1_2_9->Chassis = ChassisV1_2_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_2_9_JSON (*((EFI_REDFISH_CHASSIS_V1_2_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_2_9 *ChassisV1_2_9; + + ChassisV1_2_9 = (EFI_REDFISH_CHASSIS_V1_2_9 *)InterpProp; + DestroyChassis_V1_2_9_CS (ChassisV1_2_9->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_2_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_2_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_2_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_2_9/RedfishChassis_V1_2_9_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_2_9/RedfishChassis_V1_2_9_Dxe.inf new file mode 100644 index 00000000000..a9c16bd2b23 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_2_9/RedfishChassis_V1_2_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_2_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_2_9_Dxe + FILE_GUID = 5338c944-a3b7-48c1-bcac-2f0cae5780ac + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_2_9EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_2_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_2_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_2_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_3_0/Chassis_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_3_0/Chassis_V1_3_0_Dxe.c new file mode 100644 index 00000000000..5ec339525bb --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_3_0/Chassis_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "3", + "0" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_3_0 *ChassisV1_3_0; + EFI_REDFISH_CHASSIS_V1_3_0_CS *ChassisV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_3_0_To_CS (ResoruceRaw, &ChassisV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_3_0 = (EFI_REDFISH_CHASSIS_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_3_0)); + if (ChassisV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_3_0; + ChassisV1_3_0->Chassis = ChassisV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_3_0_JSON (*((EFI_REDFISH_CHASSIS_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_3_0 *ChassisV1_3_0; + + ChassisV1_3_0 = (EFI_REDFISH_CHASSIS_V1_3_0 *)InterpProp; + DestroyChassis_V1_3_0_CS (ChassisV1_3_0->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_3_0/RedfishChassis_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_3_0/RedfishChassis_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..31e4101776b --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_3_0/RedfishChassis_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_3_0_Dxe + FILE_GUID = 85612bce-531a-4c51-8c09-7eb40ee5fe46 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_3_1/Chassis_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_3_1/Chassis_V1_3_1_Dxe.c new file mode 100644 index 00000000000..9fce75018f2 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_3_1/Chassis_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "3", + "1" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_3_1 *ChassisV1_3_1; + EFI_REDFISH_CHASSIS_V1_3_1_CS *ChassisV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_3_1_To_CS (ResoruceRaw, &ChassisV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_3_1 = (EFI_REDFISH_CHASSIS_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_3_1)); + if (ChassisV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_3_1; + ChassisV1_3_1->Chassis = ChassisV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_3_1_JSON (*((EFI_REDFISH_CHASSIS_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_3_1 *ChassisV1_3_1; + + ChassisV1_3_1 = (EFI_REDFISH_CHASSIS_V1_3_1 *)InterpProp; + DestroyChassis_V1_3_1_CS (ChassisV1_3_1->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_3_1/RedfishChassis_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_3_1/RedfishChassis_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..355fd703a3c --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_3_1/RedfishChassis_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_3_1_Dxe + FILE_GUID = 7575d351-3900-4f5c-8856-24b489f19a3f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_3_10/Chassis_V1_3_10_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_3_10/Chassis_V1_3_10_Dxe.c new file mode 100644 index 00000000000..016b60cefca --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_3_10/Chassis_V1_3_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_3_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_3_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "3", + "10" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_3_10 *ChassisV1_3_10; + EFI_REDFISH_CHASSIS_V1_3_10_CS *ChassisV1_3_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_3_10_To_CS (ResoruceRaw, &ChassisV1_3_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_3_10 = (EFI_REDFISH_CHASSIS_V1_3_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_3_10)); + if (ChassisV1_3_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_3_10; + ChassisV1_3_10->Chassis = ChassisV1_3_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_3_10_JSON (*((EFI_REDFISH_CHASSIS_V1_3_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_3_10 *ChassisV1_3_10; + + ChassisV1_3_10 = (EFI_REDFISH_CHASSIS_V1_3_10 *)InterpProp; + DestroyChassis_V1_3_10_CS (ChassisV1_3_10->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_3_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_3_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_3_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_3_10/RedfishChassis_V1_3_10_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_3_10/RedfishChassis_V1_3_10_Dxe.inf new file mode 100644 index 00000000000..2f25816f183 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_3_10/RedfishChassis_V1_3_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_3_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_3_10_Dxe + FILE_GUID = 686451fb-a8e6-4fd9-a978-b6d65834e51e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_3_10EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_3_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_3_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_3_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_3_11/Chassis_V1_3_11_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_3_11/Chassis_V1_3_11_Dxe.c new file mode 100644 index 00000000000..e60da76b2e4 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_3_11/Chassis_V1_3_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_3_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_3_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "3", + "11" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_3_11 *ChassisV1_3_11; + EFI_REDFISH_CHASSIS_V1_3_11_CS *ChassisV1_3_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_3_11_To_CS (ResoruceRaw, &ChassisV1_3_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_3_11 = (EFI_REDFISH_CHASSIS_V1_3_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_3_11)); + if (ChassisV1_3_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_3_11; + ChassisV1_3_11->Chassis = ChassisV1_3_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_3_11_JSON (*((EFI_REDFISH_CHASSIS_V1_3_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_3_11 *ChassisV1_3_11; + + ChassisV1_3_11 = (EFI_REDFISH_CHASSIS_V1_3_11 *)InterpProp; + DestroyChassis_V1_3_11_CS (ChassisV1_3_11->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_3_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_3_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_3_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_3_11/RedfishChassis_V1_3_11_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_3_11/RedfishChassis_V1_3_11_Dxe.inf new file mode 100644 index 00000000000..6ae52ce3aef --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_3_11/RedfishChassis_V1_3_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_3_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_3_11_Dxe + FILE_GUID = f75d171b-83e7-470e-aeec-5f16d7acb445 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_3_11EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_3_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_3_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_3_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_3_2/Chassis_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_3_2/Chassis_V1_3_2_Dxe.c new file mode 100644 index 00000000000..caaaba259de --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_3_2/Chassis_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "3", + "2" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_3_2 *ChassisV1_3_2; + EFI_REDFISH_CHASSIS_V1_3_2_CS *ChassisV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_3_2_To_CS (ResoruceRaw, &ChassisV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_3_2 = (EFI_REDFISH_CHASSIS_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_3_2)); + if (ChassisV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_3_2; + ChassisV1_3_2->Chassis = ChassisV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_3_2_JSON (*((EFI_REDFISH_CHASSIS_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_3_2 *ChassisV1_3_2; + + ChassisV1_3_2 = (EFI_REDFISH_CHASSIS_V1_3_2 *)InterpProp; + DestroyChassis_V1_3_2_CS (ChassisV1_3_2->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_3_2/RedfishChassis_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_3_2/RedfishChassis_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..c2ac0f50e9d --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_3_2/RedfishChassis_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_3_2_Dxe + FILE_GUID = cdedea26-784c-43b3-b095-67f1ed9f9ed0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_3_3/Chassis_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_3_3/Chassis_V1_3_3_Dxe.c new file mode 100644 index 00000000000..c2416d39c99 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_3_3/Chassis_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "3", + "3" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_3_3 *ChassisV1_3_3; + EFI_REDFISH_CHASSIS_V1_3_3_CS *ChassisV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_3_3_To_CS (ResoruceRaw, &ChassisV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_3_3 = (EFI_REDFISH_CHASSIS_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_3_3)); + if (ChassisV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_3_3; + ChassisV1_3_3->Chassis = ChassisV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_3_3_JSON (*((EFI_REDFISH_CHASSIS_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_3_3 *ChassisV1_3_3; + + ChassisV1_3_3 = (EFI_REDFISH_CHASSIS_V1_3_3 *)InterpProp; + DestroyChassis_V1_3_3_CS (ChassisV1_3_3->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_3_3/RedfishChassis_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_3_3/RedfishChassis_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..0b0436c2205 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_3_3/RedfishChassis_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_3_3_Dxe + FILE_GUID = 331b26cf-e50c-4d0a-8b78-df60936d0426 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_3_4/Chassis_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_3_4/Chassis_V1_3_4_Dxe.c new file mode 100644 index 00000000000..1a07a4886f8 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_3_4/Chassis_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "3", + "4" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_3_4 *ChassisV1_3_4; + EFI_REDFISH_CHASSIS_V1_3_4_CS *ChassisV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_3_4_To_CS (ResoruceRaw, &ChassisV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_3_4 = (EFI_REDFISH_CHASSIS_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_3_4)); + if (ChassisV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_3_4; + ChassisV1_3_4->Chassis = ChassisV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_3_4_JSON (*((EFI_REDFISH_CHASSIS_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_3_4 *ChassisV1_3_4; + + ChassisV1_3_4 = (EFI_REDFISH_CHASSIS_V1_3_4 *)InterpProp; + DestroyChassis_V1_3_4_CS (ChassisV1_3_4->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_3_4/RedfishChassis_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_3_4/RedfishChassis_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..1515fa8fa42 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_3_4/RedfishChassis_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_3_4_Dxe + FILE_GUID = 60657c2a-9f95-4c38-b689-373c9bb21bf1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_3_5/Chassis_V1_3_5_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_3_5/Chassis_V1_3_5_Dxe.c new file mode 100644 index 00000000000..53edcc1b3be --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_3_5/Chassis_V1_3_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_3_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "3", + "5" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_3_5 *ChassisV1_3_5; + EFI_REDFISH_CHASSIS_V1_3_5_CS *ChassisV1_3_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_3_5_To_CS (ResoruceRaw, &ChassisV1_3_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_3_5 = (EFI_REDFISH_CHASSIS_V1_3_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_3_5)); + if (ChassisV1_3_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_3_5; + ChassisV1_3_5->Chassis = ChassisV1_3_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_3_5_JSON (*((EFI_REDFISH_CHASSIS_V1_3_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_3_5 *ChassisV1_3_5; + + ChassisV1_3_5 = (EFI_REDFISH_CHASSIS_V1_3_5 *)InterpProp; + DestroyChassis_V1_3_5_CS (ChassisV1_3_5->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_3_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_3_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_3_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_3_5/RedfishChassis_V1_3_5_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_3_5/RedfishChassis_V1_3_5_Dxe.inf new file mode 100644 index 00000000000..26aeeb22c99 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_3_5/RedfishChassis_V1_3_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_3_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_3_5_Dxe + FILE_GUID = 92b917da-d6bb-4d7e-8a6d-265e11521727 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_3_5EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_3_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_3_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_3_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_3_6/Chassis_V1_3_6_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_3_6/Chassis_V1_3_6_Dxe.c new file mode 100644 index 00000000000..26eb2111259 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_3_6/Chassis_V1_3_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_3_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "3", + "6" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_3_6 *ChassisV1_3_6; + EFI_REDFISH_CHASSIS_V1_3_6_CS *ChassisV1_3_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_3_6_To_CS (ResoruceRaw, &ChassisV1_3_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_3_6 = (EFI_REDFISH_CHASSIS_V1_3_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_3_6)); + if (ChassisV1_3_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_3_6; + ChassisV1_3_6->Chassis = ChassisV1_3_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_3_6_JSON (*((EFI_REDFISH_CHASSIS_V1_3_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_3_6 *ChassisV1_3_6; + + ChassisV1_3_6 = (EFI_REDFISH_CHASSIS_V1_3_6 *)InterpProp; + DestroyChassis_V1_3_6_CS (ChassisV1_3_6->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_3_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_3_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_3_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_3_6/RedfishChassis_V1_3_6_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_3_6/RedfishChassis_V1_3_6_Dxe.inf new file mode 100644 index 00000000000..65a6608002d --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_3_6/RedfishChassis_V1_3_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_3_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_3_6_Dxe + FILE_GUID = 32f49d32-a4ec-434e-ab56-be1bc597b491 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_3_6EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_3_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_3_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_3_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_3_7/Chassis_V1_3_7_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_3_7/Chassis_V1_3_7_Dxe.c new file mode 100644 index 00000000000..07f4a38d7b2 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_3_7/Chassis_V1_3_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_3_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_3_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "3", + "7" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_3_7 *ChassisV1_3_7; + EFI_REDFISH_CHASSIS_V1_3_7_CS *ChassisV1_3_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_3_7_To_CS (ResoruceRaw, &ChassisV1_3_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_3_7 = (EFI_REDFISH_CHASSIS_V1_3_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_3_7)); + if (ChassisV1_3_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_3_7; + ChassisV1_3_7->Chassis = ChassisV1_3_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_3_7_JSON (*((EFI_REDFISH_CHASSIS_V1_3_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_3_7 *ChassisV1_3_7; + + ChassisV1_3_7 = (EFI_REDFISH_CHASSIS_V1_3_7 *)InterpProp; + DestroyChassis_V1_3_7_CS (ChassisV1_3_7->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_3_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_3_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_3_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_3_7/RedfishChassis_V1_3_7_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_3_7/RedfishChassis_V1_3_7_Dxe.inf new file mode 100644 index 00000000000..606670b6ed8 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_3_7/RedfishChassis_V1_3_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_3_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_3_7_Dxe + FILE_GUID = 42225b74-90bb-490c-a6d5-e95b23e496a4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_3_7EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_3_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_3_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_3_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_3_8/Chassis_V1_3_8_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_3_8/Chassis_V1_3_8_Dxe.c new file mode 100644 index 00000000000..b990af6a221 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_3_8/Chassis_V1_3_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_3_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_3_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "3", + "8" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_3_8 *ChassisV1_3_8; + EFI_REDFISH_CHASSIS_V1_3_8_CS *ChassisV1_3_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_3_8_To_CS (ResoruceRaw, &ChassisV1_3_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_3_8 = (EFI_REDFISH_CHASSIS_V1_3_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_3_8)); + if (ChassisV1_3_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_3_8; + ChassisV1_3_8->Chassis = ChassisV1_3_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_3_8_JSON (*((EFI_REDFISH_CHASSIS_V1_3_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_3_8 *ChassisV1_3_8; + + ChassisV1_3_8 = (EFI_REDFISH_CHASSIS_V1_3_8 *)InterpProp; + DestroyChassis_V1_3_8_CS (ChassisV1_3_8->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_3_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_3_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_3_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_3_8/RedfishChassis_V1_3_8_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_3_8/RedfishChassis_V1_3_8_Dxe.inf new file mode 100644 index 00000000000..731a8ef116e --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_3_8/RedfishChassis_V1_3_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_3_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_3_8_Dxe + FILE_GUID = 6d890258-a12e-4a19-99f1-e17f4c13dc5f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_3_8EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_3_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_3_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_3_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_3_9/Chassis_V1_3_9_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_3_9/Chassis_V1_3_9_Dxe.c new file mode 100644 index 00000000000..d068dfb77bf --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_3_9/Chassis_V1_3_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_3_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_3_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "3", + "9" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_3_9 *ChassisV1_3_9; + EFI_REDFISH_CHASSIS_V1_3_9_CS *ChassisV1_3_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_3_9_To_CS (ResoruceRaw, &ChassisV1_3_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_3_9 = (EFI_REDFISH_CHASSIS_V1_3_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_3_9)); + if (ChassisV1_3_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_3_9; + ChassisV1_3_9->Chassis = ChassisV1_3_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_3_9_JSON (*((EFI_REDFISH_CHASSIS_V1_3_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_3_9 *ChassisV1_3_9; + + ChassisV1_3_9 = (EFI_REDFISH_CHASSIS_V1_3_9 *)InterpProp; + DestroyChassis_V1_3_9_CS (ChassisV1_3_9->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_3_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_3_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_3_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_3_9/RedfishChassis_V1_3_9_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_3_9/RedfishChassis_V1_3_9_Dxe.inf new file mode 100644 index 00000000000..67452a32fd6 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_3_9/RedfishChassis_V1_3_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_3_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_3_9_Dxe + FILE_GUID = 909c477c-2df9-4dc9-bfc1-8d4a652a826e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_3_9EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_3_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_3_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_3_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_4_0/Chassis_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_4_0/Chassis_V1_4_0_Dxe.c new file mode 100644 index 00000000000..24febd8e86c --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_4_0/Chassis_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "4", + "0" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_4_0 *ChassisV1_4_0; + EFI_REDFISH_CHASSIS_V1_4_0_CS *ChassisV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_4_0_To_CS (ResoruceRaw, &ChassisV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_4_0 = (EFI_REDFISH_CHASSIS_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_4_0)); + if (ChassisV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_4_0; + ChassisV1_4_0->Chassis = ChassisV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_4_0_JSON (*((EFI_REDFISH_CHASSIS_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_4_0 *ChassisV1_4_0; + + ChassisV1_4_0 = (EFI_REDFISH_CHASSIS_V1_4_0 *)InterpProp; + DestroyChassis_V1_4_0_CS (ChassisV1_4_0->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_4_0/RedfishChassis_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_4_0/RedfishChassis_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..b34389dfcd8 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_4_0/RedfishChassis_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_4_0_Dxe + FILE_GUID = 3710034c-c360-4149-82c6-75979a0c97b7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_4_1/Chassis_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_4_1/Chassis_V1_4_1_Dxe.c new file mode 100644 index 00000000000..2df610490e0 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_4_1/Chassis_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "4", + "1" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_4_1 *ChassisV1_4_1; + EFI_REDFISH_CHASSIS_V1_4_1_CS *ChassisV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_4_1_To_CS (ResoruceRaw, &ChassisV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_4_1 = (EFI_REDFISH_CHASSIS_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_4_1)); + if (ChassisV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_4_1; + ChassisV1_4_1->Chassis = ChassisV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_4_1_JSON (*((EFI_REDFISH_CHASSIS_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_4_1 *ChassisV1_4_1; + + ChassisV1_4_1 = (EFI_REDFISH_CHASSIS_V1_4_1 *)InterpProp; + DestroyChassis_V1_4_1_CS (ChassisV1_4_1->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_4_1/RedfishChassis_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_4_1/RedfishChassis_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..d578ea08df6 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_4_1/RedfishChassis_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_4_1_Dxe + FILE_GUID = 0bfe88cf-6598-481c-9617-130eb2e9f6be + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_4_10/Chassis_V1_4_10_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_4_10/Chassis_V1_4_10_Dxe.c new file mode 100644 index 00000000000..b5b48686cf0 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_4_10/Chassis_V1_4_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_4_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_4_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "4", + "10" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_4_10 *ChassisV1_4_10; + EFI_REDFISH_CHASSIS_V1_4_10_CS *ChassisV1_4_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_4_10_To_CS (ResoruceRaw, &ChassisV1_4_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_4_10 = (EFI_REDFISH_CHASSIS_V1_4_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_4_10)); + if (ChassisV1_4_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_4_10; + ChassisV1_4_10->Chassis = ChassisV1_4_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_4_10_JSON (*((EFI_REDFISH_CHASSIS_V1_4_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_4_10 *ChassisV1_4_10; + + ChassisV1_4_10 = (EFI_REDFISH_CHASSIS_V1_4_10 *)InterpProp; + DestroyChassis_V1_4_10_CS (ChassisV1_4_10->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_4_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_4_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_4_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_4_10/RedfishChassis_V1_4_10_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_4_10/RedfishChassis_V1_4_10_Dxe.inf new file mode 100644 index 00000000000..0cc812df29e --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_4_10/RedfishChassis_V1_4_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_4_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_4_10_Dxe + FILE_GUID = 8d3c13f0-dacd-4700-9414-bbb8fdf99af4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_4_10EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_4_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_4_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_4_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_4_2/Chassis_V1_4_2_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_4_2/Chassis_V1_4_2_Dxe.c new file mode 100644 index 00000000000..7aa256a4a52 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_4_2/Chassis_V1_4_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_4_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "4", + "2" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_4_2 *ChassisV1_4_2; + EFI_REDFISH_CHASSIS_V1_4_2_CS *ChassisV1_4_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_4_2_To_CS (ResoruceRaw, &ChassisV1_4_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_4_2 = (EFI_REDFISH_CHASSIS_V1_4_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_4_2)); + if (ChassisV1_4_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_4_2; + ChassisV1_4_2->Chassis = ChassisV1_4_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_4_2_JSON (*((EFI_REDFISH_CHASSIS_V1_4_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_4_2 *ChassisV1_4_2; + + ChassisV1_4_2 = (EFI_REDFISH_CHASSIS_V1_4_2 *)InterpProp; + DestroyChassis_V1_4_2_CS (ChassisV1_4_2->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_4_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_4_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_4_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_4_2/RedfishChassis_V1_4_2_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_4_2/RedfishChassis_V1_4_2_Dxe.inf new file mode 100644 index 00000000000..bf5b3db3e38 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_4_2/RedfishChassis_V1_4_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_4_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_4_2_Dxe + FILE_GUID = 027969d3-85b3-454c-962a-f4376f94105a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_4_2EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_4_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_4_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_4_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_4_3/Chassis_V1_4_3_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_4_3/Chassis_V1_4_3_Dxe.c new file mode 100644 index 00000000000..8be0fd31316 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_4_3/Chassis_V1_4_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_4_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "4", + "3" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_4_3 *ChassisV1_4_3; + EFI_REDFISH_CHASSIS_V1_4_3_CS *ChassisV1_4_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_4_3_To_CS (ResoruceRaw, &ChassisV1_4_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_4_3 = (EFI_REDFISH_CHASSIS_V1_4_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_4_3)); + if (ChassisV1_4_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_4_3; + ChassisV1_4_3->Chassis = ChassisV1_4_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_4_3_JSON (*((EFI_REDFISH_CHASSIS_V1_4_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_4_3 *ChassisV1_4_3; + + ChassisV1_4_3 = (EFI_REDFISH_CHASSIS_V1_4_3 *)InterpProp; + DestroyChassis_V1_4_3_CS (ChassisV1_4_3->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_4_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_4_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_4_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_4_3/RedfishChassis_V1_4_3_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_4_3/RedfishChassis_V1_4_3_Dxe.inf new file mode 100644 index 00000000000..7b5eb86e8fe --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_4_3/RedfishChassis_V1_4_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_4_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_4_3_Dxe + FILE_GUID = 3afcf571-4c0d-4aa4-8542-9b742ea62e48 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_4_3EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_4_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_4_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_4_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_4_4/Chassis_V1_4_4_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_4_4/Chassis_V1_4_4_Dxe.c new file mode 100644 index 00000000000..d3aa7055bd1 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_4_4/Chassis_V1_4_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_4_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "4", + "4" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_4_4 *ChassisV1_4_4; + EFI_REDFISH_CHASSIS_V1_4_4_CS *ChassisV1_4_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_4_4_To_CS (ResoruceRaw, &ChassisV1_4_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_4_4 = (EFI_REDFISH_CHASSIS_V1_4_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_4_4)); + if (ChassisV1_4_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_4_4; + ChassisV1_4_4->Chassis = ChassisV1_4_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_4_4_JSON (*((EFI_REDFISH_CHASSIS_V1_4_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_4_4 *ChassisV1_4_4; + + ChassisV1_4_4 = (EFI_REDFISH_CHASSIS_V1_4_4 *)InterpProp; + DestroyChassis_V1_4_4_CS (ChassisV1_4_4->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_4_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_4_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_4_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_4_4/RedfishChassis_V1_4_4_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_4_4/RedfishChassis_V1_4_4_Dxe.inf new file mode 100644 index 00000000000..f9e57b2e20e --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_4_4/RedfishChassis_V1_4_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_4_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_4_4_Dxe + FILE_GUID = c726ffaa-14ac-4bce-9a45-d191491ae12f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_4_4EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_4_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_4_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_4_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_4_5/Chassis_V1_4_5_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_4_5/Chassis_V1_4_5_Dxe.c new file mode 100644 index 00000000000..ee430726c62 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_4_5/Chassis_V1_4_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_4_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "4", + "5" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_4_5 *ChassisV1_4_5; + EFI_REDFISH_CHASSIS_V1_4_5_CS *ChassisV1_4_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_4_5_To_CS (ResoruceRaw, &ChassisV1_4_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_4_5 = (EFI_REDFISH_CHASSIS_V1_4_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_4_5)); + if (ChassisV1_4_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_4_5; + ChassisV1_4_5->Chassis = ChassisV1_4_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_4_5_JSON (*((EFI_REDFISH_CHASSIS_V1_4_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_4_5 *ChassisV1_4_5; + + ChassisV1_4_5 = (EFI_REDFISH_CHASSIS_V1_4_5 *)InterpProp; + DestroyChassis_V1_4_5_CS (ChassisV1_4_5->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_4_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_4_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_4_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_4_5/RedfishChassis_V1_4_5_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_4_5/RedfishChassis_V1_4_5_Dxe.inf new file mode 100644 index 00000000000..15e596e5833 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_4_5/RedfishChassis_V1_4_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_4_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_4_5_Dxe + FILE_GUID = 1dbc441c-241d-44bf-9e04-f8611ec63332 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_4_5EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_4_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_4_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_4_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_4_6/Chassis_V1_4_6_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_4_6/Chassis_V1_4_6_Dxe.c new file mode 100644 index 00000000000..246a04e45d9 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_4_6/Chassis_V1_4_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_4_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_4_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "4", + "6" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_4_6 *ChassisV1_4_6; + EFI_REDFISH_CHASSIS_V1_4_6_CS *ChassisV1_4_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_4_6_To_CS (ResoruceRaw, &ChassisV1_4_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_4_6 = (EFI_REDFISH_CHASSIS_V1_4_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_4_6)); + if (ChassisV1_4_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_4_6; + ChassisV1_4_6->Chassis = ChassisV1_4_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_4_6_JSON (*((EFI_REDFISH_CHASSIS_V1_4_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_4_6 *ChassisV1_4_6; + + ChassisV1_4_6 = (EFI_REDFISH_CHASSIS_V1_4_6 *)InterpProp; + DestroyChassis_V1_4_6_CS (ChassisV1_4_6->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_4_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_4_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_4_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_4_6/RedfishChassis_V1_4_6_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_4_6/RedfishChassis_V1_4_6_Dxe.inf new file mode 100644 index 00000000000..ecf707580d7 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_4_6/RedfishChassis_V1_4_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_4_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_4_6_Dxe + FILE_GUID = c815a44d-d07b-4124-836c-892b601f6c37 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_4_6EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_4_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_4_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_4_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_4_7/Chassis_V1_4_7_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_4_7/Chassis_V1_4_7_Dxe.c new file mode 100644 index 00000000000..1896c8c994e --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_4_7/Chassis_V1_4_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_4_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_4_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "4", + "7" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_4_7 *ChassisV1_4_7; + EFI_REDFISH_CHASSIS_V1_4_7_CS *ChassisV1_4_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_4_7_To_CS (ResoruceRaw, &ChassisV1_4_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_4_7 = (EFI_REDFISH_CHASSIS_V1_4_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_4_7)); + if (ChassisV1_4_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_4_7; + ChassisV1_4_7->Chassis = ChassisV1_4_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_4_7_JSON (*((EFI_REDFISH_CHASSIS_V1_4_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_4_7 *ChassisV1_4_7; + + ChassisV1_4_7 = (EFI_REDFISH_CHASSIS_V1_4_7 *)InterpProp; + DestroyChassis_V1_4_7_CS (ChassisV1_4_7->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_4_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_4_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_4_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_4_7/RedfishChassis_V1_4_7_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_4_7/RedfishChassis_V1_4_7_Dxe.inf new file mode 100644 index 00000000000..7451054e37b --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_4_7/RedfishChassis_V1_4_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_4_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_4_7_Dxe + FILE_GUID = 426cf844-02d4-48e2-8154-291bee7ea214 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_4_7EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_4_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_4_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_4_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_4_8/Chassis_V1_4_8_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_4_8/Chassis_V1_4_8_Dxe.c new file mode 100644 index 00000000000..343a19ed240 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_4_8/Chassis_V1_4_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_4_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_4_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "4", + "8" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_4_8 *ChassisV1_4_8; + EFI_REDFISH_CHASSIS_V1_4_8_CS *ChassisV1_4_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_4_8_To_CS (ResoruceRaw, &ChassisV1_4_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_4_8 = (EFI_REDFISH_CHASSIS_V1_4_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_4_8)); + if (ChassisV1_4_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_4_8; + ChassisV1_4_8->Chassis = ChassisV1_4_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_4_8_JSON (*((EFI_REDFISH_CHASSIS_V1_4_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_4_8 *ChassisV1_4_8; + + ChassisV1_4_8 = (EFI_REDFISH_CHASSIS_V1_4_8 *)InterpProp; + DestroyChassis_V1_4_8_CS (ChassisV1_4_8->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_4_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_4_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_4_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_4_8/RedfishChassis_V1_4_8_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_4_8/RedfishChassis_V1_4_8_Dxe.inf new file mode 100644 index 00000000000..a0e39f72960 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_4_8/RedfishChassis_V1_4_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_4_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_4_8_Dxe + FILE_GUID = 6fc45213-96af-46e7-bf4c-3c3bd19489a9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_4_8EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_4_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_4_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_4_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_4_9/Chassis_V1_4_9_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_4_9/Chassis_V1_4_9_Dxe.c new file mode 100644 index 00000000000..bef31619a29 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_4_9/Chassis_V1_4_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_4_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_4_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "4", + "9" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_4_9 *ChassisV1_4_9; + EFI_REDFISH_CHASSIS_V1_4_9_CS *ChassisV1_4_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_4_9_To_CS (ResoruceRaw, &ChassisV1_4_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_4_9 = (EFI_REDFISH_CHASSIS_V1_4_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_4_9)); + if (ChassisV1_4_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_4_9; + ChassisV1_4_9->Chassis = ChassisV1_4_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_4_9_JSON (*((EFI_REDFISH_CHASSIS_V1_4_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_4_9 *ChassisV1_4_9; + + ChassisV1_4_9 = (EFI_REDFISH_CHASSIS_V1_4_9 *)InterpProp; + DestroyChassis_V1_4_9_CS (ChassisV1_4_9->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_4_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_4_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_4_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_4_9/RedfishChassis_V1_4_9_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_4_9/RedfishChassis_V1_4_9_Dxe.inf new file mode 100644 index 00000000000..1cbac899aad --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_4_9/RedfishChassis_V1_4_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_4_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_4_9_Dxe + FILE_GUID = 71b71319-b588-4a99-a284-a28d4fe8b06c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_4_9EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_4_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_4_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_4_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_5_0/Chassis_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_5_0/Chassis_V1_5_0_Dxe.c new file mode 100644 index 00000000000..740528c7497 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_5_0/Chassis_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "5", + "0" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_5_0 *ChassisV1_5_0; + EFI_REDFISH_CHASSIS_V1_5_0_CS *ChassisV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_5_0_To_CS (ResoruceRaw, &ChassisV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_5_0 = (EFI_REDFISH_CHASSIS_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_5_0)); + if (ChassisV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_5_0; + ChassisV1_5_0->Chassis = ChassisV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_5_0_JSON (*((EFI_REDFISH_CHASSIS_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_5_0 *ChassisV1_5_0; + + ChassisV1_5_0 = (EFI_REDFISH_CHASSIS_V1_5_0 *)InterpProp; + DestroyChassis_V1_5_0_CS (ChassisV1_5_0->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_5_0/RedfishChassis_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_5_0/RedfishChassis_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..a7c0ea2552a --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_5_0/RedfishChassis_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_5_0_Dxe + FILE_GUID = 2cdd94cc-8cba-4ba6-b1f3-4071d237a7ac + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_5_1/Chassis_V1_5_1_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_5_1/Chassis_V1_5_1_Dxe.c new file mode 100644 index 00000000000..ef1c1a50533 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_5_1/Chassis_V1_5_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_5_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "5", + "1" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_5_1 *ChassisV1_5_1; + EFI_REDFISH_CHASSIS_V1_5_1_CS *ChassisV1_5_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_5_1_To_CS (ResoruceRaw, &ChassisV1_5_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_5_1 = (EFI_REDFISH_CHASSIS_V1_5_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_5_1)); + if (ChassisV1_5_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_5_1; + ChassisV1_5_1->Chassis = ChassisV1_5_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_5_1_JSON (*((EFI_REDFISH_CHASSIS_V1_5_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_5_1 *ChassisV1_5_1; + + ChassisV1_5_1 = (EFI_REDFISH_CHASSIS_V1_5_1 *)InterpProp; + DestroyChassis_V1_5_1_CS (ChassisV1_5_1->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_5_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_5_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_5_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_5_1/RedfishChassis_V1_5_1_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_5_1/RedfishChassis_V1_5_1_Dxe.inf new file mode 100644 index 00000000000..08f70b16e22 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_5_1/RedfishChassis_V1_5_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_5_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_5_1_Dxe + FILE_GUID = ac18eb25-b474-4d0e-adeb-0835df5e81ed + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_5_1EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_5_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_5_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_5_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_5_2/Chassis_V1_5_2_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_5_2/Chassis_V1_5_2_Dxe.c new file mode 100644 index 00000000000..99dfff0af75 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_5_2/Chassis_V1_5_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_5_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "5", + "2" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_5_2 *ChassisV1_5_2; + EFI_REDFISH_CHASSIS_V1_5_2_CS *ChassisV1_5_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_5_2_To_CS (ResoruceRaw, &ChassisV1_5_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_5_2 = (EFI_REDFISH_CHASSIS_V1_5_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_5_2)); + if (ChassisV1_5_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_5_2; + ChassisV1_5_2->Chassis = ChassisV1_5_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_5_2_JSON (*((EFI_REDFISH_CHASSIS_V1_5_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_5_2 *ChassisV1_5_2; + + ChassisV1_5_2 = (EFI_REDFISH_CHASSIS_V1_5_2 *)InterpProp; + DestroyChassis_V1_5_2_CS (ChassisV1_5_2->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_5_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_5_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_5_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_5_2/RedfishChassis_V1_5_2_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_5_2/RedfishChassis_V1_5_2_Dxe.inf new file mode 100644 index 00000000000..0a3ac036861 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_5_2/RedfishChassis_V1_5_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_5_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_5_2_Dxe + FILE_GUID = ffa5d03e-e4ca-448c-82a0-94ccbf0324f9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_5_2EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_5_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_5_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_5_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_5_3/Chassis_V1_5_3_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_5_3/Chassis_V1_5_3_Dxe.c new file mode 100644 index 00000000000..6342ca0a375 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_5_3/Chassis_V1_5_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_5_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "5", + "3" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_5_3 *ChassisV1_5_3; + EFI_REDFISH_CHASSIS_V1_5_3_CS *ChassisV1_5_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_5_3_To_CS (ResoruceRaw, &ChassisV1_5_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_5_3 = (EFI_REDFISH_CHASSIS_V1_5_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_5_3)); + if (ChassisV1_5_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_5_3; + ChassisV1_5_3->Chassis = ChassisV1_5_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_5_3_JSON (*((EFI_REDFISH_CHASSIS_V1_5_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_5_3 *ChassisV1_5_3; + + ChassisV1_5_3 = (EFI_REDFISH_CHASSIS_V1_5_3 *)InterpProp; + DestroyChassis_V1_5_3_CS (ChassisV1_5_3->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_5_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_5_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_5_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_5_3/RedfishChassis_V1_5_3_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_5_3/RedfishChassis_V1_5_3_Dxe.inf new file mode 100644 index 00000000000..e18ec711099 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_5_3/RedfishChassis_V1_5_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_5_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_5_3_Dxe + FILE_GUID = b9a172b7-3aa6-41ba-aad7-1d24078c4ac7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_5_3EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_5_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_5_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_5_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_5_4/Chassis_V1_5_4_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_5_4/Chassis_V1_5_4_Dxe.c new file mode 100644 index 00000000000..50fbae78347 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_5_4/Chassis_V1_5_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_5_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "5", + "4" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_5_4 *ChassisV1_5_4; + EFI_REDFISH_CHASSIS_V1_5_4_CS *ChassisV1_5_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_5_4_To_CS (ResoruceRaw, &ChassisV1_5_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_5_4 = (EFI_REDFISH_CHASSIS_V1_5_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_5_4)); + if (ChassisV1_5_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_5_4; + ChassisV1_5_4->Chassis = ChassisV1_5_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_5_4_JSON (*((EFI_REDFISH_CHASSIS_V1_5_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_5_4 *ChassisV1_5_4; + + ChassisV1_5_4 = (EFI_REDFISH_CHASSIS_V1_5_4 *)InterpProp; + DestroyChassis_V1_5_4_CS (ChassisV1_5_4->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_5_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_5_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_5_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_5_4/RedfishChassis_V1_5_4_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_5_4/RedfishChassis_V1_5_4_Dxe.inf new file mode 100644 index 00000000000..a773a7440eb --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_5_4/RedfishChassis_V1_5_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_5_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_5_4_Dxe + FILE_GUID = ba0baf27-da22-455e-be5a-5cf201a52402 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_5_4EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_5_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_5_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_5_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_5_5/Chassis_V1_5_5_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_5_5/Chassis_V1_5_5_Dxe.c new file mode 100644 index 00000000000..5de13e87471 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_5_5/Chassis_V1_5_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_5_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_5_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "5", + "5" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_5_5 *ChassisV1_5_5; + EFI_REDFISH_CHASSIS_V1_5_5_CS *ChassisV1_5_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_5_5_To_CS (ResoruceRaw, &ChassisV1_5_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_5_5 = (EFI_REDFISH_CHASSIS_V1_5_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_5_5)); + if (ChassisV1_5_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_5_5; + ChassisV1_5_5->Chassis = ChassisV1_5_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_5_5_JSON (*((EFI_REDFISH_CHASSIS_V1_5_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_5_5 *ChassisV1_5_5; + + ChassisV1_5_5 = (EFI_REDFISH_CHASSIS_V1_5_5 *)InterpProp; + DestroyChassis_V1_5_5_CS (ChassisV1_5_5->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_5_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_5_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_5_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_5_5/RedfishChassis_V1_5_5_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_5_5/RedfishChassis_V1_5_5_Dxe.inf new file mode 100644 index 00000000000..de953e6ffc9 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_5_5/RedfishChassis_V1_5_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_5_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_5_5_Dxe + FILE_GUID = ca49a13d-1ec6-4232-b483-85363aa97c10 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_5_5EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_5_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_5_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_5_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_5_6/Chassis_V1_5_6_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_5_6/Chassis_V1_5_6_Dxe.c new file mode 100644 index 00000000000..5da7d689ffb --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_5_6/Chassis_V1_5_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_5_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_5_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "5", + "6" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_5_6 *ChassisV1_5_6; + EFI_REDFISH_CHASSIS_V1_5_6_CS *ChassisV1_5_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_5_6_To_CS (ResoruceRaw, &ChassisV1_5_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_5_6 = (EFI_REDFISH_CHASSIS_V1_5_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_5_6)); + if (ChassisV1_5_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_5_6; + ChassisV1_5_6->Chassis = ChassisV1_5_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_5_6_JSON (*((EFI_REDFISH_CHASSIS_V1_5_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_5_6 *ChassisV1_5_6; + + ChassisV1_5_6 = (EFI_REDFISH_CHASSIS_V1_5_6 *)InterpProp; + DestroyChassis_V1_5_6_CS (ChassisV1_5_6->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_5_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_5_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_5_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_5_6/RedfishChassis_V1_5_6_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_5_6/RedfishChassis_V1_5_6_Dxe.inf new file mode 100644 index 00000000000..c599cc32c11 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_5_6/RedfishChassis_V1_5_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_5_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_5_6_Dxe + FILE_GUID = 69f34b64-e91c-470c-9195-c02fee385d77 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_5_6EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_5_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_5_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_5_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_5_7/Chassis_V1_5_7_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_5_7/Chassis_V1_5_7_Dxe.c new file mode 100644 index 00000000000..d1f6ea424f5 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_5_7/Chassis_V1_5_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_5_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_5_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "5", + "7" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_5_7 *ChassisV1_5_7; + EFI_REDFISH_CHASSIS_V1_5_7_CS *ChassisV1_5_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_5_7_To_CS (ResoruceRaw, &ChassisV1_5_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_5_7 = (EFI_REDFISH_CHASSIS_V1_5_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_5_7)); + if (ChassisV1_5_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_5_7; + ChassisV1_5_7->Chassis = ChassisV1_5_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_5_7_JSON (*((EFI_REDFISH_CHASSIS_V1_5_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_5_7 *ChassisV1_5_7; + + ChassisV1_5_7 = (EFI_REDFISH_CHASSIS_V1_5_7 *)InterpProp; + DestroyChassis_V1_5_7_CS (ChassisV1_5_7->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_5_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_5_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_5_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_5_7/RedfishChassis_V1_5_7_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_5_7/RedfishChassis_V1_5_7_Dxe.inf new file mode 100644 index 00000000000..252a3a8c8a5 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_5_7/RedfishChassis_V1_5_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_5_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_5_7_Dxe + FILE_GUID = 67fa449a-73c0-4fb9-80c2-133483a6f85c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_5_7EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_5_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_5_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_5_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_5_8/Chassis_V1_5_8_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_5_8/Chassis_V1_5_8_Dxe.c new file mode 100644 index 00000000000..49e8095b423 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_5_8/Chassis_V1_5_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_5_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_5_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "5", + "8" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_5_8 *ChassisV1_5_8; + EFI_REDFISH_CHASSIS_V1_5_8_CS *ChassisV1_5_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_5_8_To_CS (ResoruceRaw, &ChassisV1_5_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_5_8 = (EFI_REDFISH_CHASSIS_V1_5_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_5_8)); + if (ChassisV1_5_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_5_8; + ChassisV1_5_8->Chassis = ChassisV1_5_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_5_8_JSON (*((EFI_REDFISH_CHASSIS_V1_5_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_5_8 *ChassisV1_5_8; + + ChassisV1_5_8 = (EFI_REDFISH_CHASSIS_V1_5_8 *)InterpProp; + DestroyChassis_V1_5_8_CS (ChassisV1_5_8->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_5_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_5_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_5_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_5_8/RedfishChassis_V1_5_8_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_5_8/RedfishChassis_V1_5_8_Dxe.inf new file mode 100644 index 00000000000..d4ef470b2b6 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_5_8/RedfishChassis_V1_5_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_5_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_5_8_Dxe + FILE_GUID = ab80e4f7-6a0d-4090-a27d-97603b79f502 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_5_8EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_5_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_5_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_5_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_5_9/Chassis_V1_5_9_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_5_9/Chassis_V1_5_9_Dxe.c new file mode 100644 index 00000000000..62e6563f87c --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_5_9/Chassis_V1_5_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_5_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_5_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "5", + "9" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_5_9 *ChassisV1_5_9; + EFI_REDFISH_CHASSIS_V1_5_9_CS *ChassisV1_5_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_5_9_To_CS (ResoruceRaw, &ChassisV1_5_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_5_9 = (EFI_REDFISH_CHASSIS_V1_5_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_5_9)); + if (ChassisV1_5_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_5_9; + ChassisV1_5_9->Chassis = ChassisV1_5_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_5_9_JSON (*((EFI_REDFISH_CHASSIS_V1_5_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_5_9 *ChassisV1_5_9; + + ChassisV1_5_9 = (EFI_REDFISH_CHASSIS_V1_5_9 *)InterpProp; + DestroyChassis_V1_5_9_CS (ChassisV1_5_9->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_5_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_5_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_5_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_5_9/RedfishChassis_V1_5_9_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_5_9/RedfishChassis_V1_5_9_Dxe.inf new file mode 100644 index 00000000000..f06b330768f --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_5_9/RedfishChassis_V1_5_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_5_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_5_9_Dxe + FILE_GUID = 30d55c98-7cd2-4f25-be29-7a817926c8c1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_5_9EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_5_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_5_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_5_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_6_0/Chassis_V1_6_0_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_6_0/Chassis_V1_6_0_Dxe.c new file mode 100644 index 00000000000..31524f337e2 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_6_0/Chassis_V1_6_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_6_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "6", + "0" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_6_0 *ChassisV1_6_0; + EFI_REDFISH_CHASSIS_V1_6_0_CS *ChassisV1_6_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_6_0_To_CS (ResoruceRaw, &ChassisV1_6_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_6_0 = (EFI_REDFISH_CHASSIS_V1_6_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_6_0)); + if (ChassisV1_6_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_6_0; + ChassisV1_6_0->Chassis = ChassisV1_6_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_6_0_JSON (*((EFI_REDFISH_CHASSIS_V1_6_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_6_0 *ChassisV1_6_0; + + ChassisV1_6_0 = (EFI_REDFISH_CHASSIS_V1_6_0 *)InterpProp; + DestroyChassis_V1_6_0_CS (ChassisV1_6_0->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_6_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_6_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_6_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_6_0/RedfishChassis_V1_6_0_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_6_0/RedfishChassis_V1_6_0_Dxe.inf new file mode 100644 index 00000000000..eb8d5a8b738 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_6_0/RedfishChassis_V1_6_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_6_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_6_0_Dxe + FILE_GUID = 59281416-bc15-404d-b60e-1e4b58c05cc9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_6_0EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_6_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_6_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_6_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_6_1/Chassis_V1_6_1_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_6_1/Chassis_V1_6_1_Dxe.c new file mode 100644 index 00000000000..1e4752582e0 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_6_1/Chassis_V1_6_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_6_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "6", + "1" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_6_1 *ChassisV1_6_1; + EFI_REDFISH_CHASSIS_V1_6_1_CS *ChassisV1_6_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_6_1_To_CS (ResoruceRaw, &ChassisV1_6_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_6_1 = (EFI_REDFISH_CHASSIS_V1_6_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_6_1)); + if (ChassisV1_6_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_6_1; + ChassisV1_6_1->Chassis = ChassisV1_6_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_6_1_JSON (*((EFI_REDFISH_CHASSIS_V1_6_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_6_1 *ChassisV1_6_1; + + ChassisV1_6_1 = (EFI_REDFISH_CHASSIS_V1_6_1 *)InterpProp; + DestroyChassis_V1_6_1_CS (ChassisV1_6_1->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_6_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_6_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_6_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_6_1/RedfishChassis_V1_6_1_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_6_1/RedfishChassis_V1_6_1_Dxe.inf new file mode 100644 index 00000000000..13e0eafa850 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_6_1/RedfishChassis_V1_6_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_6_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_6_1_Dxe + FILE_GUID = 14b8fbc1-68f7-4843-8822-36a736041c31 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_6_1EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_6_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_6_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_6_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_6_2/Chassis_V1_6_2_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_6_2/Chassis_V1_6_2_Dxe.c new file mode 100644 index 00000000000..da19eed53b7 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_6_2/Chassis_V1_6_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_6_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "6", + "2" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_6_2 *ChassisV1_6_2; + EFI_REDFISH_CHASSIS_V1_6_2_CS *ChassisV1_6_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_6_2_To_CS (ResoruceRaw, &ChassisV1_6_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_6_2 = (EFI_REDFISH_CHASSIS_V1_6_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_6_2)); + if (ChassisV1_6_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_6_2; + ChassisV1_6_2->Chassis = ChassisV1_6_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_6_2_JSON (*((EFI_REDFISH_CHASSIS_V1_6_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_6_2 *ChassisV1_6_2; + + ChassisV1_6_2 = (EFI_REDFISH_CHASSIS_V1_6_2 *)InterpProp; + DestroyChassis_V1_6_2_CS (ChassisV1_6_2->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_6_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_6_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_6_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_6_2/RedfishChassis_V1_6_2_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_6_2/RedfishChassis_V1_6_2_Dxe.inf new file mode 100644 index 00000000000..2adc6718dee --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_6_2/RedfishChassis_V1_6_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_6_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_6_2_Dxe + FILE_GUID = ea9c9db7-e37b-4274-b6bf-4a3d35a1f741 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_6_2EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_6_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_6_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_6_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_6_3/Chassis_V1_6_3_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_6_3/Chassis_V1_6_3_Dxe.c new file mode 100644 index 00000000000..9c1366a222d --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_6_3/Chassis_V1_6_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_6_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_6_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "6", + "3" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_6_3 *ChassisV1_6_3; + EFI_REDFISH_CHASSIS_V1_6_3_CS *ChassisV1_6_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_6_3_To_CS (ResoruceRaw, &ChassisV1_6_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_6_3 = (EFI_REDFISH_CHASSIS_V1_6_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_6_3)); + if (ChassisV1_6_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_6_3; + ChassisV1_6_3->Chassis = ChassisV1_6_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_6_3_JSON (*((EFI_REDFISH_CHASSIS_V1_6_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_6_3 *ChassisV1_6_3; + + ChassisV1_6_3 = (EFI_REDFISH_CHASSIS_V1_6_3 *)InterpProp; + DestroyChassis_V1_6_3_CS (ChassisV1_6_3->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_6_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_6_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_6_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_6_3/RedfishChassis_V1_6_3_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_6_3/RedfishChassis_V1_6_3_Dxe.inf new file mode 100644 index 00000000000..beda7e531a2 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_6_3/RedfishChassis_V1_6_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_6_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_6_3_Dxe + FILE_GUID = 3fe3ec54-bde7-40a8-8fe2-9404deb3ff1d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_6_3EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_6_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_6_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_6_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_6_4/Chassis_V1_6_4_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_6_4/Chassis_V1_6_4_Dxe.c new file mode 100644 index 00000000000..5664607504f --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_6_4/Chassis_V1_6_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_6_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_6_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "6", + "4" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_6_4 *ChassisV1_6_4; + EFI_REDFISH_CHASSIS_V1_6_4_CS *ChassisV1_6_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_6_4_To_CS (ResoruceRaw, &ChassisV1_6_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_6_4 = (EFI_REDFISH_CHASSIS_V1_6_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_6_4)); + if (ChassisV1_6_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_6_4; + ChassisV1_6_4->Chassis = ChassisV1_6_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_6_4_JSON (*((EFI_REDFISH_CHASSIS_V1_6_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_6_4 *ChassisV1_6_4; + + ChassisV1_6_4 = (EFI_REDFISH_CHASSIS_V1_6_4 *)InterpProp; + DestroyChassis_V1_6_4_CS (ChassisV1_6_4->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_6_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_6_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_6_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_6_4/RedfishChassis_V1_6_4_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_6_4/RedfishChassis_V1_6_4_Dxe.inf new file mode 100644 index 00000000000..acac42d97cc --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_6_4/RedfishChassis_V1_6_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_6_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_6_4_Dxe + FILE_GUID = 086d0c5a-8d09-441d-87a9-2b43db6640df + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_6_4EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_6_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_6_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_6_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_6_5/Chassis_V1_6_5_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_6_5/Chassis_V1_6_5_Dxe.c new file mode 100644 index 00000000000..6e64d8821c0 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_6_5/Chassis_V1_6_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_6_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_6_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "6", + "5" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_6_5 *ChassisV1_6_5; + EFI_REDFISH_CHASSIS_V1_6_5_CS *ChassisV1_6_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_6_5_To_CS (ResoruceRaw, &ChassisV1_6_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_6_5 = (EFI_REDFISH_CHASSIS_V1_6_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_6_5)); + if (ChassisV1_6_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_6_5; + ChassisV1_6_5->Chassis = ChassisV1_6_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_6_5_JSON (*((EFI_REDFISH_CHASSIS_V1_6_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_6_5 *ChassisV1_6_5; + + ChassisV1_6_5 = (EFI_REDFISH_CHASSIS_V1_6_5 *)InterpProp; + DestroyChassis_V1_6_5_CS (ChassisV1_6_5->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_6_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_6_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_6_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_6_5/RedfishChassis_V1_6_5_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_6_5/RedfishChassis_V1_6_5_Dxe.inf new file mode 100644 index 00000000000..551984bfff1 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_6_5/RedfishChassis_V1_6_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_6_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_6_5_Dxe + FILE_GUID = b896d4d2-f644-40bd-8b4b-47a1c92aa38f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_6_5EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_6_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_6_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_6_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_6_6/Chassis_V1_6_6_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_6_6/Chassis_V1_6_6_Dxe.c new file mode 100644 index 00000000000..195608baa41 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_6_6/Chassis_V1_6_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_6_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_6_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "6", + "6" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_6_6 *ChassisV1_6_6; + EFI_REDFISH_CHASSIS_V1_6_6_CS *ChassisV1_6_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_6_6_To_CS (ResoruceRaw, &ChassisV1_6_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_6_6 = (EFI_REDFISH_CHASSIS_V1_6_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_6_6)); + if (ChassisV1_6_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_6_6; + ChassisV1_6_6->Chassis = ChassisV1_6_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_6_6_JSON (*((EFI_REDFISH_CHASSIS_V1_6_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_6_6 *ChassisV1_6_6; + + ChassisV1_6_6 = (EFI_REDFISH_CHASSIS_V1_6_6 *)InterpProp; + DestroyChassis_V1_6_6_CS (ChassisV1_6_6->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_6_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_6_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_6_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_6_6/RedfishChassis_V1_6_6_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_6_6/RedfishChassis_V1_6_6_Dxe.inf new file mode 100644 index 00000000000..1ecdd8f9168 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_6_6/RedfishChassis_V1_6_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_6_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_6_6_Dxe + FILE_GUID = 879abfcd-e19a-40dd-ab44-b1a6bc6f84dd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_6_6EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_6_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_6_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_6_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_6_7/Chassis_V1_6_7_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_6_7/Chassis_V1_6_7_Dxe.c new file mode 100644 index 00000000000..b23e02af3cb --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_6_7/Chassis_V1_6_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_6_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_6_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "6", + "7" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_6_7 *ChassisV1_6_7; + EFI_REDFISH_CHASSIS_V1_6_7_CS *ChassisV1_6_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_6_7_To_CS (ResoruceRaw, &ChassisV1_6_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_6_7 = (EFI_REDFISH_CHASSIS_V1_6_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_6_7)); + if (ChassisV1_6_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_6_7; + ChassisV1_6_7->Chassis = ChassisV1_6_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_6_7_JSON (*((EFI_REDFISH_CHASSIS_V1_6_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_6_7 *ChassisV1_6_7; + + ChassisV1_6_7 = (EFI_REDFISH_CHASSIS_V1_6_7 *)InterpProp; + DestroyChassis_V1_6_7_CS (ChassisV1_6_7->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_6_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_6_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_6_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_6_7/RedfishChassis_V1_6_7_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_6_7/RedfishChassis_V1_6_7_Dxe.inf new file mode 100644 index 00000000000..fd3f5d5ca98 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_6_7/RedfishChassis_V1_6_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_6_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_6_7_Dxe + FILE_GUID = c6e1c4c4-932a-4b0f-88fb-922ae2cd32ba + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_6_7EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_6_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_6_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_6_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_7_0/Chassis_V1_7_0_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_7_0/Chassis_V1_7_0_Dxe.c new file mode 100644 index 00000000000..51c4e794b60 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_7_0/Chassis_V1_7_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_7_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "7", + "0" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_7_0 *ChassisV1_7_0; + EFI_REDFISH_CHASSIS_V1_7_0_CS *ChassisV1_7_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_7_0_To_CS (ResoruceRaw, &ChassisV1_7_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_7_0 = (EFI_REDFISH_CHASSIS_V1_7_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_7_0)); + if (ChassisV1_7_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_7_0; + ChassisV1_7_0->Chassis = ChassisV1_7_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_7_0_JSON (*((EFI_REDFISH_CHASSIS_V1_7_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_7_0 *ChassisV1_7_0; + + ChassisV1_7_0 = (EFI_REDFISH_CHASSIS_V1_7_0 *)InterpProp; + DestroyChassis_V1_7_0_CS (ChassisV1_7_0->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_7_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_7_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_7_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_7_0/RedfishChassis_V1_7_0_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_7_0/RedfishChassis_V1_7_0_Dxe.inf new file mode 100644 index 00000000000..e97ccbc16e1 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_7_0/RedfishChassis_V1_7_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_7_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_7_0_Dxe + FILE_GUID = 2ce1c1d1-4bd6-4949-8e6b-8eea11d9211d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_7_0EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_7_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_7_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_7_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_7_1/Chassis_V1_7_1_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_7_1/Chassis_V1_7_1_Dxe.c new file mode 100644 index 00000000000..ca796aecdcd --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_7_1/Chassis_V1_7_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_7_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_7_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "7", + "1" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_7_1 *ChassisV1_7_1; + EFI_REDFISH_CHASSIS_V1_7_1_CS *ChassisV1_7_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_7_1_To_CS (ResoruceRaw, &ChassisV1_7_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_7_1 = (EFI_REDFISH_CHASSIS_V1_7_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_7_1)); + if (ChassisV1_7_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_7_1; + ChassisV1_7_1->Chassis = ChassisV1_7_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_7_1_JSON (*((EFI_REDFISH_CHASSIS_V1_7_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_7_1 *ChassisV1_7_1; + + ChassisV1_7_1 = (EFI_REDFISH_CHASSIS_V1_7_1 *)InterpProp; + DestroyChassis_V1_7_1_CS (ChassisV1_7_1->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_7_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_7_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_7_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_7_1/RedfishChassis_V1_7_1_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_7_1/RedfishChassis_V1_7_1_Dxe.inf new file mode 100644 index 00000000000..00d7d55f708 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_7_1/RedfishChassis_V1_7_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_7_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_7_1_Dxe + FILE_GUID = b4995a21-c2f6-4f59-9054-e20ff16e1ee6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_7_1EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_7_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_7_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_7_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_7_2/Chassis_V1_7_2_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_7_2/Chassis_V1_7_2_Dxe.c new file mode 100644 index 00000000000..b26336b655d --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_7_2/Chassis_V1_7_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_7_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_7_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "7", + "2" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_7_2 *ChassisV1_7_2; + EFI_REDFISH_CHASSIS_V1_7_2_CS *ChassisV1_7_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_7_2_To_CS (ResoruceRaw, &ChassisV1_7_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_7_2 = (EFI_REDFISH_CHASSIS_V1_7_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_7_2)); + if (ChassisV1_7_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_7_2; + ChassisV1_7_2->Chassis = ChassisV1_7_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_7_2_JSON (*((EFI_REDFISH_CHASSIS_V1_7_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_7_2 *ChassisV1_7_2; + + ChassisV1_7_2 = (EFI_REDFISH_CHASSIS_V1_7_2 *)InterpProp; + DestroyChassis_V1_7_2_CS (ChassisV1_7_2->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_7_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_7_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_7_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_7_2/RedfishChassis_V1_7_2_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_7_2/RedfishChassis_V1_7_2_Dxe.inf new file mode 100644 index 00000000000..4ba7c77d97f --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_7_2/RedfishChassis_V1_7_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_7_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_7_2_Dxe + FILE_GUID = 1ed6cb5d-5376-403e-ad84-c842c3695c05 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_7_2EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_7_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_7_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_7_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_7_3/Chassis_V1_7_3_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_7_3/Chassis_V1_7_3_Dxe.c new file mode 100644 index 00000000000..386e3bc8dce --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_7_3/Chassis_V1_7_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_7_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_7_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "7", + "3" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_7_3 *ChassisV1_7_3; + EFI_REDFISH_CHASSIS_V1_7_3_CS *ChassisV1_7_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_7_3_To_CS (ResoruceRaw, &ChassisV1_7_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_7_3 = (EFI_REDFISH_CHASSIS_V1_7_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_7_3)); + if (ChassisV1_7_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_7_3; + ChassisV1_7_3->Chassis = ChassisV1_7_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_7_3_JSON (*((EFI_REDFISH_CHASSIS_V1_7_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_7_3 *ChassisV1_7_3; + + ChassisV1_7_3 = (EFI_REDFISH_CHASSIS_V1_7_3 *)InterpProp; + DestroyChassis_V1_7_3_CS (ChassisV1_7_3->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_7_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_7_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_7_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_7_3/RedfishChassis_V1_7_3_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_7_3/RedfishChassis_V1_7_3_Dxe.inf new file mode 100644 index 00000000000..d026d514f7e --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_7_3/RedfishChassis_V1_7_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_7_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_7_3_Dxe + FILE_GUID = d2cf0f5d-6ee1-479c-b88a-4a37cb6e6771 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_7_3EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_7_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_7_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_7_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_7_4/Chassis_V1_7_4_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_7_4/Chassis_V1_7_4_Dxe.c new file mode 100644 index 00000000000..1e8768e60de --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_7_4/Chassis_V1_7_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_7_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_7_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "7", + "4" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_7_4 *ChassisV1_7_4; + EFI_REDFISH_CHASSIS_V1_7_4_CS *ChassisV1_7_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_7_4_To_CS (ResoruceRaw, &ChassisV1_7_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_7_4 = (EFI_REDFISH_CHASSIS_V1_7_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_7_4)); + if (ChassisV1_7_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_7_4; + ChassisV1_7_4->Chassis = ChassisV1_7_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_7_4_JSON (*((EFI_REDFISH_CHASSIS_V1_7_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_7_4 *ChassisV1_7_4; + + ChassisV1_7_4 = (EFI_REDFISH_CHASSIS_V1_7_4 *)InterpProp; + DestroyChassis_V1_7_4_CS (ChassisV1_7_4->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_7_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_7_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_7_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_7_4/RedfishChassis_V1_7_4_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_7_4/RedfishChassis_V1_7_4_Dxe.inf new file mode 100644 index 00000000000..20027200b99 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_7_4/RedfishChassis_V1_7_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_7_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_7_4_Dxe + FILE_GUID = 6f22bf51-b0ef-499a-bb9e-c738b113e1af + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_7_4EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_7_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_7_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_7_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_7_5/Chassis_V1_7_5_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_7_5/Chassis_V1_7_5_Dxe.c new file mode 100644 index 00000000000..770fa6a5889 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_7_5/Chassis_V1_7_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_7_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_7_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "7", + "5" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_7_5 *ChassisV1_7_5; + EFI_REDFISH_CHASSIS_V1_7_5_CS *ChassisV1_7_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_7_5_To_CS (ResoruceRaw, &ChassisV1_7_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_7_5 = (EFI_REDFISH_CHASSIS_V1_7_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_7_5)); + if (ChassisV1_7_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_7_5; + ChassisV1_7_5->Chassis = ChassisV1_7_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_7_5_JSON (*((EFI_REDFISH_CHASSIS_V1_7_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_7_5 *ChassisV1_7_5; + + ChassisV1_7_5 = (EFI_REDFISH_CHASSIS_V1_7_5 *)InterpProp; + DestroyChassis_V1_7_5_CS (ChassisV1_7_5->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_7_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_7_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_7_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_7_5/RedfishChassis_V1_7_5_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_7_5/RedfishChassis_V1_7_5_Dxe.inf new file mode 100644 index 00000000000..0cca430c9ab --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_7_5/RedfishChassis_V1_7_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_7_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_7_5_Dxe + FILE_GUID = c634a5e3-ef75-41ef-ad1d-611e4f007a14 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_7_5EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_7_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_7_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_7_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_7_6/Chassis_V1_7_6_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_7_6/Chassis_V1_7_6_Dxe.c new file mode 100644 index 00000000000..a599955ee04 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_7_6/Chassis_V1_7_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_7_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_7_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "7", + "6" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_7_6 *ChassisV1_7_6; + EFI_REDFISH_CHASSIS_V1_7_6_CS *ChassisV1_7_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_7_6_To_CS (ResoruceRaw, &ChassisV1_7_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_7_6 = (EFI_REDFISH_CHASSIS_V1_7_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_7_6)); + if (ChassisV1_7_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_7_6; + ChassisV1_7_6->Chassis = ChassisV1_7_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_7_6_JSON (*((EFI_REDFISH_CHASSIS_V1_7_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_7_6 *ChassisV1_7_6; + + ChassisV1_7_6 = (EFI_REDFISH_CHASSIS_V1_7_6 *)InterpProp; + DestroyChassis_V1_7_6_CS (ChassisV1_7_6->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_7_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_7_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_7_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_7_6/RedfishChassis_V1_7_6_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_7_6/RedfishChassis_V1_7_6_Dxe.inf new file mode 100644 index 00000000000..f3590b63e64 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_7_6/RedfishChassis_V1_7_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_7_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_7_6_Dxe + FILE_GUID = 990648ad-1fce-4dac-b481-eff1edbf68a6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_7_6EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_7_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_7_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_7_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_7_7/Chassis_V1_7_7_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_7_7/Chassis_V1_7_7_Dxe.c new file mode 100644 index 00000000000..a0b8f26a84e --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_7_7/Chassis_V1_7_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_7_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_7_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "7", + "7" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_7_7 *ChassisV1_7_7; + EFI_REDFISH_CHASSIS_V1_7_7_CS *ChassisV1_7_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_7_7_To_CS (ResoruceRaw, &ChassisV1_7_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_7_7 = (EFI_REDFISH_CHASSIS_V1_7_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_7_7)); + if (ChassisV1_7_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_7_7; + ChassisV1_7_7->Chassis = ChassisV1_7_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_7_7_JSON (*((EFI_REDFISH_CHASSIS_V1_7_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_7_7 *ChassisV1_7_7; + + ChassisV1_7_7 = (EFI_REDFISH_CHASSIS_V1_7_7 *)InterpProp; + DestroyChassis_V1_7_7_CS (ChassisV1_7_7->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_7_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_7_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_7_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_7_7/RedfishChassis_V1_7_7_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_7_7/RedfishChassis_V1_7_7_Dxe.inf new file mode 100644 index 00000000000..4ea9da413e3 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_7_7/RedfishChassis_V1_7_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_7_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_7_7_Dxe + FILE_GUID = 8877dd5f-5ada-4995-bd66-501d855ff816 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_7_7EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_7_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_7_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_7_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_8_0/Chassis_V1_8_0_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_8_0/Chassis_V1_8_0_Dxe.c new file mode 100644 index 00000000000..2c8d197a84b --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_8_0/Chassis_V1_8_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_8_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_8_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "8", + "0" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_8_0 *ChassisV1_8_0; + EFI_REDFISH_CHASSIS_V1_8_0_CS *ChassisV1_8_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_8_0_To_CS (ResoruceRaw, &ChassisV1_8_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_8_0 = (EFI_REDFISH_CHASSIS_V1_8_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_8_0)); + if (ChassisV1_8_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_8_0; + ChassisV1_8_0->Chassis = ChassisV1_8_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_8_0_JSON (*((EFI_REDFISH_CHASSIS_V1_8_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_8_0 *ChassisV1_8_0; + + ChassisV1_8_0 = (EFI_REDFISH_CHASSIS_V1_8_0 *)InterpProp; + DestroyChassis_V1_8_0_CS (ChassisV1_8_0->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_8_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_8_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_8_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_8_0/RedfishChassis_V1_8_0_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_8_0/RedfishChassis_V1_8_0_Dxe.inf new file mode 100644 index 00000000000..8168f358282 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_8_0/RedfishChassis_V1_8_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_8_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_8_0_Dxe + FILE_GUID = 0a160703-8f89-41e8-b960-168ac8055f2c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_8_0EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_8_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_8_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_8_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_8_1/Chassis_V1_8_1_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_8_1/Chassis_V1_8_1_Dxe.c new file mode 100644 index 00000000000..10b801e139c --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_8_1/Chassis_V1_8_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_8_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_8_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "8", + "1" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_8_1 *ChassisV1_8_1; + EFI_REDFISH_CHASSIS_V1_8_1_CS *ChassisV1_8_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_8_1_To_CS (ResoruceRaw, &ChassisV1_8_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_8_1 = (EFI_REDFISH_CHASSIS_V1_8_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_8_1)); + if (ChassisV1_8_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_8_1; + ChassisV1_8_1->Chassis = ChassisV1_8_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_8_1_JSON (*((EFI_REDFISH_CHASSIS_V1_8_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_8_1 *ChassisV1_8_1; + + ChassisV1_8_1 = (EFI_REDFISH_CHASSIS_V1_8_1 *)InterpProp; + DestroyChassis_V1_8_1_CS (ChassisV1_8_1->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_8_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_8_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_8_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_8_1/RedfishChassis_V1_8_1_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_8_1/RedfishChassis_V1_8_1_Dxe.inf new file mode 100644 index 00000000000..82c9660e1a5 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_8_1/RedfishChassis_V1_8_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_8_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_8_1_Dxe + FILE_GUID = 65bfa2d2-fb08-4eea-b695-7dd08c358597 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_8_1EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_8_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_8_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_8_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_8_2/Chassis_V1_8_2_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_8_2/Chassis_V1_8_2_Dxe.c new file mode 100644 index 00000000000..04acab4618c --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_8_2/Chassis_V1_8_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_8_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_8_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "8", + "2" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_8_2 *ChassisV1_8_2; + EFI_REDFISH_CHASSIS_V1_8_2_CS *ChassisV1_8_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_8_2_To_CS (ResoruceRaw, &ChassisV1_8_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_8_2 = (EFI_REDFISH_CHASSIS_V1_8_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_8_2)); + if (ChassisV1_8_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_8_2; + ChassisV1_8_2->Chassis = ChassisV1_8_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_8_2_JSON (*((EFI_REDFISH_CHASSIS_V1_8_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_8_2 *ChassisV1_8_2; + + ChassisV1_8_2 = (EFI_REDFISH_CHASSIS_V1_8_2 *)InterpProp; + DestroyChassis_V1_8_2_CS (ChassisV1_8_2->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_8_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_8_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_8_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_8_2/RedfishChassis_V1_8_2_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_8_2/RedfishChassis_V1_8_2_Dxe.inf new file mode 100644 index 00000000000..d844f6ba49b --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_8_2/RedfishChassis_V1_8_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_8_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_8_2_Dxe + FILE_GUID = 908ff83c-adb3-4110-9e7a-34c2a5b69fc5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_8_2EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_8_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_8_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_8_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_8_3/Chassis_V1_8_3_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_8_3/Chassis_V1_8_3_Dxe.c new file mode 100644 index 00000000000..9ee03c3950e --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_8_3/Chassis_V1_8_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_8_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_8_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "8", + "3" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_8_3 *ChassisV1_8_3; + EFI_REDFISH_CHASSIS_V1_8_3_CS *ChassisV1_8_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_8_3_To_CS (ResoruceRaw, &ChassisV1_8_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_8_3 = (EFI_REDFISH_CHASSIS_V1_8_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_8_3)); + if (ChassisV1_8_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_8_3; + ChassisV1_8_3->Chassis = ChassisV1_8_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_8_3_JSON (*((EFI_REDFISH_CHASSIS_V1_8_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_8_3 *ChassisV1_8_3; + + ChassisV1_8_3 = (EFI_REDFISH_CHASSIS_V1_8_3 *)InterpProp; + DestroyChassis_V1_8_3_CS (ChassisV1_8_3->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_8_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_8_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_8_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_8_3/RedfishChassis_V1_8_3_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_8_3/RedfishChassis_V1_8_3_Dxe.inf new file mode 100644 index 00000000000..b98ec1d55b4 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_8_3/RedfishChassis_V1_8_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_8_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_8_3_Dxe + FILE_GUID = 5adcd8aa-3b56-4799-a33d-69791f825194 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_8_3EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_8_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_8_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_8_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_8_4/Chassis_V1_8_4_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_8_4/Chassis_V1_8_4_Dxe.c new file mode 100644 index 00000000000..fb9302daa09 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_8_4/Chassis_V1_8_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_8_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_8_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "8", + "4" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_8_4 *ChassisV1_8_4; + EFI_REDFISH_CHASSIS_V1_8_4_CS *ChassisV1_8_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_8_4_To_CS (ResoruceRaw, &ChassisV1_8_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_8_4 = (EFI_REDFISH_CHASSIS_V1_8_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_8_4)); + if (ChassisV1_8_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_8_4; + ChassisV1_8_4->Chassis = ChassisV1_8_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_8_4_JSON (*((EFI_REDFISH_CHASSIS_V1_8_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_8_4 *ChassisV1_8_4; + + ChassisV1_8_4 = (EFI_REDFISH_CHASSIS_V1_8_4 *)InterpProp; + DestroyChassis_V1_8_4_CS (ChassisV1_8_4->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_8_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_8_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_8_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_8_4/RedfishChassis_V1_8_4_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_8_4/RedfishChassis_V1_8_4_Dxe.inf new file mode 100644 index 00000000000..369c53afb90 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_8_4/RedfishChassis_V1_8_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_8_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_8_4_Dxe + FILE_GUID = b150c3eb-b0b9-4751-b4c7-ef071a0b85f2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_8_4EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_8_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_8_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_8_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_8_5/Chassis_V1_8_5_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_8_5/Chassis_V1_8_5_Dxe.c new file mode 100644 index 00000000000..92ecf72abd1 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_8_5/Chassis_V1_8_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_8_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_8_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "8", + "5" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_8_5 *ChassisV1_8_5; + EFI_REDFISH_CHASSIS_V1_8_5_CS *ChassisV1_8_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_8_5_To_CS (ResoruceRaw, &ChassisV1_8_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_8_5 = (EFI_REDFISH_CHASSIS_V1_8_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_8_5)); + if (ChassisV1_8_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_8_5; + ChassisV1_8_5->Chassis = ChassisV1_8_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_8_5_JSON (*((EFI_REDFISH_CHASSIS_V1_8_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_8_5 *ChassisV1_8_5; + + ChassisV1_8_5 = (EFI_REDFISH_CHASSIS_V1_8_5 *)InterpProp; + DestroyChassis_V1_8_5_CS (ChassisV1_8_5->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_8_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_8_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_8_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_8_5/RedfishChassis_V1_8_5_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_8_5/RedfishChassis_V1_8_5_Dxe.inf new file mode 100644 index 00000000000..766a610f9ff --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_8_5/RedfishChassis_V1_8_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_8_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_8_5_Dxe + FILE_GUID = 7d469187-54e5-4b39-8d86-964a8bb193b5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_8_5EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_8_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_8_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_8_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_8_6/Chassis_V1_8_6_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_8_6/Chassis_V1_8_6_Dxe.c new file mode 100644 index 00000000000..b39992c85ab --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_8_6/Chassis_V1_8_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_8_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_8_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "8", + "6" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_8_6 *ChassisV1_8_6; + EFI_REDFISH_CHASSIS_V1_8_6_CS *ChassisV1_8_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_8_6_To_CS (ResoruceRaw, &ChassisV1_8_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_8_6 = (EFI_REDFISH_CHASSIS_V1_8_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_8_6)); + if (ChassisV1_8_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_8_6; + ChassisV1_8_6->Chassis = ChassisV1_8_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_8_6_JSON (*((EFI_REDFISH_CHASSIS_V1_8_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_8_6 *ChassisV1_8_6; + + ChassisV1_8_6 = (EFI_REDFISH_CHASSIS_V1_8_6 *)InterpProp; + DestroyChassis_V1_8_6_CS (ChassisV1_8_6->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_8_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_8_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_8_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_8_6/RedfishChassis_V1_8_6_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_8_6/RedfishChassis_V1_8_6_Dxe.inf new file mode 100644 index 00000000000..b21256353c7 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_8_6/RedfishChassis_V1_8_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_8_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_8_6_Dxe + FILE_GUID = d97f06b1-52cf-4054-b766-544a7684c5d6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_8_6EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_8_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_8_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_8_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_9_0/Chassis_V1_9_0_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_9_0/Chassis_V1_9_0_Dxe.c new file mode 100644 index 00000000000..bd607ca761a --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_9_0/Chassis_V1_9_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_9_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_9_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "9", + "0" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_9_0 *ChassisV1_9_0; + EFI_REDFISH_CHASSIS_V1_9_0_CS *ChassisV1_9_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_9_0_To_CS (ResoruceRaw, &ChassisV1_9_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_9_0 = (EFI_REDFISH_CHASSIS_V1_9_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_9_0)); + if (ChassisV1_9_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_9_0; + ChassisV1_9_0->Chassis = ChassisV1_9_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_9_0_JSON (*((EFI_REDFISH_CHASSIS_V1_9_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_9_0 *ChassisV1_9_0; + + ChassisV1_9_0 = (EFI_REDFISH_CHASSIS_V1_9_0 *)InterpProp; + DestroyChassis_V1_9_0_CS (ChassisV1_9_0->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_9_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_9_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_9_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_9_0/RedfishChassis_V1_9_0_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_9_0/RedfishChassis_V1_9_0_Dxe.inf new file mode 100644 index 00000000000..346aaa4b7a0 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_9_0/RedfishChassis_V1_9_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_9_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_9_0_Dxe + FILE_GUID = 4450f3c3-2daf-4bf8-8e24-ce22bb281fd9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_9_0EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_9_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_9_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_9_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_9_1/Chassis_V1_9_1_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_9_1/Chassis_V1_9_1_Dxe.c new file mode 100644 index 00000000000..b33b5e5499b --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_9_1/Chassis_V1_9_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_9_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_9_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "9", + "1" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_9_1 *ChassisV1_9_1; + EFI_REDFISH_CHASSIS_V1_9_1_CS *ChassisV1_9_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_9_1_To_CS (ResoruceRaw, &ChassisV1_9_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_9_1 = (EFI_REDFISH_CHASSIS_V1_9_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_9_1)); + if (ChassisV1_9_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_9_1; + ChassisV1_9_1->Chassis = ChassisV1_9_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_9_1_JSON (*((EFI_REDFISH_CHASSIS_V1_9_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_9_1 *ChassisV1_9_1; + + ChassisV1_9_1 = (EFI_REDFISH_CHASSIS_V1_9_1 *)InterpProp; + DestroyChassis_V1_9_1_CS (ChassisV1_9_1->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_9_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_9_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_9_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_9_1/RedfishChassis_V1_9_1_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_9_1/RedfishChassis_V1_9_1_Dxe.inf new file mode 100644 index 00000000000..88aecedb3f1 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_9_1/RedfishChassis_V1_9_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_9_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_9_1_Dxe + FILE_GUID = 1303f157-418d-4a92-adb8-97dea24ec3ea + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_9_1EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_9_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_9_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_9_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_9_2/Chassis_V1_9_2_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_9_2/Chassis_V1_9_2_Dxe.c new file mode 100644 index 00000000000..be8574da6b0 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_9_2/Chassis_V1_9_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_9_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_9_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "9", + "2" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_9_2 *ChassisV1_9_2; + EFI_REDFISH_CHASSIS_V1_9_2_CS *ChassisV1_9_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_9_2_To_CS (ResoruceRaw, &ChassisV1_9_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_9_2 = (EFI_REDFISH_CHASSIS_V1_9_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_9_2)); + if (ChassisV1_9_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_9_2; + ChassisV1_9_2->Chassis = ChassisV1_9_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_9_2_JSON (*((EFI_REDFISH_CHASSIS_V1_9_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_9_2 *ChassisV1_9_2; + + ChassisV1_9_2 = (EFI_REDFISH_CHASSIS_V1_9_2 *)InterpProp; + DestroyChassis_V1_9_2_CS (ChassisV1_9_2->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_9_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_9_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_9_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_9_2/RedfishChassis_V1_9_2_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_9_2/RedfishChassis_V1_9_2_Dxe.inf new file mode 100644 index 00000000000..87af2ec096e --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_9_2/RedfishChassis_V1_9_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_9_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_9_2_Dxe + FILE_GUID = d4bb8ec4-5bfe-4187-938e-a5bf7c797a62 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_9_2EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_9_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_9_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_9_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_9_3/Chassis_V1_9_3_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_9_3/Chassis_V1_9_3_Dxe.c new file mode 100644 index 00000000000..a23916d8206 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_9_3/Chassis_V1_9_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_9_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_9_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "9", + "3" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_9_3 *ChassisV1_9_3; + EFI_REDFISH_CHASSIS_V1_9_3_CS *ChassisV1_9_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_9_3_To_CS (ResoruceRaw, &ChassisV1_9_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_9_3 = (EFI_REDFISH_CHASSIS_V1_9_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_9_3)); + if (ChassisV1_9_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_9_3; + ChassisV1_9_3->Chassis = ChassisV1_9_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_9_3_JSON (*((EFI_REDFISH_CHASSIS_V1_9_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_9_3 *ChassisV1_9_3; + + ChassisV1_9_3 = (EFI_REDFISH_CHASSIS_V1_9_3 *)InterpProp; + DestroyChassis_V1_9_3_CS (ChassisV1_9_3->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_9_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_9_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_9_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_9_3/RedfishChassis_V1_9_3_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_9_3/RedfishChassis_V1_9_3_Dxe.inf new file mode 100644 index 00000000000..8f64ea30a61 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_9_3/RedfishChassis_V1_9_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_9_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_9_3_Dxe + FILE_GUID = 4ba0bfc5-ab9c-43b1-b698-7baeb88e87ea + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_9_3EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_9_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_9_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_9_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_9_4/Chassis_V1_9_4_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_9_4/Chassis_V1_9_4_Dxe.c new file mode 100644 index 00000000000..2cc947de0ea --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_9_4/Chassis_V1_9_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_9_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_9_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "9", + "4" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_9_4 *ChassisV1_9_4; + EFI_REDFISH_CHASSIS_V1_9_4_CS *ChassisV1_9_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_9_4_To_CS (ResoruceRaw, &ChassisV1_9_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_9_4 = (EFI_REDFISH_CHASSIS_V1_9_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_9_4)); + if (ChassisV1_9_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_9_4; + ChassisV1_9_4->Chassis = ChassisV1_9_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_9_4_JSON (*((EFI_REDFISH_CHASSIS_V1_9_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_9_4 *ChassisV1_9_4; + + ChassisV1_9_4 = (EFI_REDFISH_CHASSIS_V1_9_4 *)InterpProp; + DestroyChassis_V1_9_4_CS (ChassisV1_9_4->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_9_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_9_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_9_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_9_4/RedfishChassis_V1_9_4_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_9_4/RedfishChassis_V1_9_4_Dxe.inf new file mode 100644 index 00000000000..f7edf0ee991 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_9_4/RedfishChassis_V1_9_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_9_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_9_4_Dxe + FILE_GUID = dcab4db9-aa15-4502-98a9-9cdd26280479 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_9_4EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_9_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_9_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_9_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Chassis/v1_9_5/Chassis_V1_9_5_Dxe.c b/RedfishClientPkg/Converter/Chassis/v1_9_5/Chassis_V1_9_5_Dxe.c new file mode 100644 index 00000000000..601ba49acca --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_9_5/Chassis_V1_9_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Chassis.v1_9_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Chassis"; +BOOLEAN IsRevisonController = TRUE; + +// Support Chassis V1_9_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Chassis", + "1", + "9", + "5" + }, + "Chassis" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_9_5 *ChassisV1_9_5; + EFI_REDFISH_CHASSIS_V1_9_5_CS *ChassisV1_9_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Chassis") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Chassis_V1_9_5_To_CS (ResoruceRaw, &ChassisV1_9_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisV1_9_5 = (EFI_REDFISH_CHASSIS_V1_9_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSIS_V1_9_5)); + if (ChassisV1_9_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisV1_9_5; + ChassisV1_9_5->Chassis = ChassisV1_9_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Chassis"), "Chassis"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Chassis")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Chassis"), "Chassis"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Chassis_V1_9_5_JSON (*((EFI_REDFISH_CHASSIS_V1_9_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSIS_V1_9_5 *ChassisV1_9_5; + + ChassisV1_9_5 = (EFI_REDFISH_CHASSIS_V1_9_5 *)InterpProp; + DestroyChassis_V1_9_5_CS (ChassisV1_9_5->Chassis); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassis_V1_9_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_9_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisToStructWrapper, + ChassisToJson, + ChassisDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassis_V1_9_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Chassis/v1_9_5/RedfishChassis_V1_9_5_Dxe.inf b/RedfishClientPkg/Converter/Chassis/v1_9_5/RedfishChassis_V1_9_5_Dxe.inf new file mode 100644 index 00000000000..bf7ac4a09d4 --- /dev/null +++ b/RedfishClientPkg/Converter/Chassis/v1_9_5/RedfishChassis_V1_9_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Chassis.v1_9_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassis_V1_9_5_Dxe + FILE_GUID = cee6795e-42d1-4dba-92a8-35d9dfd4335c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassis_V1_9_5EntryPoint + UNLOAD_IMAGE = RedfishChassis_V1_9_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Chassis_V1_9_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisV1_9_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ChassisCollection/ChassisCollection_Dxe.c b/RedfishClientPkg/Converter/ChassisCollection/ChassisCollection_Dxe.c new file mode 100644 index 00000000000..a7e8c224b43 --- /dev/null +++ b/RedfishClientPkg/Converter/ChassisCollection/ChassisCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ChassisCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ChassisCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support ChassisCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ChassisCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "ChassisCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CHASSISCOLLECTION *ChassisCollection; + EFI_REDFISH_CHASSISCOLLECTION_CS *ChassisCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ChassisCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ChassisCollection_To_CS (ResoruceRaw, &ChassisCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + ChassisCollection = (EFI_REDFISH_CHASSISCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CHASSISCOLLECTION)); + if (ChassisCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ChassisCollection; + ChassisCollection->ChassisCollection = ChassisCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ChassisCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ChassisCollection"), "ChassisCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ChassisCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ChassisCollection"), "ChassisCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ChassisCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ChassisCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ChassisCollection_JSON (*((EFI_REDFISH_CHASSISCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ChassisCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CHASSISCOLLECTION *ChassisCollection; + + ChassisCollection = (EFI_REDFISH_CHASSISCOLLECTION *)InterpProp; + DestroyChassisCollection_CS (ChassisCollection->ChassisCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ChassisCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ChassisCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyChassisCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishChassisCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ChassisCollectionToStructWrapper, + ChassisCollectionToJson, + ChassisCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishChassisCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ChassisCollection/RedfishChassisCollection_Dxe.inf b/RedfishClientPkg/Converter/ChassisCollection/RedfishChassisCollection_Dxe.inf new file mode 100644 index 00000000000..2acb23b296c --- /dev/null +++ b/RedfishClientPkg/Converter/ChassisCollection/RedfishChassisCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ChassisCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishChassisCollection_Dxe + FILE_GUID = 74c37d14-7150-4a75-88ef-e186c0e8eb59 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishChassisCollectionEntryPoint + UNLOAD_IMAGE = RedfishChassisCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ChassisCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ChassisCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Circuit/v1_0_0/Circuit_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Circuit/v1_0_0/Circuit_V1_0_0_Dxe.c new file mode 100644 index 00000000000..31cda0f320f --- /dev/null +++ b/RedfishClientPkg/Converter/Circuit/v1_0_0/Circuit_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Circuit.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Circuit"; +BOOLEAN IsRevisonController = TRUE; + +// Support Circuit V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Circuit", + "1", + "0", + "0" + }, + "Circuit" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CIRCUIT_V1_0_0 *CircuitV1_0_0; + EFI_REDFISH_CIRCUIT_V1_0_0_CS *CircuitV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Circuit") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Circuit_V1_0_0_To_CS (ResoruceRaw, &CircuitV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CircuitV1_0_0 = (EFI_REDFISH_CIRCUIT_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CIRCUIT_V1_0_0)); + if (CircuitV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CircuitV1_0_0; + CircuitV1_0_0->Circuit = CircuitV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Circuit")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Circuit"), "Circuit"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Circuit")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Circuit"), "Circuit"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CircuitToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CircuitToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Circuit_V1_0_0_JSON (*((EFI_REDFISH_CIRCUIT_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CircuitToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CIRCUIT_V1_0_0 *CircuitV1_0_0; + + CircuitV1_0_0 = (EFI_REDFISH_CIRCUIT_V1_0_0 *)InterpProp; + DestroyCircuit_V1_0_0_CS (CircuitV1_0_0->Circuit); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CircuitFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCircuit_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCircuit_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CircuitToStructWrapper, + CircuitToJson, + CircuitDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCircuit_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Circuit/v1_0_0/RedfishCircuit_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Circuit/v1_0_0/RedfishCircuit_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..7ac4c07a5e3 --- /dev/null +++ b/RedfishClientPkg/Converter/Circuit/v1_0_0/RedfishCircuit_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Circuit.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCircuit_V1_0_0_Dxe + FILE_GUID = e2052cab-fbf7-4d8f-aeb7-0486d814bda8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCircuit_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishCircuit_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Circuit_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CircuitV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Circuit/v1_0_1/Circuit_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/Circuit/v1_0_1/Circuit_V1_0_1_Dxe.c new file mode 100644 index 00000000000..2940499710d --- /dev/null +++ b/RedfishClientPkg/Converter/Circuit/v1_0_1/Circuit_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Circuit.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Circuit"; +BOOLEAN IsRevisonController = TRUE; + +// Support Circuit V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Circuit", + "1", + "0", + "1" + }, + "Circuit" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CIRCUIT_V1_0_1 *CircuitV1_0_1; + EFI_REDFISH_CIRCUIT_V1_0_1_CS *CircuitV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Circuit") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Circuit_V1_0_1_To_CS (ResoruceRaw, &CircuitV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CircuitV1_0_1 = (EFI_REDFISH_CIRCUIT_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CIRCUIT_V1_0_1)); + if (CircuitV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CircuitV1_0_1; + CircuitV1_0_1->Circuit = CircuitV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Circuit")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Circuit"), "Circuit"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Circuit")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Circuit"), "Circuit"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CircuitToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CircuitToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Circuit_V1_0_1_JSON (*((EFI_REDFISH_CIRCUIT_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CircuitToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CIRCUIT_V1_0_1 *CircuitV1_0_1; + + CircuitV1_0_1 = (EFI_REDFISH_CIRCUIT_V1_0_1 *)InterpProp; + DestroyCircuit_V1_0_1_CS (CircuitV1_0_1->Circuit); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CircuitFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCircuit_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCircuit_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CircuitToStructWrapper, + CircuitToJson, + CircuitDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCircuit_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Circuit/v1_0_1/RedfishCircuit_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/Circuit/v1_0_1/RedfishCircuit_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..e84d8b74aa1 --- /dev/null +++ b/RedfishClientPkg/Converter/Circuit/v1_0_1/RedfishCircuit_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Circuit.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCircuit_V1_0_1_Dxe + FILE_GUID = 93cbaad6-5a48-4c2d-a93d-8fefdfee43c5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCircuit_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishCircuit_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Circuit_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CircuitV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Circuit/v1_0_2/Circuit_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Circuit/v1_0_2/Circuit_V1_0_2_Dxe.c new file mode 100644 index 00000000000..644ca2aa9fb --- /dev/null +++ b/RedfishClientPkg/Converter/Circuit/v1_0_2/Circuit_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Circuit.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Circuit"; +BOOLEAN IsRevisonController = TRUE; + +// Support Circuit V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Circuit", + "1", + "0", + "2" + }, + "Circuit" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CIRCUIT_V1_0_2 *CircuitV1_0_2; + EFI_REDFISH_CIRCUIT_V1_0_2_CS *CircuitV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Circuit") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Circuit_V1_0_2_To_CS (ResoruceRaw, &CircuitV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CircuitV1_0_2 = (EFI_REDFISH_CIRCUIT_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CIRCUIT_V1_0_2)); + if (CircuitV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CircuitV1_0_2; + CircuitV1_0_2->Circuit = CircuitV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Circuit")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Circuit"), "Circuit"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Circuit")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Circuit"), "Circuit"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CircuitToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CircuitToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Circuit_V1_0_2_JSON (*((EFI_REDFISH_CIRCUIT_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CircuitToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CIRCUIT_V1_0_2 *CircuitV1_0_2; + + CircuitV1_0_2 = (EFI_REDFISH_CIRCUIT_V1_0_2 *)InterpProp; + DestroyCircuit_V1_0_2_CS (CircuitV1_0_2->Circuit); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CircuitFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCircuit_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCircuit_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CircuitToStructWrapper, + CircuitToJson, + CircuitDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCircuit_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Circuit/v1_0_2/RedfishCircuit_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Circuit/v1_0_2/RedfishCircuit_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..6c21eaa140f --- /dev/null +++ b/RedfishClientPkg/Converter/Circuit/v1_0_2/RedfishCircuit_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Circuit.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCircuit_V1_0_2_Dxe + FILE_GUID = a409f323-c54b-4293-9199-d0c07ff8674d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCircuit_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishCircuit_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Circuit_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CircuitV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Circuit/v1_1_0/Circuit_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/Circuit/v1_1_0/Circuit_V1_1_0_Dxe.c new file mode 100644 index 00000000000..216ec5e349f --- /dev/null +++ b/RedfishClientPkg/Converter/Circuit/v1_1_0/Circuit_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Circuit.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Circuit"; +BOOLEAN IsRevisonController = TRUE; + +// Support Circuit V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Circuit", + "1", + "1", + "0" + }, + "Circuit" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CIRCUIT_V1_1_0 *CircuitV1_1_0; + EFI_REDFISH_CIRCUIT_V1_1_0_CS *CircuitV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Circuit") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Circuit_V1_1_0_To_CS (ResoruceRaw, &CircuitV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CircuitV1_1_0 = (EFI_REDFISH_CIRCUIT_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CIRCUIT_V1_1_0)); + if (CircuitV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CircuitV1_1_0; + CircuitV1_1_0->Circuit = CircuitV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Circuit")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Circuit"), "Circuit"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Circuit")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Circuit"), "Circuit"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CircuitToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CircuitToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Circuit_V1_1_0_JSON (*((EFI_REDFISH_CIRCUIT_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CircuitToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CIRCUIT_V1_1_0 *CircuitV1_1_0; + + CircuitV1_1_0 = (EFI_REDFISH_CIRCUIT_V1_1_0 *)InterpProp; + DestroyCircuit_V1_1_0_CS (CircuitV1_1_0->Circuit); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CircuitFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCircuit_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCircuit_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CircuitToStructWrapper, + CircuitToJson, + CircuitDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCircuit_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Circuit/v1_1_0/RedfishCircuit_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/Circuit/v1_1_0/RedfishCircuit_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..59acb86f973 --- /dev/null +++ b/RedfishClientPkg/Converter/Circuit/v1_1_0/RedfishCircuit_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Circuit.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCircuit_V1_1_0_Dxe + FILE_GUID = 97851634-6c3c-4a59-8095-98ef8d911f57 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCircuit_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishCircuit_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Circuit_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CircuitV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Circuit/v1_1_1/Circuit_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/Circuit/v1_1_1/Circuit_V1_1_1_Dxe.c new file mode 100644 index 00000000000..80a06ce14ce --- /dev/null +++ b/RedfishClientPkg/Converter/Circuit/v1_1_1/Circuit_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Circuit.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Circuit"; +BOOLEAN IsRevisonController = TRUE; + +// Support Circuit V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Circuit", + "1", + "1", + "1" + }, + "Circuit" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CIRCUIT_V1_1_1 *CircuitV1_1_1; + EFI_REDFISH_CIRCUIT_V1_1_1_CS *CircuitV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Circuit") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Circuit_V1_1_1_To_CS (ResoruceRaw, &CircuitV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CircuitV1_1_1 = (EFI_REDFISH_CIRCUIT_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CIRCUIT_V1_1_1)); + if (CircuitV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CircuitV1_1_1; + CircuitV1_1_1->Circuit = CircuitV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Circuit")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Circuit"), "Circuit"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Circuit")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Circuit"), "Circuit"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CircuitToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CircuitToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Circuit_V1_1_1_JSON (*((EFI_REDFISH_CIRCUIT_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CircuitToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CIRCUIT_V1_1_1 *CircuitV1_1_1; + + CircuitV1_1_1 = (EFI_REDFISH_CIRCUIT_V1_1_1 *)InterpProp; + DestroyCircuit_V1_1_1_CS (CircuitV1_1_1->Circuit); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CircuitFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCircuit_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCircuit_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CircuitToStructWrapper, + CircuitToJson, + CircuitDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCircuit_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Circuit/v1_1_1/RedfishCircuit_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/Circuit/v1_1_1/RedfishCircuit_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..e920a0ceeaf --- /dev/null +++ b/RedfishClientPkg/Converter/Circuit/v1_1_1/RedfishCircuit_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Circuit.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCircuit_V1_1_1_Dxe + FILE_GUID = 91bc1f2f-c0f8-4a9d-b312-07a3a2064234 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCircuit_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishCircuit_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Circuit_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CircuitV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Circuit/v1_2_0/Circuit_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/Circuit/v1_2_0/Circuit_V1_2_0_Dxe.c new file mode 100644 index 00000000000..56cd73f595d --- /dev/null +++ b/RedfishClientPkg/Converter/Circuit/v1_2_0/Circuit_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Circuit.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Circuit"; +BOOLEAN IsRevisonController = TRUE; + +// Support Circuit V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Circuit", + "1", + "2", + "0" + }, + "Circuit" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CIRCUIT_V1_2_0 *CircuitV1_2_0; + EFI_REDFISH_CIRCUIT_V1_2_0_CS *CircuitV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Circuit") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Circuit_V1_2_0_To_CS (ResoruceRaw, &CircuitV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CircuitV1_2_0 = (EFI_REDFISH_CIRCUIT_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CIRCUIT_V1_2_0)); + if (CircuitV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CircuitV1_2_0; + CircuitV1_2_0->Circuit = CircuitV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Circuit")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Circuit"), "Circuit"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Circuit")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Circuit"), "Circuit"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CircuitToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CircuitToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Circuit_V1_2_0_JSON (*((EFI_REDFISH_CIRCUIT_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CircuitToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CIRCUIT_V1_2_0 *CircuitV1_2_0; + + CircuitV1_2_0 = (EFI_REDFISH_CIRCUIT_V1_2_0 *)InterpProp; + DestroyCircuit_V1_2_0_CS (CircuitV1_2_0->Circuit); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CircuitFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCircuit_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCircuit_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CircuitToStructWrapper, + CircuitToJson, + CircuitDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCircuit_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Circuit/v1_2_0/RedfishCircuit_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/Circuit/v1_2_0/RedfishCircuit_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..5ef12b589a0 --- /dev/null +++ b/RedfishClientPkg/Converter/Circuit/v1_2_0/RedfishCircuit_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Circuit.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCircuit_V1_2_0_Dxe + FILE_GUID = d7c62804-ba07-41e5-9779-83b25cc0250d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCircuit_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishCircuit_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Circuit_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CircuitV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/CircuitCollection/CircuitCollection_Dxe.c b/RedfishClientPkg/Converter/CircuitCollection/CircuitCollection_Dxe.c new file mode 100644 index 00000000000..85a77721e86 --- /dev/null +++ b/RedfishClientPkg/Converter/CircuitCollection/CircuitCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - CircuitCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#CircuitCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support CircuitCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "CircuitCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "CircuitCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CIRCUITCOLLECTION *CircuitCollection; + EFI_REDFISH_CIRCUITCOLLECTION_CS *CircuitCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "CircuitCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_CircuitCollection_To_CS (ResoruceRaw, &CircuitCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + CircuitCollection = (EFI_REDFISH_CIRCUITCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CIRCUITCOLLECTION)); + if (CircuitCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CircuitCollection; + CircuitCollection->CircuitCollection = CircuitCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("CircuitCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("CircuitCollection"), "CircuitCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("CircuitCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("CircuitCollection"), "CircuitCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CircuitCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CircuitCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_CircuitCollection_JSON (*((EFI_REDFISH_CIRCUITCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CircuitCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CIRCUITCOLLECTION *CircuitCollection; + + CircuitCollection = (EFI_REDFISH_CIRCUITCOLLECTION *)InterpProp; + DestroyCircuitCollection_CS (CircuitCollection->CircuitCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CircuitCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CircuitCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCircuitCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCircuitCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CircuitCollectionToStructWrapper, + CircuitCollectionToJson, + CircuitCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCircuitCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/CircuitCollection/RedfishCircuitCollection_Dxe.inf b/RedfishClientPkg/Converter/CircuitCollection/RedfishCircuitCollection_Dxe.inf new file mode 100644 index 00000000000..0cb8337e06b --- /dev/null +++ b/RedfishClientPkg/Converter/CircuitCollection/RedfishCircuitCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of CircuitCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCircuitCollection_Dxe + FILE_GUID = c2c72a28-0198-490c-83fb-4dbb36a45b65 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCircuitCollectionEntryPoint + UNLOAD_IMAGE = RedfishCircuitCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + CircuitCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CircuitCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/CompositionService/v1_0_0/CompositionService_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/CompositionService/v1_0_0/CompositionService_V1_0_0_Dxe.c new file mode 100644 index 00000000000..0c69f0150a9 --- /dev/null +++ b/RedfishClientPkg/Converter/CompositionService/v1_0_0/CompositionService_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - CompositionService.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#CompositionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support CompositionService V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "CompositionService", + "1", + "0", + "0" + }, + "CompositionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPOSITIONSERVICE_V1_0_0 *CompositionServiceV1_0_0; + EFI_REDFISH_COMPOSITIONSERVICE_V1_0_0_CS *CompositionServiceV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "CompositionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_CompositionService_V1_0_0_To_CS (ResoruceRaw, &CompositionServiceV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CompositionServiceV1_0_0 = (EFI_REDFISH_COMPOSITIONSERVICE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPOSITIONSERVICE_V1_0_0)); + if (CompositionServiceV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CompositionServiceV1_0_0; + CompositionServiceV1_0_0->CompositionService = CompositionServiceV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("CompositionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("CompositionService"), "CompositionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("CompositionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("CompositionService"), "CompositionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CompositionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CompositionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_CompositionService_V1_0_0_JSON (*((EFI_REDFISH_COMPOSITIONSERVICE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CompositionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPOSITIONSERVICE_V1_0_0 *CompositionServiceV1_0_0; + + CompositionServiceV1_0_0 = (EFI_REDFISH_COMPOSITIONSERVICE_V1_0_0 *)InterpProp; + DestroyCompositionService_V1_0_0_CS (CompositionServiceV1_0_0->CompositionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CompositionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCompositionService_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCompositionService_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CompositionServiceToStructWrapper, + CompositionServiceToJson, + CompositionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCompositionService_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/CompositionService/v1_0_0/RedfishCompositionService_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/CompositionService/v1_0_0/RedfishCompositionService_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..f155fc23315 --- /dev/null +++ b/RedfishClientPkg/Converter/CompositionService/v1_0_0/RedfishCompositionService_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of CompositionService.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCompositionService_V1_0_0_Dxe + FILE_GUID = 1ebafe86-817e-43a8-96b6-361b5601c35c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCompositionService_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishCompositionService_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + CompositionService_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CompositionServiceV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/CompositionService/v1_0_1/CompositionService_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/CompositionService/v1_0_1/CompositionService_V1_0_1_Dxe.c new file mode 100644 index 00000000000..aae66c06bea --- /dev/null +++ b/RedfishClientPkg/Converter/CompositionService/v1_0_1/CompositionService_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - CompositionService.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#CompositionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support CompositionService V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "CompositionService", + "1", + "0", + "1" + }, + "CompositionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPOSITIONSERVICE_V1_0_1 *CompositionServiceV1_0_1; + EFI_REDFISH_COMPOSITIONSERVICE_V1_0_1_CS *CompositionServiceV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "CompositionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_CompositionService_V1_0_1_To_CS (ResoruceRaw, &CompositionServiceV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CompositionServiceV1_0_1 = (EFI_REDFISH_COMPOSITIONSERVICE_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPOSITIONSERVICE_V1_0_1)); + if (CompositionServiceV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CompositionServiceV1_0_1; + CompositionServiceV1_0_1->CompositionService = CompositionServiceV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("CompositionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("CompositionService"), "CompositionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("CompositionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("CompositionService"), "CompositionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CompositionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CompositionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_CompositionService_V1_0_1_JSON (*((EFI_REDFISH_COMPOSITIONSERVICE_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CompositionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPOSITIONSERVICE_V1_0_1 *CompositionServiceV1_0_1; + + CompositionServiceV1_0_1 = (EFI_REDFISH_COMPOSITIONSERVICE_V1_0_1 *)InterpProp; + DestroyCompositionService_V1_0_1_CS (CompositionServiceV1_0_1->CompositionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CompositionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCompositionService_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCompositionService_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CompositionServiceToStructWrapper, + CompositionServiceToJson, + CompositionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCompositionService_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/CompositionService/v1_0_1/RedfishCompositionService_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/CompositionService/v1_0_1/RedfishCompositionService_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..bda9ca3d6d9 --- /dev/null +++ b/RedfishClientPkg/Converter/CompositionService/v1_0_1/RedfishCompositionService_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of CompositionService.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCompositionService_V1_0_1_Dxe + FILE_GUID = 755d7f08-597c-4810-af0c-2606fdde5c12 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCompositionService_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishCompositionService_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + CompositionService_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CompositionServiceV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/CompositionService/v1_0_2/CompositionService_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/CompositionService/v1_0_2/CompositionService_V1_0_2_Dxe.c new file mode 100644 index 00000000000..193296b2179 --- /dev/null +++ b/RedfishClientPkg/Converter/CompositionService/v1_0_2/CompositionService_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - CompositionService.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#CompositionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support CompositionService V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "CompositionService", + "1", + "0", + "2" + }, + "CompositionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPOSITIONSERVICE_V1_0_2 *CompositionServiceV1_0_2; + EFI_REDFISH_COMPOSITIONSERVICE_V1_0_2_CS *CompositionServiceV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "CompositionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_CompositionService_V1_0_2_To_CS (ResoruceRaw, &CompositionServiceV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CompositionServiceV1_0_2 = (EFI_REDFISH_COMPOSITIONSERVICE_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPOSITIONSERVICE_V1_0_2)); + if (CompositionServiceV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CompositionServiceV1_0_2; + CompositionServiceV1_0_2->CompositionService = CompositionServiceV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("CompositionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("CompositionService"), "CompositionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("CompositionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("CompositionService"), "CompositionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CompositionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CompositionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_CompositionService_V1_0_2_JSON (*((EFI_REDFISH_COMPOSITIONSERVICE_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CompositionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPOSITIONSERVICE_V1_0_2 *CompositionServiceV1_0_2; + + CompositionServiceV1_0_2 = (EFI_REDFISH_COMPOSITIONSERVICE_V1_0_2 *)InterpProp; + DestroyCompositionService_V1_0_2_CS (CompositionServiceV1_0_2->CompositionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CompositionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCompositionService_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCompositionService_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CompositionServiceToStructWrapper, + CompositionServiceToJson, + CompositionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCompositionService_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/CompositionService/v1_0_2/RedfishCompositionService_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/CompositionService/v1_0_2/RedfishCompositionService_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..9f0ced1c36f --- /dev/null +++ b/RedfishClientPkg/Converter/CompositionService/v1_0_2/RedfishCompositionService_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of CompositionService.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCompositionService_V1_0_2_Dxe + FILE_GUID = f83e2b9d-b2b3-46e6-b34e-261e636f1433 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCompositionService_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishCompositionService_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + CompositionService_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CompositionServiceV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/CompositionService/v1_0_3/CompositionService_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/CompositionService/v1_0_3/CompositionService_V1_0_3_Dxe.c new file mode 100644 index 00000000000..1004a4062f1 --- /dev/null +++ b/RedfishClientPkg/Converter/CompositionService/v1_0_3/CompositionService_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - CompositionService.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#CompositionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support CompositionService V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "CompositionService", + "1", + "0", + "3" + }, + "CompositionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPOSITIONSERVICE_V1_0_3 *CompositionServiceV1_0_3; + EFI_REDFISH_COMPOSITIONSERVICE_V1_0_3_CS *CompositionServiceV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "CompositionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_CompositionService_V1_0_3_To_CS (ResoruceRaw, &CompositionServiceV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CompositionServiceV1_0_3 = (EFI_REDFISH_COMPOSITIONSERVICE_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPOSITIONSERVICE_V1_0_3)); + if (CompositionServiceV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CompositionServiceV1_0_3; + CompositionServiceV1_0_3->CompositionService = CompositionServiceV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("CompositionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("CompositionService"), "CompositionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("CompositionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("CompositionService"), "CompositionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CompositionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CompositionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_CompositionService_V1_0_3_JSON (*((EFI_REDFISH_COMPOSITIONSERVICE_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CompositionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPOSITIONSERVICE_V1_0_3 *CompositionServiceV1_0_3; + + CompositionServiceV1_0_3 = (EFI_REDFISH_COMPOSITIONSERVICE_V1_0_3 *)InterpProp; + DestroyCompositionService_V1_0_3_CS (CompositionServiceV1_0_3->CompositionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CompositionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCompositionService_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCompositionService_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CompositionServiceToStructWrapper, + CompositionServiceToJson, + CompositionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCompositionService_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/CompositionService/v1_0_3/RedfishCompositionService_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/CompositionService/v1_0_3/RedfishCompositionService_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..a7f78ea8fdd --- /dev/null +++ b/RedfishClientPkg/Converter/CompositionService/v1_0_3/RedfishCompositionService_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of CompositionService.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCompositionService_V1_0_3_Dxe + FILE_GUID = 02a931d4-9434-4d56-a647-3bfd4d1ccfab + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCompositionService_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishCompositionService_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + CompositionService_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CompositionServiceV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/CompositionService/v1_0_4/CompositionService_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/CompositionService/v1_0_4/CompositionService_V1_0_4_Dxe.c new file mode 100644 index 00000000000..a8821511095 --- /dev/null +++ b/RedfishClientPkg/Converter/CompositionService/v1_0_4/CompositionService_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - CompositionService.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#CompositionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support CompositionService V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "CompositionService", + "1", + "0", + "4" + }, + "CompositionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPOSITIONSERVICE_V1_0_4 *CompositionServiceV1_0_4; + EFI_REDFISH_COMPOSITIONSERVICE_V1_0_4_CS *CompositionServiceV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "CompositionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_CompositionService_V1_0_4_To_CS (ResoruceRaw, &CompositionServiceV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CompositionServiceV1_0_4 = (EFI_REDFISH_COMPOSITIONSERVICE_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPOSITIONSERVICE_V1_0_4)); + if (CompositionServiceV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CompositionServiceV1_0_4; + CompositionServiceV1_0_4->CompositionService = CompositionServiceV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("CompositionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("CompositionService"), "CompositionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("CompositionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("CompositionService"), "CompositionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CompositionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CompositionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_CompositionService_V1_0_4_JSON (*((EFI_REDFISH_COMPOSITIONSERVICE_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CompositionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPOSITIONSERVICE_V1_0_4 *CompositionServiceV1_0_4; + + CompositionServiceV1_0_4 = (EFI_REDFISH_COMPOSITIONSERVICE_V1_0_4 *)InterpProp; + DestroyCompositionService_V1_0_4_CS (CompositionServiceV1_0_4->CompositionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CompositionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCompositionService_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCompositionService_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CompositionServiceToStructWrapper, + CompositionServiceToJson, + CompositionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCompositionService_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/CompositionService/v1_0_4/RedfishCompositionService_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/CompositionService/v1_0_4/RedfishCompositionService_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..022c9a5890c --- /dev/null +++ b/RedfishClientPkg/Converter/CompositionService/v1_0_4/RedfishCompositionService_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of CompositionService.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCompositionService_V1_0_4_Dxe + FILE_GUID = aeec92c0-e177-4818-a298-a9b1bdd84de9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCompositionService_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishCompositionService_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + CompositionService_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CompositionServiceV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/CompositionService/v1_1_0/CompositionService_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/CompositionService/v1_1_0/CompositionService_V1_1_0_Dxe.c new file mode 100644 index 00000000000..9310fd1bd25 --- /dev/null +++ b/RedfishClientPkg/Converter/CompositionService/v1_1_0/CompositionService_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - CompositionService.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#CompositionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support CompositionService V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "CompositionService", + "1", + "1", + "0" + }, + "CompositionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPOSITIONSERVICE_V1_1_0 *CompositionServiceV1_1_0; + EFI_REDFISH_COMPOSITIONSERVICE_V1_1_0_CS *CompositionServiceV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "CompositionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_CompositionService_V1_1_0_To_CS (ResoruceRaw, &CompositionServiceV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CompositionServiceV1_1_0 = (EFI_REDFISH_COMPOSITIONSERVICE_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPOSITIONSERVICE_V1_1_0)); + if (CompositionServiceV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CompositionServiceV1_1_0; + CompositionServiceV1_1_0->CompositionService = CompositionServiceV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("CompositionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("CompositionService"), "CompositionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("CompositionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("CompositionService"), "CompositionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CompositionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CompositionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_CompositionService_V1_1_0_JSON (*((EFI_REDFISH_COMPOSITIONSERVICE_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CompositionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPOSITIONSERVICE_V1_1_0 *CompositionServiceV1_1_0; + + CompositionServiceV1_1_0 = (EFI_REDFISH_COMPOSITIONSERVICE_V1_1_0 *)InterpProp; + DestroyCompositionService_V1_1_0_CS (CompositionServiceV1_1_0->CompositionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CompositionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCompositionService_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCompositionService_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CompositionServiceToStructWrapper, + CompositionServiceToJson, + CompositionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCompositionService_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/CompositionService/v1_1_0/RedfishCompositionService_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/CompositionService/v1_1_0/RedfishCompositionService_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..b669d81db87 --- /dev/null +++ b/RedfishClientPkg/Converter/CompositionService/v1_1_0/RedfishCompositionService_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of CompositionService.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCompositionService_V1_1_0_Dxe + FILE_GUID = 73c6ce9b-56ee-4ca9-a9e4-dea8a344c504 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCompositionService_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishCompositionService_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + CompositionService_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CompositionServiceV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/CompositionService/v1_1_1/CompositionService_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/CompositionService/v1_1_1/CompositionService_V1_1_1_Dxe.c new file mode 100644 index 00000000000..047280b4342 --- /dev/null +++ b/RedfishClientPkg/Converter/CompositionService/v1_1_1/CompositionService_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - CompositionService.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#CompositionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support CompositionService V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "CompositionService", + "1", + "1", + "1" + }, + "CompositionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPOSITIONSERVICE_V1_1_1 *CompositionServiceV1_1_1; + EFI_REDFISH_COMPOSITIONSERVICE_V1_1_1_CS *CompositionServiceV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "CompositionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_CompositionService_V1_1_1_To_CS (ResoruceRaw, &CompositionServiceV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CompositionServiceV1_1_1 = (EFI_REDFISH_COMPOSITIONSERVICE_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPOSITIONSERVICE_V1_1_1)); + if (CompositionServiceV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CompositionServiceV1_1_1; + CompositionServiceV1_1_1->CompositionService = CompositionServiceV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("CompositionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("CompositionService"), "CompositionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("CompositionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("CompositionService"), "CompositionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CompositionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CompositionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_CompositionService_V1_1_1_JSON (*((EFI_REDFISH_COMPOSITIONSERVICE_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CompositionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPOSITIONSERVICE_V1_1_1 *CompositionServiceV1_1_1; + + CompositionServiceV1_1_1 = (EFI_REDFISH_COMPOSITIONSERVICE_V1_1_1 *)InterpProp; + DestroyCompositionService_V1_1_1_CS (CompositionServiceV1_1_1->CompositionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CompositionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCompositionService_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCompositionService_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CompositionServiceToStructWrapper, + CompositionServiceToJson, + CompositionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCompositionService_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/CompositionService/v1_1_1/RedfishCompositionService_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/CompositionService/v1_1_1/RedfishCompositionService_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..d43de1f8759 --- /dev/null +++ b/RedfishClientPkg/Converter/CompositionService/v1_1_1/RedfishCompositionService_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of CompositionService.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCompositionService_V1_1_1_Dxe + FILE_GUID = 8527722f-0c1d-4b32-afac-458cdf0a4cf5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCompositionService_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishCompositionService_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + CompositionService_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CompositionServiceV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/CompositionService/v1_1_2/CompositionService_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/CompositionService/v1_1_2/CompositionService_V1_1_2_Dxe.c new file mode 100644 index 00000000000..11da34c660d --- /dev/null +++ b/RedfishClientPkg/Converter/CompositionService/v1_1_2/CompositionService_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - CompositionService.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#CompositionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support CompositionService V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "CompositionService", + "1", + "1", + "2" + }, + "CompositionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPOSITIONSERVICE_V1_1_2 *CompositionServiceV1_1_2; + EFI_REDFISH_COMPOSITIONSERVICE_V1_1_2_CS *CompositionServiceV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "CompositionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_CompositionService_V1_1_2_To_CS (ResoruceRaw, &CompositionServiceV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + CompositionServiceV1_1_2 = (EFI_REDFISH_COMPOSITIONSERVICE_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPOSITIONSERVICE_V1_1_2)); + if (CompositionServiceV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)CompositionServiceV1_1_2; + CompositionServiceV1_1_2->CompositionService = CompositionServiceV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("CompositionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("CompositionService"), "CompositionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("CompositionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("CompositionService"), "CompositionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of CompositionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return CompositionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_CompositionService_V1_1_2_JSON (*((EFI_REDFISH_COMPOSITIONSERVICE_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in CompositionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPOSITIONSERVICE_V1_1_2 *CompositionServiceV1_1_2; + + CompositionServiceV1_1_2 = (EFI_REDFISH_COMPOSITIONSERVICE_V1_1_2 *)InterpProp; + DestroyCompositionService_V1_1_2_CS (CompositionServiceV1_1_2->CompositionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from CompositionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +CompositionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyCompositionService_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishCompositionService_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + CompositionServiceToStructWrapper, + CompositionServiceToJson, + CompositionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishCompositionService_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/CompositionService/v1_1_2/RedfishCompositionService_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/CompositionService/v1_1_2/RedfishCompositionService_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..9ab375a2648 --- /dev/null +++ b/RedfishClientPkg/Converter/CompositionService/v1_1_2/RedfishCompositionService_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of CompositionService.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishCompositionService_V1_1_2_Dxe + FILE_GUID = a2045e11-b212-4dff-b290-2073d3124ba6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishCompositionService_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishCompositionService_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + CompositionService_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + CompositionServiceV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_0/ComputerSystem_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_0_0/ComputerSystem_V1_0_0_Dxe.c new file mode 100644 index 00000000000..64e5ecc7031 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_0/ComputerSystem_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "0", + "0" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_0 *ComputerSystemV1_0_0; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_0_CS *ComputerSystemV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_0_0_To_CS (ResoruceRaw, &ComputerSystemV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_0_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_0_0)); + if (ComputerSystemV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_0_0; + ComputerSystemV1_0_0->ComputerSystem = ComputerSystemV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_0_0_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_0 *ComputerSystemV1_0_0; + + ComputerSystemV1_0_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_0 *)InterpProp; + DestroyComputerSystem_V1_0_0_CS (ComputerSystemV1_0_0->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_0/RedfishComputerSystem_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_0_0/RedfishComputerSystem_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..ea6f3e59c4c --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_0/RedfishComputerSystem_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_0_0_Dxe + FILE_GUID = a703ebb0-f2ec-4582-98ec-5ff4b1551634 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_1/ComputerSystem_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_0_1/ComputerSystem_V1_0_1_Dxe.c new file mode 100644 index 00000000000..cdb1cd22472 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_1/ComputerSystem_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "0", + "1" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_1 *ComputerSystemV1_0_1; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_1_CS *ComputerSystemV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_0_1_To_CS (ResoruceRaw, &ComputerSystemV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_0_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_0_1)); + if (ComputerSystemV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_0_1; + ComputerSystemV1_0_1->ComputerSystem = ComputerSystemV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_0_1_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_1 *ComputerSystemV1_0_1; + + ComputerSystemV1_0_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_1 *)InterpProp; + DestroyComputerSystem_V1_0_1_CS (ComputerSystemV1_0_1->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_1/RedfishComputerSystem_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_0_1/RedfishComputerSystem_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..fafe99a23a7 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_1/RedfishComputerSystem_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_0_1_Dxe + FILE_GUID = a2ba7e2e-1d05-41a2-8b63-71e8cc00144d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_10/ComputerSystem_V1_0_10_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_0_10/ComputerSystem_V1_0_10_Dxe.c new file mode 100644 index 00000000000..c91fa0df335 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_10/ComputerSystem_V1_0_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_0_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "0", + "10" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_10 *ComputerSystemV1_0_10; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_10_CS *ComputerSystemV1_0_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_0_10_To_CS (ResoruceRaw, &ComputerSystemV1_0_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_0_10 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_0_10)); + if (ComputerSystemV1_0_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_0_10; + ComputerSystemV1_0_10->ComputerSystem = ComputerSystemV1_0_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_0_10_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_0_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_10 *ComputerSystemV1_0_10; + + ComputerSystemV1_0_10 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_10 *)InterpProp; + DestroyComputerSystem_V1_0_10_CS (ComputerSystemV1_0_10->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_0_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_10/RedfishComputerSystem_V1_0_10_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_0_10/RedfishComputerSystem_V1_0_10_Dxe.inf new file mode 100644 index 00000000000..c88fa8d9019 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_10/RedfishComputerSystem_V1_0_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_0_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_0_10_Dxe + FILE_GUID = c601ea85-a3c2-444d-89b9-fc2e81f0b8ca + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_0_10EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_0_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_0_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_0_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_11/ComputerSystem_V1_0_11_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_0_11/ComputerSystem_V1_0_11_Dxe.c new file mode 100644 index 00000000000..ebb5f8613ed --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_11/ComputerSystem_V1_0_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_0_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "0", + "11" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_11 *ComputerSystemV1_0_11; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_11_CS *ComputerSystemV1_0_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_0_11_To_CS (ResoruceRaw, &ComputerSystemV1_0_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_0_11 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_0_11)); + if (ComputerSystemV1_0_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_0_11; + ComputerSystemV1_0_11->ComputerSystem = ComputerSystemV1_0_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_0_11_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_0_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_11 *ComputerSystemV1_0_11; + + ComputerSystemV1_0_11 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_11 *)InterpProp; + DestroyComputerSystem_V1_0_11_CS (ComputerSystemV1_0_11->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_0_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_11/RedfishComputerSystem_V1_0_11_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_0_11/RedfishComputerSystem_V1_0_11_Dxe.inf new file mode 100644 index 00000000000..46db3062535 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_11/RedfishComputerSystem_V1_0_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_0_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_0_11_Dxe + FILE_GUID = 2fd55805-b1af-4ce4-8690-54aa51ab0e99 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_0_11EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_0_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_0_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_0_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_12/ComputerSystem_V1_0_12_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_0_12/ComputerSystem_V1_0_12_Dxe.c new file mode 100644 index 00000000000..2cb10801d89 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_12/ComputerSystem_V1_0_12_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_0_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_0_12 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "0", + "12" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_12 *ComputerSystemV1_0_12; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_12_CS *ComputerSystemV1_0_12Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "12") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_0_12_To_CS (ResoruceRaw, &ComputerSystemV1_0_12Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_0_12 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_12 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_0_12)); + if (ComputerSystemV1_0_12 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_0_12; + ComputerSystemV1_0_12->ComputerSystem = ComputerSystemV1_0_12Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "12"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_0_12_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_0_12_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_12 *ComputerSystemV1_0_12; + + ComputerSystemV1_0_12 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_12 *)InterpProp; + DestroyComputerSystem_V1_0_12_CS (ComputerSystemV1_0_12->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_0_12_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_12EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_12Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_12/RedfishComputerSystem_V1_0_12_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_0_12/RedfishComputerSystem_V1_0_12_Dxe.inf new file mode 100644 index 00000000000..4cdf364b933 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_12/RedfishComputerSystem_V1_0_12_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_0_12 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_0_12_Dxe + FILE_GUID = 1777a7fc-2e2c-471c-b047-ad80f26181d9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_0_12EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_0_12Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_0_12_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_0_12Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_13/ComputerSystem_V1_0_13_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_0_13/ComputerSystem_V1_0_13_Dxe.c new file mode 100644 index 00000000000..8a71b606c45 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_13/ComputerSystem_V1_0_13_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_0_13 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_0_13 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "0", + "13" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_13 *ComputerSystemV1_0_13; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_13_CS *ComputerSystemV1_0_13Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "13") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_0_13_To_CS (ResoruceRaw, &ComputerSystemV1_0_13Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_0_13 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_13 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_0_13)); + if (ComputerSystemV1_0_13 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_0_13; + ComputerSystemV1_0_13->ComputerSystem = ComputerSystemV1_0_13Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "13"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_0_13_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_0_13_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_13 *ComputerSystemV1_0_13; + + ComputerSystemV1_0_13 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_13 *)InterpProp; + DestroyComputerSystem_V1_0_13_CS (ComputerSystemV1_0_13->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_0_13_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_13EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_13Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_13/RedfishComputerSystem_V1_0_13_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_0_13/RedfishComputerSystem_V1_0_13_Dxe.inf new file mode 100644 index 00000000000..7e018d8f59b --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_13/RedfishComputerSystem_V1_0_13_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_0_13 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_0_13_Dxe + FILE_GUID = 8a412203-7024-4069-ab10-2ce870efbe01 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_0_13EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_0_13Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_0_13_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_0_13Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_14/ComputerSystem_V1_0_14_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_0_14/ComputerSystem_V1_0_14_Dxe.c new file mode 100644 index 00000000000..c5124d7ad78 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_14/ComputerSystem_V1_0_14_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_0_14 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_0_14 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "0", + "14" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_14 *ComputerSystemV1_0_14; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_14_CS *ComputerSystemV1_0_14Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "14") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_0_14_To_CS (ResoruceRaw, &ComputerSystemV1_0_14Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_0_14 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_14 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_0_14)); + if (ComputerSystemV1_0_14 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_0_14; + ComputerSystemV1_0_14->ComputerSystem = ComputerSystemV1_0_14Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "14"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_0_14_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_0_14_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_14 *ComputerSystemV1_0_14; + + ComputerSystemV1_0_14 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_14 *)InterpProp; + DestroyComputerSystem_V1_0_14_CS (ComputerSystemV1_0_14->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_0_14_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_14EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_14Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_14/RedfishComputerSystem_V1_0_14_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_0_14/RedfishComputerSystem_V1_0_14_Dxe.inf new file mode 100644 index 00000000000..8ddbc51e6eb --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_14/RedfishComputerSystem_V1_0_14_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_0_14 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_0_14_Dxe + FILE_GUID = 565824db-a99f-4a2f-8477-be359cddc2c5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_0_14EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_0_14Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_0_14_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_0_14Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_15/ComputerSystem_V1_0_15_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_0_15/ComputerSystem_V1_0_15_Dxe.c new file mode 100644 index 00000000000..e01f2576a4d --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_15/ComputerSystem_V1_0_15_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_0_15 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_0_15 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "0", + "15" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_15 *ComputerSystemV1_0_15; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_15_CS *ComputerSystemV1_0_15Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "15") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_0_15_To_CS (ResoruceRaw, &ComputerSystemV1_0_15Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_0_15 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_15 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_0_15)); + if (ComputerSystemV1_0_15 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_0_15; + ComputerSystemV1_0_15->ComputerSystem = ComputerSystemV1_0_15Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "15"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_0_15_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_0_15_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_15 *ComputerSystemV1_0_15; + + ComputerSystemV1_0_15 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_15 *)InterpProp; + DestroyComputerSystem_V1_0_15_CS (ComputerSystemV1_0_15->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_0_15_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_15EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_15Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_15/RedfishComputerSystem_V1_0_15_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_0_15/RedfishComputerSystem_V1_0_15_Dxe.inf new file mode 100644 index 00000000000..94ca651fbbb --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_15/RedfishComputerSystem_V1_0_15_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_0_15 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_0_15_Dxe + FILE_GUID = fd7f22d8-3de2-43f3-861a-dcf06922efef + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_0_15EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_0_15Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_0_15_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_0_15Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_16/ComputerSystem_V1_0_16_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_0_16/ComputerSystem_V1_0_16_Dxe.c new file mode 100644 index 00000000000..ceaacd4fa5c --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_16/ComputerSystem_V1_0_16_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_0_16 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_0_16 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "0", + "16" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_16 *ComputerSystemV1_0_16; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_16_CS *ComputerSystemV1_0_16Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "16") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_0_16_To_CS (ResoruceRaw, &ComputerSystemV1_0_16Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_0_16 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_16 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_0_16)); + if (ComputerSystemV1_0_16 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_0_16; + ComputerSystemV1_0_16->ComputerSystem = ComputerSystemV1_0_16Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "16"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_0_16_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_0_16_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_16 *ComputerSystemV1_0_16; + + ComputerSystemV1_0_16 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_16 *)InterpProp; + DestroyComputerSystem_V1_0_16_CS (ComputerSystemV1_0_16->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_0_16_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_16EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_16Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_16/RedfishComputerSystem_V1_0_16_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_0_16/RedfishComputerSystem_V1_0_16_Dxe.inf new file mode 100644 index 00000000000..73d9378d720 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_16/RedfishComputerSystem_V1_0_16_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_0_16 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_0_16_Dxe + FILE_GUID = 99adb489-8fe9-4388-9bba-bcf0153c56a7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_0_16EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_0_16Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_0_16_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_0_16Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_2/ComputerSystem_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_0_2/ComputerSystem_V1_0_2_Dxe.c new file mode 100644 index 00000000000..cbad0d7333a --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_2/ComputerSystem_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "0", + "2" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_2 *ComputerSystemV1_0_2; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_2_CS *ComputerSystemV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_0_2_To_CS (ResoruceRaw, &ComputerSystemV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_0_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_0_2)); + if (ComputerSystemV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_0_2; + ComputerSystemV1_0_2->ComputerSystem = ComputerSystemV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_0_2_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_2 *ComputerSystemV1_0_2; + + ComputerSystemV1_0_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_2 *)InterpProp; + DestroyComputerSystem_V1_0_2_CS (ComputerSystemV1_0_2->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_2/RedfishComputerSystem_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_0_2/RedfishComputerSystem_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..aca13990540 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_2/RedfishComputerSystem_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_0_2_Dxe + FILE_GUID = 70a9ed83-ac9d-4d63-83a8-6e9873dc9f9f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_3/ComputerSystem_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_0_3/ComputerSystem_V1_0_3_Dxe.c new file mode 100644 index 00000000000..52f0e38e33a --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_3/ComputerSystem_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "0", + "3" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_3 *ComputerSystemV1_0_3; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_3_CS *ComputerSystemV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_0_3_To_CS (ResoruceRaw, &ComputerSystemV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_0_3 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_0_3)); + if (ComputerSystemV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_0_3; + ComputerSystemV1_0_3->ComputerSystem = ComputerSystemV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_0_3_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_3 *ComputerSystemV1_0_3; + + ComputerSystemV1_0_3 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_3 *)InterpProp; + DestroyComputerSystem_V1_0_3_CS (ComputerSystemV1_0_3->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_3/RedfishComputerSystem_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_0_3/RedfishComputerSystem_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..6acc927b026 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_3/RedfishComputerSystem_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_0_3_Dxe + FILE_GUID = d06a7d61-003b-4304-8177-ce217cb35b1a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_4/ComputerSystem_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_0_4/ComputerSystem_V1_0_4_Dxe.c new file mode 100644 index 00000000000..5e5d1baf86d --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_4/ComputerSystem_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "0", + "4" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_4 *ComputerSystemV1_0_4; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_4_CS *ComputerSystemV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_0_4_To_CS (ResoruceRaw, &ComputerSystemV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_0_4 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_0_4)); + if (ComputerSystemV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_0_4; + ComputerSystemV1_0_4->ComputerSystem = ComputerSystemV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_0_4_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_4 *ComputerSystemV1_0_4; + + ComputerSystemV1_0_4 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_4 *)InterpProp; + DestroyComputerSystem_V1_0_4_CS (ComputerSystemV1_0_4->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_4/RedfishComputerSystem_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_0_4/RedfishComputerSystem_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..6970bb62e3b --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_4/RedfishComputerSystem_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_0_4_Dxe + FILE_GUID = b94c7205-3d25-4ea5-bb47-93c3e99497d4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_5/ComputerSystem_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_0_5/ComputerSystem_V1_0_5_Dxe.c new file mode 100644 index 00000000000..5e993aaced6 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_5/ComputerSystem_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "0", + "5" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_5 *ComputerSystemV1_0_5; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_5_CS *ComputerSystemV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_0_5_To_CS (ResoruceRaw, &ComputerSystemV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_0_5 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_0_5)); + if (ComputerSystemV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_0_5; + ComputerSystemV1_0_5->ComputerSystem = ComputerSystemV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_0_5_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_5 *ComputerSystemV1_0_5; + + ComputerSystemV1_0_5 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_5 *)InterpProp; + DestroyComputerSystem_V1_0_5_CS (ComputerSystemV1_0_5->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_5/RedfishComputerSystem_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_0_5/RedfishComputerSystem_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..d70c0332fea --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_5/RedfishComputerSystem_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_0_5_Dxe + FILE_GUID = 7c176ef8-fe3e-4225-9de5-44994f652c82 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_6/ComputerSystem_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_0_6/ComputerSystem_V1_0_6_Dxe.c new file mode 100644 index 00000000000..63e8c387022 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_6/ComputerSystem_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "0", + "6" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_6 *ComputerSystemV1_0_6; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_6_CS *ComputerSystemV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_0_6_To_CS (ResoruceRaw, &ComputerSystemV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_0_6 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_0_6)); + if (ComputerSystemV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_0_6; + ComputerSystemV1_0_6->ComputerSystem = ComputerSystemV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_0_6_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_6 *ComputerSystemV1_0_6; + + ComputerSystemV1_0_6 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_6 *)InterpProp; + DestroyComputerSystem_V1_0_6_CS (ComputerSystemV1_0_6->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_6/RedfishComputerSystem_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_0_6/RedfishComputerSystem_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..d0787df4d4f --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_6/RedfishComputerSystem_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_0_6_Dxe + FILE_GUID = b0715a53-814d-4691-a945-58acd18a7ad3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_7/ComputerSystem_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_0_7/ComputerSystem_V1_0_7_Dxe.c new file mode 100644 index 00000000000..0a8ce6b10e3 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_7/ComputerSystem_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "0", + "7" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_7 *ComputerSystemV1_0_7; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_7_CS *ComputerSystemV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_0_7_To_CS (ResoruceRaw, &ComputerSystemV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_0_7 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_0_7)); + if (ComputerSystemV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_0_7; + ComputerSystemV1_0_7->ComputerSystem = ComputerSystemV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_0_7_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_7 *ComputerSystemV1_0_7; + + ComputerSystemV1_0_7 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_7 *)InterpProp; + DestroyComputerSystem_V1_0_7_CS (ComputerSystemV1_0_7->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_7/RedfishComputerSystem_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_0_7/RedfishComputerSystem_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..a2c33f93bbb --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_7/RedfishComputerSystem_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_0_7_Dxe + FILE_GUID = 19401064-cefb-4d10-b51e-aa0375091264 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_8/ComputerSystem_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_0_8/ComputerSystem_V1_0_8_Dxe.c new file mode 100644 index 00000000000..2f4b6402f24 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_8/ComputerSystem_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "0", + "8" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_8 *ComputerSystemV1_0_8; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_8_CS *ComputerSystemV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_0_8_To_CS (ResoruceRaw, &ComputerSystemV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_0_8 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_0_8)); + if (ComputerSystemV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_0_8; + ComputerSystemV1_0_8->ComputerSystem = ComputerSystemV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_0_8_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_8 *ComputerSystemV1_0_8; + + ComputerSystemV1_0_8 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_8 *)InterpProp; + DestroyComputerSystem_V1_0_8_CS (ComputerSystemV1_0_8->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_8/RedfishComputerSystem_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_0_8/RedfishComputerSystem_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..2b78aa315e2 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_8/RedfishComputerSystem_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_0_8_Dxe + FILE_GUID = 95ff76b4-04c3-438b-8000-fe3d84f46d54 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_9/ComputerSystem_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_0_9/ComputerSystem_V1_0_9_Dxe.c new file mode 100644 index 00000000000..f847ad0452c --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_9/ComputerSystem_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "0", + "9" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_9 *ComputerSystemV1_0_9; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_9_CS *ComputerSystemV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_0_9_To_CS (ResoruceRaw, &ComputerSystemV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_0_9 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_0_9)); + if (ComputerSystemV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_0_9; + ComputerSystemV1_0_9->ComputerSystem = ComputerSystemV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_0_9_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_0_9 *ComputerSystemV1_0_9; + + ComputerSystemV1_0_9 = (EFI_REDFISH_COMPUTERSYSTEM_V1_0_9 *)InterpProp; + DestroyComputerSystem_V1_0_9_CS (ComputerSystemV1_0_9->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_0_9/RedfishComputerSystem_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_0_9/RedfishComputerSystem_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..c67146e315d --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_0_9/RedfishComputerSystem_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_0_9_Dxe + FILE_GUID = ce7f0ded-be7e-4329-ac9f-a70bc26d21ee + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_10_0/ComputerSystem_V1_10_0_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_10_0/ComputerSystem_V1_10_0_Dxe.c new file mode 100644 index 00000000000..19f2db045f8 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_10_0/ComputerSystem_V1_10_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_10_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_10_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "10", + "0" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_10_0 *ComputerSystemV1_10_0; + EFI_REDFISH_COMPUTERSYSTEM_V1_10_0_CS *ComputerSystemV1_10_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_10_0_To_CS (ResoruceRaw, &ComputerSystemV1_10_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_10_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_10_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_10_0)); + if (ComputerSystemV1_10_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_10_0; + ComputerSystemV1_10_0->ComputerSystem = ComputerSystemV1_10_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "10"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_10_0_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_10_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_10_0 *ComputerSystemV1_10_0; + + ComputerSystemV1_10_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_10_0 *)InterpProp; + DestroyComputerSystem_V1_10_0_CS (ComputerSystemV1_10_0->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_10_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_10_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_10_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_10_0/RedfishComputerSystem_V1_10_0_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_10_0/RedfishComputerSystem_V1_10_0_Dxe.inf new file mode 100644 index 00000000000..d9e503d3cb6 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_10_0/RedfishComputerSystem_V1_10_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_10_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_10_0_Dxe + FILE_GUID = 5a564925-30de-47a5-b48f-ca8bf421e9b6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_10_0EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_10_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_10_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_10_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_10_1/ComputerSystem_V1_10_1_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_10_1/ComputerSystem_V1_10_1_Dxe.c new file mode 100644 index 00000000000..b35f255cc51 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_10_1/ComputerSystem_V1_10_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_10_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_10_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "10", + "1" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_10_1 *ComputerSystemV1_10_1; + EFI_REDFISH_COMPUTERSYSTEM_V1_10_1_CS *ComputerSystemV1_10_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_10_1_To_CS (ResoruceRaw, &ComputerSystemV1_10_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_10_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_10_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_10_1)); + if (ComputerSystemV1_10_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_10_1; + ComputerSystemV1_10_1->ComputerSystem = ComputerSystemV1_10_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "10"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_10_1_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_10_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_10_1 *ComputerSystemV1_10_1; + + ComputerSystemV1_10_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_10_1 *)InterpProp; + DestroyComputerSystem_V1_10_1_CS (ComputerSystemV1_10_1->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_10_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_10_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_10_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_10_1/RedfishComputerSystem_V1_10_1_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_10_1/RedfishComputerSystem_V1_10_1_Dxe.inf new file mode 100644 index 00000000000..535340288e1 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_10_1/RedfishComputerSystem_V1_10_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_10_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_10_1_Dxe + FILE_GUID = b0bd1248-f8c7-4959-ae14-910e779b4c6b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_10_1EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_10_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_10_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_10_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_10_2/ComputerSystem_V1_10_2_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_10_2/ComputerSystem_V1_10_2_Dxe.c new file mode 100644 index 00000000000..00d7862f3a2 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_10_2/ComputerSystem_V1_10_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_10_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_10_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "10", + "2" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_10_2 *ComputerSystemV1_10_2; + EFI_REDFISH_COMPUTERSYSTEM_V1_10_2_CS *ComputerSystemV1_10_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_10_2_To_CS (ResoruceRaw, &ComputerSystemV1_10_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_10_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_10_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_10_2)); + if (ComputerSystemV1_10_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_10_2; + ComputerSystemV1_10_2->ComputerSystem = ComputerSystemV1_10_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "10"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_10_2_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_10_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_10_2 *ComputerSystemV1_10_2; + + ComputerSystemV1_10_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_10_2 *)InterpProp; + DestroyComputerSystem_V1_10_2_CS (ComputerSystemV1_10_2->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_10_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_10_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_10_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_10_2/RedfishComputerSystem_V1_10_2_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_10_2/RedfishComputerSystem_V1_10_2_Dxe.inf new file mode 100644 index 00000000000..c47a74ed3cb --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_10_2/RedfishComputerSystem_V1_10_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_10_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_10_2_Dxe + FILE_GUID = fe5526c8-f3fd-4ec7-a70f-13cf632f47f5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_10_2EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_10_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_10_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_10_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_10_3/ComputerSystem_V1_10_3_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_10_3/ComputerSystem_V1_10_3_Dxe.c new file mode 100644 index 00000000000..ac83d6a412f --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_10_3/ComputerSystem_V1_10_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_10_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_10_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "10", + "3" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_10_3 *ComputerSystemV1_10_3; + EFI_REDFISH_COMPUTERSYSTEM_V1_10_3_CS *ComputerSystemV1_10_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_10_3_To_CS (ResoruceRaw, &ComputerSystemV1_10_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_10_3 = (EFI_REDFISH_COMPUTERSYSTEM_V1_10_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_10_3)); + if (ComputerSystemV1_10_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_10_3; + ComputerSystemV1_10_3->ComputerSystem = ComputerSystemV1_10_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "10"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_10_3_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_10_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_10_3 *ComputerSystemV1_10_3; + + ComputerSystemV1_10_3 = (EFI_REDFISH_COMPUTERSYSTEM_V1_10_3 *)InterpProp; + DestroyComputerSystem_V1_10_3_CS (ComputerSystemV1_10_3->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_10_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_10_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_10_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_10_3/RedfishComputerSystem_V1_10_3_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_10_3/RedfishComputerSystem_V1_10_3_Dxe.inf new file mode 100644 index 00000000000..db0d4413075 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_10_3/RedfishComputerSystem_V1_10_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_10_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_10_3_Dxe + FILE_GUID = 202f02d3-82d6-48cd-b101-4a1d4cd84358 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_10_3EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_10_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_10_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_10_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_10_4/ComputerSystem_V1_10_4_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_10_4/ComputerSystem_V1_10_4_Dxe.c new file mode 100644 index 00000000000..f4829a37322 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_10_4/ComputerSystem_V1_10_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_10_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_10_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "10", + "4" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_10_4 *ComputerSystemV1_10_4; + EFI_REDFISH_COMPUTERSYSTEM_V1_10_4_CS *ComputerSystemV1_10_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_10_4_To_CS (ResoruceRaw, &ComputerSystemV1_10_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_10_4 = (EFI_REDFISH_COMPUTERSYSTEM_V1_10_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_10_4)); + if (ComputerSystemV1_10_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_10_4; + ComputerSystemV1_10_4->ComputerSystem = ComputerSystemV1_10_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "10"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_10_4_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_10_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_10_4 *ComputerSystemV1_10_4; + + ComputerSystemV1_10_4 = (EFI_REDFISH_COMPUTERSYSTEM_V1_10_4 *)InterpProp; + DestroyComputerSystem_V1_10_4_CS (ComputerSystemV1_10_4->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_10_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_10_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_10_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_10_4/RedfishComputerSystem_V1_10_4_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_10_4/RedfishComputerSystem_V1_10_4_Dxe.inf new file mode 100644 index 00000000000..187130d6afc --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_10_4/RedfishComputerSystem_V1_10_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_10_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_10_4_Dxe + FILE_GUID = 816855e4-00c4-40fa-afbb-4361b80aeeb9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_10_4EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_10_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_10_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_10_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_11_0/ComputerSystem_V1_11_0_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_11_0/ComputerSystem_V1_11_0_Dxe.c new file mode 100644 index 00000000000..6657f874ec5 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_11_0/ComputerSystem_V1_11_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_11_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_11_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "11", + "0" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_11_0 *ComputerSystemV1_11_0; + EFI_REDFISH_COMPUTERSYSTEM_V1_11_0_CS *ComputerSystemV1_11_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_11_0_To_CS (ResoruceRaw, &ComputerSystemV1_11_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_11_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_11_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_11_0)); + if (ComputerSystemV1_11_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_11_0; + ComputerSystemV1_11_0->ComputerSystem = ComputerSystemV1_11_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "11"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_11_0_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_11_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_11_0 *ComputerSystemV1_11_0; + + ComputerSystemV1_11_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_11_0 *)InterpProp; + DestroyComputerSystem_V1_11_0_CS (ComputerSystemV1_11_0->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_11_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_11_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_11_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_11_0/RedfishComputerSystem_V1_11_0_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_11_0/RedfishComputerSystem_V1_11_0_Dxe.inf new file mode 100644 index 00000000000..253cc830062 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_11_0/RedfishComputerSystem_V1_11_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_11_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_11_0_Dxe + FILE_GUID = fdb67dbd-fbac-442f-8d76-42174733ddef + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_11_0EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_11_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_11_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_11_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_11_1/ComputerSystem_V1_11_1_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_11_1/ComputerSystem_V1_11_1_Dxe.c new file mode 100644 index 00000000000..ba39c5aacac --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_11_1/ComputerSystem_V1_11_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_11_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_11_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "11", + "1" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_11_1 *ComputerSystemV1_11_1; + EFI_REDFISH_COMPUTERSYSTEM_V1_11_1_CS *ComputerSystemV1_11_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_11_1_To_CS (ResoruceRaw, &ComputerSystemV1_11_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_11_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_11_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_11_1)); + if (ComputerSystemV1_11_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_11_1; + ComputerSystemV1_11_1->ComputerSystem = ComputerSystemV1_11_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "11"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_11_1_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_11_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_11_1 *ComputerSystemV1_11_1; + + ComputerSystemV1_11_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_11_1 *)InterpProp; + DestroyComputerSystem_V1_11_1_CS (ComputerSystemV1_11_1->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_11_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_11_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_11_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_11_1/RedfishComputerSystem_V1_11_1_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_11_1/RedfishComputerSystem_V1_11_1_Dxe.inf new file mode 100644 index 00000000000..c0a5c9ed6b2 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_11_1/RedfishComputerSystem_V1_11_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_11_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_11_1_Dxe + FILE_GUID = 7c7e513f-ba5c-43b7-8db0-18bdf1ca75a1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_11_1EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_11_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_11_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_11_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_11_2/ComputerSystem_V1_11_2_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_11_2/ComputerSystem_V1_11_2_Dxe.c new file mode 100644 index 00000000000..d5d0f4a25d6 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_11_2/ComputerSystem_V1_11_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_11_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_11_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "11", + "2" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_11_2 *ComputerSystemV1_11_2; + EFI_REDFISH_COMPUTERSYSTEM_V1_11_2_CS *ComputerSystemV1_11_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_11_2_To_CS (ResoruceRaw, &ComputerSystemV1_11_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_11_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_11_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_11_2)); + if (ComputerSystemV1_11_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_11_2; + ComputerSystemV1_11_2->ComputerSystem = ComputerSystemV1_11_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "11"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_11_2_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_11_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_11_2 *ComputerSystemV1_11_2; + + ComputerSystemV1_11_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_11_2 *)InterpProp; + DestroyComputerSystem_V1_11_2_CS (ComputerSystemV1_11_2->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_11_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_11_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_11_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_11_2/RedfishComputerSystem_V1_11_2_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_11_2/RedfishComputerSystem_V1_11_2_Dxe.inf new file mode 100644 index 00000000000..41a4c09fe7b --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_11_2/RedfishComputerSystem_V1_11_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_11_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_11_2_Dxe + FILE_GUID = ddcb9c3e-f840-4bce-9cd9-967840afb544 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_11_2EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_11_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_11_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_11_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_11_3/ComputerSystem_V1_11_3_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_11_3/ComputerSystem_V1_11_3_Dxe.c new file mode 100644 index 00000000000..374bcbe86da --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_11_3/ComputerSystem_V1_11_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_11_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_11_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "11", + "3" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_11_3 *ComputerSystemV1_11_3; + EFI_REDFISH_COMPUTERSYSTEM_V1_11_3_CS *ComputerSystemV1_11_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_11_3_To_CS (ResoruceRaw, &ComputerSystemV1_11_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_11_3 = (EFI_REDFISH_COMPUTERSYSTEM_V1_11_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_11_3)); + if (ComputerSystemV1_11_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_11_3; + ComputerSystemV1_11_3->ComputerSystem = ComputerSystemV1_11_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "11"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_11_3_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_11_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_11_3 *ComputerSystemV1_11_3; + + ComputerSystemV1_11_3 = (EFI_REDFISH_COMPUTERSYSTEM_V1_11_3 *)InterpProp; + DestroyComputerSystem_V1_11_3_CS (ComputerSystemV1_11_3->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_11_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_11_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_11_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_11_3/RedfishComputerSystem_V1_11_3_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_11_3/RedfishComputerSystem_V1_11_3_Dxe.inf new file mode 100644 index 00000000000..fe03e58cf10 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_11_3/RedfishComputerSystem_V1_11_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_11_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_11_3_Dxe + FILE_GUID = 0eba15f5-1aeb-4245-94ef-1666c8abf7ba + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_11_3EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_11_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_11_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_11_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_12_0/ComputerSystem_V1_12_0_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_12_0/ComputerSystem_V1_12_0_Dxe.c new file mode 100644 index 00000000000..6137aefdeb6 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_12_0/ComputerSystem_V1_12_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_12_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_12_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "12", + "0" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_12_0 *ComputerSystemV1_12_0; + EFI_REDFISH_COMPUTERSYSTEM_V1_12_0_CS *ComputerSystemV1_12_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "12") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_12_0_To_CS (ResoruceRaw, &ComputerSystemV1_12_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_12_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_12_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_12_0)); + if (ComputerSystemV1_12_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_12_0; + ComputerSystemV1_12_0->ComputerSystem = ComputerSystemV1_12_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "12"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_12_0_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_12_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_12_0 *ComputerSystemV1_12_0; + + ComputerSystemV1_12_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_12_0 *)InterpProp; + DestroyComputerSystem_V1_12_0_CS (ComputerSystemV1_12_0->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_12_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_12_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_12_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_12_0/RedfishComputerSystem_V1_12_0_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_12_0/RedfishComputerSystem_V1_12_0_Dxe.inf new file mode 100644 index 00000000000..c6d60edefb2 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_12_0/RedfishComputerSystem_V1_12_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_12_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_12_0_Dxe + FILE_GUID = 45e73aef-bc33-4e34-a904-612d95613a18 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_12_0EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_12_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_12_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_12_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_12_1/ComputerSystem_V1_12_1_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_12_1/ComputerSystem_V1_12_1_Dxe.c new file mode 100644 index 00000000000..77bfbdd7845 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_12_1/ComputerSystem_V1_12_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_12_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_12_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "12", + "1" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_12_1 *ComputerSystemV1_12_1; + EFI_REDFISH_COMPUTERSYSTEM_V1_12_1_CS *ComputerSystemV1_12_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "12") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_12_1_To_CS (ResoruceRaw, &ComputerSystemV1_12_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_12_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_12_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_12_1)); + if (ComputerSystemV1_12_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_12_1; + ComputerSystemV1_12_1->ComputerSystem = ComputerSystemV1_12_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "12"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_12_1_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_12_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_12_1 *ComputerSystemV1_12_1; + + ComputerSystemV1_12_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_12_1 *)InterpProp; + DestroyComputerSystem_V1_12_1_CS (ComputerSystemV1_12_1->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_12_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_12_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_12_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_12_1/RedfishComputerSystem_V1_12_1_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_12_1/RedfishComputerSystem_V1_12_1_Dxe.inf new file mode 100644 index 00000000000..c7caa134eb5 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_12_1/RedfishComputerSystem_V1_12_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_12_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_12_1_Dxe + FILE_GUID = 16b798f4-118d-48e1-92e7-21f1d4bb1219 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_12_1EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_12_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_12_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_12_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_12_2/ComputerSystem_V1_12_2_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_12_2/ComputerSystem_V1_12_2_Dxe.c new file mode 100644 index 00000000000..3b3c631428a --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_12_2/ComputerSystem_V1_12_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_12_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_12_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "12", + "2" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_12_2 *ComputerSystemV1_12_2; + EFI_REDFISH_COMPUTERSYSTEM_V1_12_2_CS *ComputerSystemV1_12_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "12") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_12_2_To_CS (ResoruceRaw, &ComputerSystemV1_12_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_12_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_12_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_12_2)); + if (ComputerSystemV1_12_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_12_2; + ComputerSystemV1_12_2->ComputerSystem = ComputerSystemV1_12_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "12"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_12_2_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_12_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_12_2 *ComputerSystemV1_12_2; + + ComputerSystemV1_12_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_12_2 *)InterpProp; + DestroyComputerSystem_V1_12_2_CS (ComputerSystemV1_12_2->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_12_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_12_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_12_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_12_2/RedfishComputerSystem_V1_12_2_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_12_2/RedfishComputerSystem_V1_12_2_Dxe.inf new file mode 100644 index 00000000000..aec31ef5a60 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_12_2/RedfishComputerSystem_V1_12_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_12_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_12_2_Dxe + FILE_GUID = 4b457e17-27d2-494d-af7c-082136b78ae0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_12_2EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_12_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_12_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_12_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_13_0/ComputerSystem_V1_13_0_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_13_0/ComputerSystem_V1_13_0_Dxe.c new file mode 100644 index 00000000000..a83104479d7 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_13_0/ComputerSystem_V1_13_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_13_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_13_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "13", + "0" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_13_0 *ComputerSystemV1_13_0; + EFI_REDFISH_COMPUTERSYSTEM_V1_13_0_CS *ComputerSystemV1_13_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "13") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_13_0_To_CS (ResoruceRaw, &ComputerSystemV1_13_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_13_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_13_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_13_0)); + if (ComputerSystemV1_13_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_13_0; + ComputerSystemV1_13_0->ComputerSystem = ComputerSystemV1_13_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "13"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_13_0_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_13_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_13_0 *ComputerSystemV1_13_0; + + ComputerSystemV1_13_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_13_0 *)InterpProp; + DestroyComputerSystem_V1_13_0_CS (ComputerSystemV1_13_0->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_13_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_13_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_13_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_13_0/RedfishComputerSystem_V1_13_0_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_13_0/RedfishComputerSystem_V1_13_0_Dxe.inf new file mode 100644 index 00000000000..d1fcce1be30 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_13_0/RedfishComputerSystem_V1_13_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_13_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_13_0_Dxe + FILE_GUID = 93660a20-f906-43c9-aa6a-a5f6c4071891 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_13_0EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_13_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_13_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_13_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_13_1/ComputerSystem_V1_13_1_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_13_1/ComputerSystem_V1_13_1_Dxe.c new file mode 100644 index 00000000000..88f4b6a9dbf --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_13_1/ComputerSystem_V1_13_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_13_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_13_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "13", + "1" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_13_1 *ComputerSystemV1_13_1; + EFI_REDFISH_COMPUTERSYSTEM_V1_13_1_CS *ComputerSystemV1_13_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "13") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_13_1_To_CS (ResoruceRaw, &ComputerSystemV1_13_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_13_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_13_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_13_1)); + if (ComputerSystemV1_13_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_13_1; + ComputerSystemV1_13_1->ComputerSystem = ComputerSystemV1_13_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "13"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_13_1_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_13_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_13_1 *ComputerSystemV1_13_1; + + ComputerSystemV1_13_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_13_1 *)InterpProp; + DestroyComputerSystem_V1_13_1_CS (ComputerSystemV1_13_1->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_13_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_13_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_13_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_13_1/RedfishComputerSystem_V1_13_1_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_13_1/RedfishComputerSystem_V1_13_1_Dxe.inf new file mode 100644 index 00000000000..22383a30f40 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_13_1/RedfishComputerSystem_V1_13_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_13_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_13_1_Dxe + FILE_GUID = 628ad7df-7147-48ff-bbef-b0114ad26aba + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_13_1EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_13_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_13_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_13_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_14_0/ComputerSystem_V1_14_0_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_14_0/ComputerSystem_V1_14_0_Dxe.c new file mode 100644 index 00000000000..74822006f10 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_14_0/ComputerSystem_V1_14_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_14_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_14_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "14", + "0" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_14_0 *ComputerSystemV1_14_0; + EFI_REDFISH_COMPUTERSYSTEM_V1_14_0_CS *ComputerSystemV1_14_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "14") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_14_0_To_CS (ResoruceRaw, &ComputerSystemV1_14_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_14_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_14_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_14_0)); + if (ComputerSystemV1_14_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_14_0; + ComputerSystemV1_14_0->ComputerSystem = ComputerSystemV1_14_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "14"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_14_0_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_14_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_14_0 *ComputerSystemV1_14_0; + + ComputerSystemV1_14_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_14_0 *)InterpProp; + DestroyComputerSystem_V1_14_0_CS (ComputerSystemV1_14_0->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_14_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_14_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_14_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_14_0/RedfishComputerSystem_V1_14_0_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_14_0/RedfishComputerSystem_V1_14_0_Dxe.inf new file mode 100644 index 00000000000..e373404c20c --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_14_0/RedfishComputerSystem_V1_14_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_14_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_14_0_Dxe + FILE_GUID = 42b435b8-184d-4074-a8ca-1ea905638271 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_14_0EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_14_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_14_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_14_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_0/ComputerSystem_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_1_0/ComputerSystem_V1_1_0_Dxe.c new file mode 100644 index 00000000000..667402360cb --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_0/ComputerSystem_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "1", + "0" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_0 *ComputerSystemV1_1_0; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_0_CS *ComputerSystemV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_1_0_To_CS (ResoruceRaw, &ComputerSystemV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_1_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_1_0)); + if (ComputerSystemV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_1_0; + ComputerSystemV1_1_0->ComputerSystem = ComputerSystemV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_1_0_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_0 *ComputerSystemV1_1_0; + + ComputerSystemV1_1_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_0 *)InterpProp; + DestroyComputerSystem_V1_1_0_CS (ComputerSystemV1_1_0->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_0/RedfishComputerSystem_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_1_0/RedfishComputerSystem_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..8985ba1b3d2 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_0/RedfishComputerSystem_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_1_0_Dxe + FILE_GUID = d000e632-f973-4f80-8a9b-5267ac1f593a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_1/ComputerSystem_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_1_1/ComputerSystem_V1_1_1_Dxe.c new file mode 100644 index 00000000000..c629b10e4de --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_1/ComputerSystem_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "1", + "1" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_1 *ComputerSystemV1_1_1; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_1_CS *ComputerSystemV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_1_1_To_CS (ResoruceRaw, &ComputerSystemV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_1_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_1_1)); + if (ComputerSystemV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_1_1; + ComputerSystemV1_1_1->ComputerSystem = ComputerSystemV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_1_1_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_1 *ComputerSystemV1_1_1; + + ComputerSystemV1_1_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_1 *)InterpProp; + DestroyComputerSystem_V1_1_1_CS (ComputerSystemV1_1_1->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_1/RedfishComputerSystem_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_1_1/RedfishComputerSystem_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..b2427bbec11 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_1/RedfishComputerSystem_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_1_1_Dxe + FILE_GUID = 5a463857-7865-4ec1-bc6c-6211c0069816 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_10/ComputerSystem_V1_1_10_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_1_10/ComputerSystem_V1_1_10_Dxe.c new file mode 100644 index 00000000000..149d938e2d7 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_10/ComputerSystem_V1_1_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_1_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_1_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "1", + "10" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_10 *ComputerSystemV1_1_10; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_10_CS *ComputerSystemV1_1_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_1_10_To_CS (ResoruceRaw, &ComputerSystemV1_1_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_1_10 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_1_10)); + if (ComputerSystemV1_1_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_1_10; + ComputerSystemV1_1_10->ComputerSystem = ComputerSystemV1_1_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_1_10_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_1_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_10 *ComputerSystemV1_1_10; + + ComputerSystemV1_1_10 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_10 *)InterpProp; + DestroyComputerSystem_V1_1_10_CS (ComputerSystemV1_1_10->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_1_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_10/RedfishComputerSystem_V1_1_10_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_1_10/RedfishComputerSystem_V1_1_10_Dxe.inf new file mode 100644 index 00000000000..3091567ccc8 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_10/RedfishComputerSystem_V1_1_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_1_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_1_10_Dxe + FILE_GUID = dc3b55ba-f33f-4cca-ab0e-002d7eb08a8d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_1_10EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_1_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_1_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_1_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_11/ComputerSystem_V1_1_11_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_1_11/ComputerSystem_V1_1_11_Dxe.c new file mode 100644 index 00000000000..e0639f182f4 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_11/ComputerSystem_V1_1_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_1_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_1_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "1", + "11" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_11 *ComputerSystemV1_1_11; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_11_CS *ComputerSystemV1_1_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_1_11_To_CS (ResoruceRaw, &ComputerSystemV1_1_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_1_11 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_1_11)); + if (ComputerSystemV1_1_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_1_11; + ComputerSystemV1_1_11->ComputerSystem = ComputerSystemV1_1_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_1_11_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_1_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_11 *ComputerSystemV1_1_11; + + ComputerSystemV1_1_11 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_11 *)InterpProp; + DestroyComputerSystem_V1_1_11_CS (ComputerSystemV1_1_11->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_1_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_11/RedfishComputerSystem_V1_1_11_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_1_11/RedfishComputerSystem_V1_1_11_Dxe.inf new file mode 100644 index 00000000000..c53b07eb8a2 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_11/RedfishComputerSystem_V1_1_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_1_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_1_11_Dxe + FILE_GUID = e3e0ddee-5e0b-47d6-a066-793e174a0f89 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_1_11EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_1_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_1_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_1_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_12/ComputerSystem_V1_1_12_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_1_12/ComputerSystem_V1_1_12_Dxe.c new file mode 100644 index 00000000000..aecf83654ee --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_12/ComputerSystem_V1_1_12_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_1_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_1_12 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "1", + "12" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_12 *ComputerSystemV1_1_12; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_12_CS *ComputerSystemV1_1_12Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "12") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_1_12_To_CS (ResoruceRaw, &ComputerSystemV1_1_12Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_1_12 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_12 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_1_12)); + if (ComputerSystemV1_1_12 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_1_12; + ComputerSystemV1_1_12->ComputerSystem = ComputerSystemV1_1_12Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "12"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_1_12_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_1_12_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_12 *ComputerSystemV1_1_12; + + ComputerSystemV1_1_12 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_12 *)InterpProp; + DestroyComputerSystem_V1_1_12_CS (ComputerSystemV1_1_12->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_1_12_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_12EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_12Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_12/RedfishComputerSystem_V1_1_12_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_1_12/RedfishComputerSystem_V1_1_12_Dxe.inf new file mode 100644 index 00000000000..934de714214 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_12/RedfishComputerSystem_V1_1_12_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_1_12 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_1_12_Dxe + FILE_GUID = 9fa6587a-7c41-4737-a0d4-636e0a6d3b87 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_1_12EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_1_12Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_1_12_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_1_12Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_13/ComputerSystem_V1_1_13_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_1_13/ComputerSystem_V1_1_13_Dxe.c new file mode 100644 index 00000000000..697433857a7 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_13/ComputerSystem_V1_1_13_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_1_13 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_1_13 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "1", + "13" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_13 *ComputerSystemV1_1_13; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_13_CS *ComputerSystemV1_1_13Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "13") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_1_13_To_CS (ResoruceRaw, &ComputerSystemV1_1_13Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_1_13 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_13 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_1_13)); + if (ComputerSystemV1_1_13 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_1_13; + ComputerSystemV1_1_13->ComputerSystem = ComputerSystemV1_1_13Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "13"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_1_13_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_1_13_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_13 *ComputerSystemV1_1_13; + + ComputerSystemV1_1_13 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_13 *)InterpProp; + DestroyComputerSystem_V1_1_13_CS (ComputerSystemV1_1_13->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_1_13_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_13EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_13Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_13/RedfishComputerSystem_V1_1_13_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_1_13/RedfishComputerSystem_V1_1_13_Dxe.inf new file mode 100644 index 00000000000..12ac5a4a813 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_13/RedfishComputerSystem_V1_1_13_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_1_13 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_1_13_Dxe + FILE_GUID = 91f27c8b-67be-4b2f-87d2-869edf6d47cb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_1_13EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_1_13Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_1_13_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_1_13Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_14/ComputerSystem_V1_1_14_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_1_14/ComputerSystem_V1_1_14_Dxe.c new file mode 100644 index 00000000000..8bbfa5099ed --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_14/ComputerSystem_V1_1_14_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_1_14 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_1_14 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "1", + "14" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_14 *ComputerSystemV1_1_14; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_14_CS *ComputerSystemV1_1_14Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "14") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_1_14_To_CS (ResoruceRaw, &ComputerSystemV1_1_14Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_1_14 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_14 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_1_14)); + if (ComputerSystemV1_1_14 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_1_14; + ComputerSystemV1_1_14->ComputerSystem = ComputerSystemV1_1_14Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "14"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_1_14_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_1_14_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_14 *ComputerSystemV1_1_14; + + ComputerSystemV1_1_14 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_14 *)InterpProp; + DestroyComputerSystem_V1_1_14_CS (ComputerSystemV1_1_14->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_1_14_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_14EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_14Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_14/RedfishComputerSystem_V1_1_14_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_1_14/RedfishComputerSystem_V1_1_14_Dxe.inf new file mode 100644 index 00000000000..ddb1deaa921 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_14/RedfishComputerSystem_V1_1_14_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_1_14 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_1_14_Dxe + FILE_GUID = 00b30753-b8b1-4eb3-98ff-cdcccb64f53f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_1_14EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_1_14Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_1_14_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_1_14Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_2/ComputerSystem_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_1_2/ComputerSystem_V1_1_2_Dxe.c new file mode 100644 index 00000000000..1570ea60df8 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_2/ComputerSystem_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "1", + "2" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_2 *ComputerSystemV1_1_2; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_2_CS *ComputerSystemV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_1_2_To_CS (ResoruceRaw, &ComputerSystemV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_1_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_1_2)); + if (ComputerSystemV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_1_2; + ComputerSystemV1_1_2->ComputerSystem = ComputerSystemV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_1_2_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_2 *ComputerSystemV1_1_2; + + ComputerSystemV1_1_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_2 *)InterpProp; + DestroyComputerSystem_V1_1_2_CS (ComputerSystemV1_1_2->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_2/RedfishComputerSystem_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_1_2/RedfishComputerSystem_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..72821c5a0b7 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_2/RedfishComputerSystem_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_1_2_Dxe + FILE_GUID = 01b43af4-d8df-4567-95db-0e1a8b84562e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_3/ComputerSystem_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_1_3/ComputerSystem_V1_1_3_Dxe.c new file mode 100644 index 00000000000..722ab935721 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_3/ComputerSystem_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "1", + "3" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_3 *ComputerSystemV1_1_3; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_3_CS *ComputerSystemV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_1_3_To_CS (ResoruceRaw, &ComputerSystemV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_1_3 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_1_3)); + if (ComputerSystemV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_1_3; + ComputerSystemV1_1_3->ComputerSystem = ComputerSystemV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_1_3_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_3 *ComputerSystemV1_1_3; + + ComputerSystemV1_1_3 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_3 *)InterpProp; + DestroyComputerSystem_V1_1_3_CS (ComputerSystemV1_1_3->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_3/RedfishComputerSystem_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_1_3/RedfishComputerSystem_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..e979773b3b7 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_3/RedfishComputerSystem_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_1_3_Dxe + FILE_GUID = 0c6023f0-a511-4d21-a87f-3e2ff67e2659 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_4/ComputerSystem_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_1_4/ComputerSystem_V1_1_4_Dxe.c new file mode 100644 index 00000000000..3065c6c8975 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_4/ComputerSystem_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "1", + "4" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_4 *ComputerSystemV1_1_4; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_4_CS *ComputerSystemV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_1_4_To_CS (ResoruceRaw, &ComputerSystemV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_1_4 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_1_4)); + if (ComputerSystemV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_1_4; + ComputerSystemV1_1_4->ComputerSystem = ComputerSystemV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_1_4_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_4 *ComputerSystemV1_1_4; + + ComputerSystemV1_1_4 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_4 *)InterpProp; + DestroyComputerSystem_V1_1_4_CS (ComputerSystemV1_1_4->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_4/RedfishComputerSystem_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_1_4/RedfishComputerSystem_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..ee8a38aff17 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_4/RedfishComputerSystem_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_1_4_Dxe + FILE_GUID = aa5053c7-e9ae-45a3-89ab-553c70fd92a6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_5/ComputerSystem_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_1_5/ComputerSystem_V1_1_5_Dxe.c new file mode 100644 index 00000000000..8b5891483a2 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_5/ComputerSystem_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "1", + "5" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_5 *ComputerSystemV1_1_5; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_5_CS *ComputerSystemV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_1_5_To_CS (ResoruceRaw, &ComputerSystemV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_1_5 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_1_5)); + if (ComputerSystemV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_1_5; + ComputerSystemV1_1_5->ComputerSystem = ComputerSystemV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_1_5_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_5 *ComputerSystemV1_1_5; + + ComputerSystemV1_1_5 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_5 *)InterpProp; + DestroyComputerSystem_V1_1_5_CS (ComputerSystemV1_1_5->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_5/RedfishComputerSystem_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_1_5/RedfishComputerSystem_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..e44d2b15442 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_5/RedfishComputerSystem_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_1_5_Dxe + FILE_GUID = 0598e67a-135b-46fd-af29-40c3f07c779f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_6/ComputerSystem_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_1_6/ComputerSystem_V1_1_6_Dxe.c new file mode 100644 index 00000000000..d97dab9ca07 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_6/ComputerSystem_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "1", + "6" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_6 *ComputerSystemV1_1_6; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_6_CS *ComputerSystemV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_1_6_To_CS (ResoruceRaw, &ComputerSystemV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_1_6 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_1_6)); + if (ComputerSystemV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_1_6; + ComputerSystemV1_1_6->ComputerSystem = ComputerSystemV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_1_6_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_6 *ComputerSystemV1_1_6; + + ComputerSystemV1_1_6 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_6 *)InterpProp; + DestroyComputerSystem_V1_1_6_CS (ComputerSystemV1_1_6->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_6/RedfishComputerSystem_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_1_6/RedfishComputerSystem_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..9c2ce1f9524 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_6/RedfishComputerSystem_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_1_6_Dxe + FILE_GUID = bbcff7c3-7803-4dec-bff2-409223578e70 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_7/ComputerSystem_V1_1_7_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_1_7/ComputerSystem_V1_1_7_Dxe.c new file mode 100644 index 00000000000..d05f5c8924d --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_7/ComputerSystem_V1_1_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_1_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "1", + "7" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_7 *ComputerSystemV1_1_7; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_7_CS *ComputerSystemV1_1_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_1_7_To_CS (ResoruceRaw, &ComputerSystemV1_1_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_1_7 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_1_7)); + if (ComputerSystemV1_1_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_1_7; + ComputerSystemV1_1_7->ComputerSystem = ComputerSystemV1_1_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_1_7_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_1_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_7 *ComputerSystemV1_1_7; + + ComputerSystemV1_1_7 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_7 *)InterpProp; + DestroyComputerSystem_V1_1_7_CS (ComputerSystemV1_1_7->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_1_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_7/RedfishComputerSystem_V1_1_7_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_1_7/RedfishComputerSystem_V1_1_7_Dxe.inf new file mode 100644 index 00000000000..fd63d51c074 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_7/RedfishComputerSystem_V1_1_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_1_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_1_7_Dxe + FILE_GUID = 1bc2a1cc-7c4c-4fbe-b2ee-9e3f100b7c65 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_1_7EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_1_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_1_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_1_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_8/ComputerSystem_V1_1_8_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_1_8/ComputerSystem_V1_1_8_Dxe.c new file mode 100644 index 00000000000..8ddcd719af6 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_8/ComputerSystem_V1_1_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_1_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "1", + "8" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_8 *ComputerSystemV1_1_8; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_8_CS *ComputerSystemV1_1_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_1_8_To_CS (ResoruceRaw, &ComputerSystemV1_1_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_1_8 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_1_8)); + if (ComputerSystemV1_1_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_1_8; + ComputerSystemV1_1_8->ComputerSystem = ComputerSystemV1_1_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_1_8_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_1_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_8 *ComputerSystemV1_1_8; + + ComputerSystemV1_1_8 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_8 *)InterpProp; + DestroyComputerSystem_V1_1_8_CS (ComputerSystemV1_1_8->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_1_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_8/RedfishComputerSystem_V1_1_8_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_1_8/RedfishComputerSystem_V1_1_8_Dxe.inf new file mode 100644 index 00000000000..62bf563d126 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_8/RedfishComputerSystem_V1_1_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_1_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_1_8_Dxe + FILE_GUID = 83f31179-9938-4c96-bb62-b03692f935ab + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_1_8EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_1_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_1_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_1_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_9/ComputerSystem_V1_1_9_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_1_9/ComputerSystem_V1_1_9_Dxe.c new file mode 100644 index 00000000000..5b024e1422b --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_9/ComputerSystem_V1_1_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_1_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "1", + "9" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_9 *ComputerSystemV1_1_9; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_9_CS *ComputerSystemV1_1_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_1_9_To_CS (ResoruceRaw, &ComputerSystemV1_1_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_1_9 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_1_9)); + if (ComputerSystemV1_1_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_1_9; + ComputerSystemV1_1_9->ComputerSystem = ComputerSystemV1_1_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_1_9_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_1_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_1_9 *ComputerSystemV1_1_9; + + ComputerSystemV1_1_9 = (EFI_REDFISH_COMPUTERSYSTEM_V1_1_9 *)InterpProp; + DestroyComputerSystem_V1_1_9_CS (ComputerSystemV1_1_9->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_1_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_1_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_1_9/RedfishComputerSystem_V1_1_9_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_1_9/RedfishComputerSystem_V1_1_9_Dxe.inf new file mode 100644 index 00000000000..d4829df72c6 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_1_9/RedfishComputerSystem_V1_1_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_1_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_1_9_Dxe + FILE_GUID = 4b6d0ecb-c539-4722-b9e6-a308ab8b5afb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_1_9EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_1_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_1_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_1_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_0/ComputerSystem_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_2_0/ComputerSystem_V1_2_0_Dxe.c new file mode 100644 index 00000000000..f6fd443850a --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_0/ComputerSystem_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "2", + "0" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_0 *ComputerSystemV1_2_0; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_0_CS *ComputerSystemV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_2_0_To_CS (ResoruceRaw, &ComputerSystemV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_2_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_2_0)); + if (ComputerSystemV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_2_0; + ComputerSystemV1_2_0->ComputerSystem = ComputerSystemV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_2_0_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_0 *ComputerSystemV1_2_0; + + ComputerSystemV1_2_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_0 *)InterpProp; + DestroyComputerSystem_V1_2_0_CS (ComputerSystemV1_2_0->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_0/RedfishComputerSystem_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_2_0/RedfishComputerSystem_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..da61bfeda7b --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_0/RedfishComputerSystem_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_2_0_Dxe + FILE_GUID = 47b5149d-fb4e-47a7-8d24-7f89940941c0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_1/ComputerSystem_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_2_1/ComputerSystem_V1_2_1_Dxe.c new file mode 100644 index 00000000000..5476f6e7cf0 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_1/ComputerSystem_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "2", + "1" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_1 *ComputerSystemV1_2_1; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_1_CS *ComputerSystemV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_2_1_To_CS (ResoruceRaw, &ComputerSystemV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_2_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_2_1)); + if (ComputerSystemV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_2_1; + ComputerSystemV1_2_1->ComputerSystem = ComputerSystemV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_2_1_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_1 *ComputerSystemV1_2_1; + + ComputerSystemV1_2_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_1 *)InterpProp; + DestroyComputerSystem_V1_2_1_CS (ComputerSystemV1_2_1->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_1/RedfishComputerSystem_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_2_1/RedfishComputerSystem_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..64d60aa65d8 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_1/RedfishComputerSystem_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_2_1_Dxe + FILE_GUID = 67116191-ef8b-4ef4-836d-e69a69e8d556 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_10/ComputerSystem_V1_2_10_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_2_10/ComputerSystem_V1_2_10_Dxe.c new file mode 100644 index 00000000000..ec52b143131 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_10/ComputerSystem_V1_2_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_2_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_2_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "2", + "10" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_10 *ComputerSystemV1_2_10; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_10_CS *ComputerSystemV1_2_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_2_10_To_CS (ResoruceRaw, &ComputerSystemV1_2_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_2_10 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_2_10)); + if (ComputerSystemV1_2_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_2_10; + ComputerSystemV1_2_10->ComputerSystem = ComputerSystemV1_2_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_2_10_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_2_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_10 *ComputerSystemV1_2_10; + + ComputerSystemV1_2_10 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_10 *)InterpProp; + DestroyComputerSystem_V1_2_10_CS (ComputerSystemV1_2_10->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_2_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_10/RedfishComputerSystem_V1_2_10_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_2_10/RedfishComputerSystem_V1_2_10_Dxe.inf new file mode 100644 index 00000000000..1af21c9f4d8 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_10/RedfishComputerSystem_V1_2_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_2_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_2_10_Dxe + FILE_GUID = 474f9038-1702-45e5-bb5f-0a75fb535289 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_2_10EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_2_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_2_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_2_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_11/ComputerSystem_V1_2_11_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_2_11/ComputerSystem_V1_2_11_Dxe.c new file mode 100644 index 00000000000..ebcb21147aa --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_11/ComputerSystem_V1_2_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_2_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_2_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "2", + "11" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_11 *ComputerSystemV1_2_11; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_11_CS *ComputerSystemV1_2_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_2_11_To_CS (ResoruceRaw, &ComputerSystemV1_2_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_2_11 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_2_11)); + if (ComputerSystemV1_2_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_2_11; + ComputerSystemV1_2_11->ComputerSystem = ComputerSystemV1_2_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_2_11_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_2_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_11 *ComputerSystemV1_2_11; + + ComputerSystemV1_2_11 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_11 *)InterpProp; + DestroyComputerSystem_V1_2_11_CS (ComputerSystemV1_2_11->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_2_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_11/RedfishComputerSystem_V1_2_11_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_2_11/RedfishComputerSystem_V1_2_11_Dxe.inf new file mode 100644 index 00000000000..9619e48afeb --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_11/RedfishComputerSystem_V1_2_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_2_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_2_11_Dxe + FILE_GUID = 06689d47-74c6-4a0e-8351-21122a02dfa9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_2_11EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_2_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_2_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_2_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_12/ComputerSystem_V1_2_12_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_2_12/ComputerSystem_V1_2_12_Dxe.c new file mode 100644 index 00000000000..6d555cf1501 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_12/ComputerSystem_V1_2_12_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_2_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_2_12 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "2", + "12" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_12 *ComputerSystemV1_2_12; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_12_CS *ComputerSystemV1_2_12Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "12") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_2_12_To_CS (ResoruceRaw, &ComputerSystemV1_2_12Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_2_12 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_12 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_2_12)); + if (ComputerSystemV1_2_12 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_2_12; + ComputerSystemV1_2_12->ComputerSystem = ComputerSystemV1_2_12Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "12"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_2_12_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_2_12_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_12 *ComputerSystemV1_2_12; + + ComputerSystemV1_2_12 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_12 *)InterpProp; + DestroyComputerSystem_V1_2_12_CS (ComputerSystemV1_2_12->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_2_12_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_12EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_12Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_12/RedfishComputerSystem_V1_2_12_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_2_12/RedfishComputerSystem_V1_2_12_Dxe.inf new file mode 100644 index 00000000000..0e36bc9503e --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_12/RedfishComputerSystem_V1_2_12_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_2_12 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_2_12_Dxe + FILE_GUID = ef35f5aa-7989-4747-9b40-ea6bb52121d9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_2_12EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_2_12Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_2_12_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_2_12Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_13/ComputerSystem_V1_2_13_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_2_13/ComputerSystem_V1_2_13_Dxe.c new file mode 100644 index 00000000000..e10f75dd57d --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_13/ComputerSystem_V1_2_13_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_2_13 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_2_13 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "2", + "13" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_13 *ComputerSystemV1_2_13; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_13_CS *ComputerSystemV1_2_13Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "13") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_2_13_To_CS (ResoruceRaw, &ComputerSystemV1_2_13Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_2_13 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_13 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_2_13)); + if (ComputerSystemV1_2_13 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_2_13; + ComputerSystemV1_2_13->ComputerSystem = ComputerSystemV1_2_13Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "13"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_2_13_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_2_13_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_13 *ComputerSystemV1_2_13; + + ComputerSystemV1_2_13 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_13 *)InterpProp; + DestroyComputerSystem_V1_2_13_CS (ComputerSystemV1_2_13->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_2_13_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_13EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_13Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_13/RedfishComputerSystem_V1_2_13_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_2_13/RedfishComputerSystem_V1_2_13_Dxe.inf new file mode 100644 index 00000000000..13ed3b3ab45 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_13/RedfishComputerSystem_V1_2_13_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_2_13 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_2_13_Dxe + FILE_GUID = c70c68e9-6eff-46b7-a200-dc0cc5060481 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_2_13EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_2_13Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_2_13_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_2_13Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_2/ComputerSystem_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_2_2/ComputerSystem_V1_2_2_Dxe.c new file mode 100644 index 00000000000..79d0401b2c3 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_2/ComputerSystem_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "2", + "2" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_2 *ComputerSystemV1_2_2; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_2_CS *ComputerSystemV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_2_2_To_CS (ResoruceRaw, &ComputerSystemV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_2_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_2_2)); + if (ComputerSystemV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_2_2; + ComputerSystemV1_2_2->ComputerSystem = ComputerSystemV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_2_2_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_2 *ComputerSystemV1_2_2; + + ComputerSystemV1_2_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_2 *)InterpProp; + DestroyComputerSystem_V1_2_2_CS (ComputerSystemV1_2_2->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_2/RedfishComputerSystem_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_2_2/RedfishComputerSystem_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..7cbcded2b5a --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_2/RedfishComputerSystem_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_2_2_Dxe + FILE_GUID = 9041819d-d335-4e5d-98ef-52bd4246983a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_3/ComputerSystem_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_2_3/ComputerSystem_V1_2_3_Dxe.c new file mode 100644 index 00000000000..442faea9bdf --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_3/ComputerSystem_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "2", + "3" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_3 *ComputerSystemV1_2_3; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_3_CS *ComputerSystemV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_2_3_To_CS (ResoruceRaw, &ComputerSystemV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_2_3 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_2_3)); + if (ComputerSystemV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_2_3; + ComputerSystemV1_2_3->ComputerSystem = ComputerSystemV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_2_3_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_3 *ComputerSystemV1_2_3; + + ComputerSystemV1_2_3 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_3 *)InterpProp; + DestroyComputerSystem_V1_2_3_CS (ComputerSystemV1_2_3->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_3/RedfishComputerSystem_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_2_3/RedfishComputerSystem_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..2a2112a0ba9 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_3/RedfishComputerSystem_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_2_3_Dxe + FILE_GUID = 10d48f5e-fca4-42f0-a696-ee3d1af252b5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_4/ComputerSystem_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_2_4/ComputerSystem_V1_2_4_Dxe.c new file mode 100644 index 00000000000..8f16ff5b6ca --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_4/ComputerSystem_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "2", + "4" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_4 *ComputerSystemV1_2_4; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_4_CS *ComputerSystemV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_2_4_To_CS (ResoruceRaw, &ComputerSystemV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_2_4 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_2_4)); + if (ComputerSystemV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_2_4; + ComputerSystemV1_2_4->ComputerSystem = ComputerSystemV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_2_4_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_4 *ComputerSystemV1_2_4; + + ComputerSystemV1_2_4 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_4 *)InterpProp; + DestroyComputerSystem_V1_2_4_CS (ComputerSystemV1_2_4->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_4/RedfishComputerSystem_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_2_4/RedfishComputerSystem_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..10dd05f7687 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_4/RedfishComputerSystem_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_2_4_Dxe + FILE_GUID = 43290fe3-0a46-4489-af66-b6ba6c41b587 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_5/ComputerSystem_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_2_5/ComputerSystem_V1_2_5_Dxe.c new file mode 100644 index 00000000000..f4b7f87c09d --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_5/ComputerSystem_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "2", + "5" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_5 *ComputerSystemV1_2_5; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_5_CS *ComputerSystemV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_2_5_To_CS (ResoruceRaw, &ComputerSystemV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_2_5 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_2_5)); + if (ComputerSystemV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_2_5; + ComputerSystemV1_2_5->ComputerSystem = ComputerSystemV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_2_5_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_5 *ComputerSystemV1_2_5; + + ComputerSystemV1_2_5 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_5 *)InterpProp; + DestroyComputerSystem_V1_2_5_CS (ComputerSystemV1_2_5->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_5/RedfishComputerSystem_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_2_5/RedfishComputerSystem_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..dca19e98874 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_5/RedfishComputerSystem_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_2_5_Dxe + FILE_GUID = 4ab8201b-fbd2-4e5b-9ae9-dc5d156c7071 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_6/ComputerSystem_V1_2_6_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_2_6/ComputerSystem_V1_2_6_Dxe.c new file mode 100644 index 00000000000..5d05a7bc524 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_6/ComputerSystem_V1_2_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_2_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "2", + "6" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_6 *ComputerSystemV1_2_6; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_6_CS *ComputerSystemV1_2_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_2_6_To_CS (ResoruceRaw, &ComputerSystemV1_2_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_2_6 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_2_6)); + if (ComputerSystemV1_2_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_2_6; + ComputerSystemV1_2_6->ComputerSystem = ComputerSystemV1_2_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_2_6_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_2_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_6 *ComputerSystemV1_2_6; + + ComputerSystemV1_2_6 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_6 *)InterpProp; + DestroyComputerSystem_V1_2_6_CS (ComputerSystemV1_2_6->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_2_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_6/RedfishComputerSystem_V1_2_6_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_2_6/RedfishComputerSystem_V1_2_6_Dxe.inf new file mode 100644 index 00000000000..8a71969f343 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_6/RedfishComputerSystem_V1_2_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_2_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_2_6_Dxe + FILE_GUID = a3c4599e-cf94-4a11-9f76-44f89805f363 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_2_6EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_2_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_2_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_2_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_7/ComputerSystem_V1_2_7_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_2_7/ComputerSystem_V1_2_7_Dxe.c new file mode 100644 index 00000000000..0c5bf000085 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_7/ComputerSystem_V1_2_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_2_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "2", + "7" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_7 *ComputerSystemV1_2_7; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_7_CS *ComputerSystemV1_2_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_2_7_To_CS (ResoruceRaw, &ComputerSystemV1_2_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_2_7 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_2_7)); + if (ComputerSystemV1_2_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_2_7; + ComputerSystemV1_2_7->ComputerSystem = ComputerSystemV1_2_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_2_7_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_2_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_7 *ComputerSystemV1_2_7; + + ComputerSystemV1_2_7 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_7 *)InterpProp; + DestroyComputerSystem_V1_2_7_CS (ComputerSystemV1_2_7->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_2_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_7/RedfishComputerSystem_V1_2_7_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_2_7/RedfishComputerSystem_V1_2_7_Dxe.inf new file mode 100644 index 00000000000..bbd730296d9 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_7/RedfishComputerSystem_V1_2_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_2_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_2_7_Dxe + FILE_GUID = eb0f54ef-094c-4d05-b541-83f862498067 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_2_7EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_2_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_2_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_2_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_8/ComputerSystem_V1_2_8_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_2_8/ComputerSystem_V1_2_8_Dxe.c new file mode 100644 index 00000000000..1381673bdb4 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_8/ComputerSystem_V1_2_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_2_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "2", + "8" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_8 *ComputerSystemV1_2_8; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_8_CS *ComputerSystemV1_2_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_2_8_To_CS (ResoruceRaw, &ComputerSystemV1_2_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_2_8 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_2_8)); + if (ComputerSystemV1_2_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_2_8; + ComputerSystemV1_2_8->ComputerSystem = ComputerSystemV1_2_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_2_8_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_2_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_8 *ComputerSystemV1_2_8; + + ComputerSystemV1_2_8 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_8 *)InterpProp; + DestroyComputerSystem_V1_2_8_CS (ComputerSystemV1_2_8->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_2_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_8/RedfishComputerSystem_V1_2_8_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_2_8/RedfishComputerSystem_V1_2_8_Dxe.inf new file mode 100644 index 00000000000..9ec3683ac21 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_8/RedfishComputerSystem_V1_2_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_2_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_2_8_Dxe + FILE_GUID = 2cb0c577-38d0-4409-89bf-e61eb9ebceae + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_2_8EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_2_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_2_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_2_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_9/ComputerSystem_V1_2_9_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_2_9/ComputerSystem_V1_2_9_Dxe.c new file mode 100644 index 00000000000..0389cda5842 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_9/ComputerSystem_V1_2_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_2_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_2_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "2", + "9" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_9 *ComputerSystemV1_2_9; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_9_CS *ComputerSystemV1_2_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_2_9_To_CS (ResoruceRaw, &ComputerSystemV1_2_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_2_9 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_2_9)); + if (ComputerSystemV1_2_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_2_9; + ComputerSystemV1_2_9->ComputerSystem = ComputerSystemV1_2_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_2_9_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_2_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_2_9 *ComputerSystemV1_2_9; + + ComputerSystemV1_2_9 = (EFI_REDFISH_COMPUTERSYSTEM_V1_2_9 *)InterpProp; + DestroyComputerSystem_V1_2_9_CS (ComputerSystemV1_2_9->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_2_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_2_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_2_9/RedfishComputerSystem_V1_2_9_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_2_9/RedfishComputerSystem_V1_2_9_Dxe.inf new file mode 100644 index 00000000000..652020aeb6d --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_2_9/RedfishComputerSystem_V1_2_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_2_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_2_9_Dxe + FILE_GUID = 37afb4fa-d46f-42ee-9dad-79ad2f00c0b0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_2_9EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_2_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_2_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_2_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_0/ComputerSystem_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_3_0/ComputerSystem_V1_3_0_Dxe.c new file mode 100644 index 00000000000..8b268d949b8 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_0/ComputerSystem_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "3", + "0" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_0 *ComputerSystemV1_3_0; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_0_CS *ComputerSystemV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_3_0_To_CS (ResoruceRaw, &ComputerSystemV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_3_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_3_0)); + if (ComputerSystemV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_3_0; + ComputerSystemV1_3_0->ComputerSystem = ComputerSystemV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_3_0_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_0 *ComputerSystemV1_3_0; + + ComputerSystemV1_3_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_0 *)InterpProp; + DestroyComputerSystem_V1_3_0_CS (ComputerSystemV1_3_0->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_0/RedfishComputerSystem_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_3_0/RedfishComputerSystem_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..44a2b477173 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_0/RedfishComputerSystem_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_3_0_Dxe + FILE_GUID = 681d0276-0562-436d-b651-aa3ddd8d4e3d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_1/ComputerSystem_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_3_1/ComputerSystem_V1_3_1_Dxe.c new file mode 100644 index 00000000000..7737352021f --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_1/ComputerSystem_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "3", + "1" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_1 *ComputerSystemV1_3_1; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_1_CS *ComputerSystemV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_3_1_To_CS (ResoruceRaw, &ComputerSystemV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_3_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_3_1)); + if (ComputerSystemV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_3_1; + ComputerSystemV1_3_1->ComputerSystem = ComputerSystemV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_3_1_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_1 *ComputerSystemV1_3_1; + + ComputerSystemV1_3_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_1 *)InterpProp; + DestroyComputerSystem_V1_3_1_CS (ComputerSystemV1_3_1->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_1/RedfishComputerSystem_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_3_1/RedfishComputerSystem_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..6a476ebacf7 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_1/RedfishComputerSystem_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_3_1_Dxe + FILE_GUID = 63408398-df01-43ba-8c04-6f878427ed6e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_10/ComputerSystem_V1_3_10_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_3_10/ComputerSystem_V1_3_10_Dxe.c new file mode 100644 index 00000000000..168e810ca6a --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_10/ComputerSystem_V1_3_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_3_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_3_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "3", + "10" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_10 *ComputerSystemV1_3_10; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_10_CS *ComputerSystemV1_3_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_3_10_To_CS (ResoruceRaw, &ComputerSystemV1_3_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_3_10 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_3_10)); + if (ComputerSystemV1_3_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_3_10; + ComputerSystemV1_3_10->ComputerSystem = ComputerSystemV1_3_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_3_10_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_3_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_10 *ComputerSystemV1_3_10; + + ComputerSystemV1_3_10 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_10 *)InterpProp; + DestroyComputerSystem_V1_3_10_CS (ComputerSystemV1_3_10->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_3_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_10/RedfishComputerSystem_V1_3_10_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_3_10/RedfishComputerSystem_V1_3_10_Dxe.inf new file mode 100644 index 00000000000..10f9606aa36 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_10/RedfishComputerSystem_V1_3_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_3_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_3_10_Dxe + FILE_GUID = e92bb487-cfa9-4b7b-ae9a-8715df1ef097 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_3_10EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_3_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_3_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_3_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_11/ComputerSystem_V1_3_11_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_3_11/ComputerSystem_V1_3_11_Dxe.c new file mode 100644 index 00000000000..d34d705da64 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_11/ComputerSystem_V1_3_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_3_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_3_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "3", + "11" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_11 *ComputerSystemV1_3_11; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_11_CS *ComputerSystemV1_3_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_3_11_To_CS (ResoruceRaw, &ComputerSystemV1_3_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_3_11 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_3_11)); + if (ComputerSystemV1_3_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_3_11; + ComputerSystemV1_3_11->ComputerSystem = ComputerSystemV1_3_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_3_11_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_3_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_11 *ComputerSystemV1_3_11; + + ComputerSystemV1_3_11 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_11 *)InterpProp; + DestroyComputerSystem_V1_3_11_CS (ComputerSystemV1_3_11->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_3_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_11/RedfishComputerSystem_V1_3_11_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_3_11/RedfishComputerSystem_V1_3_11_Dxe.inf new file mode 100644 index 00000000000..263839b4e52 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_11/RedfishComputerSystem_V1_3_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_3_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_3_11_Dxe + FILE_GUID = dba99c90-a435-4609-92dd-c92b77ee7b53 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_3_11EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_3_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_3_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_3_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_12/ComputerSystem_V1_3_12_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_3_12/ComputerSystem_V1_3_12_Dxe.c new file mode 100644 index 00000000000..10061bffb4d --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_12/ComputerSystem_V1_3_12_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_3_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_3_12 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "3", + "12" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_12 *ComputerSystemV1_3_12; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_12_CS *ComputerSystemV1_3_12Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "12") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_3_12_To_CS (ResoruceRaw, &ComputerSystemV1_3_12Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_3_12 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_12 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_3_12)); + if (ComputerSystemV1_3_12 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_3_12; + ComputerSystemV1_3_12->ComputerSystem = ComputerSystemV1_3_12Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "12"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_3_12_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_3_12_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_12 *ComputerSystemV1_3_12; + + ComputerSystemV1_3_12 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_12 *)InterpProp; + DestroyComputerSystem_V1_3_12_CS (ComputerSystemV1_3_12->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_3_12_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_12EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_12Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_12/RedfishComputerSystem_V1_3_12_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_3_12/RedfishComputerSystem_V1_3_12_Dxe.inf new file mode 100644 index 00000000000..61304b8bd9d --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_12/RedfishComputerSystem_V1_3_12_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_3_12 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_3_12_Dxe + FILE_GUID = d53d1b5a-d0d0-410d-a09c-c9d0b5baf1b9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_3_12EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_3_12Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_3_12_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_3_12Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_2/ComputerSystem_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_3_2/ComputerSystem_V1_3_2_Dxe.c new file mode 100644 index 00000000000..dda359c7ad4 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_2/ComputerSystem_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "3", + "2" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_2 *ComputerSystemV1_3_2; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_2_CS *ComputerSystemV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_3_2_To_CS (ResoruceRaw, &ComputerSystemV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_3_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_3_2)); + if (ComputerSystemV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_3_2; + ComputerSystemV1_3_2->ComputerSystem = ComputerSystemV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_3_2_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_2 *ComputerSystemV1_3_2; + + ComputerSystemV1_3_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_2 *)InterpProp; + DestroyComputerSystem_V1_3_2_CS (ComputerSystemV1_3_2->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_2/RedfishComputerSystem_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_3_2/RedfishComputerSystem_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..652925ebce4 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_2/RedfishComputerSystem_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_3_2_Dxe + FILE_GUID = 9e7e8f18-8aab-4619-b33f-673ec6766dad + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_3/ComputerSystem_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_3_3/ComputerSystem_V1_3_3_Dxe.c new file mode 100644 index 00000000000..d7233110649 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_3/ComputerSystem_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "3", + "3" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_3 *ComputerSystemV1_3_3; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_3_CS *ComputerSystemV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_3_3_To_CS (ResoruceRaw, &ComputerSystemV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_3_3 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_3_3)); + if (ComputerSystemV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_3_3; + ComputerSystemV1_3_3->ComputerSystem = ComputerSystemV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_3_3_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_3 *ComputerSystemV1_3_3; + + ComputerSystemV1_3_3 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_3 *)InterpProp; + DestroyComputerSystem_V1_3_3_CS (ComputerSystemV1_3_3->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_3/RedfishComputerSystem_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_3_3/RedfishComputerSystem_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..aeced4d14dc --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_3/RedfishComputerSystem_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_3_3_Dxe + FILE_GUID = 265f0e2a-7b2e-4958-b2e1-6d3b93a34993 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_4/ComputerSystem_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_3_4/ComputerSystem_V1_3_4_Dxe.c new file mode 100644 index 00000000000..1569f1ede8b --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_4/ComputerSystem_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "3", + "4" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_4 *ComputerSystemV1_3_4; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_4_CS *ComputerSystemV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_3_4_To_CS (ResoruceRaw, &ComputerSystemV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_3_4 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_3_4)); + if (ComputerSystemV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_3_4; + ComputerSystemV1_3_4->ComputerSystem = ComputerSystemV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_3_4_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_4 *ComputerSystemV1_3_4; + + ComputerSystemV1_3_4 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_4 *)InterpProp; + DestroyComputerSystem_V1_3_4_CS (ComputerSystemV1_3_4->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_4/RedfishComputerSystem_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_3_4/RedfishComputerSystem_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..9f7a657846f --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_4/RedfishComputerSystem_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_3_4_Dxe + FILE_GUID = 07e40abd-b7bd-44d4-b32f-3e6d933d9f69 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_5/ComputerSystem_V1_3_5_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_3_5/ComputerSystem_V1_3_5_Dxe.c new file mode 100644 index 00000000000..503acf30610 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_5/ComputerSystem_V1_3_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_3_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "3", + "5" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_5 *ComputerSystemV1_3_5; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_5_CS *ComputerSystemV1_3_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_3_5_To_CS (ResoruceRaw, &ComputerSystemV1_3_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_3_5 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_3_5)); + if (ComputerSystemV1_3_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_3_5; + ComputerSystemV1_3_5->ComputerSystem = ComputerSystemV1_3_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_3_5_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_3_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_5 *ComputerSystemV1_3_5; + + ComputerSystemV1_3_5 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_5 *)InterpProp; + DestroyComputerSystem_V1_3_5_CS (ComputerSystemV1_3_5->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_3_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_5/RedfishComputerSystem_V1_3_5_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_3_5/RedfishComputerSystem_V1_3_5_Dxe.inf new file mode 100644 index 00000000000..6a972635aee --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_5/RedfishComputerSystem_V1_3_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_3_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_3_5_Dxe + FILE_GUID = c17e8ade-6884-4ed8-aa57-b68e7b5e3c2a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_3_5EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_3_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_3_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_3_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_6/ComputerSystem_V1_3_6_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_3_6/ComputerSystem_V1_3_6_Dxe.c new file mode 100644 index 00000000000..081e337ff14 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_6/ComputerSystem_V1_3_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_3_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "3", + "6" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_6 *ComputerSystemV1_3_6; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_6_CS *ComputerSystemV1_3_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_3_6_To_CS (ResoruceRaw, &ComputerSystemV1_3_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_3_6 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_3_6)); + if (ComputerSystemV1_3_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_3_6; + ComputerSystemV1_3_6->ComputerSystem = ComputerSystemV1_3_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_3_6_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_3_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_6 *ComputerSystemV1_3_6; + + ComputerSystemV1_3_6 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_6 *)InterpProp; + DestroyComputerSystem_V1_3_6_CS (ComputerSystemV1_3_6->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_3_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_6/RedfishComputerSystem_V1_3_6_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_3_6/RedfishComputerSystem_V1_3_6_Dxe.inf new file mode 100644 index 00000000000..9a5ed8a39be --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_6/RedfishComputerSystem_V1_3_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_3_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_3_6_Dxe + FILE_GUID = e66fc82b-f08c-4932-8bb4-f92fb3807a6e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_3_6EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_3_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_3_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_3_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_7/ComputerSystem_V1_3_7_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_3_7/ComputerSystem_V1_3_7_Dxe.c new file mode 100644 index 00000000000..58d1f52a41f --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_7/ComputerSystem_V1_3_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_3_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_3_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "3", + "7" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_7 *ComputerSystemV1_3_7; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_7_CS *ComputerSystemV1_3_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_3_7_To_CS (ResoruceRaw, &ComputerSystemV1_3_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_3_7 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_3_7)); + if (ComputerSystemV1_3_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_3_7; + ComputerSystemV1_3_7->ComputerSystem = ComputerSystemV1_3_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_3_7_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_3_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_7 *ComputerSystemV1_3_7; + + ComputerSystemV1_3_7 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_7 *)InterpProp; + DestroyComputerSystem_V1_3_7_CS (ComputerSystemV1_3_7->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_3_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_7/RedfishComputerSystem_V1_3_7_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_3_7/RedfishComputerSystem_V1_3_7_Dxe.inf new file mode 100644 index 00000000000..047626c9a56 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_7/RedfishComputerSystem_V1_3_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_3_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_3_7_Dxe + FILE_GUID = 79021add-0da8-41e7-be30-82d784f3adbb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_3_7EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_3_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_3_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_3_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_8/ComputerSystem_V1_3_8_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_3_8/ComputerSystem_V1_3_8_Dxe.c new file mode 100644 index 00000000000..ab3578fc006 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_8/ComputerSystem_V1_3_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_3_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_3_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "3", + "8" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_8 *ComputerSystemV1_3_8; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_8_CS *ComputerSystemV1_3_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_3_8_To_CS (ResoruceRaw, &ComputerSystemV1_3_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_3_8 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_3_8)); + if (ComputerSystemV1_3_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_3_8; + ComputerSystemV1_3_8->ComputerSystem = ComputerSystemV1_3_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_3_8_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_3_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_8 *ComputerSystemV1_3_8; + + ComputerSystemV1_3_8 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_8 *)InterpProp; + DestroyComputerSystem_V1_3_8_CS (ComputerSystemV1_3_8->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_3_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_8/RedfishComputerSystem_V1_3_8_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_3_8/RedfishComputerSystem_V1_3_8_Dxe.inf new file mode 100644 index 00000000000..172ef68f6d8 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_8/RedfishComputerSystem_V1_3_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_3_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_3_8_Dxe + FILE_GUID = bdcabf8e-4fa5-42b4-8e7a-8f9f2001a31c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_3_8EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_3_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_3_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_3_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_9/ComputerSystem_V1_3_9_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_3_9/ComputerSystem_V1_3_9_Dxe.c new file mode 100644 index 00000000000..e1b138a0d6a --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_9/ComputerSystem_V1_3_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_3_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_3_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "3", + "9" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_9 *ComputerSystemV1_3_9; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_9_CS *ComputerSystemV1_3_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_3_9_To_CS (ResoruceRaw, &ComputerSystemV1_3_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_3_9 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_3_9)); + if (ComputerSystemV1_3_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_3_9; + ComputerSystemV1_3_9->ComputerSystem = ComputerSystemV1_3_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_3_9_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_3_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_3_9 *ComputerSystemV1_3_9; + + ComputerSystemV1_3_9 = (EFI_REDFISH_COMPUTERSYSTEM_V1_3_9 *)InterpProp; + DestroyComputerSystem_V1_3_9_CS (ComputerSystemV1_3_9->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_3_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_3_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_3_9/RedfishComputerSystem_V1_3_9_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_3_9/RedfishComputerSystem_V1_3_9_Dxe.inf new file mode 100644 index 00000000000..1d4ad278a4f --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_3_9/RedfishComputerSystem_V1_3_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_3_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_3_9_Dxe + FILE_GUID = c1ed5e6f-9ae2-443e-96b2-8acc00909abd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_3_9EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_3_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_3_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_3_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_4_0/ComputerSystem_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_4_0/ComputerSystem_V1_4_0_Dxe.c new file mode 100644 index 00000000000..119295149be --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_4_0/ComputerSystem_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "4", + "0" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_4_0 *ComputerSystemV1_4_0; + EFI_REDFISH_COMPUTERSYSTEM_V1_4_0_CS *ComputerSystemV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_4_0_To_CS (ResoruceRaw, &ComputerSystemV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_4_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_4_0)); + if (ComputerSystemV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_4_0; + ComputerSystemV1_4_0->ComputerSystem = ComputerSystemV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_4_0_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_4_0 *ComputerSystemV1_4_0; + + ComputerSystemV1_4_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_4_0 *)InterpProp; + DestroyComputerSystem_V1_4_0_CS (ComputerSystemV1_4_0->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_4_0/RedfishComputerSystem_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_4_0/RedfishComputerSystem_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..eecceff9134 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_4_0/RedfishComputerSystem_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_4_0_Dxe + FILE_GUID = c825a1fc-1c73-4f0e-89e3-c7c1129e8997 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_4_1/ComputerSystem_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_4_1/ComputerSystem_V1_4_1_Dxe.c new file mode 100644 index 00000000000..ad30f323ba5 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_4_1/ComputerSystem_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "4", + "1" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_4_1 *ComputerSystemV1_4_1; + EFI_REDFISH_COMPUTERSYSTEM_V1_4_1_CS *ComputerSystemV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_4_1_To_CS (ResoruceRaw, &ComputerSystemV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_4_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_4_1)); + if (ComputerSystemV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_4_1; + ComputerSystemV1_4_1->ComputerSystem = ComputerSystemV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_4_1_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_4_1 *ComputerSystemV1_4_1; + + ComputerSystemV1_4_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_4_1 *)InterpProp; + DestroyComputerSystem_V1_4_1_CS (ComputerSystemV1_4_1->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_4_1/RedfishComputerSystem_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_4_1/RedfishComputerSystem_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..00aad8dd351 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_4_1/RedfishComputerSystem_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_4_1_Dxe + FILE_GUID = 5bce9fcb-fe60-47de-8a0f-14d5deb8d6b3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_4_10/ComputerSystem_V1_4_10_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_4_10/ComputerSystem_V1_4_10_Dxe.c new file mode 100644 index 00000000000..44ca6c8701d --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_4_10/ComputerSystem_V1_4_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_4_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_4_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "4", + "10" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_4_10 *ComputerSystemV1_4_10; + EFI_REDFISH_COMPUTERSYSTEM_V1_4_10_CS *ComputerSystemV1_4_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_4_10_To_CS (ResoruceRaw, &ComputerSystemV1_4_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_4_10 = (EFI_REDFISH_COMPUTERSYSTEM_V1_4_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_4_10)); + if (ComputerSystemV1_4_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_4_10; + ComputerSystemV1_4_10->ComputerSystem = ComputerSystemV1_4_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_4_10_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_4_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_4_10 *ComputerSystemV1_4_10; + + ComputerSystemV1_4_10 = (EFI_REDFISH_COMPUTERSYSTEM_V1_4_10 *)InterpProp; + DestroyComputerSystem_V1_4_10_CS (ComputerSystemV1_4_10->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_4_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_4_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_4_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_4_10/RedfishComputerSystem_V1_4_10_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_4_10/RedfishComputerSystem_V1_4_10_Dxe.inf new file mode 100644 index 00000000000..285dc555fb9 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_4_10/RedfishComputerSystem_V1_4_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_4_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_4_10_Dxe + FILE_GUID = 823e0924-578a-403f-ac65-28514b0a5db9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_4_10EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_4_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_4_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_4_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_4_11/ComputerSystem_V1_4_11_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_4_11/ComputerSystem_V1_4_11_Dxe.c new file mode 100644 index 00000000000..bb839cd423c --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_4_11/ComputerSystem_V1_4_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_4_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_4_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "4", + "11" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_4_11 *ComputerSystemV1_4_11; + EFI_REDFISH_COMPUTERSYSTEM_V1_4_11_CS *ComputerSystemV1_4_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_4_11_To_CS (ResoruceRaw, &ComputerSystemV1_4_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_4_11 = (EFI_REDFISH_COMPUTERSYSTEM_V1_4_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_4_11)); + if (ComputerSystemV1_4_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_4_11; + ComputerSystemV1_4_11->ComputerSystem = ComputerSystemV1_4_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_4_11_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_4_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_4_11 *ComputerSystemV1_4_11; + + ComputerSystemV1_4_11 = (EFI_REDFISH_COMPUTERSYSTEM_V1_4_11 *)InterpProp; + DestroyComputerSystem_V1_4_11_CS (ComputerSystemV1_4_11->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_4_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_4_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_4_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_4_11/RedfishComputerSystem_V1_4_11_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_4_11/RedfishComputerSystem_V1_4_11_Dxe.inf new file mode 100644 index 00000000000..4f4d4b5ec44 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_4_11/RedfishComputerSystem_V1_4_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_4_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_4_11_Dxe + FILE_GUID = c14632fc-e98e-4225-aeb1-c314f6f703c1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_4_11EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_4_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_4_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_4_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_4_2/ComputerSystem_V1_4_2_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_4_2/ComputerSystem_V1_4_2_Dxe.c new file mode 100644 index 00000000000..f00bb8e4930 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_4_2/ComputerSystem_V1_4_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_4_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "4", + "2" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_4_2 *ComputerSystemV1_4_2; + EFI_REDFISH_COMPUTERSYSTEM_V1_4_2_CS *ComputerSystemV1_4_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_4_2_To_CS (ResoruceRaw, &ComputerSystemV1_4_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_4_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_4_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_4_2)); + if (ComputerSystemV1_4_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_4_2; + ComputerSystemV1_4_2->ComputerSystem = ComputerSystemV1_4_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_4_2_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_4_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_4_2 *ComputerSystemV1_4_2; + + ComputerSystemV1_4_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_4_2 *)InterpProp; + DestroyComputerSystem_V1_4_2_CS (ComputerSystemV1_4_2->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_4_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_4_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_4_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_4_2/RedfishComputerSystem_V1_4_2_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_4_2/RedfishComputerSystem_V1_4_2_Dxe.inf new file mode 100644 index 00000000000..1f7082b0765 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_4_2/RedfishComputerSystem_V1_4_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_4_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_4_2_Dxe + FILE_GUID = 8c5090bd-5717-4fc9-8484-a363d4c006ec + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_4_2EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_4_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_4_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_4_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_4_3/ComputerSystem_V1_4_3_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_4_3/ComputerSystem_V1_4_3_Dxe.c new file mode 100644 index 00000000000..4730e4e927e --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_4_3/ComputerSystem_V1_4_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_4_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "4", + "3" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_4_3 *ComputerSystemV1_4_3; + EFI_REDFISH_COMPUTERSYSTEM_V1_4_3_CS *ComputerSystemV1_4_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_4_3_To_CS (ResoruceRaw, &ComputerSystemV1_4_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_4_3 = (EFI_REDFISH_COMPUTERSYSTEM_V1_4_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_4_3)); + if (ComputerSystemV1_4_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_4_3; + ComputerSystemV1_4_3->ComputerSystem = ComputerSystemV1_4_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_4_3_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_4_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_4_3 *ComputerSystemV1_4_3; + + ComputerSystemV1_4_3 = (EFI_REDFISH_COMPUTERSYSTEM_V1_4_3 *)InterpProp; + DestroyComputerSystem_V1_4_3_CS (ComputerSystemV1_4_3->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_4_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_4_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_4_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_4_3/RedfishComputerSystem_V1_4_3_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_4_3/RedfishComputerSystem_V1_4_3_Dxe.inf new file mode 100644 index 00000000000..68cdade9045 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_4_3/RedfishComputerSystem_V1_4_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_4_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_4_3_Dxe + FILE_GUID = 58b1689e-7511-4c19-9829-88cb82a3ace3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_4_3EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_4_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_4_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_4_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_4_4/ComputerSystem_V1_4_4_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_4_4/ComputerSystem_V1_4_4_Dxe.c new file mode 100644 index 00000000000..351a2885630 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_4_4/ComputerSystem_V1_4_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_4_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "4", + "4" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_4_4 *ComputerSystemV1_4_4; + EFI_REDFISH_COMPUTERSYSTEM_V1_4_4_CS *ComputerSystemV1_4_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_4_4_To_CS (ResoruceRaw, &ComputerSystemV1_4_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_4_4 = (EFI_REDFISH_COMPUTERSYSTEM_V1_4_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_4_4)); + if (ComputerSystemV1_4_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_4_4; + ComputerSystemV1_4_4->ComputerSystem = ComputerSystemV1_4_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_4_4_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_4_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_4_4 *ComputerSystemV1_4_4; + + ComputerSystemV1_4_4 = (EFI_REDFISH_COMPUTERSYSTEM_V1_4_4 *)InterpProp; + DestroyComputerSystem_V1_4_4_CS (ComputerSystemV1_4_4->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_4_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_4_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_4_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_4_4/RedfishComputerSystem_V1_4_4_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_4_4/RedfishComputerSystem_V1_4_4_Dxe.inf new file mode 100644 index 00000000000..c18fe36ddf5 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_4_4/RedfishComputerSystem_V1_4_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_4_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_4_4_Dxe + FILE_GUID = ff10820f-6f30-487d-809e-a757bb1afa27 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_4_4EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_4_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_4_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_4_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_4_5/ComputerSystem_V1_4_5_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_4_5/ComputerSystem_V1_4_5_Dxe.c new file mode 100644 index 00000000000..436b9e848a0 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_4_5/ComputerSystem_V1_4_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_4_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "4", + "5" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_4_5 *ComputerSystemV1_4_5; + EFI_REDFISH_COMPUTERSYSTEM_V1_4_5_CS *ComputerSystemV1_4_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_4_5_To_CS (ResoruceRaw, &ComputerSystemV1_4_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_4_5 = (EFI_REDFISH_COMPUTERSYSTEM_V1_4_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_4_5)); + if (ComputerSystemV1_4_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_4_5; + ComputerSystemV1_4_5->ComputerSystem = ComputerSystemV1_4_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_4_5_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_4_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_4_5 *ComputerSystemV1_4_5; + + ComputerSystemV1_4_5 = (EFI_REDFISH_COMPUTERSYSTEM_V1_4_5 *)InterpProp; + DestroyComputerSystem_V1_4_5_CS (ComputerSystemV1_4_5->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_4_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_4_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_4_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_4_5/RedfishComputerSystem_V1_4_5_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_4_5/RedfishComputerSystem_V1_4_5_Dxe.inf new file mode 100644 index 00000000000..4e6249cf831 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_4_5/RedfishComputerSystem_V1_4_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_4_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_4_5_Dxe + FILE_GUID = 1e609245-1865-4977-9b5e-337e9a755442 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_4_5EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_4_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_4_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_4_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_4_6/ComputerSystem_V1_4_6_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_4_6/ComputerSystem_V1_4_6_Dxe.c new file mode 100644 index 00000000000..9f40330806f --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_4_6/ComputerSystem_V1_4_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_4_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_4_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "4", + "6" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_4_6 *ComputerSystemV1_4_6; + EFI_REDFISH_COMPUTERSYSTEM_V1_4_6_CS *ComputerSystemV1_4_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_4_6_To_CS (ResoruceRaw, &ComputerSystemV1_4_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_4_6 = (EFI_REDFISH_COMPUTERSYSTEM_V1_4_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_4_6)); + if (ComputerSystemV1_4_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_4_6; + ComputerSystemV1_4_6->ComputerSystem = ComputerSystemV1_4_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_4_6_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_4_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_4_6 *ComputerSystemV1_4_6; + + ComputerSystemV1_4_6 = (EFI_REDFISH_COMPUTERSYSTEM_V1_4_6 *)InterpProp; + DestroyComputerSystem_V1_4_6_CS (ComputerSystemV1_4_6->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_4_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_4_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_4_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_4_6/RedfishComputerSystem_V1_4_6_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_4_6/RedfishComputerSystem_V1_4_6_Dxe.inf new file mode 100644 index 00000000000..469fe9a3e97 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_4_6/RedfishComputerSystem_V1_4_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_4_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_4_6_Dxe + FILE_GUID = 33ac094f-31d2-4981-baff-8f5aa2c311bf + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_4_6EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_4_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_4_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_4_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_4_7/ComputerSystem_V1_4_7_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_4_7/ComputerSystem_V1_4_7_Dxe.c new file mode 100644 index 00000000000..930b19d3aa2 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_4_7/ComputerSystem_V1_4_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_4_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_4_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "4", + "7" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_4_7 *ComputerSystemV1_4_7; + EFI_REDFISH_COMPUTERSYSTEM_V1_4_7_CS *ComputerSystemV1_4_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_4_7_To_CS (ResoruceRaw, &ComputerSystemV1_4_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_4_7 = (EFI_REDFISH_COMPUTERSYSTEM_V1_4_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_4_7)); + if (ComputerSystemV1_4_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_4_7; + ComputerSystemV1_4_7->ComputerSystem = ComputerSystemV1_4_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_4_7_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_4_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_4_7 *ComputerSystemV1_4_7; + + ComputerSystemV1_4_7 = (EFI_REDFISH_COMPUTERSYSTEM_V1_4_7 *)InterpProp; + DestroyComputerSystem_V1_4_7_CS (ComputerSystemV1_4_7->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_4_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_4_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_4_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_4_7/RedfishComputerSystem_V1_4_7_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_4_7/RedfishComputerSystem_V1_4_7_Dxe.inf new file mode 100644 index 00000000000..e5fb8cba2e7 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_4_7/RedfishComputerSystem_V1_4_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_4_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_4_7_Dxe + FILE_GUID = 0c347174-88c9-4321-a8cd-39c2ece6f053 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_4_7EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_4_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_4_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_4_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_4_8/ComputerSystem_V1_4_8_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_4_8/ComputerSystem_V1_4_8_Dxe.c new file mode 100644 index 00000000000..c7b301f2f17 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_4_8/ComputerSystem_V1_4_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_4_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_4_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "4", + "8" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_4_8 *ComputerSystemV1_4_8; + EFI_REDFISH_COMPUTERSYSTEM_V1_4_8_CS *ComputerSystemV1_4_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_4_8_To_CS (ResoruceRaw, &ComputerSystemV1_4_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_4_8 = (EFI_REDFISH_COMPUTERSYSTEM_V1_4_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_4_8)); + if (ComputerSystemV1_4_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_4_8; + ComputerSystemV1_4_8->ComputerSystem = ComputerSystemV1_4_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_4_8_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_4_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_4_8 *ComputerSystemV1_4_8; + + ComputerSystemV1_4_8 = (EFI_REDFISH_COMPUTERSYSTEM_V1_4_8 *)InterpProp; + DestroyComputerSystem_V1_4_8_CS (ComputerSystemV1_4_8->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_4_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_4_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_4_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_4_8/RedfishComputerSystem_V1_4_8_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_4_8/RedfishComputerSystem_V1_4_8_Dxe.inf new file mode 100644 index 00000000000..c83d5dfa581 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_4_8/RedfishComputerSystem_V1_4_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_4_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_4_8_Dxe + FILE_GUID = eef95ab8-649f-4eb3-a3e2-6c926c87f59b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_4_8EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_4_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_4_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_4_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_4_9/ComputerSystem_V1_4_9_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_4_9/ComputerSystem_V1_4_9_Dxe.c new file mode 100644 index 00000000000..257d2dbe997 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_4_9/ComputerSystem_V1_4_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_4_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_4_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "4", + "9" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_4_9 *ComputerSystemV1_4_9; + EFI_REDFISH_COMPUTERSYSTEM_V1_4_9_CS *ComputerSystemV1_4_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_4_9_To_CS (ResoruceRaw, &ComputerSystemV1_4_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_4_9 = (EFI_REDFISH_COMPUTERSYSTEM_V1_4_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_4_9)); + if (ComputerSystemV1_4_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_4_9; + ComputerSystemV1_4_9->ComputerSystem = ComputerSystemV1_4_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_4_9_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_4_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_4_9 *ComputerSystemV1_4_9; + + ComputerSystemV1_4_9 = (EFI_REDFISH_COMPUTERSYSTEM_V1_4_9 *)InterpProp; + DestroyComputerSystem_V1_4_9_CS (ComputerSystemV1_4_9->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_4_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_4_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_4_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_4_9/RedfishComputerSystem_V1_4_9_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_4_9/RedfishComputerSystem_V1_4_9_Dxe.inf new file mode 100644 index 00000000000..8afe9562bfc --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_4_9/RedfishComputerSystem_V1_4_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_4_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_4_9_Dxe + FILE_GUID = 08caed2c-ae02-4892-99b7-7669ed1244c3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_4_9EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_4_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_4_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_4_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_5_0/ComputerSystem_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_5_0/ComputerSystem_V1_5_0_Dxe.c new file mode 100644 index 00000000000..fb676e70fd3 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_5_0/ComputerSystem_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "5", + "0" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_5_0 *ComputerSystemV1_5_0; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_0_CS *ComputerSystemV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_5_0_To_CS (ResoruceRaw, &ComputerSystemV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_5_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_5_0)); + if (ComputerSystemV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_5_0; + ComputerSystemV1_5_0->ComputerSystem = ComputerSystemV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_5_0_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_5_0 *ComputerSystemV1_5_0; + + ComputerSystemV1_5_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_5_0 *)InterpProp; + DestroyComputerSystem_V1_5_0_CS (ComputerSystemV1_5_0->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_5_0/RedfishComputerSystem_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_5_0/RedfishComputerSystem_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..12871f73d98 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_5_0/RedfishComputerSystem_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_5_0_Dxe + FILE_GUID = 5ff2dd5c-7061-4276-a01c-8df37d6a28b1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_5_1/ComputerSystem_V1_5_1_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_5_1/ComputerSystem_V1_5_1_Dxe.c new file mode 100644 index 00000000000..b9f7365c787 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_5_1/ComputerSystem_V1_5_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_5_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "5", + "1" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_5_1 *ComputerSystemV1_5_1; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_1_CS *ComputerSystemV1_5_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_5_1_To_CS (ResoruceRaw, &ComputerSystemV1_5_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_5_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_5_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_5_1)); + if (ComputerSystemV1_5_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_5_1; + ComputerSystemV1_5_1->ComputerSystem = ComputerSystemV1_5_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_5_1_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_5_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_5_1 *ComputerSystemV1_5_1; + + ComputerSystemV1_5_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_5_1 *)InterpProp; + DestroyComputerSystem_V1_5_1_CS (ComputerSystemV1_5_1->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_5_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_5_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_5_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_5_1/RedfishComputerSystem_V1_5_1_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_5_1/RedfishComputerSystem_V1_5_1_Dxe.inf new file mode 100644 index 00000000000..bc0b2b5a71f --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_5_1/RedfishComputerSystem_V1_5_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_5_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_5_1_Dxe + FILE_GUID = cc2dc828-d539-4166-b3f9-b1ec402733d9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_5_1EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_5_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_5_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_5_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_5_2/ComputerSystem_V1_5_2_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_5_2/ComputerSystem_V1_5_2_Dxe.c new file mode 100644 index 00000000000..19c9dc4bd21 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_5_2/ComputerSystem_V1_5_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_5_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "5", + "2" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_5_2 *ComputerSystemV1_5_2; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_2_CS *ComputerSystemV1_5_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_5_2_To_CS (ResoruceRaw, &ComputerSystemV1_5_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_5_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_5_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_5_2)); + if (ComputerSystemV1_5_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_5_2; + ComputerSystemV1_5_2->ComputerSystem = ComputerSystemV1_5_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_5_2_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_5_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_5_2 *ComputerSystemV1_5_2; + + ComputerSystemV1_5_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_5_2 *)InterpProp; + DestroyComputerSystem_V1_5_2_CS (ComputerSystemV1_5_2->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_5_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_5_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_5_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_5_2/RedfishComputerSystem_V1_5_2_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_5_2/RedfishComputerSystem_V1_5_2_Dxe.inf new file mode 100644 index 00000000000..55708954025 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_5_2/RedfishComputerSystem_V1_5_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_5_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_5_2_Dxe + FILE_GUID = e4b15a19-54a0-4e9c-8105-758ec8e92acd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_5_2EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_5_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_5_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_5_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_5_3/ComputerSystem_V1_5_3_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_5_3/ComputerSystem_V1_5_3_Dxe.c new file mode 100644 index 00000000000..06a1efe242c --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_5_3/ComputerSystem_V1_5_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_5_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "5", + "3" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_5_3 *ComputerSystemV1_5_3; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_3_CS *ComputerSystemV1_5_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_5_3_To_CS (ResoruceRaw, &ComputerSystemV1_5_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_5_3 = (EFI_REDFISH_COMPUTERSYSTEM_V1_5_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_5_3)); + if (ComputerSystemV1_5_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_5_3; + ComputerSystemV1_5_3->ComputerSystem = ComputerSystemV1_5_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_5_3_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_5_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_5_3 *ComputerSystemV1_5_3; + + ComputerSystemV1_5_3 = (EFI_REDFISH_COMPUTERSYSTEM_V1_5_3 *)InterpProp; + DestroyComputerSystem_V1_5_3_CS (ComputerSystemV1_5_3->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_5_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_5_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_5_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_5_3/RedfishComputerSystem_V1_5_3_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_5_3/RedfishComputerSystem_V1_5_3_Dxe.inf new file mode 100644 index 00000000000..8e87b68c27c --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_5_3/RedfishComputerSystem_V1_5_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_5_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_5_3_Dxe + FILE_GUID = eb103b31-7057-4de2-98c4-934a4ff65e3b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_5_3EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_5_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_5_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_5_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_5_4/ComputerSystem_V1_5_4_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_5_4/ComputerSystem_V1_5_4_Dxe.c new file mode 100644 index 00000000000..a8bb0f80da1 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_5_4/ComputerSystem_V1_5_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_5_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "5", + "4" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_5_4 *ComputerSystemV1_5_4; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_4_CS *ComputerSystemV1_5_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_5_4_To_CS (ResoruceRaw, &ComputerSystemV1_5_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_5_4 = (EFI_REDFISH_COMPUTERSYSTEM_V1_5_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_5_4)); + if (ComputerSystemV1_5_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_5_4; + ComputerSystemV1_5_4->ComputerSystem = ComputerSystemV1_5_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_5_4_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_5_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_5_4 *ComputerSystemV1_5_4; + + ComputerSystemV1_5_4 = (EFI_REDFISH_COMPUTERSYSTEM_V1_5_4 *)InterpProp; + DestroyComputerSystem_V1_5_4_CS (ComputerSystemV1_5_4->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_5_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_5_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_5_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_5_4/RedfishComputerSystem_V1_5_4_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_5_4/RedfishComputerSystem_V1_5_4_Dxe.inf new file mode 100644 index 00000000000..df5dc9f8a6e --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_5_4/RedfishComputerSystem_V1_5_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_5_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_5_4_Dxe + FILE_GUID = adbf7f82-a92c-4c4b-b13b-c16d7a977837 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_5_4EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_5_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_5_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_5_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_5_5/ComputerSystem_V1_5_5_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_5_5/ComputerSystem_V1_5_5_Dxe.c new file mode 100644 index 00000000000..12b11d289a9 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_5_5/ComputerSystem_V1_5_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_5_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_5_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "5", + "5" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_5_5 *ComputerSystemV1_5_5; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_5_CS *ComputerSystemV1_5_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_5_5_To_CS (ResoruceRaw, &ComputerSystemV1_5_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_5_5 = (EFI_REDFISH_COMPUTERSYSTEM_V1_5_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_5_5)); + if (ComputerSystemV1_5_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_5_5; + ComputerSystemV1_5_5->ComputerSystem = ComputerSystemV1_5_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_5_5_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_5_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_5_5 *ComputerSystemV1_5_5; + + ComputerSystemV1_5_5 = (EFI_REDFISH_COMPUTERSYSTEM_V1_5_5 *)InterpProp; + DestroyComputerSystem_V1_5_5_CS (ComputerSystemV1_5_5->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_5_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_5_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_5_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_5_5/RedfishComputerSystem_V1_5_5_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_5_5/RedfishComputerSystem_V1_5_5_Dxe.inf new file mode 100644 index 00000000000..96e4a4eb50a --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_5_5/RedfishComputerSystem_V1_5_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_5_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_5_5_Dxe + FILE_GUID = 857923e4-cfc7-44e7-92b9-41a694ec355b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_5_5EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_5_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_5_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_5_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_5_6/ComputerSystem_V1_5_6_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_5_6/ComputerSystem_V1_5_6_Dxe.c new file mode 100644 index 00000000000..f7501c5513d --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_5_6/ComputerSystem_V1_5_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_5_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_5_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "5", + "6" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_5_6 *ComputerSystemV1_5_6; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_6_CS *ComputerSystemV1_5_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_5_6_To_CS (ResoruceRaw, &ComputerSystemV1_5_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_5_6 = (EFI_REDFISH_COMPUTERSYSTEM_V1_5_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_5_6)); + if (ComputerSystemV1_5_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_5_6; + ComputerSystemV1_5_6->ComputerSystem = ComputerSystemV1_5_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_5_6_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_5_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_5_6 *ComputerSystemV1_5_6; + + ComputerSystemV1_5_6 = (EFI_REDFISH_COMPUTERSYSTEM_V1_5_6 *)InterpProp; + DestroyComputerSystem_V1_5_6_CS (ComputerSystemV1_5_6->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_5_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_5_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_5_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_5_6/RedfishComputerSystem_V1_5_6_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_5_6/RedfishComputerSystem_V1_5_6_Dxe.inf new file mode 100644 index 00000000000..667ebfd00ae --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_5_6/RedfishComputerSystem_V1_5_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_5_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_5_6_Dxe + FILE_GUID = e24654a6-43c1-4e27-851a-feb6919cdc51 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_5_6EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_5_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_5_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_5_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_5_7/ComputerSystem_V1_5_7_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_5_7/ComputerSystem_V1_5_7_Dxe.c new file mode 100644 index 00000000000..1899dee3190 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_5_7/ComputerSystem_V1_5_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_5_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_5_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "5", + "7" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_5_7 *ComputerSystemV1_5_7; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_7_CS *ComputerSystemV1_5_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_5_7_To_CS (ResoruceRaw, &ComputerSystemV1_5_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_5_7 = (EFI_REDFISH_COMPUTERSYSTEM_V1_5_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_5_7)); + if (ComputerSystemV1_5_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_5_7; + ComputerSystemV1_5_7->ComputerSystem = ComputerSystemV1_5_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_5_7_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_5_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_5_7 *ComputerSystemV1_5_7; + + ComputerSystemV1_5_7 = (EFI_REDFISH_COMPUTERSYSTEM_V1_5_7 *)InterpProp; + DestroyComputerSystem_V1_5_7_CS (ComputerSystemV1_5_7->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_5_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_5_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_5_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_5_7/RedfishComputerSystem_V1_5_7_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_5_7/RedfishComputerSystem_V1_5_7_Dxe.inf new file mode 100644 index 00000000000..08d38670c87 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_5_7/RedfishComputerSystem_V1_5_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_5_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_5_7_Dxe + FILE_GUID = 3d408bf7-d662-4fc9-a611-712f1733ab16 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_5_7EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_5_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_5_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_5_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_5_8/ComputerSystem_V1_5_8_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_5_8/ComputerSystem_V1_5_8_Dxe.c new file mode 100644 index 00000000000..1df00d18027 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_5_8/ComputerSystem_V1_5_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_5_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_5_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "5", + "8" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_5_8 *ComputerSystemV1_5_8; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_8_CS *ComputerSystemV1_5_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_5_8_To_CS (ResoruceRaw, &ComputerSystemV1_5_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_5_8 = (EFI_REDFISH_COMPUTERSYSTEM_V1_5_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_5_8)); + if (ComputerSystemV1_5_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_5_8; + ComputerSystemV1_5_8->ComputerSystem = ComputerSystemV1_5_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_5_8_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_5_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_5_8 *ComputerSystemV1_5_8; + + ComputerSystemV1_5_8 = (EFI_REDFISH_COMPUTERSYSTEM_V1_5_8 *)InterpProp; + DestroyComputerSystem_V1_5_8_CS (ComputerSystemV1_5_8->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_5_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_5_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_5_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_5_8/RedfishComputerSystem_V1_5_8_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_5_8/RedfishComputerSystem_V1_5_8_Dxe.inf new file mode 100644 index 00000000000..42b67c6b12c --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_5_8/RedfishComputerSystem_V1_5_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_5_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_5_8_Dxe + FILE_GUID = c209c980-1a6a-4169-9ca8-2c8228fd66d3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_5_8EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_5_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_5_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_5_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_5_9/ComputerSystem_V1_5_9_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_5_9/ComputerSystem_V1_5_9_Dxe.c new file mode 100644 index 00000000000..2a8b4ff0b1b --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_5_9/ComputerSystem_V1_5_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_5_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_5_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "5", + "9" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_5_9 *ComputerSystemV1_5_9; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_9_CS *ComputerSystemV1_5_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_5_9_To_CS (ResoruceRaw, &ComputerSystemV1_5_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_5_9 = (EFI_REDFISH_COMPUTERSYSTEM_V1_5_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_5_9)); + if (ComputerSystemV1_5_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_5_9; + ComputerSystemV1_5_9->ComputerSystem = ComputerSystemV1_5_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_5_9_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_5_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_5_9 *ComputerSystemV1_5_9; + + ComputerSystemV1_5_9 = (EFI_REDFISH_COMPUTERSYSTEM_V1_5_9 *)InterpProp; + DestroyComputerSystem_V1_5_9_CS (ComputerSystemV1_5_9->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_5_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_5_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_5_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_5_9/RedfishComputerSystem_V1_5_9_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_5_9/RedfishComputerSystem_V1_5_9_Dxe.inf new file mode 100644 index 00000000000..d530929fc4a --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_5_9/RedfishComputerSystem_V1_5_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_5_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_5_9_Dxe + FILE_GUID = 0ef64ada-2407-4440-b646-c26c096ac32e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_5_9EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_5_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_5_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_5_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_6_0/ComputerSystem_V1_6_0_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_6_0/ComputerSystem_V1_6_0_Dxe.c new file mode 100644 index 00000000000..6797049367c --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_6_0/ComputerSystem_V1_6_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_6_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "6", + "0" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_6_0 *ComputerSystemV1_6_0; + EFI_REDFISH_COMPUTERSYSTEM_V1_6_0_CS *ComputerSystemV1_6_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_6_0_To_CS (ResoruceRaw, &ComputerSystemV1_6_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_6_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_6_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_6_0)); + if (ComputerSystemV1_6_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_6_0; + ComputerSystemV1_6_0->ComputerSystem = ComputerSystemV1_6_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_6_0_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_6_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_6_0 *ComputerSystemV1_6_0; + + ComputerSystemV1_6_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_6_0 *)InterpProp; + DestroyComputerSystem_V1_6_0_CS (ComputerSystemV1_6_0->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_6_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_6_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_6_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_6_0/RedfishComputerSystem_V1_6_0_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_6_0/RedfishComputerSystem_V1_6_0_Dxe.inf new file mode 100644 index 00000000000..4f3350480e4 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_6_0/RedfishComputerSystem_V1_6_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_6_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_6_0_Dxe + FILE_GUID = 30d50405-e425-41f7-a0fa-20b02ce121e7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_6_0EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_6_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_6_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_6_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_6_1/ComputerSystem_V1_6_1_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_6_1/ComputerSystem_V1_6_1_Dxe.c new file mode 100644 index 00000000000..63efc45dce4 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_6_1/ComputerSystem_V1_6_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_6_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "6", + "1" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_6_1 *ComputerSystemV1_6_1; + EFI_REDFISH_COMPUTERSYSTEM_V1_6_1_CS *ComputerSystemV1_6_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_6_1_To_CS (ResoruceRaw, &ComputerSystemV1_6_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_6_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_6_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_6_1)); + if (ComputerSystemV1_6_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_6_1; + ComputerSystemV1_6_1->ComputerSystem = ComputerSystemV1_6_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_6_1_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_6_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_6_1 *ComputerSystemV1_6_1; + + ComputerSystemV1_6_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_6_1 *)InterpProp; + DestroyComputerSystem_V1_6_1_CS (ComputerSystemV1_6_1->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_6_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_6_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_6_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_6_1/RedfishComputerSystem_V1_6_1_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_6_1/RedfishComputerSystem_V1_6_1_Dxe.inf new file mode 100644 index 00000000000..2990d46456f --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_6_1/RedfishComputerSystem_V1_6_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_6_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_6_1_Dxe + FILE_GUID = d8a9be42-d57b-488d-91ac-ae6e193ea31a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_6_1EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_6_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_6_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_6_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_6_2/ComputerSystem_V1_6_2_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_6_2/ComputerSystem_V1_6_2_Dxe.c new file mode 100644 index 00000000000..c27b4396544 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_6_2/ComputerSystem_V1_6_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_6_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "6", + "2" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_6_2 *ComputerSystemV1_6_2; + EFI_REDFISH_COMPUTERSYSTEM_V1_6_2_CS *ComputerSystemV1_6_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_6_2_To_CS (ResoruceRaw, &ComputerSystemV1_6_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_6_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_6_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_6_2)); + if (ComputerSystemV1_6_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_6_2; + ComputerSystemV1_6_2->ComputerSystem = ComputerSystemV1_6_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_6_2_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_6_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_6_2 *ComputerSystemV1_6_2; + + ComputerSystemV1_6_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_6_2 *)InterpProp; + DestroyComputerSystem_V1_6_2_CS (ComputerSystemV1_6_2->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_6_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_6_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_6_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_6_2/RedfishComputerSystem_V1_6_2_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_6_2/RedfishComputerSystem_V1_6_2_Dxe.inf new file mode 100644 index 00000000000..ffd876ba6e7 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_6_2/RedfishComputerSystem_V1_6_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_6_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_6_2_Dxe + FILE_GUID = 474f0b83-253f-489b-b45a-0560bc9bbeb6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_6_2EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_6_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_6_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_6_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_6_3/ComputerSystem_V1_6_3_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_6_3/ComputerSystem_V1_6_3_Dxe.c new file mode 100644 index 00000000000..8ebcfa6c2dd --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_6_3/ComputerSystem_V1_6_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_6_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_6_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "6", + "3" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_6_3 *ComputerSystemV1_6_3; + EFI_REDFISH_COMPUTERSYSTEM_V1_6_3_CS *ComputerSystemV1_6_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_6_3_To_CS (ResoruceRaw, &ComputerSystemV1_6_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_6_3 = (EFI_REDFISH_COMPUTERSYSTEM_V1_6_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_6_3)); + if (ComputerSystemV1_6_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_6_3; + ComputerSystemV1_6_3->ComputerSystem = ComputerSystemV1_6_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_6_3_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_6_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_6_3 *ComputerSystemV1_6_3; + + ComputerSystemV1_6_3 = (EFI_REDFISH_COMPUTERSYSTEM_V1_6_3 *)InterpProp; + DestroyComputerSystem_V1_6_3_CS (ComputerSystemV1_6_3->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_6_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_6_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_6_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_6_3/RedfishComputerSystem_V1_6_3_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_6_3/RedfishComputerSystem_V1_6_3_Dxe.inf new file mode 100644 index 00000000000..98bcbf0f7e4 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_6_3/RedfishComputerSystem_V1_6_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_6_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_6_3_Dxe + FILE_GUID = 3150f22c-7785-4246-bbcd-08b0b2e5050c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_6_3EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_6_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_6_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_6_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_6_4/ComputerSystem_V1_6_4_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_6_4/ComputerSystem_V1_6_4_Dxe.c new file mode 100644 index 00000000000..7e85b75b1bc --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_6_4/ComputerSystem_V1_6_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_6_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_6_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "6", + "4" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_6_4 *ComputerSystemV1_6_4; + EFI_REDFISH_COMPUTERSYSTEM_V1_6_4_CS *ComputerSystemV1_6_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_6_4_To_CS (ResoruceRaw, &ComputerSystemV1_6_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_6_4 = (EFI_REDFISH_COMPUTERSYSTEM_V1_6_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_6_4)); + if (ComputerSystemV1_6_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_6_4; + ComputerSystemV1_6_4->ComputerSystem = ComputerSystemV1_6_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_6_4_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_6_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_6_4 *ComputerSystemV1_6_4; + + ComputerSystemV1_6_4 = (EFI_REDFISH_COMPUTERSYSTEM_V1_6_4 *)InterpProp; + DestroyComputerSystem_V1_6_4_CS (ComputerSystemV1_6_4->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_6_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_6_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_6_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_6_4/RedfishComputerSystem_V1_6_4_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_6_4/RedfishComputerSystem_V1_6_4_Dxe.inf new file mode 100644 index 00000000000..a5c7ec492c8 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_6_4/RedfishComputerSystem_V1_6_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_6_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_6_4_Dxe + FILE_GUID = ca95148f-9899-45f6-96c9-2230a23a8013 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_6_4EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_6_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_6_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_6_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_6_5/ComputerSystem_V1_6_5_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_6_5/ComputerSystem_V1_6_5_Dxe.c new file mode 100644 index 00000000000..9d2b5bcbd8b --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_6_5/ComputerSystem_V1_6_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_6_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_6_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "6", + "5" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_6_5 *ComputerSystemV1_6_5; + EFI_REDFISH_COMPUTERSYSTEM_V1_6_5_CS *ComputerSystemV1_6_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_6_5_To_CS (ResoruceRaw, &ComputerSystemV1_6_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_6_5 = (EFI_REDFISH_COMPUTERSYSTEM_V1_6_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_6_5)); + if (ComputerSystemV1_6_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_6_5; + ComputerSystemV1_6_5->ComputerSystem = ComputerSystemV1_6_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_6_5_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_6_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_6_5 *ComputerSystemV1_6_5; + + ComputerSystemV1_6_5 = (EFI_REDFISH_COMPUTERSYSTEM_V1_6_5 *)InterpProp; + DestroyComputerSystem_V1_6_5_CS (ComputerSystemV1_6_5->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_6_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_6_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_6_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_6_5/RedfishComputerSystem_V1_6_5_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_6_5/RedfishComputerSystem_V1_6_5_Dxe.inf new file mode 100644 index 00000000000..06f8938c7ac --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_6_5/RedfishComputerSystem_V1_6_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_6_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_6_5_Dxe + FILE_GUID = 42e38eb6-1456-4794-bf71-8d1c04205a49 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_6_5EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_6_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_6_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_6_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_6_6/ComputerSystem_V1_6_6_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_6_6/ComputerSystem_V1_6_6_Dxe.c new file mode 100644 index 00000000000..43225455175 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_6_6/ComputerSystem_V1_6_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_6_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_6_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "6", + "6" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_6_6 *ComputerSystemV1_6_6; + EFI_REDFISH_COMPUTERSYSTEM_V1_6_6_CS *ComputerSystemV1_6_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_6_6_To_CS (ResoruceRaw, &ComputerSystemV1_6_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_6_6 = (EFI_REDFISH_COMPUTERSYSTEM_V1_6_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_6_6)); + if (ComputerSystemV1_6_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_6_6; + ComputerSystemV1_6_6->ComputerSystem = ComputerSystemV1_6_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_6_6_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_6_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_6_6 *ComputerSystemV1_6_6; + + ComputerSystemV1_6_6 = (EFI_REDFISH_COMPUTERSYSTEM_V1_6_6 *)InterpProp; + DestroyComputerSystem_V1_6_6_CS (ComputerSystemV1_6_6->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_6_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_6_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_6_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_6_6/RedfishComputerSystem_V1_6_6_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_6_6/RedfishComputerSystem_V1_6_6_Dxe.inf new file mode 100644 index 00000000000..f3c7720e18e --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_6_6/RedfishComputerSystem_V1_6_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_6_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_6_6_Dxe + FILE_GUID = 508662ea-1373-4616-9e1e-1904dcbe4700 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_6_6EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_6_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_6_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_6_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_6_7/ComputerSystem_V1_6_7_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_6_7/ComputerSystem_V1_6_7_Dxe.c new file mode 100644 index 00000000000..25e9a271c73 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_6_7/ComputerSystem_V1_6_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_6_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_6_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "6", + "7" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_6_7 *ComputerSystemV1_6_7; + EFI_REDFISH_COMPUTERSYSTEM_V1_6_7_CS *ComputerSystemV1_6_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_6_7_To_CS (ResoruceRaw, &ComputerSystemV1_6_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_6_7 = (EFI_REDFISH_COMPUTERSYSTEM_V1_6_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_6_7)); + if (ComputerSystemV1_6_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_6_7; + ComputerSystemV1_6_7->ComputerSystem = ComputerSystemV1_6_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_6_7_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_6_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_6_7 *ComputerSystemV1_6_7; + + ComputerSystemV1_6_7 = (EFI_REDFISH_COMPUTERSYSTEM_V1_6_7 *)InterpProp; + DestroyComputerSystem_V1_6_7_CS (ComputerSystemV1_6_7->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_6_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_6_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_6_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_6_7/RedfishComputerSystem_V1_6_7_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_6_7/RedfishComputerSystem_V1_6_7_Dxe.inf new file mode 100644 index 00000000000..ecb30bb0463 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_6_7/RedfishComputerSystem_V1_6_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_6_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_6_7_Dxe + FILE_GUID = 53844333-808a-4a22-8872-a8442724a552 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_6_7EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_6_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_6_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_6_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_7_0/ComputerSystem_V1_7_0_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_7_0/ComputerSystem_V1_7_0_Dxe.c new file mode 100644 index 00000000000..7969abc9364 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_7_0/ComputerSystem_V1_7_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_7_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "7", + "0" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_7_0 *ComputerSystemV1_7_0; + EFI_REDFISH_COMPUTERSYSTEM_V1_7_0_CS *ComputerSystemV1_7_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_7_0_To_CS (ResoruceRaw, &ComputerSystemV1_7_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_7_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_7_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_7_0)); + if (ComputerSystemV1_7_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_7_0; + ComputerSystemV1_7_0->ComputerSystem = ComputerSystemV1_7_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_7_0_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_7_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_7_0 *ComputerSystemV1_7_0; + + ComputerSystemV1_7_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_7_0 *)InterpProp; + DestroyComputerSystem_V1_7_0_CS (ComputerSystemV1_7_0->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_7_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_7_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_7_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_7_0/RedfishComputerSystem_V1_7_0_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_7_0/RedfishComputerSystem_V1_7_0_Dxe.inf new file mode 100644 index 00000000000..8fea383837c --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_7_0/RedfishComputerSystem_V1_7_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_7_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_7_0_Dxe + FILE_GUID = 172c6631-9888-45c7-9d63-4e01580acc02 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_7_0EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_7_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_7_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_7_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_7_1/ComputerSystem_V1_7_1_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_7_1/ComputerSystem_V1_7_1_Dxe.c new file mode 100644 index 00000000000..86e681fbf9b --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_7_1/ComputerSystem_V1_7_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_7_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_7_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "7", + "1" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_7_1 *ComputerSystemV1_7_1; + EFI_REDFISH_COMPUTERSYSTEM_V1_7_1_CS *ComputerSystemV1_7_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_7_1_To_CS (ResoruceRaw, &ComputerSystemV1_7_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_7_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_7_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_7_1)); + if (ComputerSystemV1_7_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_7_1; + ComputerSystemV1_7_1->ComputerSystem = ComputerSystemV1_7_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_7_1_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_7_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_7_1 *ComputerSystemV1_7_1; + + ComputerSystemV1_7_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_7_1 *)InterpProp; + DestroyComputerSystem_V1_7_1_CS (ComputerSystemV1_7_1->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_7_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_7_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_7_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_7_1/RedfishComputerSystem_V1_7_1_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_7_1/RedfishComputerSystem_V1_7_1_Dxe.inf new file mode 100644 index 00000000000..147f5c0fb39 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_7_1/RedfishComputerSystem_V1_7_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_7_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_7_1_Dxe + FILE_GUID = 46e54b5c-669e-4409-9537-6115f49eeefa + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_7_1EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_7_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_7_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_7_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_7_2/ComputerSystem_V1_7_2_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_7_2/ComputerSystem_V1_7_2_Dxe.c new file mode 100644 index 00000000000..a1dc49a4962 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_7_2/ComputerSystem_V1_7_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_7_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_7_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "7", + "2" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_7_2 *ComputerSystemV1_7_2; + EFI_REDFISH_COMPUTERSYSTEM_V1_7_2_CS *ComputerSystemV1_7_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_7_2_To_CS (ResoruceRaw, &ComputerSystemV1_7_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_7_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_7_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_7_2)); + if (ComputerSystemV1_7_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_7_2; + ComputerSystemV1_7_2->ComputerSystem = ComputerSystemV1_7_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_7_2_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_7_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_7_2 *ComputerSystemV1_7_2; + + ComputerSystemV1_7_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_7_2 *)InterpProp; + DestroyComputerSystem_V1_7_2_CS (ComputerSystemV1_7_2->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_7_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_7_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_7_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_7_2/RedfishComputerSystem_V1_7_2_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_7_2/RedfishComputerSystem_V1_7_2_Dxe.inf new file mode 100644 index 00000000000..2e261ad91b0 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_7_2/RedfishComputerSystem_V1_7_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_7_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_7_2_Dxe + FILE_GUID = 7e5023b8-fac3-4eb6-a483-6e7320ceffbd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_7_2EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_7_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_7_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_7_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_7_3/ComputerSystem_V1_7_3_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_7_3/ComputerSystem_V1_7_3_Dxe.c new file mode 100644 index 00000000000..20fa2972555 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_7_3/ComputerSystem_V1_7_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_7_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_7_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "7", + "3" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_7_3 *ComputerSystemV1_7_3; + EFI_REDFISH_COMPUTERSYSTEM_V1_7_3_CS *ComputerSystemV1_7_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_7_3_To_CS (ResoruceRaw, &ComputerSystemV1_7_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_7_3 = (EFI_REDFISH_COMPUTERSYSTEM_V1_7_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_7_3)); + if (ComputerSystemV1_7_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_7_3; + ComputerSystemV1_7_3->ComputerSystem = ComputerSystemV1_7_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_7_3_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_7_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_7_3 *ComputerSystemV1_7_3; + + ComputerSystemV1_7_3 = (EFI_REDFISH_COMPUTERSYSTEM_V1_7_3 *)InterpProp; + DestroyComputerSystem_V1_7_3_CS (ComputerSystemV1_7_3->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_7_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_7_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_7_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_7_3/RedfishComputerSystem_V1_7_3_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_7_3/RedfishComputerSystem_V1_7_3_Dxe.inf new file mode 100644 index 00000000000..ac1731d5ad9 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_7_3/RedfishComputerSystem_V1_7_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_7_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_7_3_Dxe + FILE_GUID = 410168c9-cc72-43c2-ac3e-bfaa06fea6e0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_7_3EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_7_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_7_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_7_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_7_4/ComputerSystem_V1_7_4_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_7_4/ComputerSystem_V1_7_4_Dxe.c new file mode 100644 index 00000000000..85104e409eb --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_7_4/ComputerSystem_V1_7_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_7_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_7_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "7", + "4" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_7_4 *ComputerSystemV1_7_4; + EFI_REDFISH_COMPUTERSYSTEM_V1_7_4_CS *ComputerSystemV1_7_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_7_4_To_CS (ResoruceRaw, &ComputerSystemV1_7_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_7_4 = (EFI_REDFISH_COMPUTERSYSTEM_V1_7_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_7_4)); + if (ComputerSystemV1_7_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_7_4; + ComputerSystemV1_7_4->ComputerSystem = ComputerSystemV1_7_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_7_4_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_7_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_7_4 *ComputerSystemV1_7_4; + + ComputerSystemV1_7_4 = (EFI_REDFISH_COMPUTERSYSTEM_V1_7_4 *)InterpProp; + DestroyComputerSystem_V1_7_4_CS (ComputerSystemV1_7_4->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_7_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_7_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_7_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_7_4/RedfishComputerSystem_V1_7_4_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_7_4/RedfishComputerSystem_V1_7_4_Dxe.inf new file mode 100644 index 00000000000..34a5ade6782 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_7_4/RedfishComputerSystem_V1_7_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_7_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_7_4_Dxe + FILE_GUID = 872877ae-c0e0-4153-badc-1bc44d7e1794 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_7_4EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_7_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_7_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_7_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_7_5/ComputerSystem_V1_7_5_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_7_5/ComputerSystem_V1_7_5_Dxe.c new file mode 100644 index 00000000000..63f2659be8c --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_7_5/ComputerSystem_V1_7_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_7_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_7_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "7", + "5" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_7_5 *ComputerSystemV1_7_5; + EFI_REDFISH_COMPUTERSYSTEM_V1_7_5_CS *ComputerSystemV1_7_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_7_5_To_CS (ResoruceRaw, &ComputerSystemV1_7_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_7_5 = (EFI_REDFISH_COMPUTERSYSTEM_V1_7_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_7_5)); + if (ComputerSystemV1_7_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_7_5; + ComputerSystemV1_7_5->ComputerSystem = ComputerSystemV1_7_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_7_5_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_7_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_7_5 *ComputerSystemV1_7_5; + + ComputerSystemV1_7_5 = (EFI_REDFISH_COMPUTERSYSTEM_V1_7_5 *)InterpProp; + DestroyComputerSystem_V1_7_5_CS (ComputerSystemV1_7_5->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_7_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_7_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_7_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_7_5/RedfishComputerSystem_V1_7_5_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_7_5/RedfishComputerSystem_V1_7_5_Dxe.inf new file mode 100644 index 00000000000..388f0882a98 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_7_5/RedfishComputerSystem_V1_7_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_7_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_7_5_Dxe + FILE_GUID = c922da9a-8558-4cb8-b4b2-67167de9d71f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_7_5EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_7_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_7_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_7_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_7_6/ComputerSystem_V1_7_6_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_7_6/ComputerSystem_V1_7_6_Dxe.c new file mode 100644 index 00000000000..1d36758be25 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_7_6/ComputerSystem_V1_7_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_7_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_7_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "7", + "6" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_7_6 *ComputerSystemV1_7_6; + EFI_REDFISH_COMPUTERSYSTEM_V1_7_6_CS *ComputerSystemV1_7_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_7_6_To_CS (ResoruceRaw, &ComputerSystemV1_7_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_7_6 = (EFI_REDFISH_COMPUTERSYSTEM_V1_7_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_7_6)); + if (ComputerSystemV1_7_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_7_6; + ComputerSystemV1_7_6->ComputerSystem = ComputerSystemV1_7_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_7_6_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_7_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_7_6 *ComputerSystemV1_7_6; + + ComputerSystemV1_7_6 = (EFI_REDFISH_COMPUTERSYSTEM_V1_7_6 *)InterpProp; + DestroyComputerSystem_V1_7_6_CS (ComputerSystemV1_7_6->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_7_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_7_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_7_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_7_6/RedfishComputerSystem_V1_7_6_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_7_6/RedfishComputerSystem_V1_7_6_Dxe.inf new file mode 100644 index 00000000000..70d192144db --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_7_6/RedfishComputerSystem_V1_7_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_7_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_7_6_Dxe + FILE_GUID = 38827b80-e744-4dd3-86bb-648f09f98c50 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_7_6EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_7_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_7_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_7_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_8_0/ComputerSystem_V1_8_0_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_8_0/ComputerSystem_V1_8_0_Dxe.c new file mode 100644 index 00000000000..5c77d0b2fe0 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_8_0/ComputerSystem_V1_8_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_8_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_8_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "8", + "0" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_8_0 *ComputerSystemV1_8_0; + EFI_REDFISH_COMPUTERSYSTEM_V1_8_0_CS *ComputerSystemV1_8_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_8_0_To_CS (ResoruceRaw, &ComputerSystemV1_8_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_8_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_8_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_8_0)); + if (ComputerSystemV1_8_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_8_0; + ComputerSystemV1_8_0->ComputerSystem = ComputerSystemV1_8_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_8_0_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_8_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_8_0 *ComputerSystemV1_8_0; + + ComputerSystemV1_8_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_8_0 *)InterpProp; + DestroyComputerSystem_V1_8_0_CS (ComputerSystemV1_8_0->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_8_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_8_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_8_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_8_0/RedfishComputerSystem_V1_8_0_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_8_0/RedfishComputerSystem_V1_8_0_Dxe.inf new file mode 100644 index 00000000000..ae884696913 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_8_0/RedfishComputerSystem_V1_8_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_8_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_8_0_Dxe + FILE_GUID = c4b56034-00cc-4dfd-9279-bac1789155be + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_8_0EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_8_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_8_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_8_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_8_1/ComputerSystem_V1_8_1_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_8_1/ComputerSystem_V1_8_1_Dxe.c new file mode 100644 index 00000000000..d2ef8db0ec7 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_8_1/ComputerSystem_V1_8_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_8_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_8_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "8", + "1" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_8_1 *ComputerSystemV1_8_1; + EFI_REDFISH_COMPUTERSYSTEM_V1_8_1_CS *ComputerSystemV1_8_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_8_1_To_CS (ResoruceRaw, &ComputerSystemV1_8_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_8_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_8_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_8_1)); + if (ComputerSystemV1_8_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_8_1; + ComputerSystemV1_8_1->ComputerSystem = ComputerSystemV1_8_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_8_1_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_8_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_8_1 *ComputerSystemV1_8_1; + + ComputerSystemV1_8_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_8_1 *)InterpProp; + DestroyComputerSystem_V1_8_1_CS (ComputerSystemV1_8_1->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_8_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_8_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_8_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_8_1/RedfishComputerSystem_V1_8_1_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_8_1/RedfishComputerSystem_V1_8_1_Dxe.inf new file mode 100644 index 00000000000..f5c328fefdd --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_8_1/RedfishComputerSystem_V1_8_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_8_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_8_1_Dxe + FILE_GUID = 96173988-edb0-48f3-b0a3-e58d3f7703c7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_8_1EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_8_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_8_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_8_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_8_2/ComputerSystem_V1_8_2_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_8_2/ComputerSystem_V1_8_2_Dxe.c new file mode 100644 index 00000000000..dc8a06977ff --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_8_2/ComputerSystem_V1_8_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_8_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_8_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "8", + "2" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_8_2 *ComputerSystemV1_8_2; + EFI_REDFISH_COMPUTERSYSTEM_V1_8_2_CS *ComputerSystemV1_8_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_8_2_To_CS (ResoruceRaw, &ComputerSystemV1_8_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_8_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_8_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_8_2)); + if (ComputerSystemV1_8_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_8_2; + ComputerSystemV1_8_2->ComputerSystem = ComputerSystemV1_8_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_8_2_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_8_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_8_2 *ComputerSystemV1_8_2; + + ComputerSystemV1_8_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_8_2 *)InterpProp; + DestroyComputerSystem_V1_8_2_CS (ComputerSystemV1_8_2->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_8_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_8_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_8_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_8_2/RedfishComputerSystem_V1_8_2_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_8_2/RedfishComputerSystem_V1_8_2_Dxe.inf new file mode 100644 index 00000000000..cfa0ed5fa3b --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_8_2/RedfishComputerSystem_V1_8_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_8_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_8_2_Dxe + FILE_GUID = 4ceaa858-3b41-46ee-ae90-2135dadf8b55 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_8_2EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_8_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_8_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_8_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_8_3/ComputerSystem_V1_8_3_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_8_3/ComputerSystem_V1_8_3_Dxe.c new file mode 100644 index 00000000000..d21a20d5fe6 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_8_3/ComputerSystem_V1_8_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_8_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_8_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "8", + "3" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_8_3 *ComputerSystemV1_8_3; + EFI_REDFISH_COMPUTERSYSTEM_V1_8_3_CS *ComputerSystemV1_8_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_8_3_To_CS (ResoruceRaw, &ComputerSystemV1_8_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_8_3 = (EFI_REDFISH_COMPUTERSYSTEM_V1_8_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_8_3)); + if (ComputerSystemV1_8_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_8_3; + ComputerSystemV1_8_3->ComputerSystem = ComputerSystemV1_8_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_8_3_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_8_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_8_3 *ComputerSystemV1_8_3; + + ComputerSystemV1_8_3 = (EFI_REDFISH_COMPUTERSYSTEM_V1_8_3 *)InterpProp; + DestroyComputerSystem_V1_8_3_CS (ComputerSystemV1_8_3->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_8_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_8_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_8_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_8_3/RedfishComputerSystem_V1_8_3_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_8_3/RedfishComputerSystem_V1_8_3_Dxe.inf new file mode 100644 index 00000000000..2948fe28e75 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_8_3/RedfishComputerSystem_V1_8_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_8_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_8_3_Dxe + FILE_GUID = ea5fe1cc-6dd5-427f-bbe7-27185cd318f2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_8_3EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_8_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_8_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_8_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_8_4/ComputerSystem_V1_8_4_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_8_4/ComputerSystem_V1_8_4_Dxe.c new file mode 100644 index 00000000000..32f0ebd805c --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_8_4/ComputerSystem_V1_8_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_8_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_8_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "8", + "4" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_8_4 *ComputerSystemV1_8_4; + EFI_REDFISH_COMPUTERSYSTEM_V1_8_4_CS *ComputerSystemV1_8_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_8_4_To_CS (ResoruceRaw, &ComputerSystemV1_8_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_8_4 = (EFI_REDFISH_COMPUTERSYSTEM_V1_8_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_8_4)); + if (ComputerSystemV1_8_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_8_4; + ComputerSystemV1_8_4->ComputerSystem = ComputerSystemV1_8_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_8_4_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_8_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_8_4 *ComputerSystemV1_8_4; + + ComputerSystemV1_8_4 = (EFI_REDFISH_COMPUTERSYSTEM_V1_8_4 *)InterpProp; + DestroyComputerSystem_V1_8_4_CS (ComputerSystemV1_8_4->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_8_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_8_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_8_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_8_4/RedfishComputerSystem_V1_8_4_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_8_4/RedfishComputerSystem_V1_8_4_Dxe.inf new file mode 100644 index 00000000000..c11bf63aea3 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_8_4/RedfishComputerSystem_V1_8_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_8_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_8_4_Dxe + FILE_GUID = d2fad36c-00c2-4dcb-ba04-5f5cf1a45264 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_8_4EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_8_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_8_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_8_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_8_5/ComputerSystem_V1_8_5_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_8_5/ComputerSystem_V1_8_5_Dxe.c new file mode 100644 index 00000000000..3b57775dbbe --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_8_5/ComputerSystem_V1_8_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_8_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_8_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "8", + "5" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_8_5 *ComputerSystemV1_8_5; + EFI_REDFISH_COMPUTERSYSTEM_V1_8_5_CS *ComputerSystemV1_8_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_8_5_To_CS (ResoruceRaw, &ComputerSystemV1_8_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_8_5 = (EFI_REDFISH_COMPUTERSYSTEM_V1_8_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_8_5)); + if (ComputerSystemV1_8_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_8_5; + ComputerSystemV1_8_5->ComputerSystem = ComputerSystemV1_8_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_8_5_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_8_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_8_5 *ComputerSystemV1_8_5; + + ComputerSystemV1_8_5 = (EFI_REDFISH_COMPUTERSYSTEM_V1_8_5 *)InterpProp; + DestroyComputerSystem_V1_8_5_CS (ComputerSystemV1_8_5->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_8_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_8_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_8_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_8_5/RedfishComputerSystem_V1_8_5_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_8_5/RedfishComputerSystem_V1_8_5_Dxe.inf new file mode 100644 index 00000000000..22ca42452d8 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_8_5/RedfishComputerSystem_V1_8_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_8_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_8_5_Dxe + FILE_GUID = a16a1aec-6980-4c5c-a2cb-17cc3793df48 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_8_5EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_8_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_8_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_8_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_9_0/ComputerSystem_V1_9_0_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_9_0/ComputerSystem_V1_9_0_Dxe.c new file mode 100644 index 00000000000..d33e1e8fdac --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_9_0/ComputerSystem_V1_9_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_9_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_9_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "9", + "0" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_9_0 *ComputerSystemV1_9_0; + EFI_REDFISH_COMPUTERSYSTEM_V1_9_0_CS *ComputerSystemV1_9_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_9_0_To_CS (ResoruceRaw, &ComputerSystemV1_9_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_9_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_9_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_9_0)); + if (ComputerSystemV1_9_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_9_0; + ComputerSystemV1_9_0->ComputerSystem = ComputerSystemV1_9_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_9_0_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_9_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_9_0 *ComputerSystemV1_9_0; + + ComputerSystemV1_9_0 = (EFI_REDFISH_COMPUTERSYSTEM_V1_9_0 *)InterpProp; + DestroyComputerSystem_V1_9_0_CS (ComputerSystemV1_9_0->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_9_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_9_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_9_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_9_0/RedfishComputerSystem_V1_9_0_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_9_0/RedfishComputerSystem_V1_9_0_Dxe.inf new file mode 100644 index 00000000000..717a3ce38de --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_9_0/RedfishComputerSystem_V1_9_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_9_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_9_0_Dxe + FILE_GUID = 2f29c5b9-a6b8-4fa3-84fd-ec650b306615 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_9_0EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_9_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_9_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_9_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_9_1/ComputerSystem_V1_9_1_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_9_1/ComputerSystem_V1_9_1_Dxe.c new file mode 100644 index 00000000000..8386a5dfac6 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_9_1/ComputerSystem_V1_9_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_9_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_9_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "9", + "1" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_9_1 *ComputerSystemV1_9_1; + EFI_REDFISH_COMPUTERSYSTEM_V1_9_1_CS *ComputerSystemV1_9_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_9_1_To_CS (ResoruceRaw, &ComputerSystemV1_9_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_9_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_9_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_9_1)); + if (ComputerSystemV1_9_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_9_1; + ComputerSystemV1_9_1->ComputerSystem = ComputerSystemV1_9_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_9_1_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_9_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_9_1 *ComputerSystemV1_9_1; + + ComputerSystemV1_9_1 = (EFI_REDFISH_COMPUTERSYSTEM_V1_9_1 *)InterpProp; + DestroyComputerSystem_V1_9_1_CS (ComputerSystemV1_9_1->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_9_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_9_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_9_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_9_1/RedfishComputerSystem_V1_9_1_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_9_1/RedfishComputerSystem_V1_9_1_Dxe.inf new file mode 100644 index 00000000000..4057fb4fcb6 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_9_1/RedfishComputerSystem_V1_9_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_9_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_9_1_Dxe + FILE_GUID = da0d43a7-c3bc-43ce-b8c3-c8256070f63e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_9_1EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_9_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_9_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_9_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_9_2/ComputerSystem_V1_9_2_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_9_2/ComputerSystem_V1_9_2_Dxe.c new file mode 100644 index 00000000000..57eaaf519be --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_9_2/ComputerSystem_V1_9_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_9_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_9_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "9", + "2" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_9_2 *ComputerSystemV1_9_2; + EFI_REDFISH_COMPUTERSYSTEM_V1_9_2_CS *ComputerSystemV1_9_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_9_2_To_CS (ResoruceRaw, &ComputerSystemV1_9_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_9_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_9_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_9_2)); + if (ComputerSystemV1_9_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_9_2; + ComputerSystemV1_9_2->ComputerSystem = ComputerSystemV1_9_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_9_2_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_9_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_9_2 *ComputerSystemV1_9_2; + + ComputerSystemV1_9_2 = (EFI_REDFISH_COMPUTERSYSTEM_V1_9_2 *)InterpProp; + DestroyComputerSystem_V1_9_2_CS (ComputerSystemV1_9_2->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_9_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_9_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_9_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_9_2/RedfishComputerSystem_V1_9_2_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_9_2/RedfishComputerSystem_V1_9_2_Dxe.inf new file mode 100644 index 00000000000..b135a275d49 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_9_2/RedfishComputerSystem_V1_9_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_9_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_9_2_Dxe + FILE_GUID = aa249642-e821-4561-b230-f266d793aa27 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_9_2EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_9_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_9_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_9_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_9_3/ComputerSystem_V1_9_3_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_9_3/ComputerSystem_V1_9_3_Dxe.c new file mode 100644 index 00000000000..a31edb8db79 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_9_3/ComputerSystem_V1_9_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_9_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_9_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "9", + "3" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_9_3 *ComputerSystemV1_9_3; + EFI_REDFISH_COMPUTERSYSTEM_V1_9_3_CS *ComputerSystemV1_9_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_9_3_To_CS (ResoruceRaw, &ComputerSystemV1_9_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_9_3 = (EFI_REDFISH_COMPUTERSYSTEM_V1_9_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_9_3)); + if (ComputerSystemV1_9_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_9_3; + ComputerSystemV1_9_3->ComputerSystem = ComputerSystemV1_9_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_9_3_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_9_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_9_3 *ComputerSystemV1_9_3; + + ComputerSystemV1_9_3 = (EFI_REDFISH_COMPUTERSYSTEM_V1_9_3 *)InterpProp; + DestroyComputerSystem_V1_9_3_CS (ComputerSystemV1_9_3->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_9_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_9_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_9_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_9_3/RedfishComputerSystem_V1_9_3_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_9_3/RedfishComputerSystem_V1_9_3_Dxe.inf new file mode 100644 index 00000000000..cd4254867aa --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_9_3/RedfishComputerSystem_V1_9_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_9_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_9_3_Dxe + FILE_GUID = f94ec38b-63c2-4ccb-b360-f27e2948ed2e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_9_3EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_9_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_9_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_9_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_9_4/ComputerSystem_V1_9_4_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_9_4/ComputerSystem_V1_9_4_Dxe.c new file mode 100644 index 00000000000..47a108ed84e --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_9_4/ComputerSystem_V1_9_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_9_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_9_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "9", + "4" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_9_4 *ComputerSystemV1_9_4; + EFI_REDFISH_COMPUTERSYSTEM_V1_9_4_CS *ComputerSystemV1_9_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_9_4_To_CS (ResoruceRaw, &ComputerSystemV1_9_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_9_4 = (EFI_REDFISH_COMPUTERSYSTEM_V1_9_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_9_4)); + if (ComputerSystemV1_9_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_9_4; + ComputerSystemV1_9_4->ComputerSystem = ComputerSystemV1_9_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_9_4_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_9_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_9_4 *ComputerSystemV1_9_4; + + ComputerSystemV1_9_4 = (EFI_REDFISH_COMPUTERSYSTEM_V1_9_4 *)InterpProp; + DestroyComputerSystem_V1_9_4_CS (ComputerSystemV1_9_4->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_9_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_9_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_9_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_9_4/RedfishComputerSystem_V1_9_4_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_9_4/RedfishComputerSystem_V1_9_4_Dxe.inf new file mode 100644 index 00000000000..ed830676d81 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_9_4/RedfishComputerSystem_V1_9_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_9_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_9_4_Dxe + FILE_GUID = 5daf8821-db73-4caf-9967-15edce2c6a04 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_9_4EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_9_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_9_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_9_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_9_5/ComputerSystem_V1_9_5_Dxe.c b/RedfishClientPkg/Converter/ComputerSystem/v1_9_5/ComputerSystem_V1_9_5_Dxe.c new file mode 100644 index 00000000000..db37c6e324f --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_9_5/ComputerSystem_V1_9_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystem.v1_9_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ComputerSystem V1_9_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystem", + "1", + "9", + "5" + }, + "ComputerSystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_9_5 *ComputerSystemV1_9_5; + EFI_REDFISH_COMPUTERSYSTEM_V1_9_5_CS *ComputerSystemV1_9_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystem_V1_9_5_To_CS (ResoruceRaw, &ComputerSystemV1_9_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemV1_9_5 = (EFI_REDFISH_COMPUTERSYSTEM_V1_9_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEM_V1_9_5)); + if (ComputerSystemV1_9_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemV1_9_5; + ComputerSystemV1_9_5->ComputerSystem = ComputerSystemV1_9_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystem"), "ComputerSystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystem_V1_9_5_JSON (*((EFI_REDFISH_COMPUTERSYSTEM_V1_9_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEM_V1_9_5 *ComputerSystemV1_9_5; + + ComputerSystemV1_9_5 = (EFI_REDFISH_COMPUTERSYSTEM_V1_9_5 *)InterpProp; + DestroyComputerSystem_V1_9_5_CS (ComputerSystemV1_9_5->ComputerSystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystem_V1_9_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_9_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemToStructWrapper, + ComputerSystemToJson, + ComputerSystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystem_V1_9_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystem/v1_9_5/RedfishComputerSystem_V1_9_5_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystem/v1_9_5/RedfishComputerSystem_V1_9_5_Dxe.inf new file mode 100644 index 00000000000..d70d2f4e08a --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystem/v1_9_5/RedfishComputerSystem_V1_9_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystem.v1_9_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystem_V1_9_5_Dxe + FILE_GUID = eda97aad-c2b9-4d48-a145-42ff11ae22d1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystem_V1_9_5EntryPoint + UNLOAD_IMAGE = RedfishComputerSystem_V1_9_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystem_V1_9_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemV1_9_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ComputerSystemCollection/ComputerSystemCollection_Dxe.c b/RedfishClientPkg/Converter/ComputerSystemCollection/ComputerSystemCollection_Dxe.c new file mode 100644 index 00000000000..204d3fd0cb0 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystemCollection/ComputerSystemCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ComputerSystemCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ComputerSystemCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support ComputerSystemCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ComputerSystemCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "ComputerSystemCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEMCOLLECTION *ComputerSystemCollection; + EFI_REDFISH_COMPUTERSYSTEMCOLLECTION_CS *ComputerSystemCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ComputerSystemCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ComputerSystemCollection_To_CS (ResoruceRaw, &ComputerSystemCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + ComputerSystemCollection = (EFI_REDFISH_COMPUTERSYSTEMCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_COMPUTERSYSTEMCOLLECTION)); + if (ComputerSystemCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ComputerSystemCollection; + ComputerSystemCollection->ComputerSystemCollection = ComputerSystemCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystemCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ComputerSystemCollection"), "ComputerSystemCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ComputerSystemCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ComputerSystemCollection"), "ComputerSystemCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ComputerSystemCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ComputerSystemCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ComputerSystemCollection_JSON (*((EFI_REDFISH_COMPUTERSYSTEMCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ComputerSystemCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_COMPUTERSYSTEMCOLLECTION *ComputerSystemCollection; + + ComputerSystemCollection = (EFI_REDFISH_COMPUTERSYSTEMCOLLECTION *)InterpProp; + DestroyComputerSystemCollection_CS (ComputerSystemCollection->ComputerSystemCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ComputerSystemCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ComputerSystemCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyComputerSystemCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystemCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ComputerSystemCollectionToStructWrapper, + ComputerSystemCollectionToJson, + ComputerSystemCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishComputerSystemCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ComputerSystemCollection/RedfishComputerSystemCollection_Dxe.inf b/RedfishClientPkg/Converter/ComputerSystemCollection/RedfishComputerSystemCollection_Dxe.inf new file mode 100644 index 00000000000..f0122a7e183 --- /dev/null +++ b/RedfishClientPkg/Converter/ComputerSystemCollection/RedfishComputerSystemCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ComputerSystemCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishComputerSystemCollection_Dxe + FILE_GUID = 9989d2ea-9998-4ea1-998a-f2728171d7bc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishComputerSystemCollectionEntryPoint + UNLOAD_IMAGE = RedfishComputerSystemCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ComputerSystemCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ComputerSystemCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Connection/v1_0_0/Connection_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Connection/v1_0_0/Connection_V1_0_0_Dxe.c new file mode 100644 index 00000000000..15e10c9fa5e --- /dev/null +++ b/RedfishClientPkg/Converter/Connection/v1_0_0/Connection_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Connection.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Connection"; +BOOLEAN IsRevisonController = TRUE; + +// Support Connection V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Connection", + "1", + "0", + "0" + }, + "Connection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ConnectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CONNECTION_V1_0_0 *ConnectionV1_0_0; + EFI_REDFISH_CONNECTION_V1_0_0_CS *ConnectionV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Connection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Connection_V1_0_0_To_CS (ResoruceRaw, &ConnectionV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ConnectionV1_0_0 = (EFI_REDFISH_CONNECTION_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CONNECTION_V1_0_0)); + if (ConnectionV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ConnectionV1_0_0; + ConnectionV1_0_0->Connection = ConnectionV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Connection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Connection"), "Connection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Connection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Connection"), "Connection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ConnectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ConnectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ConnectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ConnectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Connection_V1_0_0_JSON (*((EFI_REDFISH_CONNECTION_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ConnectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ConnectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CONNECTION_V1_0_0 *ConnectionV1_0_0; + + ConnectionV1_0_0 = (EFI_REDFISH_CONNECTION_V1_0_0 *)InterpProp; + DestroyConnection_V1_0_0_CS (ConnectionV1_0_0->Connection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ConnectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ConnectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyConnection_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishConnection_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ConnectionToStructWrapper, + ConnectionToJson, + ConnectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishConnection_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Connection/v1_0_0/RedfishConnection_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Connection/v1_0_0/RedfishConnection_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..e003ef325aa --- /dev/null +++ b/RedfishClientPkg/Converter/Connection/v1_0_0/RedfishConnection_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Connection.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishConnection_V1_0_0_Dxe + FILE_GUID = 6384108d-66e8-4198-b60c-fb3aaadad661 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishConnection_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishConnection_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Connection_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ConnectionV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ConnectionCollection/ConnectionCollection_Dxe.c b/RedfishClientPkg/Converter/ConnectionCollection/ConnectionCollection_Dxe.c new file mode 100644 index 00000000000..9bb6dcb79ba --- /dev/null +++ b/RedfishClientPkg/Converter/ConnectionCollection/ConnectionCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ConnectionCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ConnectionCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support ConnectionCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ConnectionCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "ConnectionCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ConnectionCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CONNECTIONCOLLECTION *ConnectionCollection; + EFI_REDFISH_CONNECTIONCOLLECTION_CS *ConnectionCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ConnectionCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ConnectionCollection_To_CS (ResoruceRaw, &ConnectionCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + ConnectionCollection = (EFI_REDFISH_CONNECTIONCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CONNECTIONCOLLECTION)); + if (ConnectionCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ConnectionCollection; + ConnectionCollection->ConnectionCollection = ConnectionCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ConnectionCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ConnectionCollection"), "ConnectionCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ConnectionCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ConnectionCollection"), "ConnectionCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ConnectionCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ConnectionCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ConnectionCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ConnectionCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ConnectionCollection_JSON (*((EFI_REDFISH_CONNECTIONCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ConnectionCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ConnectionCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CONNECTIONCOLLECTION *ConnectionCollection; + + ConnectionCollection = (EFI_REDFISH_CONNECTIONCOLLECTION *)InterpProp; + DestroyConnectionCollection_CS (ConnectionCollection->ConnectionCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ConnectionCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ConnectionCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyConnectionCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishConnectionCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ConnectionCollectionToStructWrapper, + ConnectionCollectionToJson, + ConnectionCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishConnectionCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ConnectionCollection/RedfishConnectionCollection_Dxe.inf b/RedfishClientPkg/Converter/ConnectionCollection/RedfishConnectionCollection_Dxe.inf new file mode 100644 index 00000000000..bb45da2fd11 --- /dev/null +++ b/RedfishClientPkg/Converter/ConnectionCollection/RedfishConnectionCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ConnectionCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishConnectionCollection_Dxe + FILE_GUID = 56e32f54-2bc1-4b85-b80c-b0e4d84548ed + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishConnectionCollectionEntryPoint + UNLOAD_IMAGE = RedfishConnectionCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ConnectionCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ConnectionCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ConnectionMethod/v1_0_0/ConnectionMethod_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/ConnectionMethod/v1_0_0/ConnectionMethod_V1_0_0_Dxe.c new file mode 100644 index 00000000000..fdd625fd2ee --- /dev/null +++ b/RedfishClientPkg/Converter/ConnectionMethod/v1_0_0/ConnectionMethod_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ConnectionMethod.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ConnectionMethod"; +BOOLEAN IsRevisonController = TRUE; + +// Support ConnectionMethod V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ConnectionMethod", + "1", + "0", + "0" + }, + "ConnectionMethod" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ConnectionMethodToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CONNECTIONMETHOD_V1_0_0 *ConnectionMethodV1_0_0; + EFI_REDFISH_CONNECTIONMETHOD_V1_0_0_CS *ConnectionMethodV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ConnectionMethod") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ConnectionMethod_V1_0_0_To_CS (ResoruceRaw, &ConnectionMethodV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ConnectionMethodV1_0_0 = (EFI_REDFISH_CONNECTIONMETHOD_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CONNECTIONMETHOD_V1_0_0)); + if (ConnectionMethodV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ConnectionMethodV1_0_0; + ConnectionMethodV1_0_0->ConnectionMethod = ConnectionMethodV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ConnectionMethod")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ConnectionMethod"), "ConnectionMethod"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ConnectionMethod")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ConnectionMethod"), "ConnectionMethod"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ConnectionMethodToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ConnectionMethodToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ConnectionMethodToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ConnectionMethodToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ConnectionMethod_V1_0_0_JSON (*((EFI_REDFISH_CONNECTIONMETHOD_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ConnectionMethodToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ConnectionMethodDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CONNECTIONMETHOD_V1_0_0 *ConnectionMethodV1_0_0; + + ConnectionMethodV1_0_0 = (EFI_REDFISH_CONNECTIONMETHOD_V1_0_0 *)InterpProp; + DestroyConnectionMethod_V1_0_0_CS (ConnectionMethodV1_0_0->ConnectionMethod); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ConnectionMethodFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ConnectionMethodDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyConnectionMethod_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishConnectionMethod_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ConnectionMethodToStructWrapper, + ConnectionMethodToJson, + ConnectionMethodDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishConnectionMethod_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ConnectionMethod/v1_0_0/RedfishConnectionMethod_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/ConnectionMethod/v1_0_0/RedfishConnectionMethod_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..76cfc14d9fa --- /dev/null +++ b/RedfishClientPkg/Converter/ConnectionMethod/v1_0_0/RedfishConnectionMethod_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ConnectionMethod.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishConnectionMethod_V1_0_0_Dxe + FILE_GUID = 06064ed9-aa31-4cac-92d1-e1b314fa186e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishConnectionMethod_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishConnectionMethod_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ConnectionMethod_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ConnectionMethodV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ConnectionMethodCollection/ConnectionMethodCollection_Dxe.c b/RedfishClientPkg/Converter/ConnectionMethodCollection/ConnectionMethodCollection_Dxe.c new file mode 100644 index 00000000000..b7c7f234f59 --- /dev/null +++ b/RedfishClientPkg/Converter/ConnectionMethodCollection/ConnectionMethodCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ConnectionMethodCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ConnectionMethodCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support ConnectionMethodCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ConnectionMethodCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "ConnectionMethodCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ConnectionMethodCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_CONNECTIONMETHODCOLLECTION *ConnectionMethodCollection; + EFI_REDFISH_CONNECTIONMETHODCOLLECTION_CS *ConnectionMethodCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ConnectionMethodCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ConnectionMethodCollection_To_CS (ResoruceRaw, &ConnectionMethodCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + ConnectionMethodCollection = (EFI_REDFISH_CONNECTIONMETHODCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_CONNECTIONMETHODCOLLECTION)); + if (ConnectionMethodCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ConnectionMethodCollection; + ConnectionMethodCollection->ConnectionMethodCollection = ConnectionMethodCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ConnectionMethodCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ConnectionMethodCollection"), "ConnectionMethodCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ConnectionMethodCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ConnectionMethodCollection"), "ConnectionMethodCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ConnectionMethodCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ConnectionMethodCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ConnectionMethodCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ConnectionMethodCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ConnectionMethodCollection_JSON (*((EFI_REDFISH_CONNECTIONMETHODCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ConnectionMethodCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ConnectionMethodCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_CONNECTIONMETHODCOLLECTION *ConnectionMethodCollection; + + ConnectionMethodCollection = (EFI_REDFISH_CONNECTIONMETHODCOLLECTION *)InterpProp; + DestroyConnectionMethodCollection_CS (ConnectionMethodCollection->ConnectionMethodCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ConnectionMethodCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ConnectionMethodCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyConnectionMethodCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishConnectionMethodCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ConnectionMethodCollectionToStructWrapper, + ConnectionMethodCollectionToJson, + ConnectionMethodCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishConnectionMethodCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ConnectionMethodCollection/RedfishConnectionMethodCollection_Dxe.inf b/RedfishClientPkg/Converter/ConnectionMethodCollection/RedfishConnectionMethodCollection_Dxe.inf new file mode 100644 index 00000000000..08d996c9b9c --- /dev/null +++ b/RedfishClientPkg/Converter/ConnectionMethodCollection/RedfishConnectionMethodCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ConnectionMethodCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishConnectionMethodCollection_Dxe + FILE_GUID = 5e1a847c-e5e8-4033-8696-2ffba75dfdf3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishConnectionMethodCollectionEntryPoint + UNLOAD_IMAGE = RedfishConnectionMethodCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ConnectionMethodCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ConnectionMethodCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_0_0/Drive_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_0_0/Drive_V1_0_0_Dxe.c new file mode 100644 index 00000000000..4b6e87c6015 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_0_0/Drive_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "0", + "0" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_0_0 *DriveV1_0_0; + EFI_REDFISH_DRIVE_V1_0_0_CS *DriveV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_0_0_To_CS (ResoruceRaw, &DriveV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_0_0 = (EFI_REDFISH_DRIVE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_0_0)); + if (DriveV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_0_0; + DriveV1_0_0->Drive = DriveV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_0_0_JSON (*((EFI_REDFISH_DRIVE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_0_0 *DriveV1_0_0; + + DriveV1_0_0 = (EFI_REDFISH_DRIVE_V1_0_0 *)InterpProp; + DestroyDrive_V1_0_0_CS (DriveV1_0_0->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_0_0/RedfishDrive_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_0_0/RedfishDrive_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..d0e0670e973 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_0_0/RedfishDrive_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_0_0_Dxe + FILE_GUID = 335d6cc2-5723-40b3-b088-43d8342e620e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_0_1/Drive_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_0_1/Drive_V1_0_1_Dxe.c new file mode 100644 index 00000000000..336ecaeb35e --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_0_1/Drive_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "0", + "1" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_0_1 *DriveV1_0_1; + EFI_REDFISH_DRIVE_V1_0_1_CS *DriveV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_0_1_To_CS (ResoruceRaw, &DriveV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_0_1 = (EFI_REDFISH_DRIVE_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_0_1)); + if (DriveV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_0_1; + DriveV1_0_1->Drive = DriveV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_0_1_JSON (*((EFI_REDFISH_DRIVE_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_0_1 *DriveV1_0_1; + + DriveV1_0_1 = (EFI_REDFISH_DRIVE_V1_0_1 *)InterpProp; + DestroyDrive_V1_0_1_CS (DriveV1_0_1->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_0_1/RedfishDrive_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_0_1/RedfishDrive_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..a90c211103f --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_0_1/RedfishDrive_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_0_1_Dxe + FILE_GUID = ea7ec8d9-8970-48e8-92bb-cb41044fc99d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_0_10/Drive_V1_0_10_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_0_10/Drive_V1_0_10_Dxe.c new file mode 100644 index 00000000000..8e4d296287a --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_0_10/Drive_V1_0_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_0_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "0", + "10" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_0_10 *DriveV1_0_10; + EFI_REDFISH_DRIVE_V1_0_10_CS *DriveV1_0_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_0_10_To_CS (ResoruceRaw, &DriveV1_0_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_0_10 = (EFI_REDFISH_DRIVE_V1_0_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_0_10)); + if (DriveV1_0_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_0_10; + DriveV1_0_10->Drive = DriveV1_0_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_0_10_JSON (*((EFI_REDFISH_DRIVE_V1_0_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_0_10 *DriveV1_0_10; + + DriveV1_0_10 = (EFI_REDFISH_DRIVE_V1_0_10 *)InterpProp; + DestroyDrive_V1_0_10_CS (DriveV1_0_10->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_0_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_0_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_0_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_0_10/RedfishDrive_V1_0_10_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_0_10/RedfishDrive_V1_0_10_Dxe.inf new file mode 100644 index 00000000000..47f4a9259a0 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_0_10/RedfishDrive_V1_0_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_0_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_0_10_Dxe + FILE_GUID = fae9efb5-6ce7-498d-957a-41a64baed56e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_0_10EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_0_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_0_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_0_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_0_11/Drive_V1_0_11_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_0_11/Drive_V1_0_11_Dxe.c new file mode 100644 index 00000000000..f2315594b23 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_0_11/Drive_V1_0_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_0_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "0", + "11" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_0_11 *DriveV1_0_11; + EFI_REDFISH_DRIVE_V1_0_11_CS *DriveV1_0_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_0_11_To_CS (ResoruceRaw, &DriveV1_0_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_0_11 = (EFI_REDFISH_DRIVE_V1_0_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_0_11)); + if (DriveV1_0_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_0_11; + DriveV1_0_11->Drive = DriveV1_0_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_0_11_JSON (*((EFI_REDFISH_DRIVE_V1_0_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_0_11 *DriveV1_0_11; + + DriveV1_0_11 = (EFI_REDFISH_DRIVE_V1_0_11 *)InterpProp; + DestroyDrive_V1_0_11_CS (DriveV1_0_11->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_0_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_0_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_0_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_0_11/RedfishDrive_V1_0_11_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_0_11/RedfishDrive_V1_0_11_Dxe.inf new file mode 100644 index 00000000000..ac22b6e7968 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_0_11/RedfishDrive_V1_0_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_0_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_0_11_Dxe + FILE_GUID = aa5a0332-ede7-446c-ac9e-af03c9824cc1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_0_11EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_0_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_0_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_0_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_0_2/Drive_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_0_2/Drive_V1_0_2_Dxe.c new file mode 100644 index 00000000000..39acee7151c --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_0_2/Drive_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "0", + "2" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_0_2 *DriveV1_0_2; + EFI_REDFISH_DRIVE_V1_0_2_CS *DriveV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_0_2_To_CS (ResoruceRaw, &DriveV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_0_2 = (EFI_REDFISH_DRIVE_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_0_2)); + if (DriveV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_0_2; + DriveV1_0_2->Drive = DriveV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_0_2_JSON (*((EFI_REDFISH_DRIVE_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_0_2 *DriveV1_0_2; + + DriveV1_0_2 = (EFI_REDFISH_DRIVE_V1_0_2 *)InterpProp; + DestroyDrive_V1_0_2_CS (DriveV1_0_2->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_0_2/RedfishDrive_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_0_2/RedfishDrive_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..0225bd5fe72 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_0_2/RedfishDrive_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_0_2_Dxe + FILE_GUID = 58e2827f-2115-4d21-b1ba-f6172a7e308f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_0_3/Drive_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_0_3/Drive_V1_0_3_Dxe.c new file mode 100644 index 00000000000..c2dd30a12b0 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_0_3/Drive_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "0", + "3" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_0_3 *DriveV1_0_3; + EFI_REDFISH_DRIVE_V1_0_3_CS *DriveV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_0_3_To_CS (ResoruceRaw, &DriveV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_0_3 = (EFI_REDFISH_DRIVE_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_0_3)); + if (DriveV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_0_3; + DriveV1_0_3->Drive = DriveV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_0_3_JSON (*((EFI_REDFISH_DRIVE_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_0_3 *DriveV1_0_3; + + DriveV1_0_3 = (EFI_REDFISH_DRIVE_V1_0_3 *)InterpProp; + DestroyDrive_V1_0_3_CS (DriveV1_0_3->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_0_3/RedfishDrive_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_0_3/RedfishDrive_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..a65b544c591 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_0_3/RedfishDrive_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_0_3_Dxe + FILE_GUID = c77c79f9-477f-46f7-9293-4bdbdac092cc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_0_4/Drive_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_0_4/Drive_V1_0_4_Dxe.c new file mode 100644 index 00000000000..b907b840bc8 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_0_4/Drive_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "0", + "4" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_0_4 *DriveV1_0_4; + EFI_REDFISH_DRIVE_V1_0_4_CS *DriveV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_0_4_To_CS (ResoruceRaw, &DriveV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_0_4 = (EFI_REDFISH_DRIVE_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_0_4)); + if (DriveV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_0_4; + DriveV1_0_4->Drive = DriveV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_0_4_JSON (*((EFI_REDFISH_DRIVE_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_0_4 *DriveV1_0_4; + + DriveV1_0_4 = (EFI_REDFISH_DRIVE_V1_0_4 *)InterpProp; + DestroyDrive_V1_0_4_CS (DriveV1_0_4->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_0_4/RedfishDrive_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_0_4/RedfishDrive_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..f0940f6558e --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_0_4/RedfishDrive_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_0_4_Dxe + FILE_GUID = b39ed118-d039-43b7-b792-b074f46000fc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_0_5/Drive_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_0_5/Drive_V1_0_5_Dxe.c new file mode 100644 index 00000000000..f93a1886a8a --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_0_5/Drive_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "0", + "5" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_0_5 *DriveV1_0_5; + EFI_REDFISH_DRIVE_V1_0_5_CS *DriveV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_0_5_To_CS (ResoruceRaw, &DriveV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_0_5 = (EFI_REDFISH_DRIVE_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_0_5)); + if (DriveV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_0_5; + DriveV1_0_5->Drive = DriveV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_0_5_JSON (*((EFI_REDFISH_DRIVE_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_0_5 *DriveV1_0_5; + + DriveV1_0_5 = (EFI_REDFISH_DRIVE_V1_0_5 *)InterpProp; + DestroyDrive_V1_0_5_CS (DriveV1_0_5->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_0_5/RedfishDrive_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_0_5/RedfishDrive_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..209ae8212ce --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_0_5/RedfishDrive_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_0_5_Dxe + FILE_GUID = 7bdbb6e2-0dde-4f67-af95-b02bb57f53a7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_0_6/Drive_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_0_6/Drive_V1_0_6_Dxe.c new file mode 100644 index 00000000000..28dd9dae735 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_0_6/Drive_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "0", + "6" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_0_6 *DriveV1_0_6; + EFI_REDFISH_DRIVE_V1_0_6_CS *DriveV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_0_6_To_CS (ResoruceRaw, &DriveV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_0_6 = (EFI_REDFISH_DRIVE_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_0_6)); + if (DriveV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_0_6; + DriveV1_0_6->Drive = DriveV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_0_6_JSON (*((EFI_REDFISH_DRIVE_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_0_6 *DriveV1_0_6; + + DriveV1_0_6 = (EFI_REDFISH_DRIVE_V1_0_6 *)InterpProp; + DestroyDrive_V1_0_6_CS (DriveV1_0_6->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_0_6/RedfishDrive_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_0_6/RedfishDrive_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..d8081625496 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_0_6/RedfishDrive_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_0_6_Dxe + FILE_GUID = df3c8603-190d-4f04-9a46-4a79d278426b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_0_7/Drive_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_0_7/Drive_V1_0_7_Dxe.c new file mode 100644 index 00000000000..765c0a18068 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_0_7/Drive_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "0", + "7" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_0_7 *DriveV1_0_7; + EFI_REDFISH_DRIVE_V1_0_7_CS *DriveV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_0_7_To_CS (ResoruceRaw, &DriveV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_0_7 = (EFI_REDFISH_DRIVE_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_0_7)); + if (DriveV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_0_7; + DriveV1_0_7->Drive = DriveV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_0_7_JSON (*((EFI_REDFISH_DRIVE_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_0_7 *DriveV1_0_7; + + DriveV1_0_7 = (EFI_REDFISH_DRIVE_V1_0_7 *)InterpProp; + DestroyDrive_V1_0_7_CS (DriveV1_0_7->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_0_7/RedfishDrive_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_0_7/RedfishDrive_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..6a9061d666c --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_0_7/RedfishDrive_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_0_7_Dxe + FILE_GUID = b184229f-ff86-4b00-9dab-cfc59ebaee61 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_0_8/Drive_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_0_8/Drive_V1_0_8_Dxe.c new file mode 100644 index 00000000000..5a2c7bacf41 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_0_8/Drive_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "0", + "8" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_0_8 *DriveV1_0_8; + EFI_REDFISH_DRIVE_V1_0_8_CS *DriveV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_0_8_To_CS (ResoruceRaw, &DriveV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_0_8 = (EFI_REDFISH_DRIVE_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_0_8)); + if (DriveV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_0_8; + DriveV1_0_8->Drive = DriveV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_0_8_JSON (*((EFI_REDFISH_DRIVE_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_0_8 *DriveV1_0_8; + + DriveV1_0_8 = (EFI_REDFISH_DRIVE_V1_0_8 *)InterpProp; + DestroyDrive_V1_0_8_CS (DriveV1_0_8->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_0_8/RedfishDrive_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_0_8/RedfishDrive_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..ce6d4b1c931 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_0_8/RedfishDrive_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_0_8_Dxe + FILE_GUID = d9619eea-7cd2-4299-8f5e-13661ffc282c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_0_9/Drive_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_0_9/Drive_V1_0_9_Dxe.c new file mode 100644 index 00000000000..bd57f379d2d --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_0_9/Drive_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "0", + "9" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_0_9 *DriveV1_0_9; + EFI_REDFISH_DRIVE_V1_0_9_CS *DriveV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_0_9_To_CS (ResoruceRaw, &DriveV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_0_9 = (EFI_REDFISH_DRIVE_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_0_9)); + if (DriveV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_0_9; + DriveV1_0_9->Drive = DriveV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_0_9_JSON (*((EFI_REDFISH_DRIVE_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_0_9 *DriveV1_0_9; + + DriveV1_0_9 = (EFI_REDFISH_DRIVE_V1_0_9 *)InterpProp; + DestroyDrive_V1_0_9_CS (DriveV1_0_9->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_0_9/RedfishDrive_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_0_9/RedfishDrive_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..37ad4b5ee44 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_0_9/RedfishDrive_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_0_9_Dxe + FILE_GUID = bc5d4f40-b32a-40cb-8a76-9574a78fd2b5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_10_0/Drive_V1_10_0_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_10_0/Drive_V1_10_0_Dxe.c new file mode 100644 index 00000000000..fde8af2036d --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_10_0/Drive_V1_10_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_10_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_10_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "10", + "0" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_10_0 *DriveV1_10_0; + EFI_REDFISH_DRIVE_V1_10_0_CS *DriveV1_10_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_10_0_To_CS (ResoruceRaw, &DriveV1_10_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_10_0 = (EFI_REDFISH_DRIVE_V1_10_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_10_0)); + if (DriveV1_10_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_10_0; + DriveV1_10_0->Drive = DriveV1_10_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "10"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_10_0_JSON (*((EFI_REDFISH_DRIVE_V1_10_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_10_0 *DriveV1_10_0; + + DriveV1_10_0 = (EFI_REDFISH_DRIVE_V1_10_0 *)InterpProp; + DestroyDrive_V1_10_0_CS (DriveV1_10_0->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_10_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_10_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_10_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_10_0/RedfishDrive_V1_10_0_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_10_0/RedfishDrive_V1_10_0_Dxe.inf new file mode 100644 index 00000000000..8720cd29fa6 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_10_0/RedfishDrive_V1_10_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_10_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_10_0_Dxe + FILE_GUID = 6e144040-655b-4bde-b991-31eabe73dd8d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_10_0EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_10_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_10_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_10_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_10_1/Drive_V1_10_1_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_10_1/Drive_V1_10_1_Dxe.c new file mode 100644 index 00000000000..c223dd4f58d --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_10_1/Drive_V1_10_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_10_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_10_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "10", + "1" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_10_1 *DriveV1_10_1; + EFI_REDFISH_DRIVE_V1_10_1_CS *DriveV1_10_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_10_1_To_CS (ResoruceRaw, &DriveV1_10_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_10_1 = (EFI_REDFISH_DRIVE_V1_10_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_10_1)); + if (DriveV1_10_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_10_1; + DriveV1_10_1->Drive = DriveV1_10_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "10"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_10_1_JSON (*((EFI_REDFISH_DRIVE_V1_10_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_10_1 *DriveV1_10_1; + + DriveV1_10_1 = (EFI_REDFISH_DRIVE_V1_10_1 *)InterpProp; + DestroyDrive_V1_10_1_CS (DriveV1_10_1->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_10_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_10_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_10_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_10_1/RedfishDrive_V1_10_1_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_10_1/RedfishDrive_V1_10_1_Dxe.inf new file mode 100644 index 00000000000..2720a10f923 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_10_1/RedfishDrive_V1_10_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_10_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_10_1_Dxe + FILE_GUID = 0f372fca-8b4e-4ec8-864c-ca8b6b7f518c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_10_1EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_10_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_10_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_10_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_11_0/Drive_V1_11_0_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_11_0/Drive_V1_11_0_Dxe.c new file mode 100644 index 00000000000..05939583fb5 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_11_0/Drive_V1_11_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_11_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_11_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "11", + "0" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_11_0 *DriveV1_11_0; + EFI_REDFISH_DRIVE_V1_11_0_CS *DriveV1_11_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_11_0_To_CS (ResoruceRaw, &DriveV1_11_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_11_0 = (EFI_REDFISH_DRIVE_V1_11_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_11_0)); + if (DriveV1_11_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_11_0; + DriveV1_11_0->Drive = DriveV1_11_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "11"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_11_0_JSON (*((EFI_REDFISH_DRIVE_V1_11_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_11_0 *DriveV1_11_0; + + DriveV1_11_0 = (EFI_REDFISH_DRIVE_V1_11_0 *)InterpProp; + DestroyDrive_V1_11_0_CS (DriveV1_11_0->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_11_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_11_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_11_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_11_0/RedfishDrive_V1_11_0_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_11_0/RedfishDrive_V1_11_0_Dxe.inf new file mode 100644 index 00000000000..9de74def11a --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_11_0/RedfishDrive_V1_11_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_11_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_11_0_Dxe + FILE_GUID = 291a8a88-7ceb-459b-8caf-a64af9f8d401 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_11_0EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_11_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_11_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_11_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_11_1/Drive_V1_11_1_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_11_1/Drive_V1_11_1_Dxe.c new file mode 100644 index 00000000000..f4d37ebd226 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_11_1/Drive_V1_11_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_11_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_11_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "11", + "1" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_11_1 *DriveV1_11_1; + EFI_REDFISH_DRIVE_V1_11_1_CS *DriveV1_11_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_11_1_To_CS (ResoruceRaw, &DriveV1_11_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_11_1 = (EFI_REDFISH_DRIVE_V1_11_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_11_1)); + if (DriveV1_11_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_11_1; + DriveV1_11_1->Drive = DriveV1_11_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "11"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_11_1_JSON (*((EFI_REDFISH_DRIVE_V1_11_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_11_1 *DriveV1_11_1; + + DriveV1_11_1 = (EFI_REDFISH_DRIVE_V1_11_1 *)InterpProp; + DestroyDrive_V1_11_1_CS (DriveV1_11_1->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_11_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_11_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_11_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_11_1/RedfishDrive_V1_11_1_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_11_1/RedfishDrive_V1_11_1_Dxe.inf new file mode 100644 index 00000000000..21051480e03 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_11_1/RedfishDrive_V1_11_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_11_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_11_1_Dxe + FILE_GUID = 33823ea0-0f63-4b49-89b5-1b1fdcf0e98e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_11_1EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_11_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_11_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_11_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_12_0/Drive_V1_12_0_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_12_0/Drive_V1_12_0_Dxe.c new file mode 100644 index 00000000000..d949cde2d81 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_12_0/Drive_V1_12_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_12_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_12_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "12", + "0" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_12_0 *DriveV1_12_0; + EFI_REDFISH_DRIVE_V1_12_0_CS *DriveV1_12_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "12") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_12_0_To_CS (ResoruceRaw, &DriveV1_12_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_12_0 = (EFI_REDFISH_DRIVE_V1_12_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_12_0)); + if (DriveV1_12_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_12_0; + DriveV1_12_0->Drive = DriveV1_12_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "12"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_12_0_JSON (*((EFI_REDFISH_DRIVE_V1_12_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_12_0 *DriveV1_12_0; + + DriveV1_12_0 = (EFI_REDFISH_DRIVE_V1_12_0 *)InterpProp; + DestroyDrive_V1_12_0_CS (DriveV1_12_0->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_12_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_12_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_12_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_12_0/RedfishDrive_V1_12_0_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_12_0/RedfishDrive_V1_12_0_Dxe.inf new file mode 100644 index 00000000000..60f202debf7 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_12_0/RedfishDrive_V1_12_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_12_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_12_0_Dxe + FILE_GUID = 33439c73-34cf-4317-9634-7bd340a0344f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_12_0EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_12_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_12_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_12_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_1_0/Drive_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_1_0/Drive_V1_1_0_Dxe.c new file mode 100644 index 00000000000..6c666265771 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_1_0/Drive_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "1", + "0" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_1_0 *DriveV1_1_0; + EFI_REDFISH_DRIVE_V1_1_0_CS *DriveV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_1_0_To_CS (ResoruceRaw, &DriveV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_1_0 = (EFI_REDFISH_DRIVE_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_1_0)); + if (DriveV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_1_0; + DriveV1_1_0->Drive = DriveV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_1_0_JSON (*((EFI_REDFISH_DRIVE_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_1_0 *DriveV1_1_0; + + DriveV1_1_0 = (EFI_REDFISH_DRIVE_V1_1_0 *)InterpProp; + DestroyDrive_V1_1_0_CS (DriveV1_1_0->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_1_0/RedfishDrive_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_1_0/RedfishDrive_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..08f183ee6ea --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_1_0/RedfishDrive_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_1_0_Dxe + FILE_GUID = 602fffbc-5d11-4293-9f77-73f26353c129 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_1_1/Drive_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_1_1/Drive_V1_1_1_Dxe.c new file mode 100644 index 00000000000..599418a358d --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_1_1/Drive_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "1", + "1" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_1_1 *DriveV1_1_1; + EFI_REDFISH_DRIVE_V1_1_1_CS *DriveV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_1_1_To_CS (ResoruceRaw, &DriveV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_1_1 = (EFI_REDFISH_DRIVE_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_1_1)); + if (DriveV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_1_1; + DriveV1_1_1->Drive = DriveV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_1_1_JSON (*((EFI_REDFISH_DRIVE_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_1_1 *DriveV1_1_1; + + DriveV1_1_1 = (EFI_REDFISH_DRIVE_V1_1_1 *)InterpProp; + DestroyDrive_V1_1_1_CS (DriveV1_1_1->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_1_1/RedfishDrive_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_1_1/RedfishDrive_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..99a86be36bd --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_1_1/RedfishDrive_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_1_1_Dxe + FILE_GUID = e3a88287-2954-40d3-bca9-cdc621870fb2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_1_10/Drive_V1_1_10_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_1_10/Drive_V1_1_10_Dxe.c new file mode 100644 index 00000000000..1d182c5ecb9 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_1_10/Drive_V1_1_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_1_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_1_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "1", + "10" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_1_10 *DriveV1_1_10; + EFI_REDFISH_DRIVE_V1_1_10_CS *DriveV1_1_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_1_10_To_CS (ResoruceRaw, &DriveV1_1_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_1_10 = (EFI_REDFISH_DRIVE_V1_1_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_1_10)); + if (DriveV1_1_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_1_10; + DriveV1_1_10->Drive = DriveV1_1_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_1_10_JSON (*((EFI_REDFISH_DRIVE_V1_1_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_1_10 *DriveV1_1_10; + + DriveV1_1_10 = (EFI_REDFISH_DRIVE_V1_1_10 *)InterpProp; + DestroyDrive_V1_1_10_CS (DriveV1_1_10->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_1_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_1_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_1_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_1_10/RedfishDrive_V1_1_10_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_1_10/RedfishDrive_V1_1_10_Dxe.inf new file mode 100644 index 00000000000..b49cda696ff --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_1_10/RedfishDrive_V1_1_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_1_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_1_10_Dxe + FILE_GUID = 0ed6a170-6219-4e94-9c66-1b4120d258af + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_1_10EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_1_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_1_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_1_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_1_2/Drive_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_1_2/Drive_V1_1_2_Dxe.c new file mode 100644 index 00000000000..5b6b3344f9e --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_1_2/Drive_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "1", + "2" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_1_2 *DriveV1_1_2; + EFI_REDFISH_DRIVE_V1_1_2_CS *DriveV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_1_2_To_CS (ResoruceRaw, &DriveV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_1_2 = (EFI_REDFISH_DRIVE_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_1_2)); + if (DriveV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_1_2; + DriveV1_1_2->Drive = DriveV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_1_2_JSON (*((EFI_REDFISH_DRIVE_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_1_2 *DriveV1_1_2; + + DriveV1_1_2 = (EFI_REDFISH_DRIVE_V1_1_2 *)InterpProp; + DestroyDrive_V1_1_2_CS (DriveV1_1_2->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_1_2/RedfishDrive_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_1_2/RedfishDrive_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..faa60da3957 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_1_2/RedfishDrive_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_1_2_Dxe + FILE_GUID = 36fdae16-db7c-495d-bad5-3d7db9a55d7a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_1_3/Drive_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_1_3/Drive_V1_1_3_Dxe.c new file mode 100644 index 00000000000..b26fb25eacc --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_1_3/Drive_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "1", + "3" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_1_3 *DriveV1_1_3; + EFI_REDFISH_DRIVE_V1_1_3_CS *DriveV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_1_3_To_CS (ResoruceRaw, &DriveV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_1_3 = (EFI_REDFISH_DRIVE_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_1_3)); + if (DriveV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_1_3; + DriveV1_1_3->Drive = DriveV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_1_3_JSON (*((EFI_REDFISH_DRIVE_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_1_3 *DriveV1_1_3; + + DriveV1_1_3 = (EFI_REDFISH_DRIVE_V1_1_3 *)InterpProp; + DestroyDrive_V1_1_3_CS (DriveV1_1_3->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_1_3/RedfishDrive_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_1_3/RedfishDrive_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..17e2227590d --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_1_3/RedfishDrive_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_1_3_Dxe + FILE_GUID = 3f3c7bd8-2048-419f-acc6-6b0b71d54ecc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_1_4/Drive_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_1_4/Drive_V1_1_4_Dxe.c new file mode 100644 index 00000000000..01b1e2f5308 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_1_4/Drive_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "1", + "4" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_1_4 *DriveV1_1_4; + EFI_REDFISH_DRIVE_V1_1_4_CS *DriveV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_1_4_To_CS (ResoruceRaw, &DriveV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_1_4 = (EFI_REDFISH_DRIVE_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_1_4)); + if (DriveV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_1_4; + DriveV1_1_4->Drive = DriveV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_1_4_JSON (*((EFI_REDFISH_DRIVE_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_1_4 *DriveV1_1_4; + + DriveV1_1_4 = (EFI_REDFISH_DRIVE_V1_1_4 *)InterpProp; + DestroyDrive_V1_1_4_CS (DriveV1_1_4->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_1_4/RedfishDrive_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_1_4/RedfishDrive_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..2f85bd496f5 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_1_4/RedfishDrive_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_1_4_Dxe + FILE_GUID = dde28fab-92f0-4905-b0f9-d8f0acf307e4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_1_5/Drive_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_1_5/Drive_V1_1_5_Dxe.c new file mode 100644 index 00000000000..98023b806bf --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_1_5/Drive_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "1", + "5" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_1_5 *DriveV1_1_5; + EFI_REDFISH_DRIVE_V1_1_5_CS *DriveV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_1_5_To_CS (ResoruceRaw, &DriveV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_1_5 = (EFI_REDFISH_DRIVE_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_1_5)); + if (DriveV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_1_5; + DriveV1_1_5->Drive = DriveV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_1_5_JSON (*((EFI_REDFISH_DRIVE_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_1_5 *DriveV1_1_5; + + DriveV1_1_5 = (EFI_REDFISH_DRIVE_V1_1_5 *)InterpProp; + DestroyDrive_V1_1_5_CS (DriveV1_1_5->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_1_5/RedfishDrive_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_1_5/RedfishDrive_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..876b1cede0c --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_1_5/RedfishDrive_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_1_5_Dxe + FILE_GUID = 424ce8f3-ada9-4655-b546-26aed20a1307 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_1_6/Drive_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_1_6/Drive_V1_1_6_Dxe.c new file mode 100644 index 00000000000..778908920ff --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_1_6/Drive_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "1", + "6" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_1_6 *DriveV1_1_6; + EFI_REDFISH_DRIVE_V1_1_6_CS *DriveV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_1_6_To_CS (ResoruceRaw, &DriveV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_1_6 = (EFI_REDFISH_DRIVE_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_1_6)); + if (DriveV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_1_6; + DriveV1_1_6->Drive = DriveV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_1_6_JSON (*((EFI_REDFISH_DRIVE_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_1_6 *DriveV1_1_6; + + DriveV1_1_6 = (EFI_REDFISH_DRIVE_V1_1_6 *)InterpProp; + DestroyDrive_V1_1_6_CS (DriveV1_1_6->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_1_6/RedfishDrive_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_1_6/RedfishDrive_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..e4ce3b83e85 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_1_6/RedfishDrive_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_1_6_Dxe + FILE_GUID = 98d19a49-803a-4037-b9d2-ce676a3c71e1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_1_7/Drive_V1_1_7_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_1_7/Drive_V1_1_7_Dxe.c new file mode 100644 index 00000000000..b5472cd0b35 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_1_7/Drive_V1_1_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_1_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "1", + "7" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_1_7 *DriveV1_1_7; + EFI_REDFISH_DRIVE_V1_1_7_CS *DriveV1_1_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_1_7_To_CS (ResoruceRaw, &DriveV1_1_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_1_7 = (EFI_REDFISH_DRIVE_V1_1_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_1_7)); + if (DriveV1_1_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_1_7; + DriveV1_1_7->Drive = DriveV1_1_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_1_7_JSON (*((EFI_REDFISH_DRIVE_V1_1_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_1_7 *DriveV1_1_7; + + DriveV1_1_7 = (EFI_REDFISH_DRIVE_V1_1_7 *)InterpProp; + DestroyDrive_V1_1_7_CS (DriveV1_1_7->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_1_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_1_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_1_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_1_7/RedfishDrive_V1_1_7_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_1_7/RedfishDrive_V1_1_7_Dxe.inf new file mode 100644 index 00000000000..bd2f203b031 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_1_7/RedfishDrive_V1_1_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_1_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_1_7_Dxe + FILE_GUID = 9cbc8158-f810-44ea-8ca3-55218dd497b6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_1_7EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_1_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_1_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_1_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_1_8/Drive_V1_1_8_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_1_8/Drive_V1_1_8_Dxe.c new file mode 100644 index 00000000000..e0aa2f968b5 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_1_8/Drive_V1_1_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_1_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "1", + "8" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_1_8 *DriveV1_1_8; + EFI_REDFISH_DRIVE_V1_1_8_CS *DriveV1_1_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_1_8_To_CS (ResoruceRaw, &DriveV1_1_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_1_8 = (EFI_REDFISH_DRIVE_V1_1_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_1_8)); + if (DriveV1_1_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_1_8; + DriveV1_1_8->Drive = DriveV1_1_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_1_8_JSON (*((EFI_REDFISH_DRIVE_V1_1_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_1_8 *DriveV1_1_8; + + DriveV1_1_8 = (EFI_REDFISH_DRIVE_V1_1_8 *)InterpProp; + DestroyDrive_V1_1_8_CS (DriveV1_1_8->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_1_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_1_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_1_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_1_8/RedfishDrive_V1_1_8_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_1_8/RedfishDrive_V1_1_8_Dxe.inf new file mode 100644 index 00000000000..2f939dd28f4 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_1_8/RedfishDrive_V1_1_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_1_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_1_8_Dxe + FILE_GUID = eecd2f1e-accc-437c-af36-c0f077b387db + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_1_8EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_1_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_1_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_1_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_1_9/Drive_V1_1_9_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_1_9/Drive_V1_1_9_Dxe.c new file mode 100644 index 00000000000..b2d3d1f0b25 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_1_9/Drive_V1_1_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_1_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "1", + "9" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_1_9 *DriveV1_1_9; + EFI_REDFISH_DRIVE_V1_1_9_CS *DriveV1_1_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_1_9_To_CS (ResoruceRaw, &DriveV1_1_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_1_9 = (EFI_REDFISH_DRIVE_V1_1_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_1_9)); + if (DriveV1_1_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_1_9; + DriveV1_1_9->Drive = DriveV1_1_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_1_9_JSON (*((EFI_REDFISH_DRIVE_V1_1_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_1_9 *DriveV1_1_9; + + DriveV1_1_9 = (EFI_REDFISH_DRIVE_V1_1_9 *)InterpProp; + DestroyDrive_V1_1_9_CS (DriveV1_1_9->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_1_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_1_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_1_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_1_9/RedfishDrive_V1_1_9_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_1_9/RedfishDrive_V1_1_9_Dxe.inf new file mode 100644 index 00000000000..147c6c84682 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_1_9/RedfishDrive_V1_1_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_1_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_1_9_Dxe + FILE_GUID = 81ec94de-9160-4e83-9178-a3d52e5d74d0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_1_9EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_1_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_1_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_1_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_2_0/Drive_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_2_0/Drive_V1_2_0_Dxe.c new file mode 100644 index 00000000000..78f8e7f1cbe --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_2_0/Drive_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "2", + "0" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_2_0 *DriveV1_2_0; + EFI_REDFISH_DRIVE_V1_2_0_CS *DriveV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_2_0_To_CS (ResoruceRaw, &DriveV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_2_0 = (EFI_REDFISH_DRIVE_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_2_0)); + if (DriveV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_2_0; + DriveV1_2_0->Drive = DriveV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_2_0_JSON (*((EFI_REDFISH_DRIVE_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_2_0 *DriveV1_2_0; + + DriveV1_2_0 = (EFI_REDFISH_DRIVE_V1_2_0 *)InterpProp; + DestroyDrive_V1_2_0_CS (DriveV1_2_0->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_2_0/RedfishDrive_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_2_0/RedfishDrive_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..4e5c095f390 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_2_0/RedfishDrive_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_2_0_Dxe + FILE_GUID = e4d0d2c0-6d71-42a5-9a8e-70d45627ae8b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_2_1/Drive_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_2_1/Drive_V1_2_1_Dxe.c new file mode 100644 index 00000000000..906e185004d --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_2_1/Drive_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "2", + "1" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_2_1 *DriveV1_2_1; + EFI_REDFISH_DRIVE_V1_2_1_CS *DriveV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_2_1_To_CS (ResoruceRaw, &DriveV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_2_1 = (EFI_REDFISH_DRIVE_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_2_1)); + if (DriveV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_2_1; + DriveV1_2_1->Drive = DriveV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_2_1_JSON (*((EFI_REDFISH_DRIVE_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_2_1 *DriveV1_2_1; + + DriveV1_2_1 = (EFI_REDFISH_DRIVE_V1_2_1 *)InterpProp; + DestroyDrive_V1_2_1_CS (DriveV1_2_1->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_2_1/RedfishDrive_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_2_1/RedfishDrive_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..1ab1081c1ff --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_2_1/RedfishDrive_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_2_1_Dxe + FILE_GUID = 853da01a-d894-4353-bb01-f00cc37424c8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_2_2/Drive_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_2_2/Drive_V1_2_2_Dxe.c new file mode 100644 index 00000000000..36c86139662 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_2_2/Drive_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "2", + "2" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_2_2 *DriveV1_2_2; + EFI_REDFISH_DRIVE_V1_2_2_CS *DriveV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_2_2_To_CS (ResoruceRaw, &DriveV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_2_2 = (EFI_REDFISH_DRIVE_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_2_2)); + if (DriveV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_2_2; + DriveV1_2_2->Drive = DriveV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_2_2_JSON (*((EFI_REDFISH_DRIVE_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_2_2 *DriveV1_2_2; + + DriveV1_2_2 = (EFI_REDFISH_DRIVE_V1_2_2 *)InterpProp; + DestroyDrive_V1_2_2_CS (DriveV1_2_2->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_2_2/RedfishDrive_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_2_2/RedfishDrive_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..098029951be --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_2_2/RedfishDrive_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_2_2_Dxe + FILE_GUID = f6aedc4c-69d0-4eca-a37e-fee619e2c944 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_2_3/Drive_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_2_3/Drive_V1_2_3_Dxe.c new file mode 100644 index 00000000000..4ed5b8887fb --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_2_3/Drive_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "2", + "3" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_2_3 *DriveV1_2_3; + EFI_REDFISH_DRIVE_V1_2_3_CS *DriveV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_2_3_To_CS (ResoruceRaw, &DriveV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_2_3 = (EFI_REDFISH_DRIVE_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_2_3)); + if (DriveV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_2_3; + DriveV1_2_3->Drive = DriveV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_2_3_JSON (*((EFI_REDFISH_DRIVE_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_2_3 *DriveV1_2_3; + + DriveV1_2_3 = (EFI_REDFISH_DRIVE_V1_2_3 *)InterpProp; + DestroyDrive_V1_2_3_CS (DriveV1_2_3->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_2_3/RedfishDrive_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_2_3/RedfishDrive_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..5c3c19c6a5a --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_2_3/RedfishDrive_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_2_3_Dxe + FILE_GUID = 8b54c040-ca0a-4aa9-ae7b-ac9557ca3200 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_2_4/Drive_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_2_4/Drive_V1_2_4_Dxe.c new file mode 100644 index 00000000000..d0deabcf2bf --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_2_4/Drive_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "2", + "4" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_2_4 *DriveV1_2_4; + EFI_REDFISH_DRIVE_V1_2_4_CS *DriveV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_2_4_To_CS (ResoruceRaw, &DriveV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_2_4 = (EFI_REDFISH_DRIVE_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_2_4)); + if (DriveV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_2_4; + DriveV1_2_4->Drive = DriveV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_2_4_JSON (*((EFI_REDFISH_DRIVE_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_2_4 *DriveV1_2_4; + + DriveV1_2_4 = (EFI_REDFISH_DRIVE_V1_2_4 *)InterpProp; + DestroyDrive_V1_2_4_CS (DriveV1_2_4->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_2_4/RedfishDrive_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_2_4/RedfishDrive_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..8ae05c31567 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_2_4/RedfishDrive_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_2_4_Dxe + FILE_GUID = e1fb56cc-c11d-4e92-93bc-6d29e0d8b57d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_2_5/Drive_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_2_5/Drive_V1_2_5_Dxe.c new file mode 100644 index 00000000000..f7b3d02e58e --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_2_5/Drive_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "2", + "5" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_2_5 *DriveV1_2_5; + EFI_REDFISH_DRIVE_V1_2_5_CS *DriveV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_2_5_To_CS (ResoruceRaw, &DriveV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_2_5 = (EFI_REDFISH_DRIVE_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_2_5)); + if (DriveV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_2_5; + DriveV1_2_5->Drive = DriveV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_2_5_JSON (*((EFI_REDFISH_DRIVE_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_2_5 *DriveV1_2_5; + + DriveV1_2_5 = (EFI_REDFISH_DRIVE_V1_2_5 *)InterpProp; + DestroyDrive_V1_2_5_CS (DriveV1_2_5->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_2_5/RedfishDrive_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_2_5/RedfishDrive_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..165fb65d9d7 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_2_5/RedfishDrive_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_2_5_Dxe + FILE_GUID = f643db4d-a6fe-47b6-a443-ff1ac2d39ff3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_2_6/Drive_V1_2_6_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_2_6/Drive_V1_2_6_Dxe.c new file mode 100644 index 00000000000..71e1286ef42 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_2_6/Drive_V1_2_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_2_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "2", + "6" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_2_6 *DriveV1_2_6; + EFI_REDFISH_DRIVE_V1_2_6_CS *DriveV1_2_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_2_6_To_CS (ResoruceRaw, &DriveV1_2_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_2_6 = (EFI_REDFISH_DRIVE_V1_2_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_2_6)); + if (DriveV1_2_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_2_6; + DriveV1_2_6->Drive = DriveV1_2_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_2_6_JSON (*((EFI_REDFISH_DRIVE_V1_2_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_2_6 *DriveV1_2_6; + + DriveV1_2_6 = (EFI_REDFISH_DRIVE_V1_2_6 *)InterpProp; + DestroyDrive_V1_2_6_CS (DriveV1_2_6->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_2_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_2_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_2_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_2_6/RedfishDrive_V1_2_6_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_2_6/RedfishDrive_V1_2_6_Dxe.inf new file mode 100644 index 00000000000..a99181d1b29 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_2_6/RedfishDrive_V1_2_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_2_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_2_6_Dxe + FILE_GUID = 7b056733-b5b3-4439-a6fe-cf216c2924b0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_2_6EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_2_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_2_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_2_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_2_7/Drive_V1_2_7_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_2_7/Drive_V1_2_7_Dxe.c new file mode 100644 index 00000000000..d8a5ac69014 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_2_7/Drive_V1_2_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_2_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "2", + "7" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_2_7 *DriveV1_2_7; + EFI_REDFISH_DRIVE_V1_2_7_CS *DriveV1_2_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_2_7_To_CS (ResoruceRaw, &DriveV1_2_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_2_7 = (EFI_REDFISH_DRIVE_V1_2_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_2_7)); + if (DriveV1_2_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_2_7; + DriveV1_2_7->Drive = DriveV1_2_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_2_7_JSON (*((EFI_REDFISH_DRIVE_V1_2_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_2_7 *DriveV1_2_7; + + DriveV1_2_7 = (EFI_REDFISH_DRIVE_V1_2_7 *)InterpProp; + DestroyDrive_V1_2_7_CS (DriveV1_2_7->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_2_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_2_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_2_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_2_7/RedfishDrive_V1_2_7_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_2_7/RedfishDrive_V1_2_7_Dxe.inf new file mode 100644 index 00000000000..e6c7fc1c92b --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_2_7/RedfishDrive_V1_2_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_2_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_2_7_Dxe + FILE_GUID = 1a1b7b52-c387-45f1-ba46-6e695225c159 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_2_7EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_2_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_2_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_2_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_2_8/Drive_V1_2_8_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_2_8/Drive_V1_2_8_Dxe.c new file mode 100644 index 00000000000..3a007a00325 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_2_8/Drive_V1_2_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_2_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "2", + "8" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_2_8 *DriveV1_2_8; + EFI_REDFISH_DRIVE_V1_2_8_CS *DriveV1_2_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_2_8_To_CS (ResoruceRaw, &DriveV1_2_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_2_8 = (EFI_REDFISH_DRIVE_V1_2_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_2_8)); + if (DriveV1_2_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_2_8; + DriveV1_2_8->Drive = DriveV1_2_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_2_8_JSON (*((EFI_REDFISH_DRIVE_V1_2_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_2_8 *DriveV1_2_8; + + DriveV1_2_8 = (EFI_REDFISH_DRIVE_V1_2_8 *)InterpProp; + DestroyDrive_V1_2_8_CS (DriveV1_2_8->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_2_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_2_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_2_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_2_8/RedfishDrive_V1_2_8_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_2_8/RedfishDrive_V1_2_8_Dxe.inf new file mode 100644 index 00000000000..0245e96fb5e --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_2_8/RedfishDrive_V1_2_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_2_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_2_8_Dxe + FILE_GUID = ed43ff7b-b941-4856-9916-c1fcef5b3963 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_2_8EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_2_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_2_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_2_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_3_0/Drive_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_3_0/Drive_V1_3_0_Dxe.c new file mode 100644 index 00000000000..423f6bc245d --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_3_0/Drive_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "3", + "0" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_3_0 *DriveV1_3_0; + EFI_REDFISH_DRIVE_V1_3_0_CS *DriveV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_3_0_To_CS (ResoruceRaw, &DriveV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_3_0 = (EFI_REDFISH_DRIVE_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_3_0)); + if (DriveV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_3_0; + DriveV1_3_0->Drive = DriveV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_3_0_JSON (*((EFI_REDFISH_DRIVE_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_3_0 *DriveV1_3_0; + + DriveV1_3_0 = (EFI_REDFISH_DRIVE_V1_3_0 *)InterpProp; + DestroyDrive_V1_3_0_CS (DriveV1_3_0->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_3_0/RedfishDrive_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_3_0/RedfishDrive_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..6715944cfca --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_3_0/RedfishDrive_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_3_0_Dxe + FILE_GUID = 43797c0c-8dd5-44ac-96e8-3993189f7bf4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_3_1/Drive_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_3_1/Drive_V1_3_1_Dxe.c new file mode 100644 index 00000000000..5f5588d97a9 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_3_1/Drive_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "3", + "1" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_3_1 *DriveV1_3_1; + EFI_REDFISH_DRIVE_V1_3_1_CS *DriveV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_3_1_To_CS (ResoruceRaw, &DriveV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_3_1 = (EFI_REDFISH_DRIVE_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_3_1)); + if (DriveV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_3_1; + DriveV1_3_1->Drive = DriveV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_3_1_JSON (*((EFI_REDFISH_DRIVE_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_3_1 *DriveV1_3_1; + + DriveV1_3_1 = (EFI_REDFISH_DRIVE_V1_3_1 *)InterpProp; + DestroyDrive_V1_3_1_CS (DriveV1_3_1->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_3_1/RedfishDrive_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_3_1/RedfishDrive_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..f94aa41e42f --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_3_1/RedfishDrive_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_3_1_Dxe + FILE_GUID = 35c286b8-af7a-4b3b-9b03-4531b84fd02f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_3_2/Drive_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_3_2/Drive_V1_3_2_Dxe.c new file mode 100644 index 00000000000..6b85c6aefa0 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_3_2/Drive_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "3", + "2" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_3_2 *DriveV1_3_2; + EFI_REDFISH_DRIVE_V1_3_2_CS *DriveV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_3_2_To_CS (ResoruceRaw, &DriveV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_3_2 = (EFI_REDFISH_DRIVE_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_3_2)); + if (DriveV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_3_2; + DriveV1_3_2->Drive = DriveV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_3_2_JSON (*((EFI_REDFISH_DRIVE_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_3_2 *DriveV1_3_2; + + DriveV1_3_2 = (EFI_REDFISH_DRIVE_V1_3_2 *)InterpProp; + DestroyDrive_V1_3_2_CS (DriveV1_3_2->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_3_2/RedfishDrive_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_3_2/RedfishDrive_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..802f025f27d --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_3_2/RedfishDrive_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_3_2_Dxe + FILE_GUID = 042cc4cf-18e3-43bb-bf70-d4fac27a6067 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_3_3/Drive_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_3_3/Drive_V1_3_3_Dxe.c new file mode 100644 index 00000000000..2811a857dbc --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_3_3/Drive_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "3", + "3" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_3_3 *DriveV1_3_3; + EFI_REDFISH_DRIVE_V1_3_3_CS *DriveV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_3_3_To_CS (ResoruceRaw, &DriveV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_3_3 = (EFI_REDFISH_DRIVE_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_3_3)); + if (DriveV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_3_3; + DriveV1_3_3->Drive = DriveV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_3_3_JSON (*((EFI_REDFISH_DRIVE_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_3_3 *DriveV1_3_3; + + DriveV1_3_3 = (EFI_REDFISH_DRIVE_V1_3_3 *)InterpProp; + DestroyDrive_V1_3_3_CS (DriveV1_3_3->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_3_3/RedfishDrive_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_3_3/RedfishDrive_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..a166499f238 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_3_3/RedfishDrive_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_3_3_Dxe + FILE_GUID = e45f5f31-e0d3-4f6d-8c83-b614d45ebe6d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_3_4/Drive_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_3_4/Drive_V1_3_4_Dxe.c new file mode 100644 index 00000000000..0f900d2f31a --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_3_4/Drive_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "3", + "4" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_3_4 *DriveV1_3_4; + EFI_REDFISH_DRIVE_V1_3_4_CS *DriveV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_3_4_To_CS (ResoruceRaw, &DriveV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_3_4 = (EFI_REDFISH_DRIVE_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_3_4)); + if (DriveV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_3_4; + DriveV1_3_4->Drive = DriveV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_3_4_JSON (*((EFI_REDFISH_DRIVE_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_3_4 *DriveV1_3_4; + + DriveV1_3_4 = (EFI_REDFISH_DRIVE_V1_3_4 *)InterpProp; + DestroyDrive_V1_3_4_CS (DriveV1_3_4->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_3_4/RedfishDrive_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_3_4/RedfishDrive_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..fad7736fb73 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_3_4/RedfishDrive_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_3_4_Dxe + FILE_GUID = 303767ff-a52c-4e8c-9d75-242f3c88e6cd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_3_5/Drive_V1_3_5_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_3_5/Drive_V1_3_5_Dxe.c new file mode 100644 index 00000000000..37bb2d18a67 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_3_5/Drive_V1_3_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_3_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "3", + "5" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_3_5 *DriveV1_3_5; + EFI_REDFISH_DRIVE_V1_3_5_CS *DriveV1_3_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_3_5_To_CS (ResoruceRaw, &DriveV1_3_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_3_5 = (EFI_REDFISH_DRIVE_V1_3_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_3_5)); + if (DriveV1_3_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_3_5; + DriveV1_3_5->Drive = DriveV1_3_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_3_5_JSON (*((EFI_REDFISH_DRIVE_V1_3_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_3_5 *DriveV1_3_5; + + DriveV1_3_5 = (EFI_REDFISH_DRIVE_V1_3_5 *)InterpProp; + DestroyDrive_V1_3_5_CS (DriveV1_3_5->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_3_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_3_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_3_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_3_5/RedfishDrive_V1_3_5_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_3_5/RedfishDrive_V1_3_5_Dxe.inf new file mode 100644 index 00000000000..4fd32333d9b --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_3_5/RedfishDrive_V1_3_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_3_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_3_5_Dxe + FILE_GUID = cbe5dc70-c737-457c-a5c1-1b39fa796e65 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_3_5EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_3_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_3_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_3_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_3_6/Drive_V1_3_6_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_3_6/Drive_V1_3_6_Dxe.c new file mode 100644 index 00000000000..2f26fbbaaca --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_3_6/Drive_V1_3_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_3_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "3", + "6" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_3_6 *DriveV1_3_6; + EFI_REDFISH_DRIVE_V1_3_6_CS *DriveV1_3_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_3_6_To_CS (ResoruceRaw, &DriveV1_3_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_3_6 = (EFI_REDFISH_DRIVE_V1_3_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_3_6)); + if (DriveV1_3_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_3_6; + DriveV1_3_6->Drive = DriveV1_3_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_3_6_JSON (*((EFI_REDFISH_DRIVE_V1_3_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_3_6 *DriveV1_3_6; + + DriveV1_3_6 = (EFI_REDFISH_DRIVE_V1_3_6 *)InterpProp; + DestroyDrive_V1_3_6_CS (DriveV1_3_6->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_3_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_3_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_3_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_3_6/RedfishDrive_V1_3_6_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_3_6/RedfishDrive_V1_3_6_Dxe.inf new file mode 100644 index 00000000000..fc7499eb546 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_3_6/RedfishDrive_V1_3_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_3_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_3_6_Dxe + FILE_GUID = 709cea00-dde7-405a-8090-ef3364636e8b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_3_6EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_3_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_3_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_3_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_3_7/Drive_V1_3_7_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_3_7/Drive_V1_3_7_Dxe.c new file mode 100644 index 00000000000..150b45a191c --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_3_7/Drive_V1_3_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_3_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_3_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "3", + "7" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_3_7 *DriveV1_3_7; + EFI_REDFISH_DRIVE_V1_3_7_CS *DriveV1_3_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_3_7_To_CS (ResoruceRaw, &DriveV1_3_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_3_7 = (EFI_REDFISH_DRIVE_V1_3_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_3_7)); + if (DriveV1_3_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_3_7; + DriveV1_3_7->Drive = DriveV1_3_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_3_7_JSON (*((EFI_REDFISH_DRIVE_V1_3_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_3_7 *DriveV1_3_7; + + DriveV1_3_7 = (EFI_REDFISH_DRIVE_V1_3_7 *)InterpProp; + DestroyDrive_V1_3_7_CS (DriveV1_3_7->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_3_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_3_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_3_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_3_7/RedfishDrive_V1_3_7_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_3_7/RedfishDrive_V1_3_7_Dxe.inf new file mode 100644 index 00000000000..c63ec59cf5a --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_3_7/RedfishDrive_V1_3_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_3_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_3_7_Dxe + FILE_GUID = 955f0815-0c59-4229-881f-de659ae96d4e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_3_7EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_3_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_3_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_3_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_4_0/Drive_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_4_0/Drive_V1_4_0_Dxe.c new file mode 100644 index 00000000000..dcf429831c4 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_4_0/Drive_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "4", + "0" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_4_0 *DriveV1_4_0; + EFI_REDFISH_DRIVE_V1_4_0_CS *DriveV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_4_0_To_CS (ResoruceRaw, &DriveV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_4_0 = (EFI_REDFISH_DRIVE_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_4_0)); + if (DriveV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_4_0; + DriveV1_4_0->Drive = DriveV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_4_0_JSON (*((EFI_REDFISH_DRIVE_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_4_0 *DriveV1_4_0; + + DriveV1_4_0 = (EFI_REDFISH_DRIVE_V1_4_0 *)InterpProp; + DestroyDrive_V1_4_0_CS (DriveV1_4_0->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_4_0/RedfishDrive_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_4_0/RedfishDrive_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..d8ba68728d5 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_4_0/RedfishDrive_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_4_0_Dxe + FILE_GUID = cabf89b0-9268-4941-aa73-2ce0cf218a7c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_4_1/Drive_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_4_1/Drive_V1_4_1_Dxe.c new file mode 100644 index 00000000000..26f2535a1c6 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_4_1/Drive_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "4", + "1" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_4_1 *DriveV1_4_1; + EFI_REDFISH_DRIVE_V1_4_1_CS *DriveV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_4_1_To_CS (ResoruceRaw, &DriveV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_4_1 = (EFI_REDFISH_DRIVE_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_4_1)); + if (DriveV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_4_1; + DriveV1_4_1->Drive = DriveV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_4_1_JSON (*((EFI_REDFISH_DRIVE_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_4_1 *DriveV1_4_1; + + DriveV1_4_1 = (EFI_REDFISH_DRIVE_V1_4_1 *)InterpProp; + DestroyDrive_V1_4_1_CS (DriveV1_4_1->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_4_1/RedfishDrive_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_4_1/RedfishDrive_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..8dafa429079 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_4_1/RedfishDrive_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_4_1_Dxe + FILE_GUID = 04d6b2cc-68ac-4b89-aa33-f1dfd5238e73 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_4_2/Drive_V1_4_2_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_4_2/Drive_V1_4_2_Dxe.c new file mode 100644 index 00000000000..31108578ab9 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_4_2/Drive_V1_4_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_4_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "4", + "2" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_4_2 *DriveV1_4_2; + EFI_REDFISH_DRIVE_V1_4_2_CS *DriveV1_4_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_4_2_To_CS (ResoruceRaw, &DriveV1_4_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_4_2 = (EFI_REDFISH_DRIVE_V1_4_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_4_2)); + if (DriveV1_4_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_4_2; + DriveV1_4_2->Drive = DriveV1_4_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_4_2_JSON (*((EFI_REDFISH_DRIVE_V1_4_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_4_2 *DriveV1_4_2; + + DriveV1_4_2 = (EFI_REDFISH_DRIVE_V1_4_2 *)InterpProp; + DestroyDrive_V1_4_2_CS (DriveV1_4_2->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_4_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_4_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_4_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_4_2/RedfishDrive_V1_4_2_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_4_2/RedfishDrive_V1_4_2_Dxe.inf new file mode 100644 index 00000000000..0991d9f549a --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_4_2/RedfishDrive_V1_4_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_4_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_4_2_Dxe + FILE_GUID = 24d83fd3-30dc-433f-a84f-7568fcab561c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_4_2EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_4_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_4_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_4_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_4_3/Drive_V1_4_3_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_4_3/Drive_V1_4_3_Dxe.c new file mode 100644 index 00000000000..593dc89157d --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_4_3/Drive_V1_4_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_4_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "4", + "3" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_4_3 *DriveV1_4_3; + EFI_REDFISH_DRIVE_V1_4_3_CS *DriveV1_4_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_4_3_To_CS (ResoruceRaw, &DriveV1_4_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_4_3 = (EFI_REDFISH_DRIVE_V1_4_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_4_3)); + if (DriveV1_4_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_4_3; + DriveV1_4_3->Drive = DriveV1_4_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_4_3_JSON (*((EFI_REDFISH_DRIVE_V1_4_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_4_3 *DriveV1_4_3; + + DriveV1_4_3 = (EFI_REDFISH_DRIVE_V1_4_3 *)InterpProp; + DestroyDrive_V1_4_3_CS (DriveV1_4_3->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_4_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_4_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_4_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_4_3/RedfishDrive_V1_4_3_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_4_3/RedfishDrive_V1_4_3_Dxe.inf new file mode 100644 index 00000000000..b6a8ae67379 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_4_3/RedfishDrive_V1_4_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_4_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_4_3_Dxe + FILE_GUID = 9202f9b4-5e75-451a-8de5-2be36240780a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_4_3EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_4_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_4_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_4_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_4_4/Drive_V1_4_4_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_4_4/Drive_V1_4_4_Dxe.c new file mode 100644 index 00000000000..eec01a6ffd1 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_4_4/Drive_V1_4_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_4_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "4", + "4" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_4_4 *DriveV1_4_4; + EFI_REDFISH_DRIVE_V1_4_4_CS *DriveV1_4_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_4_4_To_CS (ResoruceRaw, &DriveV1_4_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_4_4 = (EFI_REDFISH_DRIVE_V1_4_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_4_4)); + if (DriveV1_4_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_4_4; + DriveV1_4_4->Drive = DriveV1_4_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_4_4_JSON (*((EFI_REDFISH_DRIVE_V1_4_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_4_4 *DriveV1_4_4; + + DriveV1_4_4 = (EFI_REDFISH_DRIVE_V1_4_4 *)InterpProp; + DestroyDrive_V1_4_4_CS (DriveV1_4_4->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_4_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_4_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_4_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_4_4/RedfishDrive_V1_4_4_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_4_4/RedfishDrive_V1_4_4_Dxe.inf new file mode 100644 index 00000000000..afb8acd4235 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_4_4/RedfishDrive_V1_4_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_4_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_4_4_Dxe + FILE_GUID = 2ed0b7cf-6518-42be-a5bb-8179976e087c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_4_4EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_4_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_4_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_4_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_4_5/Drive_V1_4_5_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_4_5/Drive_V1_4_5_Dxe.c new file mode 100644 index 00000000000..8ff102a5c2c --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_4_5/Drive_V1_4_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_4_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "4", + "5" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_4_5 *DriveV1_4_5; + EFI_REDFISH_DRIVE_V1_4_5_CS *DriveV1_4_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_4_5_To_CS (ResoruceRaw, &DriveV1_4_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_4_5 = (EFI_REDFISH_DRIVE_V1_4_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_4_5)); + if (DriveV1_4_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_4_5; + DriveV1_4_5->Drive = DriveV1_4_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_4_5_JSON (*((EFI_REDFISH_DRIVE_V1_4_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_4_5 *DriveV1_4_5; + + DriveV1_4_5 = (EFI_REDFISH_DRIVE_V1_4_5 *)InterpProp; + DestroyDrive_V1_4_5_CS (DriveV1_4_5->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_4_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_4_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_4_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_4_5/RedfishDrive_V1_4_5_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_4_5/RedfishDrive_V1_4_5_Dxe.inf new file mode 100644 index 00000000000..cd8bf9de87e --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_4_5/RedfishDrive_V1_4_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_4_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_4_5_Dxe + FILE_GUID = 1cc33ffb-e109-4eea-a2b8-0acd012238d8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_4_5EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_4_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_4_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_4_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_4_6/Drive_V1_4_6_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_4_6/Drive_V1_4_6_Dxe.c new file mode 100644 index 00000000000..f1d25f70d7c --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_4_6/Drive_V1_4_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_4_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_4_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "4", + "6" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_4_6 *DriveV1_4_6; + EFI_REDFISH_DRIVE_V1_4_6_CS *DriveV1_4_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_4_6_To_CS (ResoruceRaw, &DriveV1_4_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_4_6 = (EFI_REDFISH_DRIVE_V1_4_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_4_6)); + if (DriveV1_4_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_4_6; + DriveV1_4_6->Drive = DriveV1_4_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_4_6_JSON (*((EFI_REDFISH_DRIVE_V1_4_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_4_6 *DriveV1_4_6; + + DriveV1_4_6 = (EFI_REDFISH_DRIVE_V1_4_6 *)InterpProp; + DestroyDrive_V1_4_6_CS (DriveV1_4_6->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_4_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_4_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_4_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_4_6/RedfishDrive_V1_4_6_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_4_6/RedfishDrive_V1_4_6_Dxe.inf new file mode 100644 index 00000000000..a2e111dbc44 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_4_6/RedfishDrive_V1_4_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_4_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_4_6_Dxe + FILE_GUID = c2cce339-e2e2-45ba-9e8e-d38bfc4a6698 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_4_6EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_4_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_4_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_4_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_4_7/Drive_V1_4_7_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_4_7/Drive_V1_4_7_Dxe.c new file mode 100644 index 00000000000..0db42b2f2e0 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_4_7/Drive_V1_4_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_4_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_4_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "4", + "7" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_4_7 *DriveV1_4_7; + EFI_REDFISH_DRIVE_V1_4_7_CS *DriveV1_4_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_4_7_To_CS (ResoruceRaw, &DriveV1_4_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_4_7 = (EFI_REDFISH_DRIVE_V1_4_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_4_7)); + if (DriveV1_4_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_4_7; + DriveV1_4_7->Drive = DriveV1_4_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_4_7_JSON (*((EFI_REDFISH_DRIVE_V1_4_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_4_7 *DriveV1_4_7; + + DriveV1_4_7 = (EFI_REDFISH_DRIVE_V1_4_7 *)InterpProp; + DestroyDrive_V1_4_7_CS (DriveV1_4_7->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_4_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_4_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_4_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_4_7/RedfishDrive_V1_4_7_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_4_7/RedfishDrive_V1_4_7_Dxe.inf new file mode 100644 index 00000000000..c74a9d58141 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_4_7/RedfishDrive_V1_4_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_4_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_4_7_Dxe + FILE_GUID = edf964d5-aed2-45f3-951e-45e198fb9b51 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_4_7EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_4_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_4_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_4_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_5_0/Drive_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_5_0/Drive_V1_5_0_Dxe.c new file mode 100644 index 00000000000..946749f943a --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_5_0/Drive_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "5", + "0" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_5_0 *DriveV1_5_0; + EFI_REDFISH_DRIVE_V1_5_0_CS *DriveV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_5_0_To_CS (ResoruceRaw, &DriveV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_5_0 = (EFI_REDFISH_DRIVE_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_5_0)); + if (DriveV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_5_0; + DriveV1_5_0->Drive = DriveV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_5_0_JSON (*((EFI_REDFISH_DRIVE_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_5_0 *DriveV1_5_0; + + DriveV1_5_0 = (EFI_REDFISH_DRIVE_V1_5_0 *)InterpProp; + DestroyDrive_V1_5_0_CS (DriveV1_5_0->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_5_0/RedfishDrive_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_5_0/RedfishDrive_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..715dc4414ba --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_5_0/RedfishDrive_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_5_0_Dxe + FILE_GUID = 5ebf526c-a31a-42a7-bedb-5dae9120a432 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_5_1/Drive_V1_5_1_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_5_1/Drive_V1_5_1_Dxe.c new file mode 100644 index 00000000000..d4b1117cbac --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_5_1/Drive_V1_5_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_5_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "5", + "1" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_5_1 *DriveV1_5_1; + EFI_REDFISH_DRIVE_V1_5_1_CS *DriveV1_5_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_5_1_To_CS (ResoruceRaw, &DriveV1_5_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_5_1 = (EFI_REDFISH_DRIVE_V1_5_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_5_1)); + if (DriveV1_5_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_5_1; + DriveV1_5_1->Drive = DriveV1_5_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_5_1_JSON (*((EFI_REDFISH_DRIVE_V1_5_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_5_1 *DriveV1_5_1; + + DriveV1_5_1 = (EFI_REDFISH_DRIVE_V1_5_1 *)InterpProp; + DestroyDrive_V1_5_1_CS (DriveV1_5_1->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_5_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_5_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_5_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_5_1/RedfishDrive_V1_5_1_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_5_1/RedfishDrive_V1_5_1_Dxe.inf new file mode 100644 index 00000000000..b76c9ed7e21 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_5_1/RedfishDrive_V1_5_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_5_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_5_1_Dxe + FILE_GUID = d53a3ede-5bb7-4d88-9308-bf9f65de1da5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_5_1EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_5_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_5_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_5_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_5_2/Drive_V1_5_2_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_5_2/Drive_V1_5_2_Dxe.c new file mode 100644 index 00000000000..754aa91b328 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_5_2/Drive_V1_5_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_5_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "5", + "2" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_5_2 *DriveV1_5_2; + EFI_REDFISH_DRIVE_V1_5_2_CS *DriveV1_5_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_5_2_To_CS (ResoruceRaw, &DriveV1_5_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_5_2 = (EFI_REDFISH_DRIVE_V1_5_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_5_2)); + if (DriveV1_5_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_5_2; + DriveV1_5_2->Drive = DriveV1_5_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_5_2_JSON (*((EFI_REDFISH_DRIVE_V1_5_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_5_2 *DriveV1_5_2; + + DriveV1_5_2 = (EFI_REDFISH_DRIVE_V1_5_2 *)InterpProp; + DestroyDrive_V1_5_2_CS (DriveV1_5_2->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_5_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_5_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_5_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_5_2/RedfishDrive_V1_5_2_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_5_2/RedfishDrive_V1_5_2_Dxe.inf new file mode 100644 index 00000000000..482ca5a8840 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_5_2/RedfishDrive_V1_5_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_5_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_5_2_Dxe + FILE_GUID = 75c0fcb1-8197-40c6-9a00-c38a0ca1060d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_5_2EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_5_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_5_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_5_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_5_3/Drive_V1_5_3_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_5_3/Drive_V1_5_3_Dxe.c new file mode 100644 index 00000000000..17e4a1f2144 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_5_3/Drive_V1_5_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_5_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "5", + "3" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_5_3 *DriveV1_5_3; + EFI_REDFISH_DRIVE_V1_5_3_CS *DriveV1_5_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_5_3_To_CS (ResoruceRaw, &DriveV1_5_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_5_3 = (EFI_REDFISH_DRIVE_V1_5_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_5_3)); + if (DriveV1_5_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_5_3; + DriveV1_5_3->Drive = DriveV1_5_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_5_3_JSON (*((EFI_REDFISH_DRIVE_V1_5_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_5_3 *DriveV1_5_3; + + DriveV1_5_3 = (EFI_REDFISH_DRIVE_V1_5_3 *)InterpProp; + DestroyDrive_V1_5_3_CS (DriveV1_5_3->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_5_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_5_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_5_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_5_3/RedfishDrive_V1_5_3_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_5_3/RedfishDrive_V1_5_3_Dxe.inf new file mode 100644 index 00000000000..fa1362fc926 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_5_3/RedfishDrive_V1_5_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_5_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_5_3_Dxe + FILE_GUID = abec6e00-fdba-417a-88a0-35c74291111b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_5_3EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_5_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_5_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_5_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_5_4/Drive_V1_5_4_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_5_4/Drive_V1_5_4_Dxe.c new file mode 100644 index 00000000000..634ec24d0ea --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_5_4/Drive_V1_5_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_5_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "5", + "4" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_5_4 *DriveV1_5_4; + EFI_REDFISH_DRIVE_V1_5_4_CS *DriveV1_5_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_5_4_To_CS (ResoruceRaw, &DriveV1_5_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_5_4 = (EFI_REDFISH_DRIVE_V1_5_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_5_4)); + if (DriveV1_5_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_5_4; + DriveV1_5_4->Drive = DriveV1_5_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_5_4_JSON (*((EFI_REDFISH_DRIVE_V1_5_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_5_4 *DriveV1_5_4; + + DriveV1_5_4 = (EFI_REDFISH_DRIVE_V1_5_4 *)InterpProp; + DestroyDrive_V1_5_4_CS (DriveV1_5_4->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_5_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_5_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_5_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_5_4/RedfishDrive_V1_5_4_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_5_4/RedfishDrive_V1_5_4_Dxe.inf new file mode 100644 index 00000000000..52e2f822915 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_5_4/RedfishDrive_V1_5_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_5_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_5_4_Dxe + FILE_GUID = 5fad5467-3c39-4135-a631-408335c7daee + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_5_4EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_5_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_5_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_5_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_5_5/Drive_V1_5_5_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_5_5/Drive_V1_5_5_Dxe.c new file mode 100644 index 00000000000..33b1b29695d --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_5_5/Drive_V1_5_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_5_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_5_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "5", + "5" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_5_5 *DriveV1_5_5; + EFI_REDFISH_DRIVE_V1_5_5_CS *DriveV1_5_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_5_5_To_CS (ResoruceRaw, &DriveV1_5_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_5_5 = (EFI_REDFISH_DRIVE_V1_5_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_5_5)); + if (DriveV1_5_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_5_5; + DriveV1_5_5->Drive = DriveV1_5_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_5_5_JSON (*((EFI_REDFISH_DRIVE_V1_5_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_5_5 *DriveV1_5_5; + + DriveV1_5_5 = (EFI_REDFISH_DRIVE_V1_5_5 *)InterpProp; + DestroyDrive_V1_5_5_CS (DriveV1_5_5->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_5_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_5_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_5_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_5_5/RedfishDrive_V1_5_5_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_5_5/RedfishDrive_V1_5_5_Dxe.inf new file mode 100644 index 00000000000..15e0863280a --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_5_5/RedfishDrive_V1_5_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_5_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_5_5_Dxe + FILE_GUID = 8b52c19a-02ee-4372-b91d-8fd6c59963eb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_5_5EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_5_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_5_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_5_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_5_6/Drive_V1_5_6_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_5_6/Drive_V1_5_6_Dxe.c new file mode 100644 index 00000000000..3154876fe61 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_5_6/Drive_V1_5_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_5_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_5_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "5", + "6" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_5_6 *DriveV1_5_6; + EFI_REDFISH_DRIVE_V1_5_6_CS *DriveV1_5_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_5_6_To_CS (ResoruceRaw, &DriveV1_5_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_5_6 = (EFI_REDFISH_DRIVE_V1_5_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_5_6)); + if (DriveV1_5_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_5_6; + DriveV1_5_6->Drive = DriveV1_5_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_5_6_JSON (*((EFI_REDFISH_DRIVE_V1_5_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_5_6 *DriveV1_5_6; + + DriveV1_5_6 = (EFI_REDFISH_DRIVE_V1_5_6 *)InterpProp; + DestroyDrive_V1_5_6_CS (DriveV1_5_6->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_5_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_5_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_5_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_5_6/RedfishDrive_V1_5_6_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_5_6/RedfishDrive_V1_5_6_Dxe.inf new file mode 100644 index 00000000000..95ca4f9f395 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_5_6/RedfishDrive_V1_5_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_5_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_5_6_Dxe + FILE_GUID = f9569161-f3c2-4355-8b92-718eee8d3661 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_5_6EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_5_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_5_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_5_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_6_0/Drive_V1_6_0_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_6_0/Drive_V1_6_0_Dxe.c new file mode 100644 index 00000000000..b8fb6281e09 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_6_0/Drive_V1_6_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_6_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "6", + "0" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_6_0 *DriveV1_6_0; + EFI_REDFISH_DRIVE_V1_6_0_CS *DriveV1_6_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_6_0_To_CS (ResoruceRaw, &DriveV1_6_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_6_0 = (EFI_REDFISH_DRIVE_V1_6_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_6_0)); + if (DriveV1_6_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_6_0; + DriveV1_6_0->Drive = DriveV1_6_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_6_0_JSON (*((EFI_REDFISH_DRIVE_V1_6_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_6_0 *DriveV1_6_0; + + DriveV1_6_0 = (EFI_REDFISH_DRIVE_V1_6_0 *)InterpProp; + DestroyDrive_V1_6_0_CS (DriveV1_6_0->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_6_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_6_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_6_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_6_0/RedfishDrive_V1_6_0_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_6_0/RedfishDrive_V1_6_0_Dxe.inf new file mode 100644 index 00000000000..42494a48446 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_6_0/RedfishDrive_V1_6_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_6_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_6_0_Dxe + FILE_GUID = 000862f8-7eb3-4bdd-b542-44719bd9ab17 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_6_0EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_6_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_6_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_6_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_6_1/Drive_V1_6_1_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_6_1/Drive_V1_6_1_Dxe.c new file mode 100644 index 00000000000..e0642380833 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_6_1/Drive_V1_6_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_6_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "6", + "1" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_6_1 *DriveV1_6_1; + EFI_REDFISH_DRIVE_V1_6_1_CS *DriveV1_6_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_6_1_To_CS (ResoruceRaw, &DriveV1_6_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_6_1 = (EFI_REDFISH_DRIVE_V1_6_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_6_1)); + if (DriveV1_6_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_6_1; + DriveV1_6_1->Drive = DriveV1_6_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_6_1_JSON (*((EFI_REDFISH_DRIVE_V1_6_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_6_1 *DriveV1_6_1; + + DriveV1_6_1 = (EFI_REDFISH_DRIVE_V1_6_1 *)InterpProp; + DestroyDrive_V1_6_1_CS (DriveV1_6_1->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_6_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_6_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_6_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_6_1/RedfishDrive_V1_6_1_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_6_1/RedfishDrive_V1_6_1_Dxe.inf new file mode 100644 index 00000000000..100f676a4d4 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_6_1/RedfishDrive_V1_6_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_6_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_6_1_Dxe + FILE_GUID = 02c661d1-c4b9-49a2-bd6e-c91f32a965ca + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_6_1EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_6_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_6_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_6_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_6_2/Drive_V1_6_2_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_6_2/Drive_V1_6_2_Dxe.c new file mode 100644 index 00000000000..d5089aac05c --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_6_2/Drive_V1_6_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_6_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "6", + "2" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_6_2 *DriveV1_6_2; + EFI_REDFISH_DRIVE_V1_6_2_CS *DriveV1_6_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_6_2_To_CS (ResoruceRaw, &DriveV1_6_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_6_2 = (EFI_REDFISH_DRIVE_V1_6_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_6_2)); + if (DriveV1_6_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_6_2; + DriveV1_6_2->Drive = DriveV1_6_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_6_2_JSON (*((EFI_REDFISH_DRIVE_V1_6_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_6_2 *DriveV1_6_2; + + DriveV1_6_2 = (EFI_REDFISH_DRIVE_V1_6_2 *)InterpProp; + DestroyDrive_V1_6_2_CS (DriveV1_6_2->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_6_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_6_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_6_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_6_2/RedfishDrive_V1_6_2_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_6_2/RedfishDrive_V1_6_2_Dxe.inf new file mode 100644 index 00000000000..84d4b08e3f8 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_6_2/RedfishDrive_V1_6_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_6_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_6_2_Dxe + FILE_GUID = 9bfc04fa-3087-4e81-8b0c-64154fe6e1c2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_6_2EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_6_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_6_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_6_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_6_3/Drive_V1_6_3_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_6_3/Drive_V1_6_3_Dxe.c new file mode 100644 index 00000000000..ef8f05ed334 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_6_3/Drive_V1_6_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_6_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_6_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "6", + "3" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_6_3 *DriveV1_6_3; + EFI_REDFISH_DRIVE_V1_6_3_CS *DriveV1_6_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_6_3_To_CS (ResoruceRaw, &DriveV1_6_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_6_3 = (EFI_REDFISH_DRIVE_V1_6_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_6_3)); + if (DriveV1_6_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_6_3; + DriveV1_6_3->Drive = DriveV1_6_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_6_3_JSON (*((EFI_REDFISH_DRIVE_V1_6_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_6_3 *DriveV1_6_3; + + DriveV1_6_3 = (EFI_REDFISH_DRIVE_V1_6_3 *)InterpProp; + DestroyDrive_V1_6_3_CS (DriveV1_6_3->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_6_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_6_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_6_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_6_3/RedfishDrive_V1_6_3_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_6_3/RedfishDrive_V1_6_3_Dxe.inf new file mode 100644 index 00000000000..dc0a81e52ae --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_6_3/RedfishDrive_V1_6_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_6_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_6_3_Dxe + FILE_GUID = ae339d58-c550-4e16-9212-97512b2530a8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_6_3EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_6_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_6_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_6_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_6_4/Drive_V1_6_4_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_6_4/Drive_V1_6_4_Dxe.c new file mode 100644 index 00000000000..a1705443ecd --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_6_4/Drive_V1_6_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_6_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_6_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "6", + "4" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_6_4 *DriveV1_6_4; + EFI_REDFISH_DRIVE_V1_6_4_CS *DriveV1_6_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_6_4_To_CS (ResoruceRaw, &DriveV1_6_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_6_4 = (EFI_REDFISH_DRIVE_V1_6_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_6_4)); + if (DriveV1_6_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_6_4; + DriveV1_6_4->Drive = DriveV1_6_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_6_4_JSON (*((EFI_REDFISH_DRIVE_V1_6_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_6_4 *DriveV1_6_4; + + DriveV1_6_4 = (EFI_REDFISH_DRIVE_V1_6_4 *)InterpProp; + DestroyDrive_V1_6_4_CS (DriveV1_6_4->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_6_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_6_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_6_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_6_4/RedfishDrive_V1_6_4_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_6_4/RedfishDrive_V1_6_4_Dxe.inf new file mode 100644 index 00000000000..318e229a44a --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_6_4/RedfishDrive_V1_6_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_6_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_6_4_Dxe + FILE_GUID = 078b95f0-5be5-4fc5-a879-0ee5953db410 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_6_4EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_6_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_6_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_6_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_7_0/Drive_V1_7_0_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_7_0/Drive_V1_7_0_Dxe.c new file mode 100644 index 00000000000..644cef01b90 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_7_0/Drive_V1_7_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_7_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "7", + "0" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_7_0 *DriveV1_7_0; + EFI_REDFISH_DRIVE_V1_7_0_CS *DriveV1_7_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_7_0_To_CS (ResoruceRaw, &DriveV1_7_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_7_0 = (EFI_REDFISH_DRIVE_V1_7_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_7_0)); + if (DriveV1_7_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_7_0; + DriveV1_7_0->Drive = DriveV1_7_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_7_0_JSON (*((EFI_REDFISH_DRIVE_V1_7_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_7_0 *DriveV1_7_0; + + DriveV1_7_0 = (EFI_REDFISH_DRIVE_V1_7_0 *)InterpProp; + DestroyDrive_V1_7_0_CS (DriveV1_7_0->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_7_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_7_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_7_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_7_0/RedfishDrive_V1_7_0_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_7_0/RedfishDrive_V1_7_0_Dxe.inf new file mode 100644 index 00000000000..0e2229e94ba --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_7_0/RedfishDrive_V1_7_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_7_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_7_0_Dxe + FILE_GUID = 90a134bc-6f59-4824-aef5-6c5950ccc15e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_7_0EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_7_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_7_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_7_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_7_1/Drive_V1_7_1_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_7_1/Drive_V1_7_1_Dxe.c new file mode 100644 index 00000000000..968c6d4809f --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_7_1/Drive_V1_7_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_7_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_7_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "7", + "1" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_7_1 *DriveV1_7_1; + EFI_REDFISH_DRIVE_V1_7_1_CS *DriveV1_7_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_7_1_To_CS (ResoruceRaw, &DriveV1_7_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_7_1 = (EFI_REDFISH_DRIVE_V1_7_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_7_1)); + if (DriveV1_7_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_7_1; + DriveV1_7_1->Drive = DriveV1_7_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_7_1_JSON (*((EFI_REDFISH_DRIVE_V1_7_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_7_1 *DriveV1_7_1; + + DriveV1_7_1 = (EFI_REDFISH_DRIVE_V1_7_1 *)InterpProp; + DestroyDrive_V1_7_1_CS (DriveV1_7_1->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_7_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_7_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_7_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_7_1/RedfishDrive_V1_7_1_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_7_1/RedfishDrive_V1_7_1_Dxe.inf new file mode 100644 index 00000000000..4e82b53bd9c --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_7_1/RedfishDrive_V1_7_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_7_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_7_1_Dxe + FILE_GUID = 7883f0c5-9fb4-40c7-ab8c-fb0d38a3a098 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_7_1EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_7_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_7_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_7_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_7_2/Drive_V1_7_2_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_7_2/Drive_V1_7_2_Dxe.c new file mode 100644 index 00000000000..4936fbc2955 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_7_2/Drive_V1_7_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_7_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_7_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "7", + "2" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_7_2 *DriveV1_7_2; + EFI_REDFISH_DRIVE_V1_7_2_CS *DriveV1_7_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_7_2_To_CS (ResoruceRaw, &DriveV1_7_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_7_2 = (EFI_REDFISH_DRIVE_V1_7_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_7_2)); + if (DriveV1_7_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_7_2; + DriveV1_7_2->Drive = DriveV1_7_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_7_2_JSON (*((EFI_REDFISH_DRIVE_V1_7_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_7_2 *DriveV1_7_2; + + DriveV1_7_2 = (EFI_REDFISH_DRIVE_V1_7_2 *)InterpProp; + DestroyDrive_V1_7_2_CS (DriveV1_7_2->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_7_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_7_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_7_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_7_2/RedfishDrive_V1_7_2_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_7_2/RedfishDrive_V1_7_2_Dxe.inf new file mode 100644 index 00000000000..e9567243dd9 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_7_2/RedfishDrive_V1_7_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_7_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_7_2_Dxe + FILE_GUID = c9784616-c9ca-40d5-8648-c83844e8fef5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_7_2EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_7_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_7_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_7_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_7_3/Drive_V1_7_3_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_7_3/Drive_V1_7_3_Dxe.c new file mode 100644 index 00000000000..48284e2458e --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_7_3/Drive_V1_7_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_7_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_7_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "7", + "3" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_7_3 *DriveV1_7_3; + EFI_REDFISH_DRIVE_V1_7_3_CS *DriveV1_7_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_7_3_To_CS (ResoruceRaw, &DriveV1_7_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_7_3 = (EFI_REDFISH_DRIVE_V1_7_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_7_3)); + if (DriveV1_7_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_7_3; + DriveV1_7_3->Drive = DriveV1_7_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_7_3_JSON (*((EFI_REDFISH_DRIVE_V1_7_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_7_3 *DriveV1_7_3; + + DriveV1_7_3 = (EFI_REDFISH_DRIVE_V1_7_3 *)InterpProp; + DestroyDrive_V1_7_3_CS (DriveV1_7_3->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_7_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_7_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_7_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_7_3/RedfishDrive_V1_7_3_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_7_3/RedfishDrive_V1_7_3_Dxe.inf new file mode 100644 index 00000000000..82f69119564 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_7_3/RedfishDrive_V1_7_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_7_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_7_3_Dxe + FILE_GUID = bee1ffb5-c1b6-4e6b-8036-a742e9d5c357 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_7_3EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_7_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_7_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_7_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_8_0/Drive_V1_8_0_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_8_0/Drive_V1_8_0_Dxe.c new file mode 100644 index 00000000000..053981ead94 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_8_0/Drive_V1_8_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_8_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_8_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "8", + "0" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_8_0 *DriveV1_8_0; + EFI_REDFISH_DRIVE_V1_8_0_CS *DriveV1_8_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_8_0_To_CS (ResoruceRaw, &DriveV1_8_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_8_0 = (EFI_REDFISH_DRIVE_V1_8_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_8_0)); + if (DriveV1_8_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_8_0; + DriveV1_8_0->Drive = DriveV1_8_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_8_0_JSON (*((EFI_REDFISH_DRIVE_V1_8_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_8_0 *DriveV1_8_0; + + DriveV1_8_0 = (EFI_REDFISH_DRIVE_V1_8_0 *)InterpProp; + DestroyDrive_V1_8_0_CS (DriveV1_8_0->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_8_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_8_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_8_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_8_0/RedfishDrive_V1_8_0_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_8_0/RedfishDrive_V1_8_0_Dxe.inf new file mode 100644 index 00000000000..08a04fceaa9 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_8_0/RedfishDrive_V1_8_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_8_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_8_0_Dxe + FILE_GUID = 392d03e3-ba8d-43fb-b8ba-23f8d76ffe8c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_8_0EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_8_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_8_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_8_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_8_1/Drive_V1_8_1_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_8_1/Drive_V1_8_1_Dxe.c new file mode 100644 index 00000000000..adf0569457a --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_8_1/Drive_V1_8_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_8_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_8_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "8", + "1" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_8_1 *DriveV1_8_1; + EFI_REDFISH_DRIVE_V1_8_1_CS *DriveV1_8_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_8_1_To_CS (ResoruceRaw, &DriveV1_8_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_8_1 = (EFI_REDFISH_DRIVE_V1_8_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_8_1)); + if (DriveV1_8_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_8_1; + DriveV1_8_1->Drive = DriveV1_8_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_8_1_JSON (*((EFI_REDFISH_DRIVE_V1_8_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_8_1 *DriveV1_8_1; + + DriveV1_8_1 = (EFI_REDFISH_DRIVE_V1_8_1 *)InterpProp; + DestroyDrive_V1_8_1_CS (DriveV1_8_1->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_8_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_8_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_8_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_8_1/RedfishDrive_V1_8_1_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_8_1/RedfishDrive_V1_8_1_Dxe.inf new file mode 100644 index 00000000000..feb4d6d4c2f --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_8_1/RedfishDrive_V1_8_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_8_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_8_1_Dxe + FILE_GUID = aa81e741-8f88-4a96-b586-c72e16ebbe69 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_8_1EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_8_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_8_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_8_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_8_2/Drive_V1_8_2_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_8_2/Drive_V1_8_2_Dxe.c new file mode 100644 index 00000000000..ad06a3d1786 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_8_2/Drive_V1_8_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_8_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_8_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "8", + "2" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_8_2 *DriveV1_8_2; + EFI_REDFISH_DRIVE_V1_8_2_CS *DriveV1_8_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_8_2_To_CS (ResoruceRaw, &DriveV1_8_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_8_2 = (EFI_REDFISH_DRIVE_V1_8_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_8_2)); + if (DriveV1_8_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_8_2; + DriveV1_8_2->Drive = DriveV1_8_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_8_2_JSON (*((EFI_REDFISH_DRIVE_V1_8_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_8_2 *DriveV1_8_2; + + DriveV1_8_2 = (EFI_REDFISH_DRIVE_V1_8_2 *)InterpProp; + DestroyDrive_V1_8_2_CS (DriveV1_8_2->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_8_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_8_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_8_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_8_2/RedfishDrive_V1_8_2_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_8_2/RedfishDrive_V1_8_2_Dxe.inf new file mode 100644 index 00000000000..7f1c95af8a9 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_8_2/RedfishDrive_V1_8_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_8_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_8_2_Dxe + FILE_GUID = c1b1a885-7ce3-4f52-94cf-603f0842f7ae + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_8_2EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_8_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_8_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_8_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_8_3/Drive_V1_8_3_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_8_3/Drive_V1_8_3_Dxe.c new file mode 100644 index 00000000000..c50339c0da0 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_8_3/Drive_V1_8_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_8_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_8_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "8", + "3" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_8_3 *DriveV1_8_3; + EFI_REDFISH_DRIVE_V1_8_3_CS *DriveV1_8_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_8_3_To_CS (ResoruceRaw, &DriveV1_8_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_8_3 = (EFI_REDFISH_DRIVE_V1_8_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_8_3)); + if (DriveV1_8_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_8_3; + DriveV1_8_3->Drive = DriveV1_8_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_8_3_JSON (*((EFI_REDFISH_DRIVE_V1_8_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_8_3 *DriveV1_8_3; + + DriveV1_8_3 = (EFI_REDFISH_DRIVE_V1_8_3 *)InterpProp; + DestroyDrive_V1_8_3_CS (DriveV1_8_3->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_8_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_8_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_8_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_8_3/RedfishDrive_V1_8_3_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_8_3/RedfishDrive_V1_8_3_Dxe.inf new file mode 100644 index 00000000000..27fe26adcfa --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_8_3/RedfishDrive_V1_8_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_8_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_8_3_Dxe + FILE_GUID = a840cbb7-b02b-41e0-9cc6-071c325a864f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_8_3EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_8_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_8_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_8_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_9_0/Drive_V1_9_0_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_9_0/Drive_V1_9_0_Dxe.c new file mode 100644 index 00000000000..a5e57b5c029 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_9_0/Drive_V1_9_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_9_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_9_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "9", + "0" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_9_0 *DriveV1_9_0; + EFI_REDFISH_DRIVE_V1_9_0_CS *DriveV1_9_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_9_0_To_CS (ResoruceRaw, &DriveV1_9_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_9_0 = (EFI_REDFISH_DRIVE_V1_9_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_9_0)); + if (DriveV1_9_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_9_0; + DriveV1_9_0->Drive = DriveV1_9_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_9_0_JSON (*((EFI_REDFISH_DRIVE_V1_9_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_9_0 *DriveV1_9_0; + + DriveV1_9_0 = (EFI_REDFISH_DRIVE_V1_9_0 *)InterpProp; + DestroyDrive_V1_9_0_CS (DriveV1_9_0->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_9_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_9_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_9_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_9_0/RedfishDrive_V1_9_0_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_9_0/RedfishDrive_V1_9_0_Dxe.inf new file mode 100644 index 00000000000..4ccc161770c --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_9_0/RedfishDrive_V1_9_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_9_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_9_0_Dxe + FILE_GUID = b4fec24a-b228-4285-ba78-d3863ce4b7be + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_9_0EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_9_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_9_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_9_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_9_1/Drive_V1_9_1_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_9_1/Drive_V1_9_1_Dxe.c new file mode 100644 index 00000000000..101afd49389 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_9_1/Drive_V1_9_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_9_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_9_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "9", + "1" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_9_1 *DriveV1_9_1; + EFI_REDFISH_DRIVE_V1_9_1_CS *DriveV1_9_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_9_1_To_CS (ResoruceRaw, &DriveV1_9_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_9_1 = (EFI_REDFISH_DRIVE_V1_9_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_9_1)); + if (DriveV1_9_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_9_1; + DriveV1_9_1->Drive = DriveV1_9_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_9_1_JSON (*((EFI_REDFISH_DRIVE_V1_9_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_9_1 *DriveV1_9_1; + + DriveV1_9_1 = (EFI_REDFISH_DRIVE_V1_9_1 *)InterpProp; + DestroyDrive_V1_9_1_CS (DriveV1_9_1->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_9_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_9_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_9_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_9_1/RedfishDrive_V1_9_1_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_9_1/RedfishDrive_V1_9_1_Dxe.inf new file mode 100644 index 00000000000..31c1f1d01de --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_9_1/RedfishDrive_V1_9_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_9_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_9_1_Dxe + FILE_GUID = 21dab53c-4898-43c4-a746-df1f7d741ff0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_9_1EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_9_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_9_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_9_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_9_2/Drive_V1_9_2_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_9_2/Drive_V1_9_2_Dxe.c new file mode 100644 index 00000000000..67a1a9034df --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_9_2/Drive_V1_9_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_9_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_9_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "9", + "2" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_9_2 *DriveV1_9_2; + EFI_REDFISH_DRIVE_V1_9_2_CS *DriveV1_9_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_9_2_To_CS (ResoruceRaw, &DriveV1_9_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_9_2 = (EFI_REDFISH_DRIVE_V1_9_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_9_2)); + if (DriveV1_9_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_9_2; + DriveV1_9_2->Drive = DriveV1_9_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_9_2_JSON (*((EFI_REDFISH_DRIVE_V1_9_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_9_2 *DriveV1_9_2; + + DriveV1_9_2 = (EFI_REDFISH_DRIVE_V1_9_2 *)InterpProp; + DestroyDrive_V1_9_2_CS (DriveV1_9_2->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_9_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_9_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_9_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_9_2/RedfishDrive_V1_9_2_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_9_2/RedfishDrive_V1_9_2_Dxe.inf new file mode 100644 index 00000000000..139dbdd2cc1 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_9_2/RedfishDrive_V1_9_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_9_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_9_2_Dxe + FILE_GUID = 4e563c2d-800a-46a5-b5d5-b9b12f54b3e9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_9_2EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_9_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_9_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_9_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Drive/v1_9_3/Drive_V1_9_3_Dxe.c b/RedfishClientPkg/Converter/Drive/v1_9_3/Drive_V1_9_3_Dxe.c new file mode 100644 index 00000000000..fec7868b113 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_9_3/Drive_V1_9_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Drive.v1_9_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Drive"; +BOOLEAN IsRevisonController = TRUE; + +// Support Drive V1_9_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Drive", + "1", + "9", + "3" + }, + "Drive" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_9_3 *DriveV1_9_3; + EFI_REDFISH_DRIVE_V1_9_3_CS *DriveV1_9_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Drive") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Drive_V1_9_3_To_CS (ResoruceRaw, &DriveV1_9_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveV1_9_3 = (EFI_REDFISH_DRIVE_V1_9_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVE_V1_9_3)); + if (DriveV1_9_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveV1_9_3; + DriveV1_9_3->Drive = DriveV1_9_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Drive"), "Drive"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Drive")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Drive"), "Drive"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Drive_V1_9_3_JSON (*((EFI_REDFISH_DRIVE_V1_9_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVE_V1_9_3 *DriveV1_9_3; + + DriveV1_9_3 = (EFI_REDFISH_DRIVE_V1_9_3 *)InterpProp; + DestroyDrive_V1_9_3_CS (DriveV1_9_3->Drive); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDrive_V1_9_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_9_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveToStructWrapper, + DriveToJson, + DriveDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDrive_V1_9_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Drive/v1_9_3/RedfishDrive_V1_9_3_Dxe.inf b/RedfishClientPkg/Converter/Drive/v1_9_3/RedfishDrive_V1_9_3_Dxe.inf new file mode 100644 index 00000000000..6343ce7cd56 --- /dev/null +++ b/RedfishClientPkg/Converter/Drive/v1_9_3/RedfishDrive_V1_9_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Drive.v1_9_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDrive_V1_9_3_Dxe + FILE_GUID = 0f311bbd-1acb-437b-8e2e-423bde197ea0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDrive_V1_9_3EntryPoint + UNLOAD_IMAGE = RedfishDrive_V1_9_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Drive_V1_9_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveV1_9_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/DriveCollection/DriveCollection_Dxe.c b/RedfishClientPkg/Converter/DriveCollection/DriveCollection_Dxe.c new file mode 100644 index 00000000000..4b3437b2ef9 --- /dev/null +++ b/RedfishClientPkg/Converter/DriveCollection/DriveCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - DriveCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#DriveCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support DriveCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "DriveCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "DriveCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_DRIVECOLLECTION *DriveCollection; + EFI_REDFISH_DRIVECOLLECTION_CS *DriveCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "DriveCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_DriveCollection_To_CS (ResoruceRaw, &DriveCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + DriveCollection = (EFI_REDFISH_DRIVECOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_DRIVECOLLECTION)); + if (DriveCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)DriveCollection; + DriveCollection->DriveCollection = DriveCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("DriveCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("DriveCollection"), "DriveCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("DriveCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("DriveCollection"), "DriveCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of DriveCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return DriveCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_DriveCollection_JSON (*((EFI_REDFISH_DRIVECOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in DriveCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_DRIVECOLLECTION *DriveCollection; + + DriveCollection = (EFI_REDFISH_DRIVECOLLECTION *)InterpProp; + DestroyDriveCollection_CS (DriveCollection->DriveCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from DriveCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +DriveCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyDriveCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishDriveCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + DriveCollectionToStructWrapper, + DriveCollectionToJson, + DriveCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishDriveCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/DriveCollection/RedfishDriveCollection_Dxe.inf b/RedfishClientPkg/Converter/DriveCollection/RedfishDriveCollection_Dxe.inf new file mode 100644 index 00000000000..4176ca2d6c6 --- /dev/null +++ b/RedfishClientPkg/Converter/DriveCollection/RedfishDriveCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of DriveCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishDriveCollection_Dxe + FILE_GUID = 91802c1f-3b4a-4659-a52d-12a5450518a2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishDriveCollectionEntryPoint + UNLOAD_IMAGE = RedfishDriveCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + DriveCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + DriveCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_0_0/Endpoint_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_0_0/Endpoint_V1_0_0_Dxe.c new file mode 100644 index 00000000000..932c956ad47 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_0_0/Endpoint_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "0", + "0" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_0_0 *EndpointV1_0_0; + EFI_REDFISH_ENDPOINT_V1_0_0_CS *EndpointV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_0_0_To_CS (ResoruceRaw, &EndpointV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_0_0 = (EFI_REDFISH_ENDPOINT_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_0_0)); + if (EndpointV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_0_0; + EndpointV1_0_0->Endpoint = EndpointV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_0_0_JSON (*((EFI_REDFISH_ENDPOINT_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_0_0 *EndpointV1_0_0; + + EndpointV1_0_0 = (EFI_REDFISH_ENDPOINT_V1_0_0 *)InterpProp; + DestroyEndpoint_V1_0_0_CS (EndpointV1_0_0->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_0_0/RedfishEndpoint_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_0_0/RedfishEndpoint_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..308b787d6bf --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_0_0/RedfishEndpoint_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_0_0_Dxe + FILE_GUID = ab94d515-6d64-42dd-ae11-c21e613679ea + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_0_1/Endpoint_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_0_1/Endpoint_V1_0_1_Dxe.c new file mode 100644 index 00000000000..0eb6eaee243 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_0_1/Endpoint_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "0", + "1" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_0_1 *EndpointV1_0_1; + EFI_REDFISH_ENDPOINT_V1_0_1_CS *EndpointV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_0_1_To_CS (ResoruceRaw, &EndpointV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_0_1 = (EFI_REDFISH_ENDPOINT_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_0_1)); + if (EndpointV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_0_1; + EndpointV1_0_1->Endpoint = EndpointV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_0_1_JSON (*((EFI_REDFISH_ENDPOINT_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_0_1 *EndpointV1_0_1; + + EndpointV1_0_1 = (EFI_REDFISH_ENDPOINT_V1_0_1 *)InterpProp; + DestroyEndpoint_V1_0_1_CS (EndpointV1_0_1->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_0_1/RedfishEndpoint_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_0_1/RedfishEndpoint_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..5df31dd022f --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_0_1/RedfishEndpoint_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_0_1_Dxe + FILE_GUID = 4009da78-f920-4995-b79c-241bb635ba29 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_0_10/Endpoint_V1_0_10_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_0_10/Endpoint_V1_0_10_Dxe.c new file mode 100644 index 00000000000..e17e13dd87b --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_0_10/Endpoint_V1_0_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_0_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "0", + "10" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_0_10 *EndpointV1_0_10; + EFI_REDFISH_ENDPOINT_V1_0_10_CS *EndpointV1_0_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_0_10_To_CS (ResoruceRaw, &EndpointV1_0_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_0_10 = (EFI_REDFISH_ENDPOINT_V1_0_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_0_10)); + if (EndpointV1_0_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_0_10; + EndpointV1_0_10->Endpoint = EndpointV1_0_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_0_10_JSON (*((EFI_REDFISH_ENDPOINT_V1_0_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_0_10 *EndpointV1_0_10; + + EndpointV1_0_10 = (EFI_REDFISH_ENDPOINT_V1_0_10 *)InterpProp; + DestroyEndpoint_V1_0_10_CS (EndpointV1_0_10->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_0_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_0_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_0_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_0_10/RedfishEndpoint_V1_0_10_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_0_10/RedfishEndpoint_V1_0_10_Dxe.inf new file mode 100644 index 00000000000..5eab7a6923f --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_0_10/RedfishEndpoint_V1_0_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_0_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_0_10_Dxe + FILE_GUID = 97792e80-48e5-4cf1-b880-efc793103696 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_0_10EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_0_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_0_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_0_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_0_2/Endpoint_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_0_2/Endpoint_V1_0_2_Dxe.c new file mode 100644 index 00000000000..d82afb7b9e6 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_0_2/Endpoint_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "0", + "2" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_0_2 *EndpointV1_0_2; + EFI_REDFISH_ENDPOINT_V1_0_2_CS *EndpointV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_0_2_To_CS (ResoruceRaw, &EndpointV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_0_2 = (EFI_REDFISH_ENDPOINT_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_0_2)); + if (EndpointV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_0_2; + EndpointV1_0_2->Endpoint = EndpointV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_0_2_JSON (*((EFI_REDFISH_ENDPOINT_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_0_2 *EndpointV1_0_2; + + EndpointV1_0_2 = (EFI_REDFISH_ENDPOINT_V1_0_2 *)InterpProp; + DestroyEndpoint_V1_0_2_CS (EndpointV1_0_2->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_0_2/RedfishEndpoint_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_0_2/RedfishEndpoint_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..b8e0e82c463 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_0_2/RedfishEndpoint_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_0_2_Dxe + FILE_GUID = c15f3100-9f40-400f-a9f5-a1ceb372d7cf + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_0_3/Endpoint_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_0_3/Endpoint_V1_0_3_Dxe.c new file mode 100644 index 00000000000..bc83e20157d --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_0_3/Endpoint_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "0", + "3" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_0_3 *EndpointV1_0_3; + EFI_REDFISH_ENDPOINT_V1_0_3_CS *EndpointV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_0_3_To_CS (ResoruceRaw, &EndpointV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_0_3 = (EFI_REDFISH_ENDPOINT_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_0_3)); + if (EndpointV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_0_3; + EndpointV1_0_3->Endpoint = EndpointV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_0_3_JSON (*((EFI_REDFISH_ENDPOINT_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_0_3 *EndpointV1_0_3; + + EndpointV1_0_3 = (EFI_REDFISH_ENDPOINT_V1_0_3 *)InterpProp; + DestroyEndpoint_V1_0_3_CS (EndpointV1_0_3->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_0_3/RedfishEndpoint_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_0_3/RedfishEndpoint_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..e09edc146b8 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_0_3/RedfishEndpoint_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_0_3_Dxe + FILE_GUID = 3bbd84b0-6788-4942-89cc-748ef973988c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_0_4/Endpoint_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_0_4/Endpoint_V1_0_4_Dxe.c new file mode 100644 index 00000000000..fe789607c00 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_0_4/Endpoint_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "0", + "4" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_0_4 *EndpointV1_0_4; + EFI_REDFISH_ENDPOINT_V1_0_4_CS *EndpointV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_0_4_To_CS (ResoruceRaw, &EndpointV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_0_4 = (EFI_REDFISH_ENDPOINT_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_0_4)); + if (EndpointV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_0_4; + EndpointV1_0_4->Endpoint = EndpointV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_0_4_JSON (*((EFI_REDFISH_ENDPOINT_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_0_4 *EndpointV1_0_4; + + EndpointV1_0_4 = (EFI_REDFISH_ENDPOINT_V1_0_4 *)InterpProp; + DestroyEndpoint_V1_0_4_CS (EndpointV1_0_4->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_0_4/RedfishEndpoint_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_0_4/RedfishEndpoint_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..8fad6b31c61 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_0_4/RedfishEndpoint_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_0_4_Dxe + FILE_GUID = 9fc5c7cf-84cb-44a6-81f2-8b269521273d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_0_5/Endpoint_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_0_5/Endpoint_V1_0_5_Dxe.c new file mode 100644 index 00000000000..20f2bc45989 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_0_5/Endpoint_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "0", + "5" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_0_5 *EndpointV1_0_5; + EFI_REDFISH_ENDPOINT_V1_0_5_CS *EndpointV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_0_5_To_CS (ResoruceRaw, &EndpointV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_0_5 = (EFI_REDFISH_ENDPOINT_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_0_5)); + if (EndpointV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_0_5; + EndpointV1_0_5->Endpoint = EndpointV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_0_5_JSON (*((EFI_REDFISH_ENDPOINT_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_0_5 *EndpointV1_0_5; + + EndpointV1_0_5 = (EFI_REDFISH_ENDPOINT_V1_0_5 *)InterpProp; + DestroyEndpoint_V1_0_5_CS (EndpointV1_0_5->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_0_5/RedfishEndpoint_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_0_5/RedfishEndpoint_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..99f931f44bc --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_0_5/RedfishEndpoint_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_0_5_Dxe + FILE_GUID = b4a53b5d-e312-4b74-b8a7-ea38db8c82d1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_0_6/Endpoint_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_0_6/Endpoint_V1_0_6_Dxe.c new file mode 100644 index 00000000000..2b6d8880e33 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_0_6/Endpoint_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "0", + "6" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_0_6 *EndpointV1_0_6; + EFI_REDFISH_ENDPOINT_V1_0_6_CS *EndpointV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_0_6_To_CS (ResoruceRaw, &EndpointV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_0_6 = (EFI_REDFISH_ENDPOINT_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_0_6)); + if (EndpointV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_0_6; + EndpointV1_0_6->Endpoint = EndpointV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_0_6_JSON (*((EFI_REDFISH_ENDPOINT_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_0_6 *EndpointV1_0_6; + + EndpointV1_0_6 = (EFI_REDFISH_ENDPOINT_V1_0_6 *)InterpProp; + DestroyEndpoint_V1_0_6_CS (EndpointV1_0_6->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_0_6/RedfishEndpoint_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_0_6/RedfishEndpoint_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..f38c5c2fba1 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_0_6/RedfishEndpoint_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_0_6_Dxe + FILE_GUID = a269306b-3365-4ce5-b639-9daf28ccb47a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_0_7/Endpoint_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_0_7/Endpoint_V1_0_7_Dxe.c new file mode 100644 index 00000000000..8f4cf5eaed9 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_0_7/Endpoint_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "0", + "7" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_0_7 *EndpointV1_0_7; + EFI_REDFISH_ENDPOINT_V1_0_7_CS *EndpointV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_0_7_To_CS (ResoruceRaw, &EndpointV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_0_7 = (EFI_REDFISH_ENDPOINT_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_0_7)); + if (EndpointV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_0_7; + EndpointV1_0_7->Endpoint = EndpointV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_0_7_JSON (*((EFI_REDFISH_ENDPOINT_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_0_7 *EndpointV1_0_7; + + EndpointV1_0_7 = (EFI_REDFISH_ENDPOINT_V1_0_7 *)InterpProp; + DestroyEndpoint_V1_0_7_CS (EndpointV1_0_7->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_0_7/RedfishEndpoint_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_0_7/RedfishEndpoint_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..7fef61ebb9c --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_0_7/RedfishEndpoint_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_0_7_Dxe + FILE_GUID = fb27b47a-d5ba-4387-b892-844231cedde6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_0_8/Endpoint_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_0_8/Endpoint_V1_0_8_Dxe.c new file mode 100644 index 00000000000..3e133e65fdd --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_0_8/Endpoint_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "0", + "8" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_0_8 *EndpointV1_0_8; + EFI_REDFISH_ENDPOINT_V1_0_8_CS *EndpointV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_0_8_To_CS (ResoruceRaw, &EndpointV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_0_8 = (EFI_REDFISH_ENDPOINT_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_0_8)); + if (EndpointV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_0_8; + EndpointV1_0_8->Endpoint = EndpointV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_0_8_JSON (*((EFI_REDFISH_ENDPOINT_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_0_8 *EndpointV1_0_8; + + EndpointV1_0_8 = (EFI_REDFISH_ENDPOINT_V1_0_8 *)InterpProp; + DestroyEndpoint_V1_0_8_CS (EndpointV1_0_8->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_0_8/RedfishEndpoint_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_0_8/RedfishEndpoint_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..9e15430ba55 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_0_8/RedfishEndpoint_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_0_8_Dxe + FILE_GUID = b8dc5adf-d9b1-46a7-a670-f61576fef67b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_0_9/Endpoint_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_0_9/Endpoint_V1_0_9_Dxe.c new file mode 100644 index 00000000000..bebb6895b2b --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_0_9/Endpoint_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "0", + "9" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_0_9 *EndpointV1_0_9; + EFI_REDFISH_ENDPOINT_V1_0_9_CS *EndpointV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_0_9_To_CS (ResoruceRaw, &EndpointV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_0_9 = (EFI_REDFISH_ENDPOINT_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_0_9)); + if (EndpointV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_0_9; + EndpointV1_0_9->Endpoint = EndpointV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_0_9_JSON (*((EFI_REDFISH_ENDPOINT_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_0_9 *EndpointV1_0_9; + + EndpointV1_0_9 = (EFI_REDFISH_ENDPOINT_V1_0_9 *)InterpProp; + DestroyEndpoint_V1_0_9_CS (EndpointV1_0_9->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_0_9/RedfishEndpoint_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_0_9/RedfishEndpoint_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..6c9cad22745 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_0_9/RedfishEndpoint_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_0_9_Dxe + FILE_GUID = 4dcb9dd9-eb2c-48e2-a43f-ea620bf47a2a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_1_0/Endpoint_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_1_0/Endpoint_V1_1_0_Dxe.c new file mode 100644 index 00000000000..71b04255945 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_1_0/Endpoint_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "1", + "0" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_1_0 *EndpointV1_1_0; + EFI_REDFISH_ENDPOINT_V1_1_0_CS *EndpointV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_1_0_To_CS (ResoruceRaw, &EndpointV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_1_0 = (EFI_REDFISH_ENDPOINT_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_1_0)); + if (EndpointV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_1_0; + EndpointV1_1_0->Endpoint = EndpointV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_1_0_JSON (*((EFI_REDFISH_ENDPOINT_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_1_0 *EndpointV1_1_0; + + EndpointV1_1_0 = (EFI_REDFISH_ENDPOINT_V1_1_0 *)InterpProp; + DestroyEndpoint_V1_1_0_CS (EndpointV1_1_0->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_1_0/RedfishEndpoint_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_1_0/RedfishEndpoint_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..30e4bd5df9b --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_1_0/RedfishEndpoint_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_1_0_Dxe + FILE_GUID = 01c92462-e5ad-4364-8779-471c769c3fab + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_1_1/Endpoint_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_1_1/Endpoint_V1_1_1_Dxe.c new file mode 100644 index 00000000000..0750a0588f8 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_1_1/Endpoint_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "1", + "1" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_1_1 *EndpointV1_1_1; + EFI_REDFISH_ENDPOINT_V1_1_1_CS *EndpointV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_1_1_To_CS (ResoruceRaw, &EndpointV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_1_1 = (EFI_REDFISH_ENDPOINT_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_1_1)); + if (EndpointV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_1_1; + EndpointV1_1_1->Endpoint = EndpointV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_1_1_JSON (*((EFI_REDFISH_ENDPOINT_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_1_1 *EndpointV1_1_1; + + EndpointV1_1_1 = (EFI_REDFISH_ENDPOINT_V1_1_1 *)InterpProp; + DestroyEndpoint_V1_1_1_CS (EndpointV1_1_1->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_1_1/RedfishEndpoint_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_1_1/RedfishEndpoint_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..42bb3db412d --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_1_1/RedfishEndpoint_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_1_1_Dxe + FILE_GUID = 899ac33d-09de-45ee-bb77-307f6af54993 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_1_2/Endpoint_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_1_2/Endpoint_V1_1_2_Dxe.c new file mode 100644 index 00000000000..cfe067add28 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_1_2/Endpoint_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "1", + "2" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_1_2 *EndpointV1_1_2; + EFI_REDFISH_ENDPOINT_V1_1_2_CS *EndpointV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_1_2_To_CS (ResoruceRaw, &EndpointV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_1_2 = (EFI_REDFISH_ENDPOINT_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_1_2)); + if (EndpointV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_1_2; + EndpointV1_1_2->Endpoint = EndpointV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_1_2_JSON (*((EFI_REDFISH_ENDPOINT_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_1_2 *EndpointV1_1_2; + + EndpointV1_1_2 = (EFI_REDFISH_ENDPOINT_V1_1_2 *)InterpProp; + DestroyEndpoint_V1_1_2_CS (EndpointV1_1_2->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_1_2/RedfishEndpoint_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_1_2/RedfishEndpoint_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..a8865ba7434 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_1_2/RedfishEndpoint_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_1_2_Dxe + FILE_GUID = ddc4c110-8c8c-4112-a039-8bd5f67ccd41 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_1_3/Endpoint_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_1_3/Endpoint_V1_1_3_Dxe.c new file mode 100644 index 00000000000..c7ee12175eb --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_1_3/Endpoint_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "1", + "3" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_1_3 *EndpointV1_1_3; + EFI_REDFISH_ENDPOINT_V1_1_3_CS *EndpointV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_1_3_To_CS (ResoruceRaw, &EndpointV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_1_3 = (EFI_REDFISH_ENDPOINT_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_1_3)); + if (EndpointV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_1_3; + EndpointV1_1_3->Endpoint = EndpointV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_1_3_JSON (*((EFI_REDFISH_ENDPOINT_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_1_3 *EndpointV1_1_3; + + EndpointV1_1_3 = (EFI_REDFISH_ENDPOINT_V1_1_3 *)InterpProp; + DestroyEndpoint_V1_1_3_CS (EndpointV1_1_3->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_1_3/RedfishEndpoint_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_1_3/RedfishEndpoint_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..618fa884c15 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_1_3/RedfishEndpoint_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_1_3_Dxe + FILE_GUID = 47287594-0073-48c8-8fae-4cd8dc45ea1e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_1_4/Endpoint_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_1_4/Endpoint_V1_1_4_Dxe.c new file mode 100644 index 00000000000..d88fbe18aa8 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_1_4/Endpoint_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "1", + "4" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_1_4 *EndpointV1_1_4; + EFI_REDFISH_ENDPOINT_V1_1_4_CS *EndpointV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_1_4_To_CS (ResoruceRaw, &EndpointV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_1_4 = (EFI_REDFISH_ENDPOINT_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_1_4)); + if (EndpointV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_1_4; + EndpointV1_1_4->Endpoint = EndpointV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_1_4_JSON (*((EFI_REDFISH_ENDPOINT_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_1_4 *EndpointV1_1_4; + + EndpointV1_1_4 = (EFI_REDFISH_ENDPOINT_V1_1_4 *)InterpProp; + DestroyEndpoint_V1_1_4_CS (EndpointV1_1_4->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_1_4/RedfishEndpoint_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_1_4/RedfishEndpoint_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..ebfde48b0f2 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_1_4/RedfishEndpoint_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_1_4_Dxe + FILE_GUID = 308ed250-faf7-4606-82f9-85bb663d2516 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_1_5/Endpoint_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_1_5/Endpoint_V1_1_5_Dxe.c new file mode 100644 index 00000000000..ee64f7273bb --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_1_5/Endpoint_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "1", + "5" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_1_5 *EndpointV1_1_5; + EFI_REDFISH_ENDPOINT_V1_1_5_CS *EndpointV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_1_5_To_CS (ResoruceRaw, &EndpointV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_1_5 = (EFI_REDFISH_ENDPOINT_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_1_5)); + if (EndpointV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_1_5; + EndpointV1_1_5->Endpoint = EndpointV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_1_5_JSON (*((EFI_REDFISH_ENDPOINT_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_1_5 *EndpointV1_1_5; + + EndpointV1_1_5 = (EFI_REDFISH_ENDPOINT_V1_1_5 *)InterpProp; + DestroyEndpoint_V1_1_5_CS (EndpointV1_1_5->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_1_5/RedfishEndpoint_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_1_5/RedfishEndpoint_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..3ba2354713e --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_1_5/RedfishEndpoint_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_1_5_Dxe + FILE_GUID = 20be38f4-798c-4782-8ec0-67c82e421011 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_1_6/Endpoint_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_1_6/Endpoint_V1_1_6_Dxe.c new file mode 100644 index 00000000000..1b753473512 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_1_6/Endpoint_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "1", + "6" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_1_6 *EndpointV1_1_6; + EFI_REDFISH_ENDPOINT_V1_1_6_CS *EndpointV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_1_6_To_CS (ResoruceRaw, &EndpointV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_1_6 = (EFI_REDFISH_ENDPOINT_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_1_6)); + if (EndpointV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_1_6; + EndpointV1_1_6->Endpoint = EndpointV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_1_6_JSON (*((EFI_REDFISH_ENDPOINT_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_1_6 *EndpointV1_1_6; + + EndpointV1_1_6 = (EFI_REDFISH_ENDPOINT_V1_1_6 *)InterpProp; + DestroyEndpoint_V1_1_6_CS (EndpointV1_1_6->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_1_6/RedfishEndpoint_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_1_6/RedfishEndpoint_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..37bcbb4fdba --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_1_6/RedfishEndpoint_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_1_6_Dxe + FILE_GUID = 8df191cc-eeaf-4453-8cc2-7515e51e4fff + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_1_7/Endpoint_V1_1_7_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_1_7/Endpoint_V1_1_7_Dxe.c new file mode 100644 index 00000000000..85f3e1d2587 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_1_7/Endpoint_V1_1_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_1_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "1", + "7" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_1_7 *EndpointV1_1_7; + EFI_REDFISH_ENDPOINT_V1_1_7_CS *EndpointV1_1_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_1_7_To_CS (ResoruceRaw, &EndpointV1_1_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_1_7 = (EFI_REDFISH_ENDPOINT_V1_1_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_1_7)); + if (EndpointV1_1_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_1_7; + EndpointV1_1_7->Endpoint = EndpointV1_1_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_1_7_JSON (*((EFI_REDFISH_ENDPOINT_V1_1_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_1_7 *EndpointV1_1_7; + + EndpointV1_1_7 = (EFI_REDFISH_ENDPOINT_V1_1_7 *)InterpProp; + DestroyEndpoint_V1_1_7_CS (EndpointV1_1_7->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_1_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_1_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_1_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_1_7/RedfishEndpoint_V1_1_7_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_1_7/RedfishEndpoint_V1_1_7_Dxe.inf new file mode 100644 index 00000000000..6c478969312 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_1_7/RedfishEndpoint_V1_1_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_1_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_1_7_Dxe + FILE_GUID = d056d9f5-c3fb-4f66-bce1-5198bc1a600b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_1_7EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_1_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_1_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_1_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_2_0/Endpoint_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_2_0/Endpoint_V1_2_0_Dxe.c new file mode 100644 index 00000000000..5d038cf125f --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_2_0/Endpoint_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "2", + "0" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_2_0 *EndpointV1_2_0; + EFI_REDFISH_ENDPOINT_V1_2_0_CS *EndpointV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_2_0_To_CS (ResoruceRaw, &EndpointV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_2_0 = (EFI_REDFISH_ENDPOINT_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_2_0)); + if (EndpointV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_2_0; + EndpointV1_2_0->Endpoint = EndpointV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_2_0_JSON (*((EFI_REDFISH_ENDPOINT_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_2_0 *EndpointV1_2_0; + + EndpointV1_2_0 = (EFI_REDFISH_ENDPOINT_V1_2_0 *)InterpProp; + DestroyEndpoint_V1_2_0_CS (EndpointV1_2_0->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_2_0/RedfishEndpoint_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_2_0/RedfishEndpoint_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..f9f5776af2d --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_2_0/RedfishEndpoint_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_2_0_Dxe + FILE_GUID = 6e6c6a1a-d8e0-4a46-88f6-66e96b04978a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_2_1/Endpoint_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_2_1/Endpoint_V1_2_1_Dxe.c new file mode 100644 index 00000000000..8fd69609f08 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_2_1/Endpoint_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "2", + "1" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_2_1 *EndpointV1_2_1; + EFI_REDFISH_ENDPOINT_V1_2_1_CS *EndpointV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_2_1_To_CS (ResoruceRaw, &EndpointV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_2_1 = (EFI_REDFISH_ENDPOINT_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_2_1)); + if (EndpointV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_2_1; + EndpointV1_2_1->Endpoint = EndpointV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_2_1_JSON (*((EFI_REDFISH_ENDPOINT_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_2_1 *EndpointV1_2_1; + + EndpointV1_2_1 = (EFI_REDFISH_ENDPOINT_V1_2_1 *)InterpProp; + DestroyEndpoint_V1_2_1_CS (EndpointV1_2_1->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_2_1/RedfishEndpoint_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_2_1/RedfishEndpoint_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..f60475c7d73 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_2_1/RedfishEndpoint_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_2_1_Dxe + FILE_GUID = 9e1f4de5-7a4e-49a7-85cd-e3d29b6fb61d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_2_2/Endpoint_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_2_2/Endpoint_V1_2_2_Dxe.c new file mode 100644 index 00000000000..72380fab4a0 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_2_2/Endpoint_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "2", + "2" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_2_2 *EndpointV1_2_2; + EFI_REDFISH_ENDPOINT_V1_2_2_CS *EndpointV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_2_2_To_CS (ResoruceRaw, &EndpointV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_2_2 = (EFI_REDFISH_ENDPOINT_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_2_2)); + if (EndpointV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_2_2; + EndpointV1_2_2->Endpoint = EndpointV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_2_2_JSON (*((EFI_REDFISH_ENDPOINT_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_2_2 *EndpointV1_2_2; + + EndpointV1_2_2 = (EFI_REDFISH_ENDPOINT_V1_2_2 *)InterpProp; + DestroyEndpoint_V1_2_2_CS (EndpointV1_2_2->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_2_2/RedfishEndpoint_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_2_2/RedfishEndpoint_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..bb65b812d9b --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_2_2/RedfishEndpoint_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_2_2_Dxe + FILE_GUID = c75c881f-e3fd-4106-a401-f325de0b7697 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_2_3/Endpoint_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_2_3/Endpoint_V1_2_3_Dxe.c new file mode 100644 index 00000000000..f1fc064d191 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_2_3/Endpoint_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "2", + "3" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_2_3 *EndpointV1_2_3; + EFI_REDFISH_ENDPOINT_V1_2_3_CS *EndpointV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_2_3_To_CS (ResoruceRaw, &EndpointV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_2_3 = (EFI_REDFISH_ENDPOINT_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_2_3)); + if (EndpointV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_2_3; + EndpointV1_2_3->Endpoint = EndpointV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_2_3_JSON (*((EFI_REDFISH_ENDPOINT_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_2_3 *EndpointV1_2_3; + + EndpointV1_2_3 = (EFI_REDFISH_ENDPOINT_V1_2_3 *)InterpProp; + DestroyEndpoint_V1_2_3_CS (EndpointV1_2_3->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_2_3/RedfishEndpoint_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_2_3/RedfishEndpoint_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..25e35235246 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_2_3/RedfishEndpoint_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_2_3_Dxe + FILE_GUID = eda7f0c3-b055-4559-be2c-467f30eddbf1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_2_4/Endpoint_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_2_4/Endpoint_V1_2_4_Dxe.c new file mode 100644 index 00000000000..085b242a42d --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_2_4/Endpoint_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "2", + "4" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_2_4 *EndpointV1_2_4; + EFI_REDFISH_ENDPOINT_V1_2_4_CS *EndpointV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_2_4_To_CS (ResoruceRaw, &EndpointV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_2_4 = (EFI_REDFISH_ENDPOINT_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_2_4)); + if (EndpointV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_2_4; + EndpointV1_2_4->Endpoint = EndpointV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_2_4_JSON (*((EFI_REDFISH_ENDPOINT_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_2_4 *EndpointV1_2_4; + + EndpointV1_2_4 = (EFI_REDFISH_ENDPOINT_V1_2_4 *)InterpProp; + DestroyEndpoint_V1_2_4_CS (EndpointV1_2_4->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_2_4/RedfishEndpoint_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_2_4/RedfishEndpoint_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..ce8122dccab --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_2_4/RedfishEndpoint_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_2_4_Dxe + FILE_GUID = 3db93fbd-a20c-4066-bc2e-ae3a5d24dff3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_2_5/Endpoint_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_2_5/Endpoint_V1_2_5_Dxe.c new file mode 100644 index 00000000000..c02e86ecc17 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_2_5/Endpoint_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "2", + "5" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_2_5 *EndpointV1_2_5; + EFI_REDFISH_ENDPOINT_V1_2_5_CS *EndpointV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_2_5_To_CS (ResoruceRaw, &EndpointV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_2_5 = (EFI_REDFISH_ENDPOINT_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_2_5)); + if (EndpointV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_2_5; + EndpointV1_2_5->Endpoint = EndpointV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_2_5_JSON (*((EFI_REDFISH_ENDPOINT_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_2_5 *EndpointV1_2_5; + + EndpointV1_2_5 = (EFI_REDFISH_ENDPOINT_V1_2_5 *)InterpProp; + DestroyEndpoint_V1_2_5_CS (EndpointV1_2_5->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_2_5/RedfishEndpoint_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_2_5/RedfishEndpoint_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..11af8736c51 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_2_5/RedfishEndpoint_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_2_5_Dxe + FILE_GUID = d72b12b0-68bb-4db2-806d-26d61b2b2073 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_2_6/Endpoint_V1_2_6_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_2_6/Endpoint_V1_2_6_Dxe.c new file mode 100644 index 00000000000..b0d50f04602 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_2_6/Endpoint_V1_2_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_2_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "2", + "6" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_2_6 *EndpointV1_2_6; + EFI_REDFISH_ENDPOINT_V1_2_6_CS *EndpointV1_2_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_2_6_To_CS (ResoruceRaw, &EndpointV1_2_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_2_6 = (EFI_REDFISH_ENDPOINT_V1_2_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_2_6)); + if (EndpointV1_2_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_2_6; + EndpointV1_2_6->Endpoint = EndpointV1_2_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_2_6_JSON (*((EFI_REDFISH_ENDPOINT_V1_2_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_2_6 *EndpointV1_2_6; + + EndpointV1_2_6 = (EFI_REDFISH_ENDPOINT_V1_2_6 *)InterpProp; + DestroyEndpoint_V1_2_6_CS (EndpointV1_2_6->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_2_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_2_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_2_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_2_6/RedfishEndpoint_V1_2_6_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_2_6/RedfishEndpoint_V1_2_6_Dxe.inf new file mode 100644 index 00000000000..ba807e2813c --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_2_6/RedfishEndpoint_V1_2_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_2_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_2_6_Dxe + FILE_GUID = 21ec9b3d-815a-4b5a-8174-6209bf270da6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_2_6EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_2_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_2_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_2_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_3_0/Endpoint_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_3_0/Endpoint_V1_3_0_Dxe.c new file mode 100644 index 00000000000..fc53fa96985 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_3_0/Endpoint_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "3", + "0" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_3_0 *EndpointV1_3_0; + EFI_REDFISH_ENDPOINT_V1_3_0_CS *EndpointV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_3_0_To_CS (ResoruceRaw, &EndpointV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_3_0 = (EFI_REDFISH_ENDPOINT_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_3_0)); + if (EndpointV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_3_0; + EndpointV1_3_0->Endpoint = EndpointV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_3_0_JSON (*((EFI_REDFISH_ENDPOINT_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_3_0 *EndpointV1_3_0; + + EndpointV1_3_0 = (EFI_REDFISH_ENDPOINT_V1_3_0 *)InterpProp; + DestroyEndpoint_V1_3_0_CS (EndpointV1_3_0->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_3_0/RedfishEndpoint_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_3_0/RedfishEndpoint_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..0148dc28514 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_3_0/RedfishEndpoint_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_3_0_Dxe + FILE_GUID = 2d81a02a-ee4e-43d2-aef5-fe78d291a5aa + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_3_1/Endpoint_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_3_1/Endpoint_V1_3_1_Dxe.c new file mode 100644 index 00000000000..343614e2f35 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_3_1/Endpoint_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "3", + "1" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_3_1 *EndpointV1_3_1; + EFI_REDFISH_ENDPOINT_V1_3_1_CS *EndpointV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_3_1_To_CS (ResoruceRaw, &EndpointV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_3_1 = (EFI_REDFISH_ENDPOINT_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_3_1)); + if (EndpointV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_3_1; + EndpointV1_3_1->Endpoint = EndpointV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_3_1_JSON (*((EFI_REDFISH_ENDPOINT_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_3_1 *EndpointV1_3_1; + + EndpointV1_3_1 = (EFI_REDFISH_ENDPOINT_V1_3_1 *)InterpProp; + DestroyEndpoint_V1_3_1_CS (EndpointV1_3_1->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_3_1/RedfishEndpoint_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_3_1/RedfishEndpoint_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..6dfd98744f4 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_3_1/RedfishEndpoint_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_3_1_Dxe + FILE_GUID = ec6b64c8-550f-4bea-8fc6-4d86173a8433 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_3_2/Endpoint_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_3_2/Endpoint_V1_3_2_Dxe.c new file mode 100644 index 00000000000..116c8ad1ea2 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_3_2/Endpoint_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "3", + "2" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_3_2 *EndpointV1_3_2; + EFI_REDFISH_ENDPOINT_V1_3_2_CS *EndpointV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_3_2_To_CS (ResoruceRaw, &EndpointV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_3_2 = (EFI_REDFISH_ENDPOINT_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_3_2)); + if (EndpointV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_3_2; + EndpointV1_3_2->Endpoint = EndpointV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_3_2_JSON (*((EFI_REDFISH_ENDPOINT_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_3_2 *EndpointV1_3_2; + + EndpointV1_3_2 = (EFI_REDFISH_ENDPOINT_V1_3_2 *)InterpProp; + DestroyEndpoint_V1_3_2_CS (EndpointV1_3_2->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_3_2/RedfishEndpoint_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_3_2/RedfishEndpoint_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..f3117cdae4f --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_3_2/RedfishEndpoint_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_3_2_Dxe + FILE_GUID = 5f5374c3-2756-40ac-a6c1-96669613f1b4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_3_3/Endpoint_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_3_3/Endpoint_V1_3_3_Dxe.c new file mode 100644 index 00000000000..3eddc1832ac --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_3_3/Endpoint_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "3", + "3" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_3_3 *EndpointV1_3_3; + EFI_REDFISH_ENDPOINT_V1_3_3_CS *EndpointV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_3_3_To_CS (ResoruceRaw, &EndpointV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_3_3 = (EFI_REDFISH_ENDPOINT_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_3_3)); + if (EndpointV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_3_3; + EndpointV1_3_3->Endpoint = EndpointV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_3_3_JSON (*((EFI_REDFISH_ENDPOINT_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_3_3 *EndpointV1_3_3; + + EndpointV1_3_3 = (EFI_REDFISH_ENDPOINT_V1_3_3 *)InterpProp; + DestroyEndpoint_V1_3_3_CS (EndpointV1_3_3->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_3_3/RedfishEndpoint_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_3_3/RedfishEndpoint_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..75cae6e1c8d --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_3_3/RedfishEndpoint_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_3_3_Dxe + FILE_GUID = 306da92f-df70-4a28-b0c1-b1e07711d362 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_3_4/Endpoint_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_3_4/Endpoint_V1_3_4_Dxe.c new file mode 100644 index 00000000000..03e2263a49d --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_3_4/Endpoint_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "3", + "4" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_3_4 *EndpointV1_3_4; + EFI_REDFISH_ENDPOINT_V1_3_4_CS *EndpointV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_3_4_To_CS (ResoruceRaw, &EndpointV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_3_4 = (EFI_REDFISH_ENDPOINT_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_3_4)); + if (EndpointV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_3_4; + EndpointV1_3_4->Endpoint = EndpointV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_3_4_JSON (*((EFI_REDFISH_ENDPOINT_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_3_4 *EndpointV1_3_4; + + EndpointV1_3_4 = (EFI_REDFISH_ENDPOINT_V1_3_4 *)InterpProp; + DestroyEndpoint_V1_3_4_CS (EndpointV1_3_4->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_3_4/RedfishEndpoint_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_3_4/RedfishEndpoint_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..4c749d6377b --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_3_4/RedfishEndpoint_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_3_4_Dxe + FILE_GUID = 7f3df0a3-7319-429c-989c-919cb165134d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_3_5/Endpoint_V1_3_5_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_3_5/Endpoint_V1_3_5_Dxe.c new file mode 100644 index 00000000000..a2a248a55f5 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_3_5/Endpoint_V1_3_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_3_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "3", + "5" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_3_5 *EndpointV1_3_5; + EFI_REDFISH_ENDPOINT_V1_3_5_CS *EndpointV1_3_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_3_5_To_CS (ResoruceRaw, &EndpointV1_3_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_3_5 = (EFI_REDFISH_ENDPOINT_V1_3_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_3_5)); + if (EndpointV1_3_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_3_5; + EndpointV1_3_5->Endpoint = EndpointV1_3_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_3_5_JSON (*((EFI_REDFISH_ENDPOINT_V1_3_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_3_5 *EndpointV1_3_5; + + EndpointV1_3_5 = (EFI_REDFISH_ENDPOINT_V1_3_5 *)InterpProp; + DestroyEndpoint_V1_3_5_CS (EndpointV1_3_5->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_3_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_3_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_3_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_3_5/RedfishEndpoint_V1_3_5_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_3_5/RedfishEndpoint_V1_3_5_Dxe.inf new file mode 100644 index 00000000000..7286ba4ccdd --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_3_5/RedfishEndpoint_V1_3_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_3_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_3_5_Dxe + FILE_GUID = a8ff2d04-192e-4f0a-af18-4ccbcef2d525 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_3_5EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_3_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_3_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_3_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_4_0/Endpoint_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_4_0/Endpoint_V1_4_0_Dxe.c new file mode 100644 index 00000000000..da895c76d93 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_4_0/Endpoint_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "4", + "0" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_4_0 *EndpointV1_4_0; + EFI_REDFISH_ENDPOINT_V1_4_0_CS *EndpointV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_4_0_To_CS (ResoruceRaw, &EndpointV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_4_0 = (EFI_REDFISH_ENDPOINT_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_4_0)); + if (EndpointV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_4_0; + EndpointV1_4_0->Endpoint = EndpointV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_4_0_JSON (*((EFI_REDFISH_ENDPOINT_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_4_0 *EndpointV1_4_0; + + EndpointV1_4_0 = (EFI_REDFISH_ENDPOINT_V1_4_0 *)InterpProp; + DestroyEndpoint_V1_4_0_CS (EndpointV1_4_0->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_4_0/RedfishEndpoint_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_4_0/RedfishEndpoint_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..6c0a2db6690 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_4_0/RedfishEndpoint_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_4_0_Dxe + FILE_GUID = 96dfd6ea-07c3-4a37-b36c-f12635320938 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_4_1/Endpoint_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_4_1/Endpoint_V1_4_1_Dxe.c new file mode 100644 index 00000000000..39147b99b39 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_4_1/Endpoint_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "4", + "1" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_4_1 *EndpointV1_4_1; + EFI_REDFISH_ENDPOINT_V1_4_1_CS *EndpointV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_4_1_To_CS (ResoruceRaw, &EndpointV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_4_1 = (EFI_REDFISH_ENDPOINT_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_4_1)); + if (EndpointV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_4_1; + EndpointV1_4_1->Endpoint = EndpointV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_4_1_JSON (*((EFI_REDFISH_ENDPOINT_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_4_1 *EndpointV1_4_1; + + EndpointV1_4_1 = (EFI_REDFISH_ENDPOINT_V1_4_1 *)InterpProp; + DestroyEndpoint_V1_4_1_CS (EndpointV1_4_1->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_4_1/RedfishEndpoint_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_4_1/RedfishEndpoint_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..365e4fec71d --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_4_1/RedfishEndpoint_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_4_1_Dxe + FILE_GUID = 0cfdb04f-7e6f-44fe-a3b1-374c92f10a7f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_4_2/Endpoint_V1_4_2_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_4_2/Endpoint_V1_4_2_Dxe.c new file mode 100644 index 00000000000..598b884abc0 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_4_2/Endpoint_V1_4_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_4_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "4", + "2" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_4_2 *EndpointV1_4_2; + EFI_REDFISH_ENDPOINT_V1_4_2_CS *EndpointV1_4_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_4_2_To_CS (ResoruceRaw, &EndpointV1_4_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_4_2 = (EFI_REDFISH_ENDPOINT_V1_4_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_4_2)); + if (EndpointV1_4_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_4_2; + EndpointV1_4_2->Endpoint = EndpointV1_4_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_4_2_JSON (*((EFI_REDFISH_ENDPOINT_V1_4_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_4_2 *EndpointV1_4_2; + + EndpointV1_4_2 = (EFI_REDFISH_ENDPOINT_V1_4_2 *)InterpProp; + DestroyEndpoint_V1_4_2_CS (EndpointV1_4_2->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_4_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_4_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_4_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_4_2/RedfishEndpoint_V1_4_2_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_4_2/RedfishEndpoint_V1_4_2_Dxe.inf new file mode 100644 index 00000000000..4de0536445f --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_4_2/RedfishEndpoint_V1_4_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_4_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_4_2_Dxe + FILE_GUID = 83582c5d-7248-4766-8d82-0387c268322c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_4_2EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_4_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_4_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_4_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_4_3/Endpoint_V1_4_3_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_4_3/Endpoint_V1_4_3_Dxe.c new file mode 100644 index 00000000000..e851556f723 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_4_3/Endpoint_V1_4_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_4_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "4", + "3" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_4_3 *EndpointV1_4_3; + EFI_REDFISH_ENDPOINT_V1_4_3_CS *EndpointV1_4_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_4_3_To_CS (ResoruceRaw, &EndpointV1_4_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_4_3 = (EFI_REDFISH_ENDPOINT_V1_4_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_4_3)); + if (EndpointV1_4_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_4_3; + EndpointV1_4_3->Endpoint = EndpointV1_4_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_4_3_JSON (*((EFI_REDFISH_ENDPOINT_V1_4_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_4_3 *EndpointV1_4_3; + + EndpointV1_4_3 = (EFI_REDFISH_ENDPOINT_V1_4_3 *)InterpProp; + DestroyEndpoint_V1_4_3_CS (EndpointV1_4_3->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_4_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_4_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_4_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_4_3/RedfishEndpoint_V1_4_3_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_4_3/RedfishEndpoint_V1_4_3_Dxe.inf new file mode 100644 index 00000000000..5c0fe342b5f --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_4_3/RedfishEndpoint_V1_4_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_4_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_4_3_Dxe + FILE_GUID = 841c4dc4-7528-484d-9e3a-8103bf15e455 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_4_3EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_4_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_4_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_4_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_5_0/Endpoint_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_5_0/Endpoint_V1_5_0_Dxe.c new file mode 100644 index 00000000000..8d2bfe767d9 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_5_0/Endpoint_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "5", + "0" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_5_0 *EndpointV1_5_0; + EFI_REDFISH_ENDPOINT_V1_5_0_CS *EndpointV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_5_0_To_CS (ResoruceRaw, &EndpointV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_5_0 = (EFI_REDFISH_ENDPOINT_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_5_0)); + if (EndpointV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_5_0; + EndpointV1_5_0->Endpoint = EndpointV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_5_0_JSON (*((EFI_REDFISH_ENDPOINT_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_5_0 *EndpointV1_5_0; + + EndpointV1_5_0 = (EFI_REDFISH_ENDPOINT_V1_5_0 *)InterpProp; + DestroyEndpoint_V1_5_0_CS (EndpointV1_5_0->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_5_0/RedfishEndpoint_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_5_0/RedfishEndpoint_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..6ecc935eea6 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_5_0/RedfishEndpoint_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_5_0_Dxe + FILE_GUID = 721be536-5142-4ee1-b12a-f11c5ecb5693 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Endpoint/v1_5_1/Endpoint_V1_5_1_Dxe.c b/RedfishClientPkg/Converter/Endpoint/v1_5_1/Endpoint_V1_5_1_Dxe.c new file mode 100644 index 00000000000..8d96f876185 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_5_1/Endpoint_V1_5_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Endpoint.v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Endpoint"; +BOOLEAN IsRevisonController = TRUE; + +// Support Endpoint V1_5_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Endpoint", + "1", + "5", + "1" + }, + "Endpoint" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_5_1 *EndpointV1_5_1; + EFI_REDFISH_ENDPOINT_V1_5_1_CS *EndpointV1_5_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Endpoint") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Endpoint_V1_5_1_To_CS (ResoruceRaw, &EndpointV1_5_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointV1_5_1 = (EFI_REDFISH_ENDPOINT_V1_5_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINT_V1_5_1)); + if (EndpointV1_5_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointV1_5_1; + EndpointV1_5_1->Endpoint = EndpointV1_5_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Endpoint"), "Endpoint"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Endpoint")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Endpoint"), "Endpoint"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Endpoint_V1_5_1_JSON (*((EFI_REDFISH_ENDPOINT_V1_5_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINT_V1_5_1 *EndpointV1_5_1; + + EndpointV1_5_1 = (EFI_REDFISH_ENDPOINT_V1_5_1 *)InterpProp; + DestroyEndpoint_V1_5_1_CS (EndpointV1_5_1->Endpoint); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpoint_V1_5_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_5_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointToStructWrapper, + EndpointToJson, + EndpointDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpoint_V1_5_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Endpoint/v1_5_1/RedfishEndpoint_V1_5_1_Dxe.inf b/RedfishClientPkg/Converter/Endpoint/v1_5_1/RedfishEndpoint_V1_5_1_Dxe.inf new file mode 100644 index 00000000000..ae8498f8b18 --- /dev/null +++ b/RedfishClientPkg/Converter/Endpoint/v1_5_1/RedfishEndpoint_V1_5_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Endpoint.v1_5_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpoint_V1_5_1_Dxe + FILE_GUID = 51289bbd-e77e-49f1-bc11-8016f609d13f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpoint_V1_5_1EntryPoint + UNLOAD_IMAGE = RedfishEndpoint_V1_5_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Endpoint_V1_5_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointV1_5_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EndpointCollection/EndpointCollection_Dxe.c b/RedfishClientPkg/Converter/EndpointCollection/EndpointCollection_Dxe.c new file mode 100644 index 00000000000..10156b63334 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointCollection/EndpointCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EndpointCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EndpointCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support EndpointCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EndpointCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "EndpointCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINTCOLLECTION *EndpointCollection; + EFI_REDFISH_ENDPOINTCOLLECTION_CS *EndpointCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EndpointCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EndpointCollection_To_CS (ResoruceRaw, &EndpointCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointCollection = (EFI_REDFISH_ENDPOINTCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINTCOLLECTION)); + if (EndpointCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointCollection; + EndpointCollection->EndpointCollection = EndpointCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EndpointCollection"), "EndpointCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EndpointCollection"), "EndpointCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EndpointCollection_JSON (*((EFI_REDFISH_ENDPOINTCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINTCOLLECTION *EndpointCollection; + + EndpointCollection = (EFI_REDFISH_ENDPOINTCOLLECTION *)InterpProp; + DestroyEndpointCollection_CS (EndpointCollection->EndpointCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpointCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpointCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointCollectionToStructWrapper, + EndpointCollectionToJson, + EndpointCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpointCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EndpointCollection/RedfishEndpointCollection_Dxe.inf b/RedfishClientPkg/Converter/EndpointCollection/RedfishEndpointCollection_Dxe.inf new file mode 100644 index 00000000000..e3a54fae714 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointCollection/RedfishEndpointCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EndpointCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpointCollection_Dxe + FILE_GUID = 0b519449-0b84-49da-8596-25a2c42e21a3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpointCollectionEntryPoint + UNLOAD_IMAGE = RedfishEndpointCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EndpointCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_0_0/EndpointGroup_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/EndpointGroup/v1_0_0/EndpointGroup_V1_0_0_Dxe.c new file mode 100644 index 00000000000..895d1747c95 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_0_0/EndpointGroup_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EndpointGroup.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EndpointGroup"; +BOOLEAN IsRevisonController = TRUE; + +// Support EndpointGroup V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EndpointGroup", + "1", + "0", + "0" + }, + "EndpointGroup" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_0_0 *EndpointGroupV1_0_0; + EFI_REDFISH_ENDPOINTGROUP_V1_0_0_CS *EndpointGroupV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EndpointGroup") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EndpointGroup_V1_0_0_To_CS (ResoruceRaw, &EndpointGroupV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointGroupV1_0_0 = (EFI_REDFISH_ENDPOINTGROUP_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINTGROUP_V1_0_0)); + if (EndpointGroupV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointGroupV1_0_0; + EndpointGroupV1_0_0->EndpointGroup = EndpointGroupV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointGroupToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointGroupToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EndpointGroup_V1_0_0_JSON (*((EFI_REDFISH_ENDPOINTGROUP_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointGroupToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_0_0 *EndpointGroupV1_0_0; + + EndpointGroupV1_0_0 = (EFI_REDFISH_ENDPOINTGROUP_V1_0_0 *)InterpProp; + DestroyEndpointGroup_V1_0_0_CS (EndpointGroupV1_0_0->EndpointGroup); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointGroupFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpointGroup_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointGroupToStructWrapper, + EndpointGroupToJson, + EndpointGroupDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_0_0/RedfishEndpointGroup_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/EndpointGroup/v1_0_0/RedfishEndpointGroup_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..0258c0c3c6d --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_0_0/RedfishEndpointGroup_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EndpointGroup.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpointGroup_V1_0_0_Dxe + FILE_GUID = a3c0d361-cd04-4903-8a68-ab7c95d6228a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpointGroup_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishEndpointGroup_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EndpointGroup_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointGroupV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_0_1/EndpointGroup_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/EndpointGroup/v1_0_1/EndpointGroup_V1_0_1_Dxe.c new file mode 100644 index 00000000000..e150b7b3ee7 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_0_1/EndpointGroup_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EndpointGroup.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EndpointGroup"; +BOOLEAN IsRevisonController = TRUE; + +// Support EndpointGroup V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EndpointGroup", + "1", + "0", + "1" + }, + "EndpointGroup" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_0_1 *EndpointGroupV1_0_1; + EFI_REDFISH_ENDPOINTGROUP_V1_0_1_CS *EndpointGroupV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EndpointGroup") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EndpointGroup_V1_0_1_To_CS (ResoruceRaw, &EndpointGroupV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointGroupV1_0_1 = (EFI_REDFISH_ENDPOINTGROUP_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINTGROUP_V1_0_1)); + if (EndpointGroupV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointGroupV1_0_1; + EndpointGroupV1_0_1->EndpointGroup = EndpointGroupV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointGroupToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointGroupToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EndpointGroup_V1_0_1_JSON (*((EFI_REDFISH_ENDPOINTGROUP_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointGroupToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_0_1 *EndpointGroupV1_0_1; + + EndpointGroupV1_0_1 = (EFI_REDFISH_ENDPOINTGROUP_V1_0_1 *)InterpProp; + DestroyEndpointGroup_V1_0_1_CS (EndpointGroupV1_0_1->EndpointGroup); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointGroupFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpointGroup_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointGroupToStructWrapper, + EndpointGroupToJson, + EndpointGroupDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_0_1/RedfishEndpointGroup_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/EndpointGroup/v1_0_1/RedfishEndpointGroup_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..e013f445f3f --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_0_1/RedfishEndpointGroup_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EndpointGroup.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpointGroup_V1_0_1_Dxe + FILE_GUID = 7a7e7af6-b604-4d84-b14c-34f65126e528 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpointGroup_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishEndpointGroup_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EndpointGroup_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointGroupV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_0_2/EndpointGroup_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/EndpointGroup/v1_0_2/EndpointGroup_V1_0_2_Dxe.c new file mode 100644 index 00000000000..2836bf7c9e9 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_0_2/EndpointGroup_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EndpointGroup.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EndpointGroup"; +BOOLEAN IsRevisonController = TRUE; + +// Support EndpointGroup V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EndpointGroup", + "1", + "0", + "2" + }, + "EndpointGroup" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_0_2 *EndpointGroupV1_0_2; + EFI_REDFISH_ENDPOINTGROUP_V1_0_2_CS *EndpointGroupV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EndpointGroup") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EndpointGroup_V1_0_2_To_CS (ResoruceRaw, &EndpointGroupV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointGroupV1_0_2 = (EFI_REDFISH_ENDPOINTGROUP_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINTGROUP_V1_0_2)); + if (EndpointGroupV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointGroupV1_0_2; + EndpointGroupV1_0_2->EndpointGroup = EndpointGroupV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointGroupToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointGroupToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EndpointGroup_V1_0_2_JSON (*((EFI_REDFISH_ENDPOINTGROUP_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointGroupToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_0_2 *EndpointGroupV1_0_2; + + EndpointGroupV1_0_2 = (EFI_REDFISH_ENDPOINTGROUP_V1_0_2 *)InterpProp; + DestroyEndpointGroup_V1_0_2_CS (EndpointGroupV1_0_2->EndpointGroup); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointGroupFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpointGroup_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointGroupToStructWrapper, + EndpointGroupToJson, + EndpointGroupDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_0_2/RedfishEndpointGroup_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/EndpointGroup/v1_0_2/RedfishEndpointGroup_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..f36c07fbc69 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_0_2/RedfishEndpointGroup_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EndpointGroup.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpointGroup_V1_0_2_Dxe + FILE_GUID = 1b8a2181-c3e6-4b73-a6a3-e0aa08c75097 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpointGroup_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishEndpointGroup_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EndpointGroup_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointGroupV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_0_3/EndpointGroup_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/EndpointGroup/v1_0_3/EndpointGroup_V1_0_3_Dxe.c new file mode 100644 index 00000000000..4c826f2cb6e --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_0_3/EndpointGroup_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EndpointGroup.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EndpointGroup"; +BOOLEAN IsRevisonController = TRUE; + +// Support EndpointGroup V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EndpointGroup", + "1", + "0", + "3" + }, + "EndpointGroup" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_0_3 *EndpointGroupV1_0_3; + EFI_REDFISH_ENDPOINTGROUP_V1_0_3_CS *EndpointGroupV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EndpointGroup") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EndpointGroup_V1_0_3_To_CS (ResoruceRaw, &EndpointGroupV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointGroupV1_0_3 = (EFI_REDFISH_ENDPOINTGROUP_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINTGROUP_V1_0_3)); + if (EndpointGroupV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointGroupV1_0_3; + EndpointGroupV1_0_3->EndpointGroup = EndpointGroupV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointGroupToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointGroupToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EndpointGroup_V1_0_3_JSON (*((EFI_REDFISH_ENDPOINTGROUP_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointGroupToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_0_3 *EndpointGroupV1_0_3; + + EndpointGroupV1_0_3 = (EFI_REDFISH_ENDPOINTGROUP_V1_0_3 *)InterpProp; + DestroyEndpointGroup_V1_0_3_CS (EndpointGroupV1_0_3->EndpointGroup); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointGroupFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpointGroup_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointGroupToStructWrapper, + EndpointGroupToJson, + EndpointGroupDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_0_3/RedfishEndpointGroup_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/EndpointGroup/v1_0_3/RedfishEndpointGroup_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..bec581291b3 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_0_3/RedfishEndpointGroup_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EndpointGroup.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpointGroup_V1_0_3_Dxe + FILE_GUID = 84946468-88e9-4f68-9a0d-b0c193713d3c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpointGroup_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishEndpointGroup_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EndpointGroup_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointGroupV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_0_4/EndpointGroup_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/EndpointGroup/v1_0_4/EndpointGroup_V1_0_4_Dxe.c new file mode 100644 index 00000000000..527c8bbed97 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_0_4/EndpointGroup_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EndpointGroup.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EndpointGroup"; +BOOLEAN IsRevisonController = TRUE; + +// Support EndpointGroup V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EndpointGroup", + "1", + "0", + "4" + }, + "EndpointGroup" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_0_4 *EndpointGroupV1_0_4; + EFI_REDFISH_ENDPOINTGROUP_V1_0_4_CS *EndpointGroupV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EndpointGroup") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EndpointGroup_V1_0_4_To_CS (ResoruceRaw, &EndpointGroupV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointGroupV1_0_4 = (EFI_REDFISH_ENDPOINTGROUP_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINTGROUP_V1_0_4)); + if (EndpointGroupV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointGroupV1_0_4; + EndpointGroupV1_0_4->EndpointGroup = EndpointGroupV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointGroupToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointGroupToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EndpointGroup_V1_0_4_JSON (*((EFI_REDFISH_ENDPOINTGROUP_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointGroupToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_0_4 *EndpointGroupV1_0_4; + + EndpointGroupV1_0_4 = (EFI_REDFISH_ENDPOINTGROUP_V1_0_4 *)InterpProp; + DestroyEndpointGroup_V1_0_4_CS (EndpointGroupV1_0_4->EndpointGroup); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointGroupFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpointGroup_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointGroupToStructWrapper, + EndpointGroupToJson, + EndpointGroupDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_0_4/RedfishEndpointGroup_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/EndpointGroup/v1_0_4/RedfishEndpointGroup_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..b7e6203875e --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_0_4/RedfishEndpointGroup_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EndpointGroup.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpointGroup_V1_0_4_Dxe + FILE_GUID = a0e24cc5-1e59-40dc-84ae-b1e47aaaa64c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpointGroup_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishEndpointGroup_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EndpointGroup_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointGroupV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_1_0/EndpointGroup_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/EndpointGroup/v1_1_0/EndpointGroup_V1_1_0_Dxe.c new file mode 100644 index 00000000000..c2fd1aff244 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_1_0/EndpointGroup_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EndpointGroup.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EndpointGroup"; +BOOLEAN IsRevisonController = TRUE; + +// Support EndpointGroup V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EndpointGroup", + "1", + "1", + "0" + }, + "EndpointGroup" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_1_0 *EndpointGroupV1_1_0; + EFI_REDFISH_ENDPOINTGROUP_V1_1_0_CS *EndpointGroupV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EndpointGroup") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EndpointGroup_V1_1_0_To_CS (ResoruceRaw, &EndpointGroupV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointGroupV1_1_0 = (EFI_REDFISH_ENDPOINTGROUP_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINTGROUP_V1_1_0)); + if (EndpointGroupV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointGroupV1_1_0; + EndpointGroupV1_1_0->EndpointGroup = EndpointGroupV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointGroupToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointGroupToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EndpointGroup_V1_1_0_JSON (*((EFI_REDFISH_ENDPOINTGROUP_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointGroupToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_1_0 *EndpointGroupV1_1_0; + + EndpointGroupV1_1_0 = (EFI_REDFISH_ENDPOINTGROUP_V1_1_0 *)InterpProp; + DestroyEndpointGroup_V1_1_0_CS (EndpointGroupV1_1_0->EndpointGroup); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointGroupFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpointGroup_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointGroupToStructWrapper, + EndpointGroupToJson, + EndpointGroupDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_1_0/RedfishEndpointGroup_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/EndpointGroup/v1_1_0/RedfishEndpointGroup_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..aac5fa0af13 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_1_0/RedfishEndpointGroup_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EndpointGroup.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpointGroup_V1_1_0_Dxe + FILE_GUID = 28061db2-1651-4802-8924-d935969ac85a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpointGroup_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishEndpointGroup_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EndpointGroup_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointGroupV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_1_1/EndpointGroup_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/EndpointGroup/v1_1_1/EndpointGroup_V1_1_1_Dxe.c new file mode 100644 index 00000000000..510158bd727 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_1_1/EndpointGroup_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EndpointGroup.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EndpointGroup"; +BOOLEAN IsRevisonController = TRUE; + +// Support EndpointGroup V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EndpointGroup", + "1", + "1", + "1" + }, + "EndpointGroup" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_1_1 *EndpointGroupV1_1_1; + EFI_REDFISH_ENDPOINTGROUP_V1_1_1_CS *EndpointGroupV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EndpointGroup") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EndpointGroup_V1_1_1_To_CS (ResoruceRaw, &EndpointGroupV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointGroupV1_1_1 = (EFI_REDFISH_ENDPOINTGROUP_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINTGROUP_V1_1_1)); + if (EndpointGroupV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointGroupV1_1_1; + EndpointGroupV1_1_1->EndpointGroup = EndpointGroupV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointGroupToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointGroupToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EndpointGroup_V1_1_1_JSON (*((EFI_REDFISH_ENDPOINTGROUP_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointGroupToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_1_1 *EndpointGroupV1_1_1; + + EndpointGroupV1_1_1 = (EFI_REDFISH_ENDPOINTGROUP_V1_1_1 *)InterpProp; + DestroyEndpointGroup_V1_1_1_CS (EndpointGroupV1_1_1->EndpointGroup); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointGroupFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpointGroup_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointGroupToStructWrapper, + EndpointGroupToJson, + EndpointGroupDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_1_1/RedfishEndpointGroup_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/EndpointGroup/v1_1_1/RedfishEndpointGroup_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..d4e8fc3b5e6 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_1_1/RedfishEndpointGroup_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EndpointGroup.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpointGroup_V1_1_1_Dxe + FILE_GUID = 368eb46e-a936-4d75-8f08-2c11f7185674 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpointGroup_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishEndpointGroup_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EndpointGroup_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointGroupV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_1_2/EndpointGroup_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/EndpointGroup/v1_1_2/EndpointGroup_V1_1_2_Dxe.c new file mode 100644 index 00000000000..88c10ec9841 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_1_2/EndpointGroup_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EndpointGroup.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EndpointGroup"; +BOOLEAN IsRevisonController = TRUE; + +// Support EndpointGroup V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EndpointGroup", + "1", + "1", + "2" + }, + "EndpointGroup" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_1_2 *EndpointGroupV1_1_2; + EFI_REDFISH_ENDPOINTGROUP_V1_1_2_CS *EndpointGroupV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EndpointGroup") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EndpointGroup_V1_1_2_To_CS (ResoruceRaw, &EndpointGroupV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointGroupV1_1_2 = (EFI_REDFISH_ENDPOINTGROUP_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINTGROUP_V1_1_2)); + if (EndpointGroupV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointGroupV1_1_2; + EndpointGroupV1_1_2->EndpointGroup = EndpointGroupV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointGroupToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointGroupToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EndpointGroup_V1_1_2_JSON (*((EFI_REDFISH_ENDPOINTGROUP_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointGroupToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_1_2 *EndpointGroupV1_1_2; + + EndpointGroupV1_1_2 = (EFI_REDFISH_ENDPOINTGROUP_V1_1_2 *)InterpProp; + DestroyEndpointGroup_V1_1_2_CS (EndpointGroupV1_1_2->EndpointGroup); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointGroupFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpointGroup_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointGroupToStructWrapper, + EndpointGroupToJson, + EndpointGroupDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_1_2/RedfishEndpointGroup_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/EndpointGroup/v1_1_2/RedfishEndpointGroup_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..2875c346d12 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_1_2/RedfishEndpointGroup_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EndpointGroup.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpointGroup_V1_1_2_Dxe + FILE_GUID = f404e965-5ca8-474c-b1b5-76ebff83782e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpointGroup_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishEndpointGroup_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EndpointGroup_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointGroupV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_1_3/EndpointGroup_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/EndpointGroup/v1_1_3/EndpointGroup_V1_1_3_Dxe.c new file mode 100644 index 00000000000..a7820b6219c --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_1_3/EndpointGroup_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EndpointGroup.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EndpointGroup"; +BOOLEAN IsRevisonController = TRUE; + +// Support EndpointGroup V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EndpointGroup", + "1", + "1", + "3" + }, + "EndpointGroup" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_1_3 *EndpointGroupV1_1_3; + EFI_REDFISH_ENDPOINTGROUP_V1_1_3_CS *EndpointGroupV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EndpointGroup") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EndpointGroup_V1_1_3_To_CS (ResoruceRaw, &EndpointGroupV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointGroupV1_1_3 = (EFI_REDFISH_ENDPOINTGROUP_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINTGROUP_V1_1_3)); + if (EndpointGroupV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointGroupV1_1_3; + EndpointGroupV1_1_3->EndpointGroup = EndpointGroupV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointGroupToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointGroupToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EndpointGroup_V1_1_3_JSON (*((EFI_REDFISH_ENDPOINTGROUP_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointGroupToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_1_3 *EndpointGroupV1_1_3; + + EndpointGroupV1_1_3 = (EFI_REDFISH_ENDPOINTGROUP_V1_1_3 *)InterpProp; + DestroyEndpointGroup_V1_1_3_CS (EndpointGroupV1_1_3->EndpointGroup); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointGroupFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpointGroup_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointGroupToStructWrapper, + EndpointGroupToJson, + EndpointGroupDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_1_3/RedfishEndpointGroup_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/EndpointGroup/v1_1_3/RedfishEndpointGroup_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..4e8153c6bce --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_1_3/RedfishEndpointGroup_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EndpointGroup.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpointGroup_V1_1_3_Dxe + FILE_GUID = bc4df4a7-fb9f-4247-857c-126ede9593f4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpointGroup_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishEndpointGroup_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EndpointGroup_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointGroupV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_1_4/EndpointGroup_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/EndpointGroup/v1_1_4/EndpointGroup_V1_1_4_Dxe.c new file mode 100644 index 00000000000..f4ba6526038 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_1_4/EndpointGroup_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EndpointGroup.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EndpointGroup"; +BOOLEAN IsRevisonController = TRUE; + +// Support EndpointGroup V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EndpointGroup", + "1", + "1", + "4" + }, + "EndpointGroup" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_1_4 *EndpointGroupV1_1_4; + EFI_REDFISH_ENDPOINTGROUP_V1_1_4_CS *EndpointGroupV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EndpointGroup") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EndpointGroup_V1_1_4_To_CS (ResoruceRaw, &EndpointGroupV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointGroupV1_1_4 = (EFI_REDFISH_ENDPOINTGROUP_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINTGROUP_V1_1_4)); + if (EndpointGroupV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointGroupV1_1_4; + EndpointGroupV1_1_4->EndpointGroup = EndpointGroupV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointGroupToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointGroupToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EndpointGroup_V1_1_4_JSON (*((EFI_REDFISH_ENDPOINTGROUP_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointGroupToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_1_4 *EndpointGroupV1_1_4; + + EndpointGroupV1_1_4 = (EFI_REDFISH_ENDPOINTGROUP_V1_1_4 *)InterpProp; + DestroyEndpointGroup_V1_1_4_CS (EndpointGroupV1_1_4->EndpointGroup); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointGroupFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpointGroup_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointGroupToStructWrapper, + EndpointGroupToJson, + EndpointGroupDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_1_4/RedfishEndpointGroup_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/EndpointGroup/v1_1_4/RedfishEndpointGroup_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..cf1e0158724 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_1_4/RedfishEndpointGroup_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EndpointGroup.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpointGroup_V1_1_4_Dxe + FILE_GUID = aa1442e4-b032-45dc-9a45-ae388e41bb08 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpointGroup_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishEndpointGroup_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EndpointGroup_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointGroupV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_1_5/EndpointGroup_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/EndpointGroup/v1_1_5/EndpointGroup_V1_1_5_Dxe.c new file mode 100644 index 00000000000..cdf4d70489b --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_1_5/EndpointGroup_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EndpointGroup.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EndpointGroup"; +BOOLEAN IsRevisonController = TRUE; + +// Support EndpointGroup V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EndpointGroup", + "1", + "1", + "5" + }, + "EndpointGroup" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_1_5 *EndpointGroupV1_1_5; + EFI_REDFISH_ENDPOINTGROUP_V1_1_5_CS *EndpointGroupV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EndpointGroup") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EndpointGroup_V1_1_5_To_CS (ResoruceRaw, &EndpointGroupV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointGroupV1_1_5 = (EFI_REDFISH_ENDPOINTGROUP_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINTGROUP_V1_1_5)); + if (EndpointGroupV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointGroupV1_1_5; + EndpointGroupV1_1_5->EndpointGroup = EndpointGroupV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointGroupToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointGroupToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EndpointGroup_V1_1_5_JSON (*((EFI_REDFISH_ENDPOINTGROUP_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointGroupToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_1_5 *EndpointGroupV1_1_5; + + EndpointGroupV1_1_5 = (EFI_REDFISH_ENDPOINTGROUP_V1_1_5 *)InterpProp; + DestroyEndpointGroup_V1_1_5_CS (EndpointGroupV1_1_5->EndpointGroup); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointGroupFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpointGroup_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointGroupToStructWrapper, + EndpointGroupToJson, + EndpointGroupDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_1_5/RedfishEndpointGroup_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/EndpointGroup/v1_1_5/RedfishEndpointGroup_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..5ee8e4a51bb --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_1_5/RedfishEndpointGroup_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EndpointGroup.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpointGroup_V1_1_5_Dxe + FILE_GUID = 3303206e-6682-4388-a81d-29a0eb167146 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpointGroup_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishEndpointGroup_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EndpointGroup_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointGroupV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_2_0/EndpointGroup_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/EndpointGroup/v1_2_0/EndpointGroup_V1_2_0_Dxe.c new file mode 100644 index 00000000000..4f770fe4b09 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_2_0/EndpointGroup_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EndpointGroup.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EndpointGroup"; +BOOLEAN IsRevisonController = TRUE; + +// Support EndpointGroup V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EndpointGroup", + "1", + "2", + "0" + }, + "EndpointGroup" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_2_0 *EndpointGroupV1_2_0; + EFI_REDFISH_ENDPOINTGROUP_V1_2_0_CS *EndpointGroupV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EndpointGroup") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EndpointGroup_V1_2_0_To_CS (ResoruceRaw, &EndpointGroupV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointGroupV1_2_0 = (EFI_REDFISH_ENDPOINTGROUP_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINTGROUP_V1_2_0)); + if (EndpointGroupV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointGroupV1_2_0; + EndpointGroupV1_2_0->EndpointGroup = EndpointGroupV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointGroupToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointGroupToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EndpointGroup_V1_2_0_JSON (*((EFI_REDFISH_ENDPOINTGROUP_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointGroupToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_2_0 *EndpointGroupV1_2_0; + + EndpointGroupV1_2_0 = (EFI_REDFISH_ENDPOINTGROUP_V1_2_0 *)InterpProp; + DestroyEndpointGroup_V1_2_0_CS (EndpointGroupV1_2_0->EndpointGroup); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointGroupFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpointGroup_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointGroupToStructWrapper, + EndpointGroupToJson, + EndpointGroupDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_2_0/RedfishEndpointGroup_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/EndpointGroup/v1_2_0/RedfishEndpointGroup_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..1554f2eae83 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_2_0/RedfishEndpointGroup_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EndpointGroup.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpointGroup_V1_2_0_Dxe + FILE_GUID = de6f3f31-c0f7-4c12-a138-6a01169ff535 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpointGroup_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishEndpointGroup_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EndpointGroup_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointGroupV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_2_1/EndpointGroup_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/EndpointGroup/v1_2_1/EndpointGroup_V1_2_1_Dxe.c new file mode 100644 index 00000000000..cbb096f6fa5 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_2_1/EndpointGroup_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EndpointGroup.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EndpointGroup"; +BOOLEAN IsRevisonController = TRUE; + +// Support EndpointGroup V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EndpointGroup", + "1", + "2", + "1" + }, + "EndpointGroup" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_2_1 *EndpointGroupV1_2_1; + EFI_REDFISH_ENDPOINTGROUP_V1_2_1_CS *EndpointGroupV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EndpointGroup") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EndpointGroup_V1_2_1_To_CS (ResoruceRaw, &EndpointGroupV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointGroupV1_2_1 = (EFI_REDFISH_ENDPOINTGROUP_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINTGROUP_V1_2_1)); + if (EndpointGroupV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointGroupV1_2_1; + EndpointGroupV1_2_1->EndpointGroup = EndpointGroupV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointGroupToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointGroupToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EndpointGroup_V1_2_1_JSON (*((EFI_REDFISH_ENDPOINTGROUP_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointGroupToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_2_1 *EndpointGroupV1_2_1; + + EndpointGroupV1_2_1 = (EFI_REDFISH_ENDPOINTGROUP_V1_2_1 *)InterpProp; + DestroyEndpointGroup_V1_2_1_CS (EndpointGroupV1_2_1->EndpointGroup); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointGroupFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpointGroup_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointGroupToStructWrapper, + EndpointGroupToJson, + EndpointGroupDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_2_1/RedfishEndpointGroup_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/EndpointGroup/v1_2_1/RedfishEndpointGroup_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..9fe453c93e4 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_2_1/RedfishEndpointGroup_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EndpointGroup.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpointGroup_V1_2_1_Dxe + FILE_GUID = 2b92d34a-d645-4e06-ba87-8dec9d1f2cc3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpointGroup_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishEndpointGroup_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EndpointGroup_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointGroupV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_2_2/EndpointGroup_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/EndpointGroup/v1_2_2/EndpointGroup_V1_2_2_Dxe.c new file mode 100644 index 00000000000..d60b4906173 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_2_2/EndpointGroup_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EndpointGroup.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EndpointGroup"; +BOOLEAN IsRevisonController = TRUE; + +// Support EndpointGroup V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EndpointGroup", + "1", + "2", + "2" + }, + "EndpointGroup" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_2_2 *EndpointGroupV1_2_2; + EFI_REDFISH_ENDPOINTGROUP_V1_2_2_CS *EndpointGroupV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EndpointGroup") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EndpointGroup_V1_2_2_To_CS (ResoruceRaw, &EndpointGroupV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointGroupV1_2_2 = (EFI_REDFISH_ENDPOINTGROUP_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINTGROUP_V1_2_2)); + if (EndpointGroupV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointGroupV1_2_2; + EndpointGroupV1_2_2->EndpointGroup = EndpointGroupV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointGroupToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointGroupToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EndpointGroup_V1_2_2_JSON (*((EFI_REDFISH_ENDPOINTGROUP_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointGroupToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_2_2 *EndpointGroupV1_2_2; + + EndpointGroupV1_2_2 = (EFI_REDFISH_ENDPOINTGROUP_V1_2_2 *)InterpProp; + DestroyEndpointGroup_V1_2_2_CS (EndpointGroupV1_2_2->EndpointGroup); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointGroupFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpointGroup_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointGroupToStructWrapper, + EndpointGroupToJson, + EndpointGroupDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_2_2/RedfishEndpointGroup_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/EndpointGroup/v1_2_2/RedfishEndpointGroup_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..64ec6e63268 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_2_2/RedfishEndpointGroup_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EndpointGroup.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpointGroup_V1_2_2_Dxe + FILE_GUID = ad3d5136-7a56-443f-95f7-f7050b365225 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpointGroup_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishEndpointGroup_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EndpointGroup_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointGroupV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_2_3/EndpointGroup_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/EndpointGroup/v1_2_3/EndpointGroup_V1_2_3_Dxe.c new file mode 100644 index 00000000000..18e6e79d486 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_2_3/EndpointGroup_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EndpointGroup.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EndpointGroup"; +BOOLEAN IsRevisonController = TRUE; + +// Support EndpointGroup V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EndpointGroup", + "1", + "2", + "3" + }, + "EndpointGroup" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_2_3 *EndpointGroupV1_2_3; + EFI_REDFISH_ENDPOINTGROUP_V1_2_3_CS *EndpointGroupV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EndpointGroup") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EndpointGroup_V1_2_3_To_CS (ResoruceRaw, &EndpointGroupV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointGroupV1_2_3 = (EFI_REDFISH_ENDPOINTGROUP_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINTGROUP_V1_2_3)); + if (EndpointGroupV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointGroupV1_2_3; + EndpointGroupV1_2_3->EndpointGroup = EndpointGroupV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointGroupToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointGroupToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EndpointGroup_V1_2_3_JSON (*((EFI_REDFISH_ENDPOINTGROUP_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointGroupToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_2_3 *EndpointGroupV1_2_3; + + EndpointGroupV1_2_3 = (EFI_REDFISH_ENDPOINTGROUP_V1_2_3 *)InterpProp; + DestroyEndpointGroup_V1_2_3_CS (EndpointGroupV1_2_3->EndpointGroup); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointGroupFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpointGroup_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointGroupToStructWrapper, + EndpointGroupToJson, + EndpointGroupDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_2_3/RedfishEndpointGroup_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/EndpointGroup/v1_2_3/RedfishEndpointGroup_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..857df849892 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_2_3/RedfishEndpointGroup_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EndpointGroup.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpointGroup_V1_2_3_Dxe + FILE_GUID = c4b2f15e-334c-41bf-b91e-620c949c9df2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpointGroup_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishEndpointGroup_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EndpointGroup_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointGroupV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_3_0/EndpointGroup_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/EndpointGroup/v1_3_0/EndpointGroup_V1_3_0_Dxe.c new file mode 100644 index 00000000000..8f7cfd8f3db --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_3_0/EndpointGroup_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EndpointGroup.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EndpointGroup"; +BOOLEAN IsRevisonController = TRUE; + +// Support EndpointGroup V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EndpointGroup", + "1", + "3", + "0" + }, + "EndpointGroup" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_3_0 *EndpointGroupV1_3_0; + EFI_REDFISH_ENDPOINTGROUP_V1_3_0_CS *EndpointGroupV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EndpointGroup") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EndpointGroup_V1_3_0_To_CS (ResoruceRaw, &EndpointGroupV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointGroupV1_3_0 = (EFI_REDFISH_ENDPOINTGROUP_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINTGROUP_V1_3_0)); + if (EndpointGroupV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointGroupV1_3_0; + EndpointGroupV1_3_0->EndpointGroup = EndpointGroupV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointGroupToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointGroupToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EndpointGroup_V1_3_0_JSON (*((EFI_REDFISH_ENDPOINTGROUP_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointGroupToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_3_0 *EndpointGroupV1_3_0; + + EndpointGroupV1_3_0 = (EFI_REDFISH_ENDPOINTGROUP_V1_3_0 *)InterpProp; + DestroyEndpointGroup_V1_3_0_CS (EndpointGroupV1_3_0->EndpointGroup); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointGroupFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpointGroup_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointGroupToStructWrapper, + EndpointGroupToJson, + EndpointGroupDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_3_0/RedfishEndpointGroup_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/EndpointGroup/v1_3_0/RedfishEndpointGroup_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..1b33859ebb8 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_3_0/RedfishEndpointGroup_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EndpointGroup.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpointGroup_V1_3_0_Dxe + FILE_GUID = ce6fff14-8536-486f-a3e3-2f736e865351 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpointGroup_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishEndpointGroup_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EndpointGroup_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointGroupV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_3_1/EndpointGroup_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/EndpointGroup/v1_3_1/EndpointGroup_V1_3_1_Dxe.c new file mode 100644 index 00000000000..bab0b27de3a --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_3_1/EndpointGroup_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EndpointGroup.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EndpointGroup"; +BOOLEAN IsRevisonController = TRUE; + +// Support EndpointGroup V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EndpointGroup", + "1", + "3", + "1" + }, + "EndpointGroup" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_3_1 *EndpointGroupV1_3_1; + EFI_REDFISH_ENDPOINTGROUP_V1_3_1_CS *EndpointGroupV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EndpointGroup") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EndpointGroup_V1_3_1_To_CS (ResoruceRaw, &EndpointGroupV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointGroupV1_3_1 = (EFI_REDFISH_ENDPOINTGROUP_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINTGROUP_V1_3_1)); + if (EndpointGroupV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointGroupV1_3_1; + EndpointGroupV1_3_1->EndpointGroup = EndpointGroupV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EndpointGroup"), "EndpointGroup"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointGroupToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointGroupToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EndpointGroup_V1_3_1_JSON (*((EFI_REDFISH_ENDPOINTGROUP_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointGroupToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUP_V1_3_1 *EndpointGroupV1_3_1; + + EndpointGroupV1_3_1 = (EFI_REDFISH_ENDPOINTGROUP_V1_3_1 *)InterpProp; + DestroyEndpointGroup_V1_3_1_CS (EndpointGroupV1_3_1->EndpointGroup); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointGroupFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpointGroup_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointGroupToStructWrapper, + EndpointGroupToJson, + EndpointGroupDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroup_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EndpointGroup/v1_3_1/RedfishEndpointGroup_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/EndpointGroup/v1_3_1/RedfishEndpointGroup_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..3d028499bd2 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroup/v1_3_1/RedfishEndpointGroup_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EndpointGroup.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpointGroup_V1_3_1_Dxe + FILE_GUID = 01bef57e-44f4-4589-9ec7-6dd93f997289 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpointGroup_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishEndpointGroup_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EndpointGroup_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointGroupV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EndpointGroupCollection/EndpointGroupCollection_Dxe.c b/RedfishClientPkg/Converter/EndpointGroupCollection/EndpointGroupCollection_Dxe.c new file mode 100644 index 00000000000..0dc38650bb6 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroupCollection/EndpointGroupCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EndpointGroupCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EndpointGroupCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support EndpointGroupCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EndpointGroupCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "EndpointGroupCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUPCOLLECTION *EndpointGroupCollection; + EFI_REDFISH_ENDPOINTGROUPCOLLECTION_CS *EndpointGroupCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EndpointGroupCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EndpointGroupCollection_To_CS (ResoruceRaw, &EndpointGroupCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + EndpointGroupCollection = (EFI_REDFISH_ENDPOINTGROUPCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENDPOINTGROUPCOLLECTION)); + if (EndpointGroupCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EndpointGroupCollection; + EndpointGroupCollection->EndpointGroupCollection = EndpointGroupCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroupCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EndpointGroupCollection"), "EndpointGroupCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EndpointGroupCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EndpointGroupCollection"), "EndpointGroupCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EndpointGroupCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EndpointGroupCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EndpointGroupCollection_JSON (*((EFI_REDFISH_ENDPOINTGROUPCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EndpointGroupCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENDPOINTGROUPCOLLECTION *EndpointGroupCollection; + + EndpointGroupCollection = (EFI_REDFISH_ENDPOINTGROUPCOLLECTION *)InterpProp; + DestroyEndpointGroupCollection_CS (EndpointGroupCollection->EndpointGroupCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EndpointGroupCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EndpointGroupCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEndpointGroupCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroupCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EndpointGroupCollectionToStructWrapper, + EndpointGroupCollectionToJson, + EndpointGroupCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEndpointGroupCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EndpointGroupCollection/RedfishEndpointGroupCollection_Dxe.inf b/RedfishClientPkg/Converter/EndpointGroupCollection/RedfishEndpointGroupCollection_Dxe.inf new file mode 100644 index 00000000000..0fe53f2b619 --- /dev/null +++ b/RedfishClientPkg/Converter/EndpointGroupCollection/RedfishEndpointGroupCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EndpointGroupCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEndpointGroupCollection_Dxe + FILE_GUID = 1db8fa66-2ee5-4400-8be4-2f1c2aae74dc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEndpointGroupCollectionEntryPoint + UNLOAD_IMAGE = RedfishEndpointGroupCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EndpointGroupCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EndpointGroupCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EnvironmentMetrics/v1_0_0/EnvironmentMetrics_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/EnvironmentMetrics/v1_0_0/EnvironmentMetrics_V1_0_0_Dxe.c new file mode 100644 index 00000000000..2bb0d94e032 --- /dev/null +++ b/RedfishClientPkg/Converter/EnvironmentMetrics/v1_0_0/EnvironmentMetrics_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EnvironmentMetrics.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EnvironmentMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support EnvironmentMetrics V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EnvironmentMetrics", + "1", + "0", + "0" + }, + "EnvironmentMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EnvironmentMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ENVIRONMENTMETRICS_V1_0_0 *EnvironmentMetricsV1_0_0; + EFI_REDFISH_ENVIRONMENTMETRICS_V1_0_0_CS *EnvironmentMetricsV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EnvironmentMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EnvironmentMetrics_V1_0_0_To_CS (ResoruceRaw, &EnvironmentMetricsV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EnvironmentMetricsV1_0_0 = (EFI_REDFISH_ENVIRONMENTMETRICS_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ENVIRONMENTMETRICS_V1_0_0)); + if (EnvironmentMetricsV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EnvironmentMetricsV1_0_0; + EnvironmentMetricsV1_0_0->EnvironmentMetrics = EnvironmentMetricsV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EnvironmentMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EnvironmentMetrics"), "EnvironmentMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EnvironmentMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EnvironmentMetrics"), "EnvironmentMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EnvironmentMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EnvironmentMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EnvironmentMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EnvironmentMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EnvironmentMetrics_V1_0_0_JSON (*((EFI_REDFISH_ENVIRONMENTMETRICS_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EnvironmentMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EnvironmentMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ENVIRONMENTMETRICS_V1_0_0 *EnvironmentMetricsV1_0_0; + + EnvironmentMetricsV1_0_0 = (EFI_REDFISH_ENVIRONMENTMETRICS_V1_0_0 *)InterpProp; + DestroyEnvironmentMetrics_V1_0_0_CS (EnvironmentMetricsV1_0_0->EnvironmentMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EnvironmentMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EnvironmentMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEnvironmentMetrics_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEnvironmentMetrics_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EnvironmentMetricsToStructWrapper, + EnvironmentMetricsToJson, + EnvironmentMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEnvironmentMetrics_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EnvironmentMetrics/v1_0_0/RedfishEnvironmentMetrics_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/EnvironmentMetrics/v1_0_0/RedfishEnvironmentMetrics_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..28e648c05d8 --- /dev/null +++ b/RedfishClientPkg/Converter/EnvironmentMetrics/v1_0_0/RedfishEnvironmentMetrics_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EnvironmentMetrics.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEnvironmentMetrics_V1_0_0_Dxe + FILE_GUID = 88e7018d-b82b-44f1-b68e-09275dab788c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEnvironmentMetrics_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishEnvironmentMetrics_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EnvironmentMetrics_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EnvironmentMetricsV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_0_0/EthernetInterface_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_0_0/EthernetInterface_V1_0_0_Dxe.c new file mode 100644 index 00000000000..f53ead8906f --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_0_0/EthernetInterface_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "0", + "0" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_0_0 *EthernetInterfaceV1_0_0; + EFI_REDFISH_ETHERNETINTERFACE_V1_0_0_CS *EthernetInterfaceV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_0_0_To_CS (ResoruceRaw, &EthernetInterfaceV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_0_0 = (EFI_REDFISH_ETHERNETINTERFACE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_0_0)); + if (EthernetInterfaceV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_0_0; + EthernetInterfaceV1_0_0->EthernetInterface = EthernetInterfaceV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_0_0_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_0_0 *EthernetInterfaceV1_0_0; + + EthernetInterfaceV1_0_0 = (EFI_REDFISH_ETHERNETINTERFACE_V1_0_0 *)InterpProp; + DestroyEthernetInterface_V1_0_0_CS (EthernetInterfaceV1_0_0->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_0_0/RedfishEthernetInterface_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_0_0/RedfishEthernetInterface_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..c7b354cf24f --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_0_0/RedfishEthernetInterface_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_0_0_Dxe + FILE_GUID = c9a001d3-7462-4311-9f4a-29ca0216bef4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_0_10/EthernetInterface_V1_0_10_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_0_10/EthernetInterface_V1_0_10_Dxe.c new file mode 100644 index 00000000000..031acd7d69b --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_0_10/EthernetInterface_V1_0_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_0_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "0", + "10" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_0_10 *EthernetInterfaceV1_0_10; + EFI_REDFISH_ETHERNETINTERFACE_V1_0_10_CS *EthernetInterfaceV1_0_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_0_10_To_CS (ResoruceRaw, &EthernetInterfaceV1_0_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_0_10 = (EFI_REDFISH_ETHERNETINTERFACE_V1_0_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_0_10)); + if (EthernetInterfaceV1_0_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_0_10; + EthernetInterfaceV1_0_10->EthernetInterface = EthernetInterfaceV1_0_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_0_10_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_0_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_0_10 *EthernetInterfaceV1_0_10; + + EthernetInterfaceV1_0_10 = (EFI_REDFISH_ETHERNETINTERFACE_V1_0_10 *)InterpProp; + DestroyEthernetInterface_V1_0_10_CS (EthernetInterfaceV1_0_10->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_0_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_0_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_0_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_0_10/RedfishEthernetInterface_V1_0_10_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_0_10/RedfishEthernetInterface_V1_0_10_Dxe.inf new file mode 100644 index 00000000000..92cb456ee7d --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_0_10/RedfishEthernetInterface_V1_0_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_0_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_0_10_Dxe + FILE_GUID = 2b139851-ce73-44e6-932f-2bbab74393b1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_0_10EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_0_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_0_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_0_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_0_11/EthernetInterface_V1_0_11_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_0_11/EthernetInterface_V1_0_11_Dxe.c new file mode 100644 index 00000000000..b862acde159 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_0_11/EthernetInterface_V1_0_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_0_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "0", + "11" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_0_11 *EthernetInterfaceV1_0_11; + EFI_REDFISH_ETHERNETINTERFACE_V1_0_11_CS *EthernetInterfaceV1_0_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_0_11_To_CS (ResoruceRaw, &EthernetInterfaceV1_0_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_0_11 = (EFI_REDFISH_ETHERNETINTERFACE_V1_0_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_0_11)); + if (EthernetInterfaceV1_0_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_0_11; + EthernetInterfaceV1_0_11->EthernetInterface = EthernetInterfaceV1_0_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_0_11_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_0_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_0_11 *EthernetInterfaceV1_0_11; + + EthernetInterfaceV1_0_11 = (EFI_REDFISH_ETHERNETINTERFACE_V1_0_11 *)InterpProp; + DestroyEthernetInterface_V1_0_11_CS (EthernetInterfaceV1_0_11->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_0_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_0_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_0_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_0_11/RedfishEthernetInterface_V1_0_11_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_0_11/RedfishEthernetInterface_V1_0_11_Dxe.inf new file mode 100644 index 00000000000..f799b7aed80 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_0_11/RedfishEthernetInterface_V1_0_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_0_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_0_11_Dxe + FILE_GUID = 4d649d14-402e-4525-8748-7b85595db9c6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_0_11EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_0_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_0_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_0_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_0_12/EthernetInterface_V1_0_12_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_0_12/EthernetInterface_V1_0_12_Dxe.c new file mode 100644 index 00000000000..e90c4a3768c --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_0_12/EthernetInterface_V1_0_12_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_0_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_0_12 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "0", + "12" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_0_12 *EthernetInterfaceV1_0_12; + EFI_REDFISH_ETHERNETINTERFACE_V1_0_12_CS *EthernetInterfaceV1_0_12Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "12") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_0_12_To_CS (ResoruceRaw, &EthernetInterfaceV1_0_12Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_0_12 = (EFI_REDFISH_ETHERNETINTERFACE_V1_0_12 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_0_12)); + if (EthernetInterfaceV1_0_12 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_0_12; + EthernetInterfaceV1_0_12->EthernetInterface = EthernetInterfaceV1_0_12Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "12"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_0_12_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_0_12_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_0_12 *EthernetInterfaceV1_0_12; + + EthernetInterfaceV1_0_12 = (EFI_REDFISH_ETHERNETINTERFACE_V1_0_12 *)InterpProp; + DestroyEthernetInterface_V1_0_12_CS (EthernetInterfaceV1_0_12->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_0_12_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_0_12EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_0_12Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_0_12/RedfishEthernetInterface_V1_0_12_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_0_12/RedfishEthernetInterface_V1_0_12_Dxe.inf new file mode 100644 index 00000000000..8d4612d28a2 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_0_12/RedfishEthernetInterface_V1_0_12_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_0_12 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_0_12_Dxe + FILE_GUID = 4dccfdd8-6f1b-444d-9409-0c0e757044d4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_0_12EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_0_12Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_0_12_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_0_12Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_0_2/EthernetInterface_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_0_2/EthernetInterface_V1_0_2_Dxe.c new file mode 100644 index 00000000000..e0e64cb967d --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_0_2/EthernetInterface_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "0", + "2" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_0_2 *EthernetInterfaceV1_0_2; + EFI_REDFISH_ETHERNETINTERFACE_V1_0_2_CS *EthernetInterfaceV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_0_2_To_CS (ResoruceRaw, &EthernetInterfaceV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_0_2 = (EFI_REDFISH_ETHERNETINTERFACE_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_0_2)); + if (EthernetInterfaceV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_0_2; + EthernetInterfaceV1_0_2->EthernetInterface = EthernetInterfaceV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_0_2_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_0_2 *EthernetInterfaceV1_0_2; + + EthernetInterfaceV1_0_2 = (EFI_REDFISH_ETHERNETINTERFACE_V1_0_2 *)InterpProp; + DestroyEthernetInterface_V1_0_2_CS (EthernetInterfaceV1_0_2->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_0_2/RedfishEthernetInterface_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_0_2/RedfishEthernetInterface_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..d28a16d8b22 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_0_2/RedfishEthernetInterface_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_0_2_Dxe + FILE_GUID = 1b804989-7507-4372-808b-02cc71c4b9ba + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_0_3/EthernetInterface_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_0_3/EthernetInterface_V1_0_3_Dxe.c new file mode 100644 index 00000000000..29788d280b8 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_0_3/EthernetInterface_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "0", + "3" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_0_3 *EthernetInterfaceV1_0_3; + EFI_REDFISH_ETHERNETINTERFACE_V1_0_3_CS *EthernetInterfaceV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_0_3_To_CS (ResoruceRaw, &EthernetInterfaceV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_0_3 = (EFI_REDFISH_ETHERNETINTERFACE_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_0_3)); + if (EthernetInterfaceV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_0_3; + EthernetInterfaceV1_0_3->EthernetInterface = EthernetInterfaceV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_0_3_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_0_3 *EthernetInterfaceV1_0_3; + + EthernetInterfaceV1_0_3 = (EFI_REDFISH_ETHERNETINTERFACE_V1_0_3 *)InterpProp; + DestroyEthernetInterface_V1_0_3_CS (EthernetInterfaceV1_0_3->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_0_3/RedfishEthernetInterface_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_0_3/RedfishEthernetInterface_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..912786ae443 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_0_3/RedfishEthernetInterface_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_0_3_Dxe + FILE_GUID = 9c257448-90d8-49ca-9d65-71ec2ac2a6a9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_0_4/EthernetInterface_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_0_4/EthernetInterface_V1_0_4_Dxe.c new file mode 100644 index 00000000000..19d4f73bcc0 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_0_4/EthernetInterface_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "0", + "4" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_0_4 *EthernetInterfaceV1_0_4; + EFI_REDFISH_ETHERNETINTERFACE_V1_0_4_CS *EthernetInterfaceV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_0_4_To_CS (ResoruceRaw, &EthernetInterfaceV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_0_4 = (EFI_REDFISH_ETHERNETINTERFACE_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_0_4)); + if (EthernetInterfaceV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_0_4; + EthernetInterfaceV1_0_4->EthernetInterface = EthernetInterfaceV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_0_4_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_0_4 *EthernetInterfaceV1_0_4; + + EthernetInterfaceV1_0_4 = (EFI_REDFISH_ETHERNETINTERFACE_V1_0_4 *)InterpProp; + DestroyEthernetInterface_V1_0_4_CS (EthernetInterfaceV1_0_4->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_0_4/RedfishEthernetInterface_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_0_4/RedfishEthernetInterface_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..548d197c933 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_0_4/RedfishEthernetInterface_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_0_4_Dxe + FILE_GUID = 623c3719-d0b7-4e6e-81a5-114ecea09e6e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_0_5/EthernetInterface_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_0_5/EthernetInterface_V1_0_5_Dxe.c new file mode 100644 index 00000000000..2d66c4ec1c6 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_0_5/EthernetInterface_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "0", + "5" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_0_5 *EthernetInterfaceV1_0_5; + EFI_REDFISH_ETHERNETINTERFACE_V1_0_5_CS *EthernetInterfaceV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_0_5_To_CS (ResoruceRaw, &EthernetInterfaceV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_0_5 = (EFI_REDFISH_ETHERNETINTERFACE_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_0_5)); + if (EthernetInterfaceV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_0_5; + EthernetInterfaceV1_0_5->EthernetInterface = EthernetInterfaceV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_0_5_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_0_5 *EthernetInterfaceV1_0_5; + + EthernetInterfaceV1_0_5 = (EFI_REDFISH_ETHERNETINTERFACE_V1_0_5 *)InterpProp; + DestroyEthernetInterface_V1_0_5_CS (EthernetInterfaceV1_0_5->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_0_5/RedfishEthernetInterface_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_0_5/RedfishEthernetInterface_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..53aacc43f22 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_0_5/RedfishEthernetInterface_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_0_5_Dxe + FILE_GUID = e6058916-d229-42e2-ac5c-aecab5a5d424 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_0_6/EthernetInterface_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_0_6/EthernetInterface_V1_0_6_Dxe.c new file mode 100644 index 00000000000..34bd337dec8 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_0_6/EthernetInterface_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "0", + "6" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_0_6 *EthernetInterfaceV1_0_6; + EFI_REDFISH_ETHERNETINTERFACE_V1_0_6_CS *EthernetInterfaceV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_0_6_To_CS (ResoruceRaw, &EthernetInterfaceV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_0_6 = (EFI_REDFISH_ETHERNETINTERFACE_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_0_6)); + if (EthernetInterfaceV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_0_6; + EthernetInterfaceV1_0_6->EthernetInterface = EthernetInterfaceV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_0_6_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_0_6 *EthernetInterfaceV1_0_6; + + EthernetInterfaceV1_0_6 = (EFI_REDFISH_ETHERNETINTERFACE_V1_0_6 *)InterpProp; + DestroyEthernetInterface_V1_0_6_CS (EthernetInterfaceV1_0_6->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_0_6/RedfishEthernetInterface_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_0_6/RedfishEthernetInterface_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..3a372abb7e6 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_0_6/RedfishEthernetInterface_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_0_6_Dxe + FILE_GUID = a1e25a59-1b17-4237-8398-e1e560fe2176 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_0_7/EthernetInterface_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_0_7/EthernetInterface_V1_0_7_Dxe.c new file mode 100644 index 00000000000..0ae7836b22d --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_0_7/EthernetInterface_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "0", + "7" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_0_7 *EthernetInterfaceV1_0_7; + EFI_REDFISH_ETHERNETINTERFACE_V1_0_7_CS *EthernetInterfaceV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_0_7_To_CS (ResoruceRaw, &EthernetInterfaceV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_0_7 = (EFI_REDFISH_ETHERNETINTERFACE_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_0_7)); + if (EthernetInterfaceV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_0_7; + EthernetInterfaceV1_0_7->EthernetInterface = EthernetInterfaceV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_0_7_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_0_7 *EthernetInterfaceV1_0_7; + + EthernetInterfaceV1_0_7 = (EFI_REDFISH_ETHERNETINTERFACE_V1_0_7 *)InterpProp; + DestroyEthernetInterface_V1_0_7_CS (EthernetInterfaceV1_0_7->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_0_7/RedfishEthernetInterface_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_0_7/RedfishEthernetInterface_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..8f5301084b9 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_0_7/RedfishEthernetInterface_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_0_7_Dxe + FILE_GUID = b7bfe841-281a-44f9-a2f6-c9e1f695c94d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_0_8/EthernetInterface_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_0_8/EthernetInterface_V1_0_8_Dxe.c new file mode 100644 index 00000000000..d3977b3a1c6 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_0_8/EthernetInterface_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "0", + "8" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_0_8 *EthernetInterfaceV1_0_8; + EFI_REDFISH_ETHERNETINTERFACE_V1_0_8_CS *EthernetInterfaceV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_0_8_To_CS (ResoruceRaw, &EthernetInterfaceV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_0_8 = (EFI_REDFISH_ETHERNETINTERFACE_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_0_8)); + if (EthernetInterfaceV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_0_8; + EthernetInterfaceV1_0_8->EthernetInterface = EthernetInterfaceV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_0_8_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_0_8 *EthernetInterfaceV1_0_8; + + EthernetInterfaceV1_0_8 = (EFI_REDFISH_ETHERNETINTERFACE_V1_0_8 *)InterpProp; + DestroyEthernetInterface_V1_0_8_CS (EthernetInterfaceV1_0_8->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_0_8/RedfishEthernetInterface_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_0_8/RedfishEthernetInterface_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..646ddd04e57 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_0_8/RedfishEthernetInterface_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_0_8_Dxe + FILE_GUID = a9e1827b-3d25-4577-9df6-3721f2e010b4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_0_9/EthernetInterface_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_0_9/EthernetInterface_V1_0_9_Dxe.c new file mode 100644 index 00000000000..9ed73021341 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_0_9/EthernetInterface_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "0", + "9" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_0_9 *EthernetInterfaceV1_0_9; + EFI_REDFISH_ETHERNETINTERFACE_V1_0_9_CS *EthernetInterfaceV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_0_9_To_CS (ResoruceRaw, &EthernetInterfaceV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_0_9 = (EFI_REDFISH_ETHERNETINTERFACE_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_0_9)); + if (EthernetInterfaceV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_0_9; + EthernetInterfaceV1_0_9->EthernetInterface = EthernetInterfaceV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_0_9_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_0_9 *EthernetInterfaceV1_0_9; + + EthernetInterfaceV1_0_9 = (EFI_REDFISH_ETHERNETINTERFACE_V1_0_9 *)InterpProp; + DestroyEthernetInterface_V1_0_9_CS (EthernetInterfaceV1_0_9->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_0_9/RedfishEthernetInterface_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_0_9/RedfishEthernetInterface_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..66d219b2a3d --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_0_9/RedfishEthernetInterface_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_0_9_Dxe + FILE_GUID = 720769b3-460f-4253-835e-ee161b08cace + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_1_0/EthernetInterface_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_1_0/EthernetInterface_V1_1_0_Dxe.c new file mode 100644 index 00000000000..b5c8d662390 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_1_0/EthernetInterface_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "1", + "0" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_1_0 *EthernetInterfaceV1_1_0; + EFI_REDFISH_ETHERNETINTERFACE_V1_1_0_CS *EthernetInterfaceV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_1_0_To_CS (ResoruceRaw, &EthernetInterfaceV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_1_0 = (EFI_REDFISH_ETHERNETINTERFACE_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_1_0)); + if (EthernetInterfaceV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_1_0; + EthernetInterfaceV1_1_0->EthernetInterface = EthernetInterfaceV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_1_0_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_1_0 *EthernetInterfaceV1_1_0; + + EthernetInterfaceV1_1_0 = (EFI_REDFISH_ETHERNETINTERFACE_V1_1_0 *)InterpProp; + DestroyEthernetInterface_V1_1_0_CS (EthernetInterfaceV1_1_0->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_1_0/RedfishEthernetInterface_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_1_0/RedfishEthernetInterface_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..02a1a21ac84 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_1_0/RedfishEthernetInterface_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_1_0_Dxe + FILE_GUID = 901d5f6f-9b57-4883-b0f0-ec66d179c9e2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_1_1/EthernetInterface_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_1_1/EthernetInterface_V1_1_1_Dxe.c new file mode 100644 index 00000000000..e695b1245b9 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_1_1/EthernetInterface_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "1", + "1" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_1_1 *EthernetInterfaceV1_1_1; + EFI_REDFISH_ETHERNETINTERFACE_V1_1_1_CS *EthernetInterfaceV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_1_1_To_CS (ResoruceRaw, &EthernetInterfaceV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_1_1 = (EFI_REDFISH_ETHERNETINTERFACE_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_1_1)); + if (EthernetInterfaceV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_1_1; + EthernetInterfaceV1_1_1->EthernetInterface = EthernetInterfaceV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_1_1_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_1_1 *EthernetInterfaceV1_1_1; + + EthernetInterfaceV1_1_1 = (EFI_REDFISH_ETHERNETINTERFACE_V1_1_1 *)InterpProp; + DestroyEthernetInterface_V1_1_1_CS (EthernetInterfaceV1_1_1->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_1_1/RedfishEthernetInterface_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_1_1/RedfishEthernetInterface_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..5c98078240f --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_1_1/RedfishEthernetInterface_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_1_1_Dxe + FILE_GUID = 3cdb0fe8-721d-4cac-b6bf-e444b5580112 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_1_10/EthernetInterface_V1_1_10_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_1_10/EthernetInterface_V1_1_10_Dxe.c new file mode 100644 index 00000000000..343b2c9bd71 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_1_10/EthernetInterface_V1_1_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_1_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_1_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "1", + "10" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_1_10 *EthernetInterfaceV1_1_10; + EFI_REDFISH_ETHERNETINTERFACE_V1_1_10_CS *EthernetInterfaceV1_1_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_1_10_To_CS (ResoruceRaw, &EthernetInterfaceV1_1_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_1_10 = (EFI_REDFISH_ETHERNETINTERFACE_V1_1_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_1_10)); + if (EthernetInterfaceV1_1_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_1_10; + EthernetInterfaceV1_1_10->EthernetInterface = EthernetInterfaceV1_1_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_1_10_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_1_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_1_10 *EthernetInterfaceV1_1_10; + + EthernetInterfaceV1_1_10 = (EFI_REDFISH_ETHERNETINTERFACE_V1_1_10 *)InterpProp; + DestroyEthernetInterface_V1_1_10_CS (EthernetInterfaceV1_1_10->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_1_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_1_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_1_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_1_10/RedfishEthernetInterface_V1_1_10_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_1_10/RedfishEthernetInterface_V1_1_10_Dxe.inf new file mode 100644 index 00000000000..587f9d65d3b --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_1_10/RedfishEthernetInterface_V1_1_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_1_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_1_10_Dxe + FILE_GUID = 0c8775f0-cbac-4758-9815-f091ba9ee8ca + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_1_10EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_1_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_1_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_1_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_1_2/EthernetInterface_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_1_2/EthernetInterface_V1_1_2_Dxe.c new file mode 100644 index 00000000000..e7f6ddcd177 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_1_2/EthernetInterface_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "1", + "2" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_1_2 *EthernetInterfaceV1_1_2; + EFI_REDFISH_ETHERNETINTERFACE_V1_1_2_CS *EthernetInterfaceV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_1_2_To_CS (ResoruceRaw, &EthernetInterfaceV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_1_2 = (EFI_REDFISH_ETHERNETINTERFACE_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_1_2)); + if (EthernetInterfaceV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_1_2; + EthernetInterfaceV1_1_2->EthernetInterface = EthernetInterfaceV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_1_2_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_1_2 *EthernetInterfaceV1_1_2; + + EthernetInterfaceV1_1_2 = (EFI_REDFISH_ETHERNETINTERFACE_V1_1_2 *)InterpProp; + DestroyEthernetInterface_V1_1_2_CS (EthernetInterfaceV1_1_2->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_1_2/RedfishEthernetInterface_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_1_2/RedfishEthernetInterface_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..25075545a2b --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_1_2/RedfishEthernetInterface_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_1_2_Dxe + FILE_GUID = 18e0f4f2-4026-43bd-b090-069a1d2a8f8d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_1_3/EthernetInterface_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_1_3/EthernetInterface_V1_1_3_Dxe.c new file mode 100644 index 00000000000..29f09385b5a --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_1_3/EthernetInterface_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "1", + "3" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_1_3 *EthernetInterfaceV1_1_3; + EFI_REDFISH_ETHERNETINTERFACE_V1_1_3_CS *EthernetInterfaceV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_1_3_To_CS (ResoruceRaw, &EthernetInterfaceV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_1_3 = (EFI_REDFISH_ETHERNETINTERFACE_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_1_3)); + if (EthernetInterfaceV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_1_3; + EthernetInterfaceV1_1_3->EthernetInterface = EthernetInterfaceV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_1_3_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_1_3 *EthernetInterfaceV1_1_3; + + EthernetInterfaceV1_1_3 = (EFI_REDFISH_ETHERNETINTERFACE_V1_1_3 *)InterpProp; + DestroyEthernetInterface_V1_1_3_CS (EthernetInterfaceV1_1_3->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_1_3/RedfishEthernetInterface_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_1_3/RedfishEthernetInterface_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..a2116fdcbf2 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_1_3/RedfishEthernetInterface_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_1_3_Dxe + FILE_GUID = 1fd703ee-28a7-4f33-9c7e-72ee2a276e19 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_1_4/EthernetInterface_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_1_4/EthernetInterface_V1_1_4_Dxe.c new file mode 100644 index 00000000000..ccfd967ee88 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_1_4/EthernetInterface_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "1", + "4" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_1_4 *EthernetInterfaceV1_1_4; + EFI_REDFISH_ETHERNETINTERFACE_V1_1_4_CS *EthernetInterfaceV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_1_4_To_CS (ResoruceRaw, &EthernetInterfaceV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_1_4 = (EFI_REDFISH_ETHERNETINTERFACE_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_1_4)); + if (EthernetInterfaceV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_1_4; + EthernetInterfaceV1_1_4->EthernetInterface = EthernetInterfaceV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_1_4_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_1_4 *EthernetInterfaceV1_1_4; + + EthernetInterfaceV1_1_4 = (EFI_REDFISH_ETHERNETINTERFACE_V1_1_4 *)InterpProp; + DestroyEthernetInterface_V1_1_4_CS (EthernetInterfaceV1_1_4->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_1_4/RedfishEthernetInterface_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_1_4/RedfishEthernetInterface_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..f12b65e08de --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_1_4/RedfishEthernetInterface_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_1_4_Dxe + FILE_GUID = 030c81be-90d0-4b06-a48c-9fb0a2e6c337 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_1_5/EthernetInterface_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_1_5/EthernetInterface_V1_1_5_Dxe.c new file mode 100644 index 00000000000..ffff5a1cb0a --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_1_5/EthernetInterface_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "1", + "5" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_1_5 *EthernetInterfaceV1_1_5; + EFI_REDFISH_ETHERNETINTERFACE_V1_1_5_CS *EthernetInterfaceV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_1_5_To_CS (ResoruceRaw, &EthernetInterfaceV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_1_5 = (EFI_REDFISH_ETHERNETINTERFACE_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_1_5)); + if (EthernetInterfaceV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_1_5; + EthernetInterfaceV1_1_5->EthernetInterface = EthernetInterfaceV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_1_5_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_1_5 *EthernetInterfaceV1_1_5; + + EthernetInterfaceV1_1_5 = (EFI_REDFISH_ETHERNETINTERFACE_V1_1_5 *)InterpProp; + DestroyEthernetInterface_V1_1_5_CS (EthernetInterfaceV1_1_5->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_1_5/RedfishEthernetInterface_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_1_5/RedfishEthernetInterface_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..3fdf58c6cd2 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_1_5/RedfishEthernetInterface_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_1_5_Dxe + FILE_GUID = 8813d693-5c99-4052-9bc7-0b3abf5218c9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_1_6/EthernetInterface_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_1_6/EthernetInterface_V1_1_6_Dxe.c new file mode 100644 index 00000000000..1a2ef0619b0 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_1_6/EthernetInterface_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "1", + "6" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_1_6 *EthernetInterfaceV1_1_6; + EFI_REDFISH_ETHERNETINTERFACE_V1_1_6_CS *EthernetInterfaceV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_1_6_To_CS (ResoruceRaw, &EthernetInterfaceV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_1_6 = (EFI_REDFISH_ETHERNETINTERFACE_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_1_6)); + if (EthernetInterfaceV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_1_6; + EthernetInterfaceV1_1_6->EthernetInterface = EthernetInterfaceV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_1_6_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_1_6 *EthernetInterfaceV1_1_6; + + EthernetInterfaceV1_1_6 = (EFI_REDFISH_ETHERNETINTERFACE_V1_1_6 *)InterpProp; + DestroyEthernetInterface_V1_1_6_CS (EthernetInterfaceV1_1_6->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_1_6/RedfishEthernetInterface_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_1_6/RedfishEthernetInterface_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..e7535f115f7 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_1_6/RedfishEthernetInterface_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_1_6_Dxe + FILE_GUID = 724beafe-90e1-49b2-8314-efa9f5ff828e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_1_7/EthernetInterface_V1_1_7_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_1_7/EthernetInterface_V1_1_7_Dxe.c new file mode 100644 index 00000000000..8d72ba7b80e --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_1_7/EthernetInterface_V1_1_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_1_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "1", + "7" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_1_7 *EthernetInterfaceV1_1_7; + EFI_REDFISH_ETHERNETINTERFACE_V1_1_7_CS *EthernetInterfaceV1_1_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_1_7_To_CS (ResoruceRaw, &EthernetInterfaceV1_1_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_1_7 = (EFI_REDFISH_ETHERNETINTERFACE_V1_1_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_1_7)); + if (EthernetInterfaceV1_1_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_1_7; + EthernetInterfaceV1_1_7->EthernetInterface = EthernetInterfaceV1_1_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_1_7_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_1_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_1_7 *EthernetInterfaceV1_1_7; + + EthernetInterfaceV1_1_7 = (EFI_REDFISH_ETHERNETINTERFACE_V1_1_7 *)InterpProp; + DestroyEthernetInterface_V1_1_7_CS (EthernetInterfaceV1_1_7->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_1_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_1_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_1_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_1_7/RedfishEthernetInterface_V1_1_7_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_1_7/RedfishEthernetInterface_V1_1_7_Dxe.inf new file mode 100644 index 00000000000..0a46b16af6d --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_1_7/RedfishEthernetInterface_V1_1_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_1_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_1_7_Dxe + FILE_GUID = 29714993-34ec-4c93-816d-7d9bdb1035ae + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_1_7EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_1_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_1_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_1_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_1_8/EthernetInterface_V1_1_8_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_1_8/EthernetInterface_V1_1_8_Dxe.c new file mode 100644 index 00000000000..8cb91ed3263 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_1_8/EthernetInterface_V1_1_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_1_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "1", + "8" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_1_8 *EthernetInterfaceV1_1_8; + EFI_REDFISH_ETHERNETINTERFACE_V1_1_8_CS *EthernetInterfaceV1_1_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_1_8_To_CS (ResoruceRaw, &EthernetInterfaceV1_1_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_1_8 = (EFI_REDFISH_ETHERNETINTERFACE_V1_1_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_1_8)); + if (EthernetInterfaceV1_1_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_1_8; + EthernetInterfaceV1_1_8->EthernetInterface = EthernetInterfaceV1_1_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_1_8_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_1_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_1_8 *EthernetInterfaceV1_1_8; + + EthernetInterfaceV1_1_8 = (EFI_REDFISH_ETHERNETINTERFACE_V1_1_8 *)InterpProp; + DestroyEthernetInterface_V1_1_8_CS (EthernetInterfaceV1_1_8->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_1_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_1_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_1_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_1_8/RedfishEthernetInterface_V1_1_8_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_1_8/RedfishEthernetInterface_V1_1_8_Dxe.inf new file mode 100644 index 00000000000..fdc73843fea --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_1_8/RedfishEthernetInterface_V1_1_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_1_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_1_8_Dxe + FILE_GUID = f92fc2db-a2ab-4715-8924-a9eb35f55576 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_1_8EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_1_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_1_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_1_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_1_9/EthernetInterface_V1_1_9_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_1_9/EthernetInterface_V1_1_9_Dxe.c new file mode 100644 index 00000000000..c6b14cfd99e --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_1_9/EthernetInterface_V1_1_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_1_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "1", + "9" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_1_9 *EthernetInterfaceV1_1_9; + EFI_REDFISH_ETHERNETINTERFACE_V1_1_9_CS *EthernetInterfaceV1_1_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_1_9_To_CS (ResoruceRaw, &EthernetInterfaceV1_1_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_1_9 = (EFI_REDFISH_ETHERNETINTERFACE_V1_1_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_1_9)); + if (EthernetInterfaceV1_1_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_1_9; + EthernetInterfaceV1_1_9->EthernetInterface = EthernetInterfaceV1_1_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_1_9_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_1_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_1_9 *EthernetInterfaceV1_1_9; + + EthernetInterfaceV1_1_9 = (EFI_REDFISH_ETHERNETINTERFACE_V1_1_9 *)InterpProp; + DestroyEthernetInterface_V1_1_9_CS (EthernetInterfaceV1_1_9->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_1_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_1_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_1_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_1_9/RedfishEthernetInterface_V1_1_9_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_1_9/RedfishEthernetInterface_V1_1_9_Dxe.inf new file mode 100644 index 00000000000..89d214c6b24 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_1_9/RedfishEthernetInterface_V1_1_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_1_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_1_9_Dxe + FILE_GUID = 80773873-83ac-4850-ad87-3618394593c1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_1_9EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_1_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_1_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_1_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_2_0/EthernetInterface_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_2_0/EthernetInterface_V1_2_0_Dxe.c new file mode 100644 index 00000000000..b20540ff1d3 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_2_0/EthernetInterface_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "2", + "0" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_2_0 *EthernetInterfaceV1_2_0; + EFI_REDFISH_ETHERNETINTERFACE_V1_2_0_CS *EthernetInterfaceV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_2_0_To_CS (ResoruceRaw, &EthernetInterfaceV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_2_0 = (EFI_REDFISH_ETHERNETINTERFACE_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_2_0)); + if (EthernetInterfaceV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_2_0; + EthernetInterfaceV1_2_0->EthernetInterface = EthernetInterfaceV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_2_0_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_2_0 *EthernetInterfaceV1_2_0; + + EthernetInterfaceV1_2_0 = (EFI_REDFISH_ETHERNETINTERFACE_V1_2_0 *)InterpProp; + DestroyEthernetInterface_V1_2_0_CS (EthernetInterfaceV1_2_0->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_2_0/RedfishEthernetInterface_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_2_0/RedfishEthernetInterface_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..768651c42c9 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_2_0/RedfishEthernetInterface_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_2_0_Dxe + FILE_GUID = a6ec758c-7952-468b-a4e2-a22f130dd641 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_2_1/EthernetInterface_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_2_1/EthernetInterface_V1_2_1_Dxe.c new file mode 100644 index 00000000000..50e903ceaaa --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_2_1/EthernetInterface_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "2", + "1" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_2_1 *EthernetInterfaceV1_2_1; + EFI_REDFISH_ETHERNETINTERFACE_V1_2_1_CS *EthernetInterfaceV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_2_1_To_CS (ResoruceRaw, &EthernetInterfaceV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_2_1 = (EFI_REDFISH_ETHERNETINTERFACE_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_2_1)); + if (EthernetInterfaceV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_2_1; + EthernetInterfaceV1_2_1->EthernetInterface = EthernetInterfaceV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_2_1_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_2_1 *EthernetInterfaceV1_2_1; + + EthernetInterfaceV1_2_1 = (EFI_REDFISH_ETHERNETINTERFACE_V1_2_1 *)InterpProp; + DestroyEthernetInterface_V1_2_1_CS (EthernetInterfaceV1_2_1->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_2_1/RedfishEthernetInterface_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_2_1/RedfishEthernetInterface_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..acae0d04708 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_2_1/RedfishEthernetInterface_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_2_1_Dxe + FILE_GUID = 2d3238ba-ed2d-4c53-916a-99c4b888aaba + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_2_2/EthernetInterface_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_2_2/EthernetInterface_V1_2_2_Dxe.c new file mode 100644 index 00000000000..fda7026fbf6 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_2_2/EthernetInterface_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "2", + "2" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_2_2 *EthernetInterfaceV1_2_2; + EFI_REDFISH_ETHERNETINTERFACE_V1_2_2_CS *EthernetInterfaceV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_2_2_To_CS (ResoruceRaw, &EthernetInterfaceV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_2_2 = (EFI_REDFISH_ETHERNETINTERFACE_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_2_2)); + if (EthernetInterfaceV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_2_2; + EthernetInterfaceV1_2_2->EthernetInterface = EthernetInterfaceV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_2_2_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_2_2 *EthernetInterfaceV1_2_2; + + EthernetInterfaceV1_2_2 = (EFI_REDFISH_ETHERNETINTERFACE_V1_2_2 *)InterpProp; + DestroyEthernetInterface_V1_2_2_CS (EthernetInterfaceV1_2_2->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_2_2/RedfishEthernetInterface_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_2_2/RedfishEthernetInterface_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..c480948057e --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_2_2/RedfishEthernetInterface_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_2_2_Dxe + FILE_GUID = d5673c11-2705-4cb2-880b-0d5bbb0dbcdd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_2_3/EthernetInterface_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_2_3/EthernetInterface_V1_2_3_Dxe.c new file mode 100644 index 00000000000..24283bf1f06 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_2_3/EthernetInterface_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "2", + "3" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_2_3 *EthernetInterfaceV1_2_3; + EFI_REDFISH_ETHERNETINTERFACE_V1_2_3_CS *EthernetInterfaceV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_2_3_To_CS (ResoruceRaw, &EthernetInterfaceV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_2_3 = (EFI_REDFISH_ETHERNETINTERFACE_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_2_3)); + if (EthernetInterfaceV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_2_3; + EthernetInterfaceV1_2_3->EthernetInterface = EthernetInterfaceV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_2_3_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_2_3 *EthernetInterfaceV1_2_3; + + EthernetInterfaceV1_2_3 = (EFI_REDFISH_ETHERNETINTERFACE_V1_2_3 *)InterpProp; + DestroyEthernetInterface_V1_2_3_CS (EthernetInterfaceV1_2_3->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_2_3/RedfishEthernetInterface_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_2_3/RedfishEthernetInterface_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..c8463fae1b9 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_2_3/RedfishEthernetInterface_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_2_3_Dxe + FILE_GUID = 0bd83b5f-1a7d-4edb-8739-0ca98b9baffc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_2_4/EthernetInterface_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_2_4/EthernetInterface_V1_2_4_Dxe.c new file mode 100644 index 00000000000..0f2aba28076 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_2_4/EthernetInterface_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "2", + "4" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_2_4 *EthernetInterfaceV1_2_4; + EFI_REDFISH_ETHERNETINTERFACE_V1_2_4_CS *EthernetInterfaceV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_2_4_To_CS (ResoruceRaw, &EthernetInterfaceV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_2_4 = (EFI_REDFISH_ETHERNETINTERFACE_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_2_4)); + if (EthernetInterfaceV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_2_4; + EthernetInterfaceV1_2_4->EthernetInterface = EthernetInterfaceV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_2_4_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_2_4 *EthernetInterfaceV1_2_4; + + EthernetInterfaceV1_2_4 = (EFI_REDFISH_ETHERNETINTERFACE_V1_2_4 *)InterpProp; + DestroyEthernetInterface_V1_2_4_CS (EthernetInterfaceV1_2_4->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_2_4/RedfishEthernetInterface_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_2_4/RedfishEthernetInterface_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..f0158a039c6 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_2_4/RedfishEthernetInterface_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_2_4_Dxe + FILE_GUID = a19f6a50-0317-4796-b913-9c9ff85cdc83 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_2_5/EthernetInterface_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_2_5/EthernetInterface_V1_2_5_Dxe.c new file mode 100644 index 00000000000..d68ba804655 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_2_5/EthernetInterface_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "2", + "5" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_2_5 *EthernetInterfaceV1_2_5; + EFI_REDFISH_ETHERNETINTERFACE_V1_2_5_CS *EthernetInterfaceV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_2_5_To_CS (ResoruceRaw, &EthernetInterfaceV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_2_5 = (EFI_REDFISH_ETHERNETINTERFACE_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_2_5)); + if (EthernetInterfaceV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_2_5; + EthernetInterfaceV1_2_5->EthernetInterface = EthernetInterfaceV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_2_5_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_2_5 *EthernetInterfaceV1_2_5; + + EthernetInterfaceV1_2_5 = (EFI_REDFISH_ETHERNETINTERFACE_V1_2_5 *)InterpProp; + DestroyEthernetInterface_V1_2_5_CS (EthernetInterfaceV1_2_5->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_2_5/RedfishEthernetInterface_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_2_5/RedfishEthernetInterface_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..9fbfe3dac59 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_2_5/RedfishEthernetInterface_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_2_5_Dxe + FILE_GUID = 537bdfb1-6e2f-4b6a-a0b2-856c785515a8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_2_6/EthernetInterface_V1_2_6_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_2_6/EthernetInterface_V1_2_6_Dxe.c new file mode 100644 index 00000000000..d5dd3a90eaa --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_2_6/EthernetInterface_V1_2_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_2_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "2", + "6" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_2_6 *EthernetInterfaceV1_2_6; + EFI_REDFISH_ETHERNETINTERFACE_V1_2_6_CS *EthernetInterfaceV1_2_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_2_6_To_CS (ResoruceRaw, &EthernetInterfaceV1_2_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_2_6 = (EFI_REDFISH_ETHERNETINTERFACE_V1_2_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_2_6)); + if (EthernetInterfaceV1_2_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_2_6; + EthernetInterfaceV1_2_6->EthernetInterface = EthernetInterfaceV1_2_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_2_6_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_2_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_2_6 *EthernetInterfaceV1_2_6; + + EthernetInterfaceV1_2_6 = (EFI_REDFISH_ETHERNETINTERFACE_V1_2_6 *)InterpProp; + DestroyEthernetInterface_V1_2_6_CS (EthernetInterfaceV1_2_6->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_2_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_2_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_2_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_2_6/RedfishEthernetInterface_V1_2_6_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_2_6/RedfishEthernetInterface_V1_2_6_Dxe.inf new file mode 100644 index 00000000000..07fcd23f334 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_2_6/RedfishEthernetInterface_V1_2_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_2_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_2_6_Dxe + FILE_GUID = c6bd606f-378b-453a-a6aa-5a09c177e7b0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_2_6EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_2_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_2_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_2_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_2_7/EthernetInterface_V1_2_7_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_2_7/EthernetInterface_V1_2_7_Dxe.c new file mode 100644 index 00000000000..da3283f2072 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_2_7/EthernetInterface_V1_2_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_2_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "2", + "7" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_2_7 *EthernetInterfaceV1_2_7; + EFI_REDFISH_ETHERNETINTERFACE_V1_2_7_CS *EthernetInterfaceV1_2_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_2_7_To_CS (ResoruceRaw, &EthernetInterfaceV1_2_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_2_7 = (EFI_REDFISH_ETHERNETINTERFACE_V1_2_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_2_7)); + if (EthernetInterfaceV1_2_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_2_7; + EthernetInterfaceV1_2_7->EthernetInterface = EthernetInterfaceV1_2_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_2_7_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_2_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_2_7 *EthernetInterfaceV1_2_7; + + EthernetInterfaceV1_2_7 = (EFI_REDFISH_ETHERNETINTERFACE_V1_2_7 *)InterpProp; + DestroyEthernetInterface_V1_2_7_CS (EthernetInterfaceV1_2_7->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_2_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_2_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_2_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_2_7/RedfishEthernetInterface_V1_2_7_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_2_7/RedfishEthernetInterface_V1_2_7_Dxe.inf new file mode 100644 index 00000000000..efbe1d36b37 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_2_7/RedfishEthernetInterface_V1_2_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_2_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_2_7_Dxe + FILE_GUID = d071a869-7ae1-4361-9a05-d4ec28c4522d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_2_7EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_2_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_2_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_2_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_2_8/EthernetInterface_V1_2_8_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_2_8/EthernetInterface_V1_2_8_Dxe.c new file mode 100644 index 00000000000..6c3ebefdfb3 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_2_8/EthernetInterface_V1_2_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_2_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "2", + "8" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_2_8 *EthernetInterfaceV1_2_8; + EFI_REDFISH_ETHERNETINTERFACE_V1_2_8_CS *EthernetInterfaceV1_2_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_2_8_To_CS (ResoruceRaw, &EthernetInterfaceV1_2_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_2_8 = (EFI_REDFISH_ETHERNETINTERFACE_V1_2_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_2_8)); + if (EthernetInterfaceV1_2_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_2_8; + EthernetInterfaceV1_2_8->EthernetInterface = EthernetInterfaceV1_2_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_2_8_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_2_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_2_8 *EthernetInterfaceV1_2_8; + + EthernetInterfaceV1_2_8 = (EFI_REDFISH_ETHERNETINTERFACE_V1_2_8 *)InterpProp; + DestroyEthernetInterface_V1_2_8_CS (EthernetInterfaceV1_2_8->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_2_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_2_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_2_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_2_8/RedfishEthernetInterface_V1_2_8_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_2_8/RedfishEthernetInterface_V1_2_8_Dxe.inf new file mode 100644 index 00000000000..5ec106eeea9 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_2_8/RedfishEthernetInterface_V1_2_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_2_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_2_8_Dxe + FILE_GUID = 9bb80ec6-7157-4f0f-9ee7-af8e3e78e3bc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_2_8EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_2_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_2_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_2_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_2_9/EthernetInterface_V1_2_9_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_2_9/EthernetInterface_V1_2_9_Dxe.c new file mode 100644 index 00000000000..389e0779270 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_2_9/EthernetInterface_V1_2_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_2_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_2_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "2", + "9" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_2_9 *EthernetInterfaceV1_2_9; + EFI_REDFISH_ETHERNETINTERFACE_V1_2_9_CS *EthernetInterfaceV1_2_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_2_9_To_CS (ResoruceRaw, &EthernetInterfaceV1_2_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_2_9 = (EFI_REDFISH_ETHERNETINTERFACE_V1_2_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_2_9)); + if (EthernetInterfaceV1_2_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_2_9; + EthernetInterfaceV1_2_9->EthernetInterface = EthernetInterfaceV1_2_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_2_9_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_2_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_2_9 *EthernetInterfaceV1_2_9; + + EthernetInterfaceV1_2_9 = (EFI_REDFISH_ETHERNETINTERFACE_V1_2_9 *)InterpProp; + DestroyEthernetInterface_V1_2_9_CS (EthernetInterfaceV1_2_9->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_2_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_2_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_2_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_2_9/RedfishEthernetInterface_V1_2_9_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_2_9/RedfishEthernetInterface_V1_2_9_Dxe.inf new file mode 100644 index 00000000000..235ad4e264b --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_2_9/RedfishEthernetInterface_V1_2_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_2_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_2_9_Dxe + FILE_GUID = 4798a21b-5a92-4886-ba52-ff7ded180ab3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_2_9EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_2_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_2_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_2_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_3_0/EthernetInterface_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_3_0/EthernetInterface_V1_3_0_Dxe.c new file mode 100644 index 00000000000..0ced65cfbde --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_3_0/EthernetInterface_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "3", + "0" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_3_0 *EthernetInterfaceV1_3_0; + EFI_REDFISH_ETHERNETINTERFACE_V1_3_0_CS *EthernetInterfaceV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_3_0_To_CS (ResoruceRaw, &EthernetInterfaceV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_3_0 = (EFI_REDFISH_ETHERNETINTERFACE_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_3_0)); + if (EthernetInterfaceV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_3_0; + EthernetInterfaceV1_3_0->EthernetInterface = EthernetInterfaceV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_3_0_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_3_0 *EthernetInterfaceV1_3_0; + + EthernetInterfaceV1_3_0 = (EFI_REDFISH_ETHERNETINTERFACE_V1_3_0 *)InterpProp; + DestroyEthernetInterface_V1_3_0_CS (EthernetInterfaceV1_3_0->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_3_0/RedfishEthernetInterface_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_3_0/RedfishEthernetInterface_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..7a4131eb8a7 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_3_0/RedfishEthernetInterface_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_3_0_Dxe + FILE_GUID = 14fc4fb4-d655-4a48-9aeb-525318fecb57 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_3_1/EthernetInterface_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_3_1/EthernetInterface_V1_3_1_Dxe.c new file mode 100644 index 00000000000..32b6ce43d99 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_3_1/EthernetInterface_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "3", + "1" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_3_1 *EthernetInterfaceV1_3_1; + EFI_REDFISH_ETHERNETINTERFACE_V1_3_1_CS *EthernetInterfaceV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_3_1_To_CS (ResoruceRaw, &EthernetInterfaceV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_3_1 = (EFI_REDFISH_ETHERNETINTERFACE_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_3_1)); + if (EthernetInterfaceV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_3_1; + EthernetInterfaceV1_3_1->EthernetInterface = EthernetInterfaceV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_3_1_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_3_1 *EthernetInterfaceV1_3_1; + + EthernetInterfaceV1_3_1 = (EFI_REDFISH_ETHERNETINTERFACE_V1_3_1 *)InterpProp; + DestroyEthernetInterface_V1_3_1_CS (EthernetInterfaceV1_3_1->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_3_1/RedfishEthernetInterface_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_3_1/RedfishEthernetInterface_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..e50f1debb45 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_3_1/RedfishEthernetInterface_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_3_1_Dxe + FILE_GUID = 7bf6365f-d445-43b7-bdb6-d2550a4d1b7d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_3_2/EthernetInterface_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_3_2/EthernetInterface_V1_3_2_Dxe.c new file mode 100644 index 00000000000..c8e391a6910 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_3_2/EthernetInterface_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "3", + "2" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_3_2 *EthernetInterfaceV1_3_2; + EFI_REDFISH_ETHERNETINTERFACE_V1_3_2_CS *EthernetInterfaceV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_3_2_To_CS (ResoruceRaw, &EthernetInterfaceV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_3_2 = (EFI_REDFISH_ETHERNETINTERFACE_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_3_2)); + if (EthernetInterfaceV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_3_2; + EthernetInterfaceV1_3_2->EthernetInterface = EthernetInterfaceV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_3_2_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_3_2 *EthernetInterfaceV1_3_2; + + EthernetInterfaceV1_3_2 = (EFI_REDFISH_ETHERNETINTERFACE_V1_3_2 *)InterpProp; + DestroyEthernetInterface_V1_3_2_CS (EthernetInterfaceV1_3_2->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_3_2/RedfishEthernetInterface_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_3_2/RedfishEthernetInterface_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..f5e707d38c7 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_3_2/RedfishEthernetInterface_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_3_2_Dxe + FILE_GUID = ecf7dbf5-9ee6-4d39-b555-8bb6b619426e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_3_3/EthernetInterface_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_3_3/EthernetInterface_V1_3_3_Dxe.c new file mode 100644 index 00000000000..cd9084abf49 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_3_3/EthernetInterface_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "3", + "3" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_3_3 *EthernetInterfaceV1_3_3; + EFI_REDFISH_ETHERNETINTERFACE_V1_3_3_CS *EthernetInterfaceV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_3_3_To_CS (ResoruceRaw, &EthernetInterfaceV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_3_3 = (EFI_REDFISH_ETHERNETINTERFACE_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_3_3)); + if (EthernetInterfaceV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_3_3; + EthernetInterfaceV1_3_3->EthernetInterface = EthernetInterfaceV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_3_3_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_3_3 *EthernetInterfaceV1_3_3; + + EthernetInterfaceV1_3_3 = (EFI_REDFISH_ETHERNETINTERFACE_V1_3_3 *)InterpProp; + DestroyEthernetInterface_V1_3_3_CS (EthernetInterfaceV1_3_3->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_3_3/RedfishEthernetInterface_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_3_3/RedfishEthernetInterface_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..1dd3f967907 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_3_3/RedfishEthernetInterface_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_3_3_Dxe + FILE_GUID = 09af6d5d-df2f-4b81-8f53-abfc05f2900a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_3_4/EthernetInterface_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_3_4/EthernetInterface_V1_3_4_Dxe.c new file mode 100644 index 00000000000..8aee6408bf6 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_3_4/EthernetInterface_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "3", + "4" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_3_4 *EthernetInterfaceV1_3_4; + EFI_REDFISH_ETHERNETINTERFACE_V1_3_4_CS *EthernetInterfaceV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_3_4_To_CS (ResoruceRaw, &EthernetInterfaceV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_3_4 = (EFI_REDFISH_ETHERNETINTERFACE_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_3_4)); + if (EthernetInterfaceV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_3_4; + EthernetInterfaceV1_3_4->EthernetInterface = EthernetInterfaceV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_3_4_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_3_4 *EthernetInterfaceV1_3_4; + + EthernetInterfaceV1_3_4 = (EFI_REDFISH_ETHERNETINTERFACE_V1_3_4 *)InterpProp; + DestroyEthernetInterface_V1_3_4_CS (EthernetInterfaceV1_3_4->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_3_4/RedfishEthernetInterface_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_3_4/RedfishEthernetInterface_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..b12ba7f3712 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_3_4/RedfishEthernetInterface_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_3_4_Dxe + FILE_GUID = b075c439-240b-42af-b1ac-9c29732ce146 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_3_5/EthernetInterface_V1_3_5_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_3_5/EthernetInterface_V1_3_5_Dxe.c new file mode 100644 index 00000000000..bad04a78041 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_3_5/EthernetInterface_V1_3_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_3_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "3", + "5" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_3_5 *EthernetInterfaceV1_3_5; + EFI_REDFISH_ETHERNETINTERFACE_V1_3_5_CS *EthernetInterfaceV1_3_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_3_5_To_CS (ResoruceRaw, &EthernetInterfaceV1_3_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_3_5 = (EFI_REDFISH_ETHERNETINTERFACE_V1_3_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_3_5)); + if (EthernetInterfaceV1_3_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_3_5; + EthernetInterfaceV1_3_5->EthernetInterface = EthernetInterfaceV1_3_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_3_5_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_3_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_3_5 *EthernetInterfaceV1_3_5; + + EthernetInterfaceV1_3_5 = (EFI_REDFISH_ETHERNETINTERFACE_V1_3_5 *)InterpProp; + DestroyEthernetInterface_V1_3_5_CS (EthernetInterfaceV1_3_5->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_3_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_3_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_3_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_3_5/RedfishEthernetInterface_V1_3_5_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_3_5/RedfishEthernetInterface_V1_3_5_Dxe.inf new file mode 100644 index 00000000000..3b55f1f5da4 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_3_5/RedfishEthernetInterface_V1_3_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_3_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_3_5_Dxe + FILE_GUID = 12725091-11ee-4fe5-b603-256f63be800d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_3_5EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_3_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_3_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_3_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_3_6/EthernetInterface_V1_3_6_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_3_6/EthernetInterface_V1_3_6_Dxe.c new file mode 100644 index 00000000000..520054a9bdd --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_3_6/EthernetInterface_V1_3_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_3_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "3", + "6" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_3_6 *EthernetInterfaceV1_3_6; + EFI_REDFISH_ETHERNETINTERFACE_V1_3_6_CS *EthernetInterfaceV1_3_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_3_6_To_CS (ResoruceRaw, &EthernetInterfaceV1_3_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_3_6 = (EFI_REDFISH_ETHERNETINTERFACE_V1_3_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_3_6)); + if (EthernetInterfaceV1_3_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_3_6; + EthernetInterfaceV1_3_6->EthernetInterface = EthernetInterfaceV1_3_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_3_6_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_3_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_3_6 *EthernetInterfaceV1_3_6; + + EthernetInterfaceV1_3_6 = (EFI_REDFISH_ETHERNETINTERFACE_V1_3_6 *)InterpProp; + DestroyEthernetInterface_V1_3_6_CS (EthernetInterfaceV1_3_6->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_3_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_3_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_3_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_3_6/RedfishEthernetInterface_V1_3_6_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_3_6/RedfishEthernetInterface_V1_3_6_Dxe.inf new file mode 100644 index 00000000000..6228261ebee --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_3_6/RedfishEthernetInterface_V1_3_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_3_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_3_6_Dxe + FILE_GUID = e11512de-e81b-4fd8-bc29-6f7b55bfa822 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_3_6EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_3_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_3_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_3_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_3_7/EthernetInterface_V1_3_7_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_3_7/EthernetInterface_V1_3_7_Dxe.c new file mode 100644 index 00000000000..548a3c3fadf --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_3_7/EthernetInterface_V1_3_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_3_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_3_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "3", + "7" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_3_7 *EthernetInterfaceV1_3_7; + EFI_REDFISH_ETHERNETINTERFACE_V1_3_7_CS *EthernetInterfaceV1_3_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_3_7_To_CS (ResoruceRaw, &EthernetInterfaceV1_3_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_3_7 = (EFI_REDFISH_ETHERNETINTERFACE_V1_3_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_3_7)); + if (EthernetInterfaceV1_3_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_3_7; + EthernetInterfaceV1_3_7->EthernetInterface = EthernetInterfaceV1_3_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_3_7_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_3_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_3_7 *EthernetInterfaceV1_3_7; + + EthernetInterfaceV1_3_7 = (EFI_REDFISH_ETHERNETINTERFACE_V1_3_7 *)InterpProp; + DestroyEthernetInterface_V1_3_7_CS (EthernetInterfaceV1_3_7->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_3_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_3_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_3_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_3_7/RedfishEthernetInterface_V1_3_7_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_3_7/RedfishEthernetInterface_V1_3_7_Dxe.inf new file mode 100644 index 00000000000..2eb4f89e019 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_3_7/RedfishEthernetInterface_V1_3_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_3_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_3_7_Dxe + FILE_GUID = 15e9b304-7750-4737-96c5-125ee5cdcc42 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_3_7EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_3_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_3_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_3_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_3_8/EthernetInterface_V1_3_8_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_3_8/EthernetInterface_V1_3_8_Dxe.c new file mode 100644 index 00000000000..8f19f629de8 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_3_8/EthernetInterface_V1_3_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_3_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_3_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "3", + "8" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_3_8 *EthernetInterfaceV1_3_8; + EFI_REDFISH_ETHERNETINTERFACE_V1_3_8_CS *EthernetInterfaceV1_3_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_3_8_To_CS (ResoruceRaw, &EthernetInterfaceV1_3_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_3_8 = (EFI_REDFISH_ETHERNETINTERFACE_V1_3_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_3_8)); + if (EthernetInterfaceV1_3_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_3_8; + EthernetInterfaceV1_3_8->EthernetInterface = EthernetInterfaceV1_3_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_3_8_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_3_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_3_8 *EthernetInterfaceV1_3_8; + + EthernetInterfaceV1_3_8 = (EFI_REDFISH_ETHERNETINTERFACE_V1_3_8 *)InterpProp; + DestroyEthernetInterface_V1_3_8_CS (EthernetInterfaceV1_3_8->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_3_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_3_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_3_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_3_8/RedfishEthernetInterface_V1_3_8_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_3_8/RedfishEthernetInterface_V1_3_8_Dxe.inf new file mode 100644 index 00000000000..a16231ecdfd --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_3_8/RedfishEthernetInterface_V1_3_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_3_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_3_8_Dxe + FILE_GUID = c8b4a9c3-3a90-4e8e-bf9f-9d143a2f9307 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_3_8EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_3_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_3_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_3_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_4_0/EthernetInterface_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_4_0/EthernetInterface_V1_4_0_Dxe.c new file mode 100644 index 00000000000..773622c1312 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_4_0/EthernetInterface_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "4", + "0" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_4_0 *EthernetInterfaceV1_4_0; + EFI_REDFISH_ETHERNETINTERFACE_V1_4_0_CS *EthernetInterfaceV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_4_0_To_CS (ResoruceRaw, &EthernetInterfaceV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_4_0 = (EFI_REDFISH_ETHERNETINTERFACE_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_4_0)); + if (EthernetInterfaceV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_4_0; + EthernetInterfaceV1_4_0->EthernetInterface = EthernetInterfaceV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_4_0_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_4_0 *EthernetInterfaceV1_4_0; + + EthernetInterfaceV1_4_0 = (EFI_REDFISH_ETHERNETINTERFACE_V1_4_0 *)InterpProp; + DestroyEthernetInterface_V1_4_0_CS (EthernetInterfaceV1_4_0->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_4_0/RedfishEthernetInterface_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_4_0/RedfishEthernetInterface_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..798045a4eac --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_4_0/RedfishEthernetInterface_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_4_0_Dxe + FILE_GUID = 7371d8f8-9111-4660-bdd6-2a334d7eaf56 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_4_1/EthernetInterface_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_4_1/EthernetInterface_V1_4_1_Dxe.c new file mode 100644 index 00000000000..1b8dcd542b8 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_4_1/EthernetInterface_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "4", + "1" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_4_1 *EthernetInterfaceV1_4_1; + EFI_REDFISH_ETHERNETINTERFACE_V1_4_1_CS *EthernetInterfaceV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_4_1_To_CS (ResoruceRaw, &EthernetInterfaceV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_4_1 = (EFI_REDFISH_ETHERNETINTERFACE_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_4_1)); + if (EthernetInterfaceV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_4_1; + EthernetInterfaceV1_4_1->EthernetInterface = EthernetInterfaceV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_4_1_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_4_1 *EthernetInterfaceV1_4_1; + + EthernetInterfaceV1_4_1 = (EFI_REDFISH_ETHERNETINTERFACE_V1_4_1 *)InterpProp; + DestroyEthernetInterface_V1_4_1_CS (EthernetInterfaceV1_4_1->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_4_1/RedfishEthernetInterface_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_4_1/RedfishEthernetInterface_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..b39b2939dcf --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_4_1/RedfishEthernetInterface_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_4_1_Dxe + FILE_GUID = f6faf8ed-f177-4026-8eea-32752a9d961b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_4_2/EthernetInterface_V1_4_2_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_4_2/EthernetInterface_V1_4_2_Dxe.c new file mode 100644 index 00000000000..9720d2743f9 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_4_2/EthernetInterface_V1_4_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_4_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "4", + "2" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_4_2 *EthernetInterfaceV1_4_2; + EFI_REDFISH_ETHERNETINTERFACE_V1_4_2_CS *EthernetInterfaceV1_4_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_4_2_To_CS (ResoruceRaw, &EthernetInterfaceV1_4_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_4_2 = (EFI_REDFISH_ETHERNETINTERFACE_V1_4_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_4_2)); + if (EthernetInterfaceV1_4_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_4_2; + EthernetInterfaceV1_4_2->EthernetInterface = EthernetInterfaceV1_4_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_4_2_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_4_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_4_2 *EthernetInterfaceV1_4_2; + + EthernetInterfaceV1_4_2 = (EFI_REDFISH_ETHERNETINTERFACE_V1_4_2 *)InterpProp; + DestroyEthernetInterface_V1_4_2_CS (EthernetInterfaceV1_4_2->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_4_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_4_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_4_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_4_2/RedfishEthernetInterface_V1_4_2_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_4_2/RedfishEthernetInterface_V1_4_2_Dxe.inf new file mode 100644 index 00000000000..e5fac76fc4a --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_4_2/RedfishEthernetInterface_V1_4_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_4_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_4_2_Dxe + FILE_GUID = b3cbbe4b-072d-4e50-b435-107a452fcb1c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_4_2EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_4_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_4_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_4_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_4_3/EthernetInterface_V1_4_3_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_4_3/EthernetInterface_V1_4_3_Dxe.c new file mode 100644 index 00000000000..46fca979337 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_4_3/EthernetInterface_V1_4_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_4_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "4", + "3" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_4_3 *EthernetInterfaceV1_4_3; + EFI_REDFISH_ETHERNETINTERFACE_V1_4_3_CS *EthernetInterfaceV1_4_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_4_3_To_CS (ResoruceRaw, &EthernetInterfaceV1_4_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_4_3 = (EFI_REDFISH_ETHERNETINTERFACE_V1_4_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_4_3)); + if (EthernetInterfaceV1_4_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_4_3; + EthernetInterfaceV1_4_3->EthernetInterface = EthernetInterfaceV1_4_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_4_3_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_4_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_4_3 *EthernetInterfaceV1_4_3; + + EthernetInterfaceV1_4_3 = (EFI_REDFISH_ETHERNETINTERFACE_V1_4_3 *)InterpProp; + DestroyEthernetInterface_V1_4_3_CS (EthernetInterfaceV1_4_3->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_4_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_4_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_4_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_4_3/RedfishEthernetInterface_V1_4_3_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_4_3/RedfishEthernetInterface_V1_4_3_Dxe.inf new file mode 100644 index 00000000000..8f5c731ab28 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_4_3/RedfishEthernetInterface_V1_4_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_4_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_4_3_Dxe + FILE_GUID = 4cc79fa9-ce81-449b-a779-4214309328a3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_4_3EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_4_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_4_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_4_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_4_4/EthernetInterface_V1_4_4_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_4_4/EthernetInterface_V1_4_4_Dxe.c new file mode 100644 index 00000000000..48d8e2970c0 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_4_4/EthernetInterface_V1_4_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_4_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "4", + "4" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_4_4 *EthernetInterfaceV1_4_4; + EFI_REDFISH_ETHERNETINTERFACE_V1_4_4_CS *EthernetInterfaceV1_4_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_4_4_To_CS (ResoruceRaw, &EthernetInterfaceV1_4_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_4_4 = (EFI_REDFISH_ETHERNETINTERFACE_V1_4_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_4_4)); + if (EthernetInterfaceV1_4_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_4_4; + EthernetInterfaceV1_4_4->EthernetInterface = EthernetInterfaceV1_4_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_4_4_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_4_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_4_4 *EthernetInterfaceV1_4_4; + + EthernetInterfaceV1_4_4 = (EFI_REDFISH_ETHERNETINTERFACE_V1_4_4 *)InterpProp; + DestroyEthernetInterface_V1_4_4_CS (EthernetInterfaceV1_4_4->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_4_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_4_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_4_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_4_4/RedfishEthernetInterface_V1_4_4_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_4_4/RedfishEthernetInterface_V1_4_4_Dxe.inf new file mode 100644 index 00000000000..3f45a139cce --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_4_4/RedfishEthernetInterface_V1_4_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_4_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_4_4_Dxe + FILE_GUID = c2242332-4264-41ad-905a-b3e63a25d60d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_4_4EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_4_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_4_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_4_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_4_5/EthernetInterface_V1_4_5_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_4_5/EthernetInterface_V1_4_5_Dxe.c new file mode 100644 index 00000000000..53cd1796daa --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_4_5/EthernetInterface_V1_4_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_4_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "4", + "5" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_4_5 *EthernetInterfaceV1_4_5; + EFI_REDFISH_ETHERNETINTERFACE_V1_4_5_CS *EthernetInterfaceV1_4_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_4_5_To_CS (ResoruceRaw, &EthernetInterfaceV1_4_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_4_5 = (EFI_REDFISH_ETHERNETINTERFACE_V1_4_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_4_5)); + if (EthernetInterfaceV1_4_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_4_5; + EthernetInterfaceV1_4_5->EthernetInterface = EthernetInterfaceV1_4_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_4_5_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_4_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_4_5 *EthernetInterfaceV1_4_5; + + EthernetInterfaceV1_4_5 = (EFI_REDFISH_ETHERNETINTERFACE_V1_4_5 *)InterpProp; + DestroyEthernetInterface_V1_4_5_CS (EthernetInterfaceV1_4_5->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_4_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_4_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_4_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_4_5/RedfishEthernetInterface_V1_4_5_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_4_5/RedfishEthernetInterface_V1_4_5_Dxe.inf new file mode 100644 index 00000000000..41c5cd32ebe --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_4_5/RedfishEthernetInterface_V1_4_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_4_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_4_5_Dxe + FILE_GUID = 54fee217-41c0-4a6c-b86d-4e6c6675d8a7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_4_5EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_4_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_4_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_4_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_4_6/EthernetInterface_V1_4_6_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_4_6/EthernetInterface_V1_4_6_Dxe.c new file mode 100644 index 00000000000..9f4b864dce2 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_4_6/EthernetInterface_V1_4_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_4_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_4_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "4", + "6" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_4_6 *EthernetInterfaceV1_4_6; + EFI_REDFISH_ETHERNETINTERFACE_V1_4_6_CS *EthernetInterfaceV1_4_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_4_6_To_CS (ResoruceRaw, &EthernetInterfaceV1_4_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_4_6 = (EFI_REDFISH_ETHERNETINTERFACE_V1_4_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_4_6)); + if (EthernetInterfaceV1_4_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_4_6; + EthernetInterfaceV1_4_6->EthernetInterface = EthernetInterfaceV1_4_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_4_6_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_4_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_4_6 *EthernetInterfaceV1_4_6; + + EthernetInterfaceV1_4_6 = (EFI_REDFISH_ETHERNETINTERFACE_V1_4_6 *)InterpProp; + DestroyEthernetInterface_V1_4_6_CS (EthernetInterfaceV1_4_6->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_4_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_4_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_4_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_4_6/RedfishEthernetInterface_V1_4_6_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_4_6/RedfishEthernetInterface_V1_4_6_Dxe.inf new file mode 100644 index 00000000000..8441a9dd60a --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_4_6/RedfishEthernetInterface_V1_4_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_4_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_4_6_Dxe + FILE_GUID = 2eecfd74-22ed-4733-9553-0b7946393ca7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_4_6EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_4_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_4_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_4_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_4_7/EthernetInterface_V1_4_7_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_4_7/EthernetInterface_V1_4_7_Dxe.c new file mode 100644 index 00000000000..e687107ff4e --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_4_7/EthernetInterface_V1_4_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_4_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_4_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "4", + "7" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_4_7 *EthernetInterfaceV1_4_7; + EFI_REDFISH_ETHERNETINTERFACE_V1_4_7_CS *EthernetInterfaceV1_4_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_4_7_To_CS (ResoruceRaw, &EthernetInterfaceV1_4_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_4_7 = (EFI_REDFISH_ETHERNETINTERFACE_V1_4_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_4_7)); + if (EthernetInterfaceV1_4_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_4_7; + EthernetInterfaceV1_4_7->EthernetInterface = EthernetInterfaceV1_4_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_4_7_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_4_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_4_7 *EthernetInterfaceV1_4_7; + + EthernetInterfaceV1_4_7 = (EFI_REDFISH_ETHERNETINTERFACE_V1_4_7 *)InterpProp; + DestroyEthernetInterface_V1_4_7_CS (EthernetInterfaceV1_4_7->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_4_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_4_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_4_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_4_7/RedfishEthernetInterface_V1_4_7_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_4_7/RedfishEthernetInterface_V1_4_7_Dxe.inf new file mode 100644 index 00000000000..540ea4a08e1 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_4_7/RedfishEthernetInterface_V1_4_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_4_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_4_7_Dxe + FILE_GUID = 3ed1385f-962a-4d0a-8d58-4d4133303089 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_4_7EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_4_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_4_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_4_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_5_0/EthernetInterface_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_5_0/EthernetInterface_V1_5_0_Dxe.c new file mode 100644 index 00000000000..deff7ca6065 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_5_0/EthernetInterface_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "5", + "0" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_5_0 *EthernetInterfaceV1_5_0; + EFI_REDFISH_ETHERNETINTERFACE_V1_5_0_CS *EthernetInterfaceV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_5_0_To_CS (ResoruceRaw, &EthernetInterfaceV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_5_0 = (EFI_REDFISH_ETHERNETINTERFACE_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_5_0)); + if (EthernetInterfaceV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_5_0; + EthernetInterfaceV1_5_0->EthernetInterface = EthernetInterfaceV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_5_0_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_5_0 *EthernetInterfaceV1_5_0; + + EthernetInterfaceV1_5_0 = (EFI_REDFISH_ETHERNETINTERFACE_V1_5_0 *)InterpProp; + DestroyEthernetInterface_V1_5_0_CS (EthernetInterfaceV1_5_0->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_5_0/RedfishEthernetInterface_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_5_0/RedfishEthernetInterface_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..3c0a572f3a4 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_5_0/RedfishEthernetInterface_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_5_0_Dxe + FILE_GUID = 9f5e96f0-e84a-4688-9a4a-23668f2d270d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_5_1/EthernetInterface_V1_5_1_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_5_1/EthernetInterface_V1_5_1_Dxe.c new file mode 100644 index 00000000000..954cd7198a8 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_5_1/EthernetInterface_V1_5_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_5_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "5", + "1" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_5_1 *EthernetInterfaceV1_5_1; + EFI_REDFISH_ETHERNETINTERFACE_V1_5_1_CS *EthernetInterfaceV1_5_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_5_1_To_CS (ResoruceRaw, &EthernetInterfaceV1_5_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_5_1 = (EFI_REDFISH_ETHERNETINTERFACE_V1_5_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_5_1)); + if (EthernetInterfaceV1_5_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_5_1; + EthernetInterfaceV1_5_1->EthernetInterface = EthernetInterfaceV1_5_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_5_1_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_5_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_5_1 *EthernetInterfaceV1_5_1; + + EthernetInterfaceV1_5_1 = (EFI_REDFISH_ETHERNETINTERFACE_V1_5_1 *)InterpProp; + DestroyEthernetInterface_V1_5_1_CS (EthernetInterfaceV1_5_1->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_5_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_5_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_5_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_5_1/RedfishEthernetInterface_V1_5_1_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_5_1/RedfishEthernetInterface_V1_5_1_Dxe.inf new file mode 100644 index 00000000000..4aad158d870 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_5_1/RedfishEthernetInterface_V1_5_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_5_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_5_1_Dxe + FILE_GUID = c6358f42-e92e-44ee-9062-45b0f600082a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_5_1EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_5_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_5_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_5_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_5_2/EthernetInterface_V1_5_2_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_5_2/EthernetInterface_V1_5_2_Dxe.c new file mode 100644 index 00000000000..70ad602d06e --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_5_2/EthernetInterface_V1_5_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_5_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "5", + "2" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_5_2 *EthernetInterfaceV1_5_2; + EFI_REDFISH_ETHERNETINTERFACE_V1_5_2_CS *EthernetInterfaceV1_5_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_5_2_To_CS (ResoruceRaw, &EthernetInterfaceV1_5_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_5_2 = (EFI_REDFISH_ETHERNETINTERFACE_V1_5_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_5_2)); + if (EthernetInterfaceV1_5_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_5_2; + EthernetInterfaceV1_5_2->EthernetInterface = EthernetInterfaceV1_5_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_5_2_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_5_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_5_2 *EthernetInterfaceV1_5_2; + + EthernetInterfaceV1_5_2 = (EFI_REDFISH_ETHERNETINTERFACE_V1_5_2 *)InterpProp; + DestroyEthernetInterface_V1_5_2_CS (EthernetInterfaceV1_5_2->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_5_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_5_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_5_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_5_2/RedfishEthernetInterface_V1_5_2_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_5_2/RedfishEthernetInterface_V1_5_2_Dxe.inf new file mode 100644 index 00000000000..d4230116d9b --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_5_2/RedfishEthernetInterface_V1_5_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_5_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_5_2_Dxe + FILE_GUID = 241d5f10-6c08-4212-81c3-250b07e20a5f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_5_2EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_5_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_5_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_5_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_5_3/EthernetInterface_V1_5_3_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_5_3/EthernetInterface_V1_5_3_Dxe.c new file mode 100644 index 00000000000..5cd13f4ec84 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_5_3/EthernetInterface_V1_5_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_5_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "5", + "3" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_5_3 *EthernetInterfaceV1_5_3; + EFI_REDFISH_ETHERNETINTERFACE_V1_5_3_CS *EthernetInterfaceV1_5_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_5_3_To_CS (ResoruceRaw, &EthernetInterfaceV1_5_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_5_3 = (EFI_REDFISH_ETHERNETINTERFACE_V1_5_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_5_3)); + if (EthernetInterfaceV1_5_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_5_3; + EthernetInterfaceV1_5_3->EthernetInterface = EthernetInterfaceV1_5_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_5_3_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_5_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_5_3 *EthernetInterfaceV1_5_3; + + EthernetInterfaceV1_5_3 = (EFI_REDFISH_ETHERNETINTERFACE_V1_5_3 *)InterpProp; + DestroyEthernetInterface_V1_5_3_CS (EthernetInterfaceV1_5_3->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_5_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_5_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_5_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_5_3/RedfishEthernetInterface_V1_5_3_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_5_3/RedfishEthernetInterface_V1_5_3_Dxe.inf new file mode 100644 index 00000000000..4b4a6056dd1 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_5_3/RedfishEthernetInterface_V1_5_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_5_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_5_3_Dxe + FILE_GUID = 498089c9-7436-4c56-8ed1-d80b6b17fa95 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_5_3EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_5_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_5_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_5_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_5_4/EthernetInterface_V1_5_4_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_5_4/EthernetInterface_V1_5_4_Dxe.c new file mode 100644 index 00000000000..2abe96a3291 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_5_4/EthernetInterface_V1_5_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_5_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "5", + "4" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_5_4 *EthernetInterfaceV1_5_4; + EFI_REDFISH_ETHERNETINTERFACE_V1_5_4_CS *EthernetInterfaceV1_5_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_5_4_To_CS (ResoruceRaw, &EthernetInterfaceV1_5_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_5_4 = (EFI_REDFISH_ETHERNETINTERFACE_V1_5_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_5_4)); + if (EthernetInterfaceV1_5_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_5_4; + EthernetInterfaceV1_5_4->EthernetInterface = EthernetInterfaceV1_5_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_5_4_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_5_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_5_4 *EthernetInterfaceV1_5_4; + + EthernetInterfaceV1_5_4 = (EFI_REDFISH_ETHERNETINTERFACE_V1_5_4 *)InterpProp; + DestroyEthernetInterface_V1_5_4_CS (EthernetInterfaceV1_5_4->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_5_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_5_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_5_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_5_4/RedfishEthernetInterface_V1_5_4_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_5_4/RedfishEthernetInterface_V1_5_4_Dxe.inf new file mode 100644 index 00000000000..b4c460c8cb0 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_5_4/RedfishEthernetInterface_V1_5_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_5_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_5_4_Dxe + FILE_GUID = 30a67efc-1912-4c3d-b94f-5389b02fd799 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_5_4EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_5_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_5_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_5_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_5_5/EthernetInterface_V1_5_5_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_5_5/EthernetInterface_V1_5_5_Dxe.c new file mode 100644 index 00000000000..8fe62ffa2ad --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_5_5/EthernetInterface_V1_5_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_5_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_5_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "5", + "5" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_5_5 *EthernetInterfaceV1_5_5; + EFI_REDFISH_ETHERNETINTERFACE_V1_5_5_CS *EthernetInterfaceV1_5_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_5_5_To_CS (ResoruceRaw, &EthernetInterfaceV1_5_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_5_5 = (EFI_REDFISH_ETHERNETINTERFACE_V1_5_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_5_5)); + if (EthernetInterfaceV1_5_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_5_5; + EthernetInterfaceV1_5_5->EthernetInterface = EthernetInterfaceV1_5_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_5_5_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_5_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_5_5 *EthernetInterfaceV1_5_5; + + EthernetInterfaceV1_5_5 = (EFI_REDFISH_ETHERNETINTERFACE_V1_5_5 *)InterpProp; + DestroyEthernetInterface_V1_5_5_CS (EthernetInterfaceV1_5_5->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_5_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_5_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_5_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_5_5/RedfishEthernetInterface_V1_5_5_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_5_5/RedfishEthernetInterface_V1_5_5_Dxe.inf new file mode 100644 index 00000000000..3a8bbeb785a --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_5_5/RedfishEthernetInterface_V1_5_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_5_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_5_5_Dxe + FILE_GUID = d1074217-e461-436b-9668-4f9c7d065c88 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_5_5EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_5_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_5_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_5_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_6_0/EthernetInterface_V1_6_0_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_6_0/EthernetInterface_V1_6_0_Dxe.c new file mode 100644 index 00000000000..d687f4bbd39 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_6_0/EthernetInterface_V1_6_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_6_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "6", + "0" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_6_0 *EthernetInterfaceV1_6_0; + EFI_REDFISH_ETHERNETINTERFACE_V1_6_0_CS *EthernetInterfaceV1_6_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_6_0_To_CS (ResoruceRaw, &EthernetInterfaceV1_6_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_6_0 = (EFI_REDFISH_ETHERNETINTERFACE_V1_6_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_6_0)); + if (EthernetInterfaceV1_6_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_6_0; + EthernetInterfaceV1_6_0->EthernetInterface = EthernetInterfaceV1_6_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_6_0_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_6_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_6_0 *EthernetInterfaceV1_6_0; + + EthernetInterfaceV1_6_0 = (EFI_REDFISH_ETHERNETINTERFACE_V1_6_0 *)InterpProp; + DestroyEthernetInterface_V1_6_0_CS (EthernetInterfaceV1_6_0->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_6_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_6_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_6_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_6_0/RedfishEthernetInterface_V1_6_0_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_6_0/RedfishEthernetInterface_V1_6_0_Dxe.inf new file mode 100644 index 00000000000..194afdd738c --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_6_0/RedfishEthernetInterface_V1_6_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_6_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_6_0_Dxe + FILE_GUID = 0cc097d6-bd80-4d79-9ed5-9b807fc93e11 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_6_0EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_6_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_6_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_6_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_6_1/EthernetInterface_V1_6_1_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_6_1/EthernetInterface_V1_6_1_Dxe.c new file mode 100644 index 00000000000..f70a8ac596b --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_6_1/EthernetInterface_V1_6_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_6_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "6", + "1" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_6_1 *EthernetInterfaceV1_6_1; + EFI_REDFISH_ETHERNETINTERFACE_V1_6_1_CS *EthernetInterfaceV1_6_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_6_1_To_CS (ResoruceRaw, &EthernetInterfaceV1_6_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_6_1 = (EFI_REDFISH_ETHERNETINTERFACE_V1_6_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_6_1)); + if (EthernetInterfaceV1_6_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_6_1; + EthernetInterfaceV1_6_1->EthernetInterface = EthernetInterfaceV1_6_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_6_1_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_6_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_6_1 *EthernetInterfaceV1_6_1; + + EthernetInterfaceV1_6_1 = (EFI_REDFISH_ETHERNETINTERFACE_V1_6_1 *)InterpProp; + DestroyEthernetInterface_V1_6_1_CS (EthernetInterfaceV1_6_1->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_6_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_6_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_6_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_6_1/RedfishEthernetInterface_V1_6_1_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_6_1/RedfishEthernetInterface_V1_6_1_Dxe.inf new file mode 100644 index 00000000000..4ca8d22ca28 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_6_1/RedfishEthernetInterface_V1_6_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_6_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_6_1_Dxe + FILE_GUID = b8231836-f882-4b8e-a50e-84a32706c4cf + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_6_1EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_6_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_6_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_6_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_6_2/EthernetInterface_V1_6_2_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_6_2/EthernetInterface_V1_6_2_Dxe.c new file mode 100644 index 00000000000..599f17e8971 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_6_2/EthernetInterface_V1_6_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_6_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "6", + "2" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_6_2 *EthernetInterfaceV1_6_2; + EFI_REDFISH_ETHERNETINTERFACE_V1_6_2_CS *EthernetInterfaceV1_6_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_6_2_To_CS (ResoruceRaw, &EthernetInterfaceV1_6_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_6_2 = (EFI_REDFISH_ETHERNETINTERFACE_V1_6_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_6_2)); + if (EthernetInterfaceV1_6_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_6_2; + EthernetInterfaceV1_6_2->EthernetInterface = EthernetInterfaceV1_6_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_6_2_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_6_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_6_2 *EthernetInterfaceV1_6_2; + + EthernetInterfaceV1_6_2 = (EFI_REDFISH_ETHERNETINTERFACE_V1_6_2 *)InterpProp; + DestroyEthernetInterface_V1_6_2_CS (EthernetInterfaceV1_6_2->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_6_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_6_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_6_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_6_2/RedfishEthernetInterface_V1_6_2_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_6_2/RedfishEthernetInterface_V1_6_2_Dxe.inf new file mode 100644 index 00000000000..05204af1d89 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_6_2/RedfishEthernetInterface_V1_6_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_6_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_6_2_Dxe + FILE_GUID = a1d072e4-e08e-40c5-b1e2-d69bbad647e1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_6_2EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_6_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_6_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_6_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_6_3/EthernetInterface_V1_6_3_Dxe.c b/RedfishClientPkg/Converter/EthernetInterface/v1_6_3/EthernetInterface_V1_6_3_Dxe.c new file mode 100644 index 00000000000..a552f4222fe --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_6_3/EthernetInterface_V1_6_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterface.v1_6_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support EthernetInterface V1_6_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterface", + "1", + "6", + "3" + }, + "EthernetInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_6_3 *EthernetInterfaceV1_6_3; + EFI_REDFISH_ETHERNETINTERFACE_V1_6_3_CS *EthernetInterfaceV1_6_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterface_V1_6_3_To_CS (ResoruceRaw, &EthernetInterfaceV1_6_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceV1_6_3 = (EFI_REDFISH_ETHERNETINTERFACE_V1_6_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACE_V1_6_3)); + if (EthernetInterfaceV1_6_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceV1_6_3; + EthernetInterfaceV1_6_3->EthernetInterface = EthernetInterfaceV1_6_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterface"), "EthernetInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterface_V1_6_3_JSON (*((EFI_REDFISH_ETHERNETINTERFACE_V1_6_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACE_V1_6_3 *EthernetInterfaceV1_6_3; + + EthernetInterfaceV1_6_3 = (EFI_REDFISH_ETHERNETINTERFACE_V1_6_3 *)InterpProp; + DestroyEthernetInterface_V1_6_3_CS (EthernetInterfaceV1_6_3->EthernetInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterface_V1_6_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_6_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceToStructWrapper, + EthernetInterfaceToJson, + EthernetInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterface_V1_6_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterface/v1_6_3/RedfishEthernetInterface_V1_6_3_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterface/v1_6_3/RedfishEthernetInterface_V1_6_3_Dxe.inf new file mode 100644 index 00000000000..fa55eae414f --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterface/v1_6_3/RedfishEthernetInterface_V1_6_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterface.v1_6_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterface_V1_6_3_Dxe + FILE_GUID = 8fd8302b-3dd6-4110-aae0-c23c9455f0b6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterface_V1_6_3EntryPoint + UNLOAD_IMAGE = RedfishEthernetInterface_V1_6_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterface_V1_6_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceV1_6_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EthernetInterfaceCollection/EthernetInterfaceCollection_Dxe.c b/RedfishClientPkg/Converter/EthernetInterfaceCollection/EthernetInterfaceCollection_Dxe.c new file mode 100644 index 00000000000..d78937fa130 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterfaceCollection/EthernetInterfaceCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EthernetInterfaceCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EthernetInterfaceCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support EthernetInterfaceCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EthernetInterfaceCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "EthernetInterfaceCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACECOLLECTION *EthernetInterfaceCollection; + EFI_REDFISH_ETHERNETINTERFACECOLLECTION_CS *EthernetInterfaceCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EthernetInterfaceCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EthernetInterfaceCollection_To_CS (ResoruceRaw, &EthernetInterfaceCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + EthernetInterfaceCollection = (EFI_REDFISH_ETHERNETINTERFACECOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ETHERNETINTERFACECOLLECTION)); + if (EthernetInterfaceCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EthernetInterfaceCollection; + EthernetInterfaceCollection->EthernetInterfaceCollection = EthernetInterfaceCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterfaceCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EthernetInterfaceCollection"), "EthernetInterfaceCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EthernetInterfaceCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EthernetInterfaceCollection"), "EthernetInterfaceCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EthernetInterfaceCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EthernetInterfaceCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EthernetInterfaceCollection_JSON (*((EFI_REDFISH_ETHERNETINTERFACECOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EthernetInterfaceCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ETHERNETINTERFACECOLLECTION *EthernetInterfaceCollection; + + EthernetInterfaceCollection = (EFI_REDFISH_ETHERNETINTERFACECOLLECTION *)InterpProp; + DestroyEthernetInterfaceCollection_CS (EthernetInterfaceCollection->EthernetInterfaceCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EthernetInterfaceCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EthernetInterfaceCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEthernetInterfaceCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterfaceCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EthernetInterfaceCollectionToStructWrapper, + EthernetInterfaceCollectionToJson, + EthernetInterfaceCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEthernetInterfaceCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EthernetInterfaceCollection/RedfishEthernetInterfaceCollection_Dxe.inf b/RedfishClientPkg/Converter/EthernetInterfaceCollection/RedfishEthernetInterfaceCollection_Dxe.inf new file mode 100644 index 00000000000..7a5d01a3e35 --- /dev/null +++ b/RedfishClientPkg/Converter/EthernetInterfaceCollection/RedfishEthernetInterfaceCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EthernetInterfaceCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEthernetInterfaceCollection_Dxe + FILE_GUID = 78398ea0-3758-4066-8642-4cefe5ee4150 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEthernetInterfaceCollectionEntryPoint + UNLOAD_IMAGE = RedfishEthernetInterfaceCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EthernetInterfaceCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EthernetInterfaceCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_0_0/Event_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Event/v1_0_0/Event_V1_0_0_Dxe.c new file mode 100644 index 00000000000..99e4a7537ec --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_0/Event_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "0", + "0" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_0 *EventV1_0_0; + EFI_REDFISH_EVENT_V1_0_0_CS *EventV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_0_0_To_CS (ResoruceRaw, &EventV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_0_0 = (EFI_REDFISH_EVENT_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_0_0)); + if (EventV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_0_0; + EventV1_0_0->Event = EventV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_0_0_JSON (*((EFI_REDFISH_EVENT_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_0 *EventV1_0_0; + + EventV1_0_0 = (EFI_REDFISH_EVENT_V1_0_0 *)InterpProp; + DestroyEvent_V1_0_0_CS (EventV1_0_0->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_0_0/RedfishEvent_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_0_0/RedfishEvent_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..3054c5ac3ec --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_0/RedfishEvent_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_0_0_Dxe + FILE_GUID = cffb1ae4-1ec7-4b01-9886-fc14564fb9d4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_0_10/Event_V1_0_10_Dxe.c b/RedfishClientPkg/Converter/Event/v1_0_10/Event_V1_0_10_Dxe.c new file mode 100644 index 00000000000..e7b23423f0c --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_10/Event_V1_0_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_0_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "0", + "10" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_10 *EventV1_0_10; + EFI_REDFISH_EVENT_V1_0_10_CS *EventV1_0_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_0_10_To_CS (ResoruceRaw, &EventV1_0_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_0_10 = (EFI_REDFISH_EVENT_V1_0_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_0_10)); + if (EventV1_0_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_0_10; + EventV1_0_10->Event = EventV1_0_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_0_10_JSON (*((EFI_REDFISH_EVENT_V1_0_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_10 *EventV1_0_10; + + EventV1_0_10 = (EFI_REDFISH_EVENT_V1_0_10 *)InterpProp; + DestroyEvent_V1_0_10_CS (EventV1_0_10->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_0_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_0_10/RedfishEvent_V1_0_10_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_0_10/RedfishEvent_V1_0_10_Dxe.inf new file mode 100644 index 00000000000..eecd25e563b --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_10/RedfishEvent_V1_0_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_0_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_0_10_Dxe + FILE_GUID = 6a90b158-c563-4699-b521-97f89cd49485 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_0_10EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_0_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_0_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_0_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_0_11/Event_V1_0_11_Dxe.c b/RedfishClientPkg/Converter/Event/v1_0_11/Event_V1_0_11_Dxe.c new file mode 100644 index 00000000000..6db87e002c6 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_11/Event_V1_0_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_0_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "0", + "11" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_11 *EventV1_0_11; + EFI_REDFISH_EVENT_V1_0_11_CS *EventV1_0_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_0_11_To_CS (ResoruceRaw, &EventV1_0_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_0_11 = (EFI_REDFISH_EVENT_V1_0_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_0_11)); + if (EventV1_0_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_0_11; + EventV1_0_11->Event = EventV1_0_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_0_11_JSON (*((EFI_REDFISH_EVENT_V1_0_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_11 *EventV1_0_11; + + EventV1_0_11 = (EFI_REDFISH_EVENT_V1_0_11 *)InterpProp; + DestroyEvent_V1_0_11_CS (EventV1_0_11->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_0_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_0_11/RedfishEvent_V1_0_11_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_0_11/RedfishEvent_V1_0_11_Dxe.inf new file mode 100644 index 00000000000..9b368b97c3b --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_11/RedfishEvent_V1_0_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_0_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_0_11_Dxe + FILE_GUID = 1fecc964-c473-4c10-b7aa-956770ad757c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_0_11EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_0_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_0_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_0_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_0_12/Event_V1_0_12_Dxe.c b/RedfishClientPkg/Converter/Event/v1_0_12/Event_V1_0_12_Dxe.c new file mode 100644 index 00000000000..9ce5643b0de --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_12/Event_V1_0_12_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_0_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_0_12 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "0", + "12" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_12 *EventV1_0_12; + EFI_REDFISH_EVENT_V1_0_12_CS *EventV1_0_12Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "12") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_0_12_To_CS (ResoruceRaw, &EventV1_0_12Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_0_12 = (EFI_REDFISH_EVENT_V1_0_12 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_0_12)); + if (EventV1_0_12 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_0_12; + EventV1_0_12->Event = EventV1_0_12Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "12"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_0_12_JSON (*((EFI_REDFISH_EVENT_V1_0_12_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_12 *EventV1_0_12; + + EventV1_0_12 = (EFI_REDFISH_EVENT_V1_0_12 *)InterpProp; + DestroyEvent_V1_0_12_CS (EventV1_0_12->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_0_12_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_12EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_12Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_0_12/RedfishEvent_V1_0_12_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_0_12/RedfishEvent_V1_0_12_Dxe.inf new file mode 100644 index 00000000000..02f6d141845 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_12/RedfishEvent_V1_0_12_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_0_12 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_0_12_Dxe + FILE_GUID = 87b42d12-b159-4cac-b881-2d01daff5abc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_0_12EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_0_12Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_0_12_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_0_12Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_0_13/Event_V1_0_13_Dxe.c b/RedfishClientPkg/Converter/Event/v1_0_13/Event_V1_0_13_Dxe.c new file mode 100644 index 00000000000..5e1bda6bd6c --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_13/Event_V1_0_13_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_0_13 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_0_13 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "0", + "13" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_13 *EventV1_0_13; + EFI_REDFISH_EVENT_V1_0_13_CS *EventV1_0_13Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "13") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_0_13_To_CS (ResoruceRaw, &EventV1_0_13Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_0_13 = (EFI_REDFISH_EVENT_V1_0_13 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_0_13)); + if (EventV1_0_13 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_0_13; + EventV1_0_13->Event = EventV1_0_13Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "13"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_0_13_JSON (*((EFI_REDFISH_EVENT_V1_0_13_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_13 *EventV1_0_13; + + EventV1_0_13 = (EFI_REDFISH_EVENT_V1_0_13 *)InterpProp; + DestroyEvent_V1_0_13_CS (EventV1_0_13->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_0_13_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_13EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_13Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_0_13/RedfishEvent_V1_0_13_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_0_13/RedfishEvent_V1_0_13_Dxe.inf new file mode 100644 index 00000000000..790dcefd9c8 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_13/RedfishEvent_V1_0_13_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_0_13 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_0_13_Dxe + FILE_GUID = 4d26638b-d9e6-4230-b7dd-745cf6136f7c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_0_13EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_0_13Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_0_13_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_0_13Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_0_2/Event_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Event/v1_0_2/Event_V1_0_2_Dxe.c new file mode 100644 index 00000000000..8f5e1d9915e --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_2/Event_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "0", + "2" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_2 *EventV1_0_2; + EFI_REDFISH_EVENT_V1_0_2_CS *EventV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_0_2_To_CS (ResoruceRaw, &EventV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_0_2 = (EFI_REDFISH_EVENT_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_0_2)); + if (EventV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_0_2; + EventV1_0_2->Event = EventV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_0_2_JSON (*((EFI_REDFISH_EVENT_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_2 *EventV1_0_2; + + EventV1_0_2 = (EFI_REDFISH_EVENT_V1_0_2 *)InterpProp; + DestroyEvent_V1_0_2_CS (EventV1_0_2->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_0_2/RedfishEvent_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_0_2/RedfishEvent_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..ad13e303106 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_2/RedfishEvent_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_0_2_Dxe + FILE_GUID = aed2c346-beeb-4be8-afa8-e7e876f6f1f5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_0_3/Event_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/Event/v1_0_3/Event_V1_0_3_Dxe.c new file mode 100644 index 00000000000..2fe6471f760 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_3/Event_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "0", + "3" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_3 *EventV1_0_3; + EFI_REDFISH_EVENT_V1_0_3_CS *EventV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_0_3_To_CS (ResoruceRaw, &EventV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_0_3 = (EFI_REDFISH_EVENT_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_0_3)); + if (EventV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_0_3; + EventV1_0_3->Event = EventV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_0_3_JSON (*((EFI_REDFISH_EVENT_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_3 *EventV1_0_3; + + EventV1_0_3 = (EFI_REDFISH_EVENT_V1_0_3 *)InterpProp; + DestroyEvent_V1_0_3_CS (EventV1_0_3->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_0_3/RedfishEvent_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_0_3/RedfishEvent_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..d40e5c77316 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_3/RedfishEvent_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_0_3_Dxe + FILE_GUID = 1ae6bf46-887b-49ce-aad5-c207db546e5a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_0_4/Event_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/Event/v1_0_4/Event_V1_0_4_Dxe.c new file mode 100644 index 00000000000..95874ff4658 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_4/Event_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "0", + "4" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_4 *EventV1_0_4; + EFI_REDFISH_EVENT_V1_0_4_CS *EventV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_0_4_To_CS (ResoruceRaw, &EventV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_0_4 = (EFI_REDFISH_EVENT_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_0_4)); + if (EventV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_0_4; + EventV1_0_4->Event = EventV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_0_4_JSON (*((EFI_REDFISH_EVENT_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_4 *EventV1_0_4; + + EventV1_0_4 = (EFI_REDFISH_EVENT_V1_0_4 *)InterpProp; + DestroyEvent_V1_0_4_CS (EventV1_0_4->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_0_4/RedfishEvent_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_0_4/RedfishEvent_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..60f2e76319c --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_4/RedfishEvent_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_0_4_Dxe + FILE_GUID = 0a2cc072-12cc-4e51-af0b-2acfcb2b31fb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_0_5/Event_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/Event/v1_0_5/Event_V1_0_5_Dxe.c new file mode 100644 index 00000000000..2d45099b3c4 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_5/Event_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "0", + "5" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_5 *EventV1_0_5; + EFI_REDFISH_EVENT_V1_0_5_CS *EventV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_0_5_To_CS (ResoruceRaw, &EventV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_0_5 = (EFI_REDFISH_EVENT_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_0_5)); + if (EventV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_0_5; + EventV1_0_5->Event = EventV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_0_5_JSON (*((EFI_REDFISH_EVENT_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_5 *EventV1_0_5; + + EventV1_0_5 = (EFI_REDFISH_EVENT_V1_0_5 *)InterpProp; + DestroyEvent_V1_0_5_CS (EventV1_0_5->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_0_5/RedfishEvent_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_0_5/RedfishEvent_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..8dca6fa0725 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_5/RedfishEvent_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_0_5_Dxe + FILE_GUID = f22da65b-8226-454b-817f-17005ce4dcf8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_0_6/Event_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/Event/v1_0_6/Event_V1_0_6_Dxe.c new file mode 100644 index 00000000000..9e17eac8972 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_6/Event_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "0", + "6" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_6 *EventV1_0_6; + EFI_REDFISH_EVENT_V1_0_6_CS *EventV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_0_6_To_CS (ResoruceRaw, &EventV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_0_6 = (EFI_REDFISH_EVENT_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_0_6)); + if (EventV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_0_6; + EventV1_0_6->Event = EventV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_0_6_JSON (*((EFI_REDFISH_EVENT_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_6 *EventV1_0_6; + + EventV1_0_6 = (EFI_REDFISH_EVENT_V1_0_6 *)InterpProp; + DestroyEvent_V1_0_6_CS (EventV1_0_6->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_0_6/RedfishEvent_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_0_6/RedfishEvent_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..93a1aafce8f --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_6/RedfishEvent_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_0_6_Dxe + FILE_GUID = 7336409f-3219-4606-887b-ad2403f25d8f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_0_7/Event_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/Event/v1_0_7/Event_V1_0_7_Dxe.c new file mode 100644 index 00000000000..33db25be8be --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_7/Event_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "0", + "7" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_7 *EventV1_0_7; + EFI_REDFISH_EVENT_V1_0_7_CS *EventV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_0_7_To_CS (ResoruceRaw, &EventV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_0_7 = (EFI_REDFISH_EVENT_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_0_7)); + if (EventV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_0_7; + EventV1_0_7->Event = EventV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_0_7_JSON (*((EFI_REDFISH_EVENT_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_7 *EventV1_0_7; + + EventV1_0_7 = (EFI_REDFISH_EVENT_V1_0_7 *)InterpProp; + DestroyEvent_V1_0_7_CS (EventV1_0_7->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_0_7/RedfishEvent_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_0_7/RedfishEvent_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..6a22973e3c2 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_7/RedfishEvent_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_0_7_Dxe + FILE_GUID = 271918d9-4af6-4b09-b020-ecc21ca86d79 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_0_8/Event_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/Event/v1_0_8/Event_V1_0_8_Dxe.c new file mode 100644 index 00000000000..5a950c6cbdb --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_8/Event_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "0", + "8" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_8 *EventV1_0_8; + EFI_REDFISH_EVENT_V1_0_8_CS *EventV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_0_8_To_CS (ResoruceRaw, &EventV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_0_8 = (EFI_REDFISH_EVENT_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_0_8)); + if (EventV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_0_8; + EventV1_0_8->Event = EventV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_0_8_JSON (*((EFI_REDFISH_EVENT_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_8 *EventV1_0_8; + + EventV1_0_8 = (EFI_REDFISH_EVENT_V1_0_8 *)InterpProp; + DestroyEvent_V1_0_8_CS (EventV1_0_8->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_0_8/RedfishEvent_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_0_8/RedfishEvent_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..732137506af --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_8/RedfishEvent_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_0_8_Dxe + FILE_GUID = b7c7b079-9ed6-41b9-8d35-f7df90ddff7a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_0_9/Event_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/Event/v1_0_9/Event_V1_0_9_Dxe.c new file mode 100644 index 00000000000..2c4e7e34efd --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_9/Event_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "0", + "9" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_9 *EventV1_0_9; + EFI_REDFISH_EVENT_V1_0_9_CS *EventV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_0_9_To_CS (ResoruceRaw, &EventV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_0_9 = (EFI_REDFISH_EVENT_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_0_9)); + if (EventV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_0_9; + EventV1_0_9->Event = EventV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_0_9_JSON (*((EFI_REDFISH_EVENT_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_0_9 *EventV1_0_9; + + EventV1_0_9 = (EFI_REDFISH_EVENT_V1_0_9 *)InterpProp; + DestroyEvent_V1_0_9_CS (EventV1_0_9->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_0_9/RedfishEvent_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_0_9/RedfishEvent_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..97cfbbc5a85 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_0_9/RedfishEvent_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_0_9_Dxe + FILE_GUID = 2c4bd89e-8517-4f06-aeda-950888e3a62f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_1_0/Event_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/Event/v1_1_0/Event_V1_1_0_Dxe.c new file mode 100644 index 00000000000..1059a24b3b1 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_1_0/Event_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "1", + "0" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_1_0 *EventV1_1_0; + EFI_REDFISH_EVENT_V1_1_0_CS *EventV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_1_0_To_CS (ResoruceRaw, &EventV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_1_0 = (EFI_REDFISH_EVENT_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_1_0)); + if (EventV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_1_0; + EventV1_1_0->Event = EventV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_1_0_JSON (*((EFI_REDFISH_EVENT_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_1_0 *EventV1_1_0; + + EventV1_1_0 = (EFI_REDFISH_EVENT_V1_1_0 *)InterpProp; + DestroyEvent_V1_1_0_CS (EventV1_1_0->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_1_0/RedfishEvent_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_1_0/RedfishEvent_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..0df56ef2b76 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_1_0/RedfishEvent_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_1_0_Dxe + FILE_GUID = 4cddac4b-71da-4a21-91d2-e7ae646bfcb6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_1_1/Event_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/Event/v1_1_1/Event_V1_1_1_Dxe.c new file mode 100644 index 00000000000..0e9fdbc85c2 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_1_1/Event_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "1", + "1" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_1_1 *EventV1_1_1; + EFI_REDFISH_EVENT_V1_1_1_CS *EventV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_1_1_To_CS (ResoruceRaw, &EventV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_1_1 = (EFI_REDFISH_EVENT_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_1_1)); + if (EventV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_1_1; + EventV1_1_1->Event = EventV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_1_1_JSON (*((EFI_REDFISH_EVENT_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_1_1 *EventV1_1_1; + + EventV1_1_1 = (EFI_REDFISH_EVENT_V1_1_1 *)InterpProp; + DestroyEvent_V1_1_1_CS (EventV1_1_1->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_1_1/RedfishEvent_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_1_1/RedfishEvent_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..f6ab095e9b8 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_1_1/RedfishEvent_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_1_1_Dxe + FILE_GUID = 9c9c3c70-fd6e-4ae8-a8b2-6ed5d73f7de3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_1_10/Event_V1_1_10_Dxe.c b/RedfishClientPkg/Converter/Event/v1_1_10/Event_V1_1_10_Dxe.c new file mode 100644 index 00000000000..d014ec64682 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_1_10/Event_V1_1_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_1_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_1_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "1", + "10" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_1_10 *EventV1_1_10; + EFI_REDFISH_EVENT_V1_1_10_CS *EventV1_1_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_1_10_To_CS (ResoruceRaw, &EventV1_1_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_1_10 = (EFI_REDFISH_EVENT_V1_1_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_1_10)); + if (EventV1_1_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_1_10; + EventV1_1_10->Event = EventV1_1_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_1_10_JSON (*((EFI_REDFISH_EVENT_V1_1_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_1_10 *EventV1_1_10; + + EventV1_1_10 = (EFI_REDFISH_EVENT_V1_1_10 *)InterpProp; + DestroyEvent_V1_1_10_CS (EventV1_1_10->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_1_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_1_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_1_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_1_10/RedfishEvent_V1_1_10_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_1_10/RedfishEvent_V1_1_10_Dxe.inf new file mode 100644 index 00000000000..b3f6ba38a2e --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_1_10/RedfishEvent_V1_1_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_1_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_1_10_Dxe + FILE_GUID = cd15070b-8229-4fea-a468-a45060faba77 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_1_10EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_1_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_1_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_1_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_1_11/Event_V1_1_11_Dxe.c b/RedfishClientPkg/Converter/Event/v1_1_11/Event_V1_1_11_Dxe.c new file mode 100644 index 00000000000..063b4d9e878 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_1_11/Event_V1_1_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_1_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_1_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "1", + "11" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_1_11 *EventV1_1_11; + EFI_REDFISH_EVENT_V1_1_11_CS *EventV1_1_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_1_11_To_CS (ResoruceRaw, &EventV1_1_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_1_11 = (EFI_REDFISH_EVENT_V1_1_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_1_11)); + if (EventV1_1_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_1_11; + EventV1_1_11->Event = EventV1_1_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_1_11_JSON (*((EFI_REDFISH_EVENT_V1_1_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_1_11 *EventV1_1_11; + + EventV1_1_11 = (EFI_REDFISH_EVENT_V1_1_11 *)InterpProp; + DestroyEvent_V1_1_11_CS (EventV1_1_11->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_1_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_1_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_1_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_1_11/RedfishEvent_V1_1_11_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_1_11/RedfishEvent_V1_1_11_Dxe.inf new file mode 100644 index 00000000000..a1995285287 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_1_11/RedfishEvent_V1_1_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_1_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_1_11_Dxe + FILE_GUID = 5bb96d31-c0e3-40f3-b1f8-62b84048bc11 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_1_11EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_1_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_1_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_1_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_1_2/Event_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/Event/v1_1_2/Event_V1_1_2_Dxe.c new file mode 100644 index 00000000000..34cdc815edf --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_1_2/Event_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "1", + "2" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_1_2 *EventV1_1_2; + EFI_REDFISH_EVENT_V1_1_2_CS *EventV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_1_2_To_CS (ResoruceRaw, &EventV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_1_2 = (EFI_REDFISH_EVENT_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_1_2)); + if (EventV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_1_2; + EventV1_1_2->Event = EventV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_1_2_JSON (*((EFI_REDFISH_EVENT_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_1_2 *EventV1_1_2; + + EventV1_1_2 = (EFI_REDFISH_EVENT_V1_1_2 *)InterpProp; + DestroyEvent_V1_1_2_CS (EventV1_1_2->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_1_2/RedfishEvent_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_1_2/RedfishEvent_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..5c91d7c2388 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_1_2/RedfishEvent_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_1_2_Dxe + FILE_GUID = 875c7f35-c0fb-4eb9-a30c-d7a888e63f2a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_1_3/Event_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/Event/v1_1_3/Event_V1_1_3_Dxe.c new file mode 100644 index 00000000000..e1f29202614 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_1_3/Event_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "1", + "3" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_1_3 *EventV1_1_3; + EFI_REDFISH_EVENT_V1_1_3_CS *EventV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_1_3_To_CS (ResoruceRaw, &EventV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_1_3 = (EFI_REDFISH_EVENT_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_1_3)); + if (EventV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_1_3; + EventV1_1_3->Event = EventV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_1_3_JSON (*((EFI_REDFISH_EVENT_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_1_3 *EventV1_1_3; + + EventV1_1_3 = (EFI_REDFISH_EVENT_V1_1_3 *)InterpProp; + DestroyEvent_V1_1_3_CS (EventV1_1_3->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_1_3/RedfishEvent_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_1_3/RedfishEvent_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..ea62565267c --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_1_3/RedfishEvent_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_1_3_Dxe + FILE_GUID = f4aead09-2ebe-4ba2-bcad-4a8cc427cf09 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_1_4/Event_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/Event/v1_1_4/Event_V1_1_4_Dxe.c new file mode 100644 index 00000000000..1caabaf29a8 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_1_4/Event_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "1", + "4" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_1_4 *EventV1_1_4; + EFI_REDFISH_EVENT_V1_1_4_CS *EventV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_1_4_To_CS (ResoruceRaw, &EventV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_1_4 = (EFI_REDFISH_EVENT_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_1_4)); + if (EventV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_1_4; + EventV1_1_4->Event = EventV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_1_4_JSON (*((EFI_REDFISH_EVENT_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_1_4 *EventV1_1_4; + + EventV1_1_4 = (EFI_REDFISH_EVENT_V1_1_4 *)InterpProp; + DestroyEvent_V1_1_4_CS (EventV1_1_4->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_1_4/RedfishEvent_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_1_4/RedfishEvent_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..0f03c5c4912 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_1_4/RedfishEvent_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_1_4_Dxe + FILE_GUID = b25baf88-d625-4a17-bb98-fcb005baf7f4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_1_5/Event_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/Event/v1_1_5/Event_V1_1_5_Dxe.c new file mode 100644 index 00000000000..05b1080eb74 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_1_5/Event_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "1", + "5" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_1_5 *EventV1_1_5; + EFI_REDFISH_EVENT_V1_1_5_CS *EventV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_1_5_To_CS (ResoruceRaw, &EventV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_1_5 = (EFI_REDFISH_EVENT_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_1_5)); + if (EventV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_1_5; + EventV1_1_5->Event = EventV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_1_5_JSON (*((EFI_REDFISH_EVENT_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_1_5 *EventV1_1_5; + + EventV1_1_5 = (EFI_REDFISH_EVENT_V1_1_5 *)InterpProp; + DestroyEvent_V1_1_5_CS (EventV1_1_5->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_1_5/RedfishEvent_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_1_5/RedfishEvent_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..6967fb28f2b --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_1_5/RedfishEvent_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_1_5_Dxe + FILE_GUID = 37f42910-0383-441c-83cf-c8bcb01287d5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_1_6/Event_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/Event/v1_1_6/Event_V1_1_6_Dxe.c new file mode 100644 index 00000000000..70a40941ca4 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_1_6/Event_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "1", + "6" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_1_6 *EventV1_1_6; + EFI_REDFISH_EVENT_V1_1_6_CS *EventV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_1_6_To_CS (ResoruceRaw, &EventV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_1_6 = (EFI_REDFISH_EVENT_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_1_6)); + if (EventV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_1_6; + EventV1_1_6->Event = EventV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_1_6_JSON (*((EFI_REDFISH_EVENT_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_1_6 *EventV1_1_6; + + EventV1_1_6 = (EFI_REDFISH_EVENT_V1_1_6 *)InterpProp; + DestroyEvent_V1_1_6_CS (EventV1_1_6->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_1_6/RedfishEvent_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_1_6/RedfishEvent_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..539f6689d14 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_1_6/RedfishEvent_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_1_6_Dxe + FILE_GUID = 0e44174e-6518-4d99-8c66-379f39820476 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_1_7/Event_V1_1_7_Dxe.c b/RedfishClientPkg/Converter/Event/v1_1_7/Event_V1_1_7_Dxe.c new file mode 100644 index 00000000000..8d0c4517e46 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_1_7/Event_V1_1_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_1_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "1", + "7" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_1_7 *EventV1_1_7; + EFI_REDFISH_EVENT_V1_1_7_CS *EventV1_1_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_1_7_To_CS (ResoruceRaw, &EventV1_1_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_1_7 = (EFI_REDFISH_EVENT_V1_1_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_1_7)); + if (EventV1_1_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_1_7; + EventV1_1_7->Event = EventV1_1_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_1_7_JSON (*((EFI_REDFISH_EVENT_V1_1_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_1_7 *EventV1_1_7; + + EventV1_1_7 = (EFI_REDFISH_EVENT_V1_1_7 *)InterpProp; + DestroyEvent_V1_1_7_CS (EventV1_1_7->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_1_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_1_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_1_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_1_7/RedfishEvent_V1_1_7_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_1_7/RedfishEvent_V1_1_7_Dxe.inf new file mode 100644 index 00000000000..7c20960bab3 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_1_7/RedfishEvent_V1_1_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_1_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_1_7_Dxe + FILE_GUID = 15bddfad-8704-4123-8a3b-c15667711754 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_1_7EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_1_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_1_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_1_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_1_8/Event_V1_1_8_Dxe.c b/RedfishClientPkg/Converter/Event/v1_1_8/Event_V1_1_8_Dxe.c new file mode 100644 index 00000000000..66fb713a575 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_1_8/Event_V1_1_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_1_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "1", + "8" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_1_8 *EventV1_1_8; + EFI_REDFISH_EVENT_V1_1_8_CS *EventV1_1_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_1_8_To_CS (ResoruceRaw, &EventV1_1_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_1_8 = (EFI_REDFISH_EVENT_V1_1_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_1_8)); + if (EventV1_1_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_1_8; + EventV1_1_8->Event = EventV1_1_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_1_8_JSON (*((EFI_REDFISH_EVENT_V1_1_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_1_8 *EventV1_1_8; + + EventV1_1_8 = (EFI_REDFISH_EVENT_V1_1_8 *)InterpProp; + DestroyEvent_V1_1_8_CS (EventV1_1_8->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_1_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_1_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_1_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_1_8/RedfishEvent_V1_1_8_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_1_8/RedfishEvent_V1_1_8_Dxe.inf new file mode 100644 index 00000000000..ae47088cb65 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_1_8/RedfishEvent_V1_1_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_1_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_1_8_Dxe + FILE_GUID = fc5a96f2-8ca3-4bb5-aac2-ed29f8d11a10 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_1_8EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_1_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_1_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_1_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_1_9/Event_V1_1_9_Dxe.c b/RedfishClientPkg/Converter/Event/v1_1_9/Event_V1_1_9_Dxe.c new file mode 100644 index 00000000000..3a7da719659 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_1_9/Event_V1_1_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_1_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "1", + "9" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_1_9 *EventV1_1_9; + EFI_REDFISH_EVENT_V1_1_9_CS *EventV1_1_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_1_9_To_CS (ResoruceRaw, &EventV1_1_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_1_9 = (EFI_REDFISH_EVENT_V1_1_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_1_9)); + if (EventV1_1_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_1_9; + EventV1_1_9->Event = EventV1_1_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_1_9_JSON (*((EFI_REDFISH_EVENT_V1_1_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_1_9 *EventV1_1_9; + + EventV1_1_9 = (EFI_REDFISH_EVENT_V1_1_9 *)InterpProp; + DestroyEvent_V1_1_9_CS (EventV1_1_9->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_1_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_1_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_1_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_1_9/RedfishEvent_V1_1_9_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_1_9/RedfishEvent_V1_1_9_Dxe.inf new file mode 100644 index 00000000000..ff7c2c3a219 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_1_9/RedfishEvent_V1_1_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_1_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_1_9_Dxe + FILE_GUID = 5fa76c30-7bb8-4dfa-b672-e86fbe133800 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_1_9EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_1_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_1_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_1_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_2_0/Event_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/Event/v1_2_0/Event_V1_2_0_Dxe.c new file mode 100644 index 00000000000..33a247c908b --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_2_0/Event_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "2", + "0" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_2_0 *EventV1_2_0; + EFI_REDFISH_EVENT_V1_2_0_CS *EventV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_2_0_To_CS (ResoruceRaw, &EventV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_2_0 = (EFI_REDFISH_EVENT_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_2_0)); + if (EventV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_2_0; + EventV1_2_0->Event = EventV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_2_0_JSON (*((EFI_REDFISH_EVENT_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_2_0 *EventV1_2_0; + + EventV1_2_0 = (EFI_REDFISH_EVENT_V1_2_0 *)InterpProp; + DestroyEvent_V1_2_0_CS (EventV1_2_0->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_2_0/RedfishEvent_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_2_0/RedfishEvent_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..16b3d90992f --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_2_0/RedfishEvent_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_2_0_Dxe + FILE_GUID = 69aac1b6-10bd-43c3-9c98-ec228d31ac76 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_2_1/Event_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/Event/v1_2_1/Event_V1_2_1_Dxe.c new file mode 100644 index 00000000000..c6654e8e7a5 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_2_1/Event_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "2", + "1" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_2_1 *EventV1_2_1; + EFI_REDFISH_EVENT_V1_2_1_CS *EventV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_2_1_To_CS (ResoruceRaw, &EventV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_2_1 = (EFI_REDFISH_EVENT_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_2_1)); + if (EventV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_2_1; + EventV1_2_1->Event = EventV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_2_1_JSON (*((EFI_REDFISH_EVENT_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_2_1 *EventV1_2_1; + + EventV1_2_1 = (EFI_REDFISH_EVENT_V1_2_1 *)InterpProp; + DestroyEvent_V1_2_1_CS (EventV1_2_1->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_2_1/RedfishEvent_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_2_1/RedfishEvent_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..a382aaee702 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_2_1/RedfishEvent_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_2_1_Dxe + FILE_GUID = ee1e658c-8663-4be2-a099-a615da249129 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_2_2/Event_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/Event/v1_2_2/Event_V1_2_2_Dxe.c new file mode 100644 index 00000000000..78364b4e36b --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_2_2/Event_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "2", + "2" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_2_2 *EventV1_2_2; + EFI_REDFISH_EVENT_V1_2_2_CS *EventV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_2_2_To_CS (ResoruceRaw, &EventV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_2_2 = (EFI_REDFISH_EVENT_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_2_2)); + if (EventV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_2_2; + EventV1_2_2->Event = EventV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_2_2_JSON (*((EFI_REDFISH_EVENT_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_2_2 *EventV1_2_2; + + EventV1_2_2 = (EFI_REDFISH_EVENT_V1_2_2 *)InterpProp; + DestroyEvent_V1_2_2_CS (EventV1_2_2->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_2_2/RedfishEvent_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_2_2/RedfishEvent_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..f7d18418ad8 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_2_2/RedfishEvent_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_2_2_Dxe + FILE_GUID = 7a29f4fb-2079-40ca-9209-ebfb9823b39d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_2_3/Event_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/Event/v1_2_3/Event_V1_2_3_Dxe.c new file mode 100644 index 00000000000..77193986fa9 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_2_3/Event_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "2", + "3" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_2_3 *EventV1_2_3; + EFI_REDFISH_EVENT_V1_2_3_CS *EventV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_2_3_To_CS (ResoruceRaw, &EventV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_2_3 = (EFI_REDFISH_EVENT_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_2_3)); + if (EventV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_2_3; + EventV1_2_3->Event = EventV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_2_3_JSON (*((EFI_REDFISH_EVENT_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_2_3 *EventV1_2_3; + + EventV1_2_3 = (EFI_REDFISH_EVENT_V1_2_3 *)InterpProp; + DestroyEvent_V1_2_3_CS (EventV1_2_3->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_2_3/RedfishEvent_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_2_3/RedfishEvent_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..d50be3e2731 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_2_3/RedfishEvent_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_2_3_Dxe + FILE_GUID = 13cf338d-f357-4e45-afc9-9828fbe3e4e6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_2_4/Event_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/Event/v1_2_4/Event_V1_2_4_Dxe.c new file mode 100644 index 00000000000..063e6bc5031 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_2_4/Event_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "2", + "4" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_2_4 *EventV1_2_4; + EFI_REDFISH_EVENT_V1_2_4_CS *EventV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_2_4_To_CS (ResoruceRaw, &EventV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_2_4 = (EFI_REDFISH_EVENT_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_2_4)); + if (EventV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_2_4; + EventV1_2_4->Event = EventV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_2_4_JSON (*((EFI_REDFISH_EVENT_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_2_4 *EventV1_2_4; + + EventV1_2_4 = (EFI_REDFISH_EVENT_V1_2_4 *)InterpProp; + DestroyEvent_V1_2_4_CS (EventV1_2_4->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_2_4/RedfishEvent_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_2_4/RedfishEvent_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..508af8ca1d7 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_2_4/RedfishEvent_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_2_4_Dxe + FILE_GUID = f8578ede-a40b-4b69-88ef-504598382461 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_2_5/Event_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/Event/v1_2_5/Event_V1_2_5_Dxe.c new file mode 100644 index 00000000000..154e0cb096d --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_2_5/Event_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "2", + "5" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_2_5 *EventV1_2_5; + EFI_REDFISH_EVENT_V1_2_5_CS *EventV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_2_5_To_CS (ResoruceRaw, &EventV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_2_5 = (EFI_REDFISH_EVENT_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_2_5)); + if (EventV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_2_5; + EventV1_2_5->Event = EventV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_2_5_JSON (*((EFI_REDFISH_EVENT_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_2_5 *EventV1_2_5; + + EventV1_2_5 = (EFI_REDFISH_EVENT_V1_2_5 *)InterpProp; + DestroyEvent_V1_2_5_CS (EventV1_2_5->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_2_5/RedfishEvent_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_2_5/RedfishEvent_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..71312e91ae4 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_2_5/RedfishEvent_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_2_5_Dxe + FILE_GUID = b3f0ece5-7c4c-40e3-90cc-6b99f1024820 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_2_6/Event_V1_2_6_Dxe.c b/RedfishClientPkg/Converter/Event/v1_2_6/Event_V1_2_6_Dxe.c new file mode 100644 index 00000000000..d085606976c --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_2_6/Event_V1_2_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_2_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "2", + "6" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_2_6 *EventV1_2_6; + EFI_REDFISH_EVENT_V1_2_6_CS *EventV1_2_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_2_6_To_CS (ResoruceRaw, &EventV1_2_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_2_6 = (EFI_REDFISH_EVENT_V1_2_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_2_6)); + if (EventV1_2_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_2_6; + EventV1_2_6->Event = EventV1_2_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_2_6_JSON (*((EFI_REDFISH_EVENT_V1_2_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_2_6 *EventV1_2_6; + + EventV1_2_6 = (EFI_REDFISH_EVENT_V1_2_6 *)InterpProp; + DestroyEvent_V1_2_6_CS (EventV1_2_6->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_2_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_2_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_2_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_2_6/RedfishEvent_V1_2_6_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_2_6/RedfishEvent_V1_2_6_Dxe.inf new file mode 100644 index 00000000000..26259d46d4f --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_2_6/RedfishEvent_V1_2_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_2_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_2_6_Dxe + FILE_GUID = a6435fc2-3996-4228-9ad4-37cd6dfd1961 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_2_6EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_2_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_2_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_2_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_2_7/Event_V1_2_7_Dxe.c b/RedfishClientPkg/Converter/Event/v1_2_7/Event_V1_2_7_Dxe.c new file mode 100644 index 00000000000..dd546271c79 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_2_7/Event_V1_2_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_2_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "2", + "7" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_2_7 *EventV1_2_7; + EFI_REDFISH_EVENT_V1_2_7_CS *EventV1_2_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_2_7_To_CS (ResoruceRaw, &EventV1_2_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_2_7 = (EFI_REDFISH_EVENT_V1_2_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_2_7)); + if (EventV1_2_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_2_7; + EventV1_2_7->Event = EventV1_2_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_2_7_JSON (*((EFI_REDFISH_EVENT_V1_2_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_2_7 *EventV1_2_7; + + EventV1_2_7 = (EFI_REDFISH_EVENT_V1_2_7 *)InterpProp; + DestroyEvent_V1_2_7_CS (EventV1_2_7->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_2_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_2_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_2_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_2_7/RedfishEvent_V1_2_7_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_2_7/RedfishEvent_V1_2_7_Dxe.inf new file mode 100644 index 00000000000..33bdf64397a --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_2_7/RedfishEvent_V1_2_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_2_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_2_7_Dxe + FILE_GUID = 69aa52fb-bd99-4f69-a8f8-d6770a9ca92d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_2_7EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_2_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_2_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_2_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_2_8/Event_V1_2_8_Dxe.c b/RedfishClientPkg/Converter/Event/v1_2_8/Event_V1_2_8_Dxe.c new file mode 100644 index 00000000000..05b8c5b0859 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_2_8/Event_V1_2_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_2_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "2", + "8" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_2_8 *EventV1_2_8; + EFI_REDFISH_EVENT_V1_2_8_CS *EventV1_2_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_2_8_To_CS (ResoruceRaw, &EventV1_2_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_2_8 = (EFI_REDFISH_EVENT_V1_2_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_2_8)); + if (EventV1_2_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_2_8; + EventV1_2_8->Event = EventV1_2_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_2_8_JSON (*((EFI_REDFISH_EVENT_V1_2_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_2_8 *EventV1_2_8; + + EventV1_2_8 = (EFI_REDFISH_EVENT_V1_2_8 *)InterpProp; + DestroyEvent_V1_2_8_CS (EventV1_2_8->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_2_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_2_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_2_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_2_8/RedfishEvent_V1_2_8_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_2_8/RedfishEvent_V1_2_8_Dxe.inf new file mode 100644 index 00000000000..8ebd3363487 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_2_8/RedfishEvent_V1_2_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_2_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_2_8_Dxe + FILE_GUID = db89fa72-368f-4e9d-86ff-3c94e3edaebe + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_2_8EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_2_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_2_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_2_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_3_0/Event_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/Event/v1_3_0/Event_V1_3_0_Dxe.c new file mode 100644 index 00000000000..eefc1f3e100 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_3_0/Event_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "3", + "0" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_3_0 *EventV1_3_0; + EFI_REDFISH_EVENT_V1_3_0_CS *EventV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_3_0_To_CS (ResoruceRaw, &EventV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_3_0 = (EFI_REDFISH_EVENT_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_3_0)); + if (EventV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_3_0; + EventV1_3_0->Event = EventV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_3_0_JSON (*((EFI_REDFISH_EVENT_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_3_0 *EventV1_3_0; + + EventV1_3_0 = (EFI_REDFISH_EVENT_V1_3_0 *)InterpProp; + DestroyEvent_V1_3_0_CS (EventV1_3_0->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_3_0/RedfishEvent_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_3_0/RedfishEvent_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..d7b996faee6 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_3_0/RedfishEvent_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_3_0_Dxe + FILE_GUID = ca40d10e-7dbc-4d30-bb59-fc7dfc0871f4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_3_1/Event_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/Event/v1_3_1/Event_V1_3_1_Dxe.c new file mode 100644 index 00000000000..1c3a069b59c --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_3_1/Event_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "3", + "1" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_3_1 *EventV1_3_1; + EFI_REDFISH_EVENT_V1_3_1_CS *EventV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_3_1_To_CS (ResoruceRaw, &EventV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_3_1 = (EFI_REDFISH_EVENT_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_3_1)); + if (EventV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_3_1; + EventV1_3_1->Event = EventV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_3_1_JSON (*((EFI_REDFISH_EVENT_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_3_1 *EventV1_3_1; + + EventV1_3_1 = (EFI_REDFISH_EVENT_V1_3_1 *)InterpProp; + DestroyEvent_V1_3_1_CS (EventV1_3_1->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_3_1/RedfishEvent_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_3_1/RedfishEvent_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..e4042489b2a --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_3_1/RedfishEvent_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_3_1_Dxe + FILE_GUID = c4ebc9de-8f7c-4360-af3f-95a5f39779b8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_3_2/Event_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/Event/v1_3_2/Event_V1_3_2_Dxe.c new file mode 100644 index 00000000000..a422ed1dd6a --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_3_2/Event_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "3", + "2" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_3_2 *EventV1_3_2; + EFI_REDFISH_EVENT_V1_3_2_CS *EventV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_3_2_To_CS (ResoruceRaw, &EventV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_3_2 = (EFI_REDFISH_EVENT_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_3_2)); + if (EventV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_3_2; + EventV1_3_2->Event = EventV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_3_2_JSON (*((EFI_REDFISH_EVENT_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_3_2 *EventV1_3_2; + + EventV1_3_2 = (EFI_REDFISH_EVENT_V1_3_2 *)InterpProp; + DestroyEvent_V1_3_2_CS (EventV1_3_2->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_3_2/RedfishEvent_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_3_2/RedfishEvent_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..afe8d99ee39 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_3_2/RedfishEvent_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_3_2_Dxe + FILE_GUID = bd400750-f234-47c4-b91f-0772300c2f7e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_3_3/Event_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/Event/v1_3_3/Event_V1_3_3_Dxe.c new file mode 100644 index 00000000000..42b47ea75ca --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_3_3/Event_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "3", + "3" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_3_3 *EventV1_3_3; + EFI_REDFISH_EVENT_V1_3_3_CS *EventV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_3_3_To_CS (ResoruceRaw, &EventV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_3_3 = (EFI_REDFISH_EVENT_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_3_3)); + if (EventV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_3_3; + EventV1_3_3->Event = EventV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_3_3_JSON (*((EFI_REDFISH_EVENT_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_3_3 *EventV1_3_3; + + EventV1_3_3 = (EFI_REDFISH_EVENT_V1_3_3 *)InterpProp; + DestroyEvent_V1_3_3_CS (EventV1_3_3->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_3_3/RedfishEvent_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_3_3/RedfishEvent_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..8182458fd60 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_3_3/RedfishEvent_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_3_3_Dxe + FILE_GUID = e0a82ced-e6d1-4340-82f3-53f4b9c739ec + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_3_4/Event_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/Event/v1_3_4/Event_V1_3_4_Dxe.c new file mode 100644 index 00000000000..0b6f901159d --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_3_4/Event_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "3", + "4" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_3_4 *EventV1_3_4; + EFI_REDFISH_EVENT_V1_3_4_CS *EventV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_3_4_To_CS (ResoruceRaw, &EventV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_3_4 = (EFI_REDFISH_EVENT_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_3_4)); + if (EventV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_3_4; + EventV1_3_4->Event = EventV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_3_4_JSON (*((EFI_REDFISH_EVENT_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_3_4 *EventV1_3_4; + + EventV1_3_4 = (EFI_REDFISH_EVENT_V1_3_4 *)InterpProp; + DestroyEvent_V1_3_4_CS (EventV1_3_4->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_3_4/RedfishEvent_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_3_4/RedfishEvent_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..e5408dd5a1e --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_3_4/RedfishEvent_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_3_4_Dxe + FILE_GUID = d1f6409a-aa06-4f50-8a68-fe3b3f51fcf8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_3_5/Event_V1_3_5_Dxe.c b/RedfishClientPkg/Converter/Event/v1_3_5/Event_V1_3_5_Dxe.c new file mode 100644 index 00000000000..b6cd52b8e1b --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_3_5/Event_V1_3_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_3_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "3", + "5" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_3_5 *EventV1_3_5; + EFI_REDFISH_EVENT_V1_3_5_CS *EventV1_3_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_3_5_To_CS (ResoruceRaw, &EventV1_3_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_3_5 = (EFI_REDFISH_EVENT_V1_3_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_3_5)); + if (EventV1_3_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_3_5; + EventV1_3_5->Event = EventV1_3_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_3_5_JSON (*((EFI_REDFISH_EVENT_V1_3_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_3_5 *EventV1_3_5; + + EventV1_3_5 = (EFI_REDFISH_EVENT_V1_3_5 *)InterpProp; + DestroyEvent_V1_3_5_CS (EventV1_3_5->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_3_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_3_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_3_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_3_5/RedfishEvent_V1_3_5_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_3_5/RedfishEvent_V1_3_5_Dxe.inf new file mode 100644 index 00000000000..88c74922dc2 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_3_5/RedfishEvent_V1_3_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_3_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_3_5_Dxe + FILE_GUID = 40546ae9-3979-459a-a7b1-e1d1dedd8e62 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_3_5EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_3_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_3_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_3_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_3_6/Event_V1_3_6_Dxe.c b/RedfishClientPkg/Converter/Event/v1_3_6/Event_V1_3_6_Dxe.c new file mode 100644 index 00000000000..702de106209 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_3_6/Event_V1_3_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_3_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "3", + "6" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_3_6 *EventV1_3_6; + EFI_REDFISH_EVENT_V1_3_6_CS *EventV1_3_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_3_6_To_CS (ResoruceRaw, &EventV1_3_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_3_6 = (EFI_REDFISH_EVENT_V1_3_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_3_6)); + if (EventV1_3_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_3_6; + EventV1_3_6->Event = EventV1_3_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_3_6_JSON (*((EFI_REDFISH_EVENT_V1_3_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_3_6 *EventV1_3_6; + + EventV1_3_6 = (EFI_REDFISH_EVENT_V1_3_6 *)InterpProp; + DestroyEvent_V1_3_6_CS (EventV1_3_6->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_3_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_3_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_3_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_3_6/RedfishEvent_V1_3_6_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_3_6/RedfishEvent_V1_3_6_Dxe.inf new file mode 100644 index 00000000000..7a3375079a4 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_3_6/RedfishEvent_V1_3_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_3_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_3_6_Dxe + FILE_GUID = 008e8319-e510-4411-ac6e-1eba480a3e76 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_3_6EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_3_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_3_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_3_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_4_0/Event_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/Event/v1_4_0/Event_V1_4_0_Dxe.c new file mode 100644 index 00000000000..0e54ee9df00 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_4_0/Event_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "4", + "0" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_4_0 *EventV1_4_0; + EFI_REDFISH_EVENT_V1_4_0_CS *EventV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_4_0_To_CS (ResoruceRaw, &EventV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_4_0 = (EFI_REDFISH_EVENT_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_4_0)); + if (EventV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_4_0; + EventV1_4_0->Event = EventV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_4_0_JSON (*((EFI_REDFISH_EVENT_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_4_0 *EventV1_4_0; + + EventV1_4_0 = (EFI_REDFISH_EVENT_V1_4_0 *)InterpProp; + DestroyEvent_V1_4_0_CS (EventV1_4_0->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_4_0/RedfishEvent_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_4_0/RedfishEvent_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..2f657fe28d1 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_4_0/RedfishEvent_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_4_0_Dxe + FILE_GUID = d1b0caa4-215c-4c18-a778-470f0fc51fd4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_4_1/Event_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/Event/v1_4_1/Event_V1_4_1_Dxe.c new file mode 100644 index 00000000000..49f1799e45f --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_4_1/Event_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "4", + "1" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_4_1 *EventV1_4_1; + EFI_REDFISH_EVENT_V1_4_1_CS *EventV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_4_1_To_CS (ResoruceRaw, &EventV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_4_1 = (EFI_REDFISH_EVENT_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_4_1)); + if (EventV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_4_1; + EventV1_4_1->Event = EventV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_4_1_JSON (*((EFI_REDFISH_EVENT_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_4_1 *EventV1_4_1; + + EventV1_4_1 = (EFI_REDFISH_EVENT_V1_4_1 *)InterpProp; + DestroyEvent_V1_4_1_CS (EventV1_4_1->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_4_1/RedfishEvent_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_4_1/RedfishEvent_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..84a8f903f91 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_4_1/RedfishEvent_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_4_1_Dxe + FILE_GUID = 19436f36-2ad1-49a8-84cd-a80eadb98ff7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_4_2/Event_V1_4_2_Dxe.c b/RedfishClientPkg/Converter/Event/v1_4_2/Event_V1_4_2_Dxe.c new file mode 100644 index 00000000000..51901ff08e4 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_4_2/Event_V1_4_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_4_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "4", + "2" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_4_2 *EventV1_4_2; + EFI_REDFISH_EVENT_V1_4_2_CS *EventV1_4_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_4_2_To_CS (ResoruceRaw, &EventV1_4_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_4_2 = (EFI_REDFISH_EVENT_V1_4_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_4_2)); + if (EventV1_4_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_4_2; + EventV1_4_2->Event = EventV1_4_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_4_2_JSON (*((EFI_REDFISH_EVENT_V1_4_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_4_2 *EventV1_4_2; + + EventV1_4_2 = (EFI_REDFISH_EVENT_V1_4_2 *)InterpProp; + DestroyEvent_V1_4_2_CS (EventV1_4_2->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_4_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_4_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_4_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_4_2/RedfishEvent_V1_4_2_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_4_2/RedfishEvent_V1_4_2_Dxe.inf new file mode 100644 index 00000000000..d7276bd4b19 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_4_2/RedfishEvent_V1_4_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_4_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_4_2_Dxe + FILE_GUID = 9705221c-4c3a-4105-ae2c-0062cb9871b5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_4_2EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_4_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_4_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_4_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_4_3/Event_V1_4_3_Dxe.c b/RedfishClientPkg/Converter/Event/v1_4_3/Event_V1_4_3_Dxe.c new file mode 100644 index 00000000000..ade383ec2b8 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_4_3/Event_V1_4_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_4_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "4", + "3" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_4_3 *EventV1_4_3; + EFI_REDFISH_EVENT_V1_4_3_CS *EventV1_4_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_4_3_To_CS (ResoruceRaw, &EventV1_4_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_4_3 = (EFI_REDFISH_EVENT_V1_4_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_4_3)); + if (EventV1_4_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_4_3; + EventV1_4_3->Event = EventV1_4_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_4_3_JSON (*((EFI_REDFISH_EVENT_V1_4_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_4_3 *EventV1_4_3; + + EventV1_4_3 = (EFI_REDFISH_EVENT_V1_4_3 *)InterpProp; + DestroyEvent_V1_4_3_CS (EventV1_4_3->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_4_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_4_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_4_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_4_3/RedfishEvent_V1_4_3_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_4_3/RedfishEvent_V1_4_3_Dxe.inf new file mode 100644 index 00000000000..c1612000776 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_4_3/RedfishEvent_V1_4_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_4_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_4_3_Dxe + FILE_GUID = f6b61e88-4da0-46d9-b1c3-4c14872d8604 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_4_3EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_4_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_4_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_4_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_4_4/Event_V1_4_4_Dxe.c b/RedfishClientPkg/Converter/Event/v1_4_4/Event_V1_4_4_Dxe.c new file mode 100644 index 00000000000..9133923dcde --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_4_4/Event_V1_4_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_4_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "4", + "4" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_4_4 *EventV1_4_4; + EFI_REDFISH_EVENT_V1_4_4_CS *EventV1_4_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_4_4_To_CS (ResoruceRaw, &EventV1_4_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_4_4 = (EFI_REDFISH_EVENT_V1_4_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_4_4)); + if (EventV1_4_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_4_4; + EventV1_4_4->Event = EventV1_4_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_4_4_JSON (*((EFI_REDFISH_EVENT_V1_4_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_4_4 *EventV1_4_4; + + EventV1_4_4 = (EFI_REDFISH_EVENT_V1_4_4 *)InterpProp; + DestroyEvent_V1_4_4_CS (EventV1_4_4->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_4_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_4_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_4_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_4_4/RedfishEvent_V1_4_4_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_4_4/RedfishEvent_V1_4_4_Dxe.inf new file mode 100644 index 00000000000..282221d4d6b --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_4_4/RedfishEvent_V1_4_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_4_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_4_4_Dxe + FILE_GUID = eb6a3373-06fc-4d0e-b828-29d1a00ef2da + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_4_4EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_4_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_4_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_4_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_5_0/Event_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/Event/v1_5_0/Event_V1_5_0_Dxe.c new file mode 100644 index 00000000000..26eba08ff60 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_5_0/Event_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "5", + "0" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_5_0 *EventV1_5_0; + EFI_REDFISH_EVENT_V1_5_0_CS *EventV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_5_0_To_CS (ResoruceRaw, &EventV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_5_0 = (EFI_REDFISH_EVENT_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_5_0)); + if (EventV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_5_0; + EventV1_5_0->Event = EventV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_5_0_JSON (*((EFI_REDFISH_EVENT_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_5_0 *EventV1_5_0; + + EventV1_5_0 = (EFI_REDFISH_EVENT_V1_5_0 *)InterpProp; + DestroyEvent_V1_5_0_CS (EventV1_5_0->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_5_0/RedfishEvent_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_5_0/RedfishEvent_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..e01107bd02e --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_5_0/RedfishEvent_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_5_0_Dxe + FILE_GUID = 501235ce-d30d-4b64-8b65-cf92c66252ae + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_5_1/Event_V1_5_1_Dxe.c b/RedfishClientPkg/Converter/Event/v1_5_1/Event_V1_5_1_Dxe.c new file mode 100644 index 00000000000..b4f881367a7 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_5_1/Event_V1_5_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_5_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "5", + "1" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_5_1 *EventV1_5_1; + EFI_REDFISH_EVENT_V1_5_1_CS *EventV1_5_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_5_1_To_CS (ResoruceRaw, &EventV1_5_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_5_1 = (EFI_REDFISH_EVENT_V1_5_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_5_1)); + if (EventV1_5_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_5_1; + EventV1_5_1->Event = EventV1_5_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_5_1_JSON (*((EFI_REDFISH_EVENT_V1_5_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_5_1 *EventV1_5_1; + + EventV1_5_1 = (EFI_REDFISH_EVENT_V1_5_1 *)InterpProp; + DestroyEvent_V1_5_1_CS (EventV1_5_1->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_5_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_5_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_5_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_5_1/RedfishEvent_V1_5_1_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_5_1/RedfishEvent_V1_5_1_Dxe.inf new file mode 100644 index 00000000000..36491890a9e --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_5_1/RedfishEvent_V1_5_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_5_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_5_1_Dxe + FILE_GUID = 839cb276-0a86-45eb-8cb5-7e18db4b86bd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_5_1EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_5_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_5_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_5_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_5_2/Event_V1_5_2_Dxe.c b/RedfishClientPkg/Converter/Event/v1_5_2/Event_V1_5_2_Dxe.c new file mode 100644 index 00000000000..83352c6a145 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_5_2/Event_V1_5_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_5_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "5", + "2" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_5_2 *EventV1_5_2; + EFI_REDFISH_EVENT_V1_5_2_CS *EventV1_5_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_5_2_To_CS (ResoruceRaw, &EventV1_5_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_5_2 = (EFI_REDFISH_EVENT_V1_5_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_5_2)); + if (EventV1_5_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_5_2; + EventV1_5_2->Event = EventV1_5_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_5_2_JSON (*((EFI_REDFISH_EVENT_V1_5_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_5_2 *EventV1_5_2; + + EventV1_5_2 = (EFI_REDFISH_EVENT_V1_5_2 *)InterpProp; + DestroyEvent_V1_5_2_CS (EventV1_5_2->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_5_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_5_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_5_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_5_2/RedfishEvent_V1_5_2_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_5_2/RedfishEvent_V1_5_2_Dxe.inf new file mode 100644 index 00000000000..b8c2928013e --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_5_2/RedfishEvent_V1_5_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_5_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_5_2_Dxe + FILE_GUID = e08e45b7-e234-44e1-80f9-44a0d7217266 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_5_2EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_5_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_5_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_5_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_6_0/Event_V1_6_0_Dxe.c b/RedfishClientPkg/Converter/Event/v1_6_0/Event_V1_6_0_Dxe.c new file mode 100644 index 00000000000..5443fc40021 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_6_0/Event_V1_6_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_6_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "6", + "0" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_6_0 *EventV1_6_0; + EFI_REDFISH_EVENT_V1_6_0_CS *EventV1_6_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_6_0_To_CS (ResoruceRaw, &EventV1_6_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_6_0 = (EFI_REDFISH_EVENT_V1_6_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_6_0)); + if (EventV1_6_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_6_0; + EventV1_6_0->Event = EventV1_6_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_6_0_JSON (*((EFI_REDFISH_EVENT_V1_6_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_6_0 *EventV1_6_0; + + EventV1_6_0 = (EFI_REDFISH_EVENT_V1_6_0 *)InterpProp; + DestroyEvent_V1_6_0_CS (EventV1_6_0->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_6_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_6_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_6_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_6_0/RedfishEvent_V1_6_0_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_6_0/RedfishEvent_V1_6_0_Dxe.inf new file mode 100644 index 00000000000..634738ab852 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_6_0/RedfishEvent_V1_6_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_6_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_6_0_Dxe + FILE_GUID = f2458fe9-e8b5-497c-8f41-7ee442fc32ca + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_6_0EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_6_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_6_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_6_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Event/v1_6_1/Event_V1_6_1_Dxe.c b/RedfishClientPkg/Converter/Event/v1_6_1/Event_V1_6_1_Dxe.c new file mode 100644 index 00000000000..334191e3d8a --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_6_1/Event_V1_6_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Event.v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Event"; +BOOLEAN IsRevisonController = TRUE; + +// Support Event V1_6_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Event", + "1", + "6", + "1" + }, + "Event" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENT_V1_6_1 *EventV1_6_1; + EFI_REDFISH_EVENT_V1_6_1_CS *EventV1_6_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Event") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Event_V1_6_1_To_CS (ResoruceRaw, &EventV1_6_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventV1_6_1 = (EFI_REDFISH_EVENT_V1_6_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENT_V1_6_1)); + if (EventV1_6_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventV1_6_1; + EventV1_6_1->Event = EventV1_6_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Event"), "Event"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Event")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Event"), "Event"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Event_V1_6_1_JSON (*((EFI_REDFISH_EVENT_V1_6_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENT_V1_6_1 *EventV1_6_1; + + EventV1_6_1 = (EFI_REDFISH_EVENT_V1_6_1 *)InterpProp; + DestroyEvent_V1_6_1_CS (EventV1_6_1->Event); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEvent_V1_6_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_6_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventToStructWrapper, + EventToJson, + EventDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEvent_V1_6_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Event/v1_6_1/RedfishEvent_V1_6_1_Dxe.inf b/RedfishClientPkg/Converter/Event/v1_6_1/RedfishEvent_V1_6_1_Dxe.inf new file mode 100644 index 00000000000..6d312f1bc65 --- /dev/null +++ b/RedfishClientPkg/Converter/Event/v1_6_1/RedfishEvent_V1_6_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Event.v1_6_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEvent_V1_6_1_Dxe + FILE_GUID = 79d640f2-43e2-4302-bf69-d969325cacd2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEvent_V1_6_1EntryPoint + UNLOAD_IMAGE = RedfishEvent_V1_6_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Event_V1_6_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventV1_6_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_0_0/EventDestination_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_0_0/EventDestination_V1_0_0_Dxe.c new file mode 100644 index 00000000000..c63fe499001 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_0_0/EventDestination_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "0", + "0" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_0_0 *EventDestinationV1_0_0; + EFI_REDFISH_EVENTDESTINATION_V1_0_0_CS *EventDestinationV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_0_0_To_CS (ResoruceRaw, &EventDestinationV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_0_0 = (EFI_REDFISH_EVENTDESTINATION_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_0_0)); + if (EventDestinationV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_0_0; + EventDestinationV1_0_0->EventDestination = EventDestinationV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_0_0_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_0_0 *EventDestinationV1_0_0; + + EventDestinationV1_0_0 = (EFI_REDFISH_EVENTDESTINATION_V1_0_0 *)InterpProp; + DestroyEventDestination_V1_0_0_CS (EventDestinationV1_0_0->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_0_0/RedfishEventDestination_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_0_0/RedfishEventDestination_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..586c6e7950d --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_0_0/RedfishEventDestination_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_0_0_Dxe + FILE_GUID = 558de883-90f3-4b4e-8ec4-acef4d05c26e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_0_2/EventDestination_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_0_2/EventDestination_V1_0_2_Dxe.c new file mode 100644 index 00000000000..2fbcec3d29b --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_0_2/EventDestination_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "0", + "2" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_0_2 *EventDestinationV1_0_2; + EFI_REDFISH_EVENTDESTINATION_V1_0_2_CS *EventDestinationV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_0_2_To_CS (ResoruceRaw, &EventDestinationV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_0_2 = (EFI_REDFISH_EVENTDESTINATION_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_0_2)); + if (EventDestinationV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_0_2; + EventDestinationV1_0_2->EventDestination = EventDestinationV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_0_2_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_0_2 *EventDestinationV1_0_2; + + EventDestinationV1_0_2 = (EFI_REDFISH_EVENTDESTINATION_V1_0_2 *)InterpProp; + DestroyEventDestination_V1_0_2_CS (EventDestinationV1_0_2->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_0_2/RedfishEventDestination_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_0_2/RedfishEventDestination_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..eda23eb65ce --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_0_2/RedfishEventDestination_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_0_2_Dxe + FILE_GUID = 1c44a75c-bed4-4a07-a020-a53412df0903 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_0_3/EventDestination_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_0_3/EventDestination_V1_0_3_Dxe.c new file mode 100644 index 00000000000..39723f57f13 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_0_3/EventDestination_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "0", + "3" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_0_3 *EventDestinationV1_0_3; + EFI_REDFISH_EVENTDESTINATION_V1_0_3_CS *EventDestinationV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_0_3_To_CS (ResoruceRaw, &EventDestinationV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_0_3 = (EFI_REDFISH_EVENTDESTINATION_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_0_3)); + if (EventDestinationV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_0_3; + EventDestinationV1_0_3->EventDestination = EventDestinationV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_0_3_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_0_3 *EventDestinationV1_0_3; + + EventDestinationV1_0_3 = (EFI_REDFISH_EVENTDESTINATION_V1_0_3 *)InterpProp; + DestroyEventDestination_V1_0_3_CS (EventDestinationV1_0_3->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_0_3/RedfishEventDestination_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_0_3/RedfishEventDestination_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..a9164b375d7 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_0_3/RedfishEventDestination_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_0_3_Dxe + FILE_GUID = a5ea3608-184f-4544-b043-d42fd4dc5998 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_0_4/EventDestination_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_0_4/EventDestination_V1_0_4_Dxe.c new file mode 100644 index 00000000000..1a9e804e897 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_0_4/EventDestination_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "0", + "4" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_0_4 *EventDestinationV1_0_4; + EFI_REDFISH_EVENTDESTINATION_V1_0_4_CS *EventDestinationV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_0_4_To_CS (ResoruceRaw, &EventDestinationV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_0_4 = (EFI_REDFISH_EVENTDESTINATION_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_0_4)); + if (EventDestinationV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_0_4; + EventDestinationV1_0_4->EventDestination = EventDestinationV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_0_4_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_0_4 *EventDestinationV1_0_4; + + EventDestinationV1_0_4 = (EFI_REDFISH_EVENTDESTINATION_V1_0_4 *)InterpProp; + DestroyEventDestination_V1_0_4_CS (EventDestinationV1_0_4->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_0_4/RedfishEventDestination_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_0_4/RedfishEventDestination_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..201ef84cb93 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_0_4/RedfishEventDestination_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_0_4_Dxe + FILE_GUID = eb5c26c4-2f50-44f5-83e5-5e87d4506281 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_0_5/EventDestination_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_0_5/EventDestination_V1_0_5_Dxe.c new file mode 100644 index 00000000000..0f3f7456ba5 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_0_5/EventDestination_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "0", + "5" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_0_5 *EventDestinationV1_0_5; + EFI_REDFISH_EVENTDESTINATION_V1_0_5_CS *EventDestinationV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_0_5_To_CS (ResoruceRaw, &EventDestinationV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_0_5 = (EFI_REDFISH_EVENTDESTINATION_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_0_5)); + if (EventDestinationV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_0_5; + EventDestinationV1_0_5->EventDestination = EventDestinationV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_0_5_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_0_5 *EventDestinationV1_0_5; + + EventDestinationV1_0_5 = (EFI_REDFISH_EVENTDESTINATION_V1_0_5 *)InterpProp; + DestroyEventDestination_V1_0_5_CS (EventDestinationV1_0_5->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_0_5/RedfishEventDestination_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_0_5/RedfishEventDestination_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..8ab71742689 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_0_5/RedfishEventDestination_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_0_5_Dxe + FILE_GUID = e585001c-43a8-4470-8bee-101bd64c9da1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_0_6/EventDestination_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_0_6/EventDestination_V1_0_6_Dxe.c new file mode 100644 index 00000000000..31c8b19b20f --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_0_6/EventDestination_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "0", + "6" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_0_6 *EventDestinationV1_0_6; + EFI_REDFISH_EVENTDESTINATION_V1_0_6_CS *EventDestinationV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_0_6_To_CS (ResoruceRaw, &EventDestinationV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_0_6 = (EFI_REDFISH_EVENTDESTINATION_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_0_6)); + if (EventDestinationV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_0_6; + EventDestinationV1_0_6->EventDestination = EventDestinationV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_0_6_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_0_6 *EventDestinationV1_0_6; + + EventDestinationV1_0_6 = (EFI_REDFISH_EVENTDESTINATION_V1_0_6 *)InterpProp; + DestroyEventDestination_V1_0_6_CS (EventDestinationV1_0_6->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_0_6/RedfishEventDestination_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_0_6/RedfishEventDestination_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..e92f0196768 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_0_6/RedfishEventDestination_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_0_6_Dxe + FILE_GUID = 1d0f5b27-f90d-43a0-a263-9edae2b6bde5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_0_7/EventDestination_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_0_7/EventDestination_V1_0_7_Dxe.c new file mode 100644 index 00000000000..7e957461bb7 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_0_7/EventDestination_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "0", + "7" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_0_7 *EventDestinationV1_0_7; + EFI_REDFISH_EVENTDESTINATION_V1_0_7_CS *EventDestinationV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_0_7_To_CS (ResoruceRaw, &EventDestinationV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_0_7 = (EFI_REDFISH_EVENTDESTINATION_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_0_7)); + if (EventDestinationV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_0_7; + EventDestinationV1_0_7->EventDestination = EventDestinationV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_0_7_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_0_7 *EventDestinationV1_0_7; + + EventDestinationV1_0_7 = (EFI_REDFISH_EVENTDESTINATION_V1_0_7 *)InterpProp; + DestroyEventDestination_V1_0_7_CS (EventDestinationV1_0_7->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_0_7/RedfishEventDestination_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_0_7/RedfishEventDestination_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..aea3c426fdb --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_0_7/RedfishEventDestination_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_0_7_Dxe + FILE_GUID = d3302424-d841-4914-98af-696c7b60115b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_0_8/EventDestination_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_0_8/EventDestination_V1_0_8_Dxe.c new file mode 100644 index 00000000000..fa7fc088c11 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_0_8/EventDestination_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "0", + "8" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_0_8 *EventDestinationV1_0_8; + EFI_REDFISH_EVENTDESTINATION_V1_0_8_CS *EventDestinationV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_0_8_To_CS (ResoruceRaw, &EventDestinationV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_0_8 = (EFI_REDFISH_EVENTDESTINATION_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_0_8)); + if (EventDestinationV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_0_8; + EventDestinationV1_0_8->EventDestination = EventDestinationV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_0_8_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_0_8 *EventDestinationV1_0_8; + + EventDestinationV1_0_8 = (EFI_REDFISH_EVENTDESTINATION_V1_0_8 *)InterpProp; + DestroyEventDestination_V1_0_8_CS (EventDestinationV1_0_8->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_0_8/RedfishEventDestination_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_0_8/RedfishEventDestination_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..a3b5a3cbb49 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_0_8/RedfishEventDestination_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_0_8_Dxe + FILE_GUID = 71db2533-b1d6-4384-8266-5092b04d8150 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_0_9/EventDestination_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_0_9/EventDestination_V1_0_9_Dxe.c new file mode 100644 index 00000000000..ee332e64ddd --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_0_9/EventDestination_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "0", + "9" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_0_9 *EventDestinationV1_0_9; + EFI_REDFISH_EVENTDESTINATION_V1_0_9_CS *EventDestinationV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_0_9_To_CS (ResoruceRaw, &EventDestinationV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_0_9 = (EFI_REDFISH_EVENTDESTINATION_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_0_9)); + if (EventDestinationV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_0_9; + EventDestinationV1_0_9->EventDestination = EventDestinationV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_0_9_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_0_9 *EventDestinationV1_0_9; + + EventDestinationV1_0_9 = (EFI_REDFISH_EVENTDESTINATION_V1_0_9 *)InterpProp; + DestroyEventDestination_V1_0_9_CS (EventDestinationV1_0_9->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_0_9/RedfishEventDestination_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_0_9/RedfishEventDestination_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..7a6793748c2 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_0_9/RedfishEventDestination_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_0_9_Dxe + FILE_GUID = 836d6db2-9fa7-46f9-ae8f-62764900a38b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_10_0/EventDestination_V1_10_0_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_10_0/EventDestination_V1_10_0_Dxe.c new file mode 100644 index 00000000000..5a1f14e7a80 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_10_0/EventDestination_V1_10_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_10_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_10_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "10", + "0" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_10_0 *EventDestinationV1_10_0; + EFI_REDFISH_EVENTDESTINATION_V1_10_0_CS *EventDestinationV1_10_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_10_0_To_CS (ResoruceRaw, &EventDestinationV1_10_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_10_0 = (EFI_REDFISH_EVENTDESTINATION_V1_10_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_10_0)); + if (EventDestinationV1_10_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_10_0; + EventDestinationV1_10_0->EventDestination = EventDestinationV1_10_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "10"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_10_0_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_10_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_10_0 *EventDestinationV1_10_0; + + EventDestinationV1_10_0 = (EFI_REDFISH_EVENTDESTINATION_V1_10_0 *)InterpProp; + DestroyEventDestination_V1_10_0_CS (EventDestinationV1_10_0->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_10_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_10_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_10_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_10_0/RedfishEventDestination_V1_10_0_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_10_0/RedfishEventDestination_V1_10_0_Dxe.inf new file mode 100644 index 00000000000..e5bce62542c --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_10_0/RedfishEventDestination_V1_10_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_10_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_10_0_Dxe + FILE_GUID = 39f86c4c-308c-43be-a84d-d73278143950 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_10_0EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_10_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_10_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_10_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_1_0/EventDestination_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_1_0/EventDestination_V1_1_0_Dxe.c new file mode 100644 index 00000000000..00fc1b38b15 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_1_0/EventDestination_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "1", + "0" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_1_0 *EventDestinationV1_1_0; + EFI_REDFISH_EVENTDESTINATION_V1_1_0_CS *EventDestinationV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_1_0_To_CS (ResoruceRaw, &EventDestinationV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_1_0 = (EFI_REDFISH_EVENTDESTINATION_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_1_0)); + if (EventDestinationV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_1_0; + EventDestinationV1_1_0->EventDestination = EventDestinationV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_1_0_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_1_0 *EventDestinationV1_1_0; + + EventDestinationV1_1_0 = (EFI_REDFISH_EVENTDESTINATION_V1_1_0 *)InterpProp; + DestroyEventDestination_V1_1_0_CS (EventDestinationV1_1_0->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_1_0/RedfishEventDestination_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_1_0/RedfishEventDestination_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..b8fd7974e74 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_1_0/RedfishEventDestination_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_1_0_Dxe + FILE_GUID = 4a5b1618-5693-4902-905d-143699b0186d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_1_1/EventDestination_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_1_1/EventDestination_V1_1_1_Dxe.c new file mode 100644 index 00000000000..145dcd58b51 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_1_1/EventDestination_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "1", + "1" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_1_1 *EventDestinationV1_1_1; + EFI_REDFISH_EVENTDESTINATION_V1_1_1_CS *EventDestinationV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_1_1_To_CS (ResoruceRaw, &EventDestinationV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_1_1 = (EFI_REDFISH_EVENTDESTINATION_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_1_1)); + if (EventDestinationV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_1_1; + EventDestinationV1_1_1->EventDestination = EventDestinationV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_1_1_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_1_1 *EventDestinationV1_1_1; + + EventDestinationV1_1_1 = (EFI_REDFISH_EVENTDESTINATION_V1_1_1 *)InterpProp; + DestroyEventDestination_V1_1_1_CS (EventDestinationV1_1_1->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_1_1/RedfishEventDestination_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_1_1/RedfishEventDestination_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..11e8e23e148 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_1_1/RedfishEventDestination_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_1_1_Dxe + FILE_GUID = bfd04576-d8bd-4cfc-8d48-3d3f8c3b9969 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_1_2/EventDestination_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_1_2/EventDestination_V1_1_2_Dxe.c new file mode 100644 index 00000000000..5898b745f78 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_1_2/EventDestination_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "1", + "2" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_1_2 *EventDestinationV1_1_2; + EFI_REDFISH_EVENTDESTINATION_V1_1_2_CS *EventDestinationV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_1_2_To_CS (ResoruceRaw, &EventDestinationV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_1_2 = (EFI_REDFISH_EVENTDESTINATION_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_1_2)); + if (EventDestinationV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_1_2; + EventDestinationV1_1_2->EventDestination = EventDestinationV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_1_2_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_1_2 *EventDestinationV1_1_2; + + EventDestinationV1_1_2 = (EFI_REDFISH_EVENTDESTINATION_V1_1_2 *)InterpProp; + DestroyEventDestination_V1_1_2_CS (EventDestinationV1_1_2->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_1_2/RedfishEventDestination_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_1_2/RedfishEventDestination_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..dda30ccb4da --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_1_2/RedfishEventDestination_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_1_2_Dxe + FILE_GUID = caa51b87-6ea8-4c1a-86dd-01fcf4c978cc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_1_3/EventDestination_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_1_3/EventDestination_V1_1_3_Dxe.c new file mode 100644 index 00000000000..cbdfe60b0d8 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_1_3/EventDestination_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "1", + "3" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_1_3 *EventDestinationV1_1_3; + EFI_REDFISH_EVENTDESTINATION_V1_1_3_CS *EventDestinationV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_1_3_To_CS (ResoruceRaw, &EventDestinationV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_1_3 = (EFI_REDFISH_EVENTDESTINATION_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_1_3)); + if (EventDestinationV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_1_3; + EventDestinationV1_1_3->EventDestination = EventDestinationV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_1_3_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_1_3 *EventDestinationV1_1_3; + + EventDestinationV1_1_3 = (EFI_REDFISH_EVENTDESTINATION_V1_1_3 *)InterpProp; + DestroyEventDestination_V1_1_3_CS (EventDestinationV1_1_3->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_1_3/RedfishEventDestination_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_1_3/RedfishEventDestination_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..07049cc82d4 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_1_3/RedfishEventDestination_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_1_3_Dxe + FILE_GUID = 38dbe110-d488-4229-8a9f-08e404d11611 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_1_4/EventDestination_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_1_4/EventDestination_V1_1_4_Dxe.c new file mode 100644 index 00000000000..c703d646a52 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_1_4/EventDestination_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "1", + "4" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_1_4 *EventDestinationV1_1_4; + EFI_REDFISH_EVENTDESTINATION_V1_1_4_CS *EventDestinationV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_1_4_To_CS (ResoruceRaw, &EventDestinationV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_1_4 = (EFI_REDFISH_EVENTDESTINATION_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_1_4)); + if (EventDestinationV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_1_4; + EventDestinationV1_1_4->EventDestination = EventDestinationV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_1_4_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_1_4 *EventDestinationV1_1_4; + + EventDestinationV1_1_4 = (EFI_REDFISH_EVENTDESTINATION_V1_1_4 *)InterpProp; + DestroyEventDestination_V1_1_4_CS (EventDestinationV1_1_4->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_1_4/RedfishEventDestination_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_1_4/RedfishEventDestination_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..f32ca24682c --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_1_4/RedfishEventDestination_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_1_4_Dxe + FILE_GUID = e84e668e-f3e1-4c48-8b50-654d6e32c433 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_1_5/EventDestination_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_1_5/EventDestination_V1_1_5_Dxe.c new file mode 100644 index 00000000000..7f854074f43 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_1_5/EventDestination_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "1", + "5" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_1_5 *EventDestinationV1_1_5; + EFI_REDFISH_EVENTDESTINATION_V1_1_5_CS *EventDestinationV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_1_5_To_CS (ResoruceRaw, &EventDestinationV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_1_5 = (EFI_REDFISH_EVENTDESTINATION_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_1_5)); + if (EventDestinationV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_1_5; + EventDestinationV1_1_5->EventDestination = EventDestinationV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_1_5_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_1_5 *EventDestinationV1_1_5; + + EventDestinationV1_1_5 = (EFI_REDFISH_EVENTDESTINATION_V1_1_5 *)InterpProp; + DestroyEventDestination_V1_1_5_CS (EventDestinationV1_1_5->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_1_5/RedfishEventDestination_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_1_5/RedfishEventDestination_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..707653d4a35 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_1_5/RedfishEventDestination_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_1_5_Dxe + FILE_GUID = 57218039-eaa0-40af-b4e1-eeb9f50db388 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_1_6/EventDestination_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_1_6/EventDestination_V1_1_6_Dxe.c new file mode 100644 index 00000000000..e3cf048d4cc --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_1_6/EventDestination_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "1", + "6" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_1_6 *EventDestinationV1_1_6; + EFI_REDFISH_EVENTDESTINATION_V1_1_6_CS *EventDestinationV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_1_6_To_CS (ResoruceRaw, &EventDestinationV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_1_6 = (EFI_REDFISH_EVENTDESTINATION_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_1_6)); + if (EventDestinationV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_1_6; + EventDestinationV1_1_6->EventDestination = EventDestinationV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_1_6_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_1_6 *EventDestinationV1_1_6; + + EventDestinationV1_1_6 = (EFI_REDFISH_EVENTDESTINATION_V1_1_6 *)InterpProp; + DestroyEventDestination_V1_1_6_CS (EventDestinationV1_1_6->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_1_6/RedfishEventDestination_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_1_6/RedfishEventDestination_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..06f833f1dc1 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_1_6/RedfishEventDestination_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_1_6_Dxe + FILE_GUID = b68e491a-bbf9-462d-9215-8a48115efe6f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_1_7/EventDestination_V1_1_7_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_1_7/EventDestination_V1_1_7_Dxe.c new file mode 100644 index 00000000000..d2505626b71 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_1_7/EventDestination_V1_1_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_1_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "1", + "7" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_1_7 *EventDestinationV1_1_7; + EFI_REDFISH_EVENTDESTINATION_V1_1_7_CS *EventDestinationV1_1_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_1_7_To_CS (ResoruceRaw, &EventDestinationV1_1_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_1_7 = (EFI_REDFISH_EVENTDESTINATION_V1_1_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_1_7)); + if (EventDestinationV1_1_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_1_7; + EventDestinationV1_1_7->EventDestination = EventDestinationV1_1_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_1_7_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_1_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_1_7 *EventDestinationV1_1_7; + + EventDestinationV1_1_7 = (EFI_REDFISH_EVENTDESTINATION_V1_1_7 *)InterpProp; + DestroyEventDestination_V1_1_7_CS (EventDestinationV1_1_7->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_1_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_1_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_1_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_1_7/RedfishEventDestination_V1_1_7_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_1_7/RedfishEventDestination_V1_1_7_Dxe.inf new file mode 100644 index 00000000000..622d018571a --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_1_7/RedfishEventDestination_V1_1_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_1_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_1_7_Dxe + FILE_GUID = 18bdf0bf-eb2f-4d47-86ca-74d28e813f5e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_1_7EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_1_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_1_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_1_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_1_8/EventDestination_V1_1_8_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_1_8/EventDestination_V1_1_8_Dxe.c new file mode 100644 index 00000000000..a6017ec559a --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_1_8/EventDestination_V1_1_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_1_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "1", + "8" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_1_8 *EventDestinationV1_1_8; + EFI_REDFISH_EVENTDESTINATION_V1_1_8_CS *EventDestinationV1_1_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_1_8_To_CS (ResoruceRaw, &EventDestinationV1_1_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_1_8 = (EFI_REDFISH_EVENTDESTINATION_V1_1_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_1_8)); + if (EventDestinationV1_1_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_1_8; + EventDestinationV1_1_8->EventDestination = EventDestinationV1_1_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_1_8_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_1_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_1_8 *EventDestinationV1_1_8; + + EventDestinationV1_1_8 = (EFI_REDFISH_EVENTDESTINATION_V1_1_8 *)InterpProp; + DestroyEventDestination_V1_1_8_CS (EventDestinationV1_1_8->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_1_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_1_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_1_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_1_8/RedfishEventDestination_V1_1_8_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_1_8/RedfishEventDestination_V1_1_8_Dxe.inf new file mode 100644 index 00000000000..d167f686c40 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_1_8/RedfishEventDestination_V1_1_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_1_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_1_8_Dxe + FILE_GUID = 06b5520f-0681-47fa-a141-081a47624fbb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_1_8EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_1_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_1_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_1_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_2_0/EventDestination_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_2_0/EventDestination_V1_2_0_Dxe.c new file mode 100644 index 00000000000..2d03d88154e --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_2_0/EventDestination_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "2", + "0" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_2_0 *EventDestinationV1_2_0; + EFI_REDFISH_EVENTDESTINATION_V1_2_0_CS *EventDestinationV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_2_0_To_CS (ResoruceRaw, &EventDestinationV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_2_0 = (EFI_REDFISH_EVENTDESTINATION_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_2_0)); + if (EventDestinationV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_2_0; + EventDestinationV1_2_0->EventDestination = EventDestinationV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_2_0_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_2_0 *EventDestinationV1_2_0; + + EventDestinationV1_2_0 = (EFI_REDFISH_EVENTDESTINATION_V1_2_0 *)InterpProp; + DestroyEventDestination_V1_2_0_CS (EventDestinationV1_2_0->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_2_0/RedfishEventDestination_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_2_0/RedfishEventDestination_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..d45f9223746 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_2_0/RedfishEventDestination_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_2_0_Dxe + FILE_GUID = 900a0912-1b9c-44bd-83a1-55146bfe5c0b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_2_1/EventDestination_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_2_1/EventDestination_V1_2_1_Dxe.c new file mode 100644 index 00000000000..cee1af12d68 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_2_1/EventDestination_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "2", + "1" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_2_1 *EventDestinationV1_2_1; + EFI_REDFISH_EVENTDESTINATION_V1_2_1_CS *EventDestinationV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_2_1_To_CS (ResoruceRaw, &EventDestinationV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_2_1 = (EFI_REDFISH_EVENTDESTINATION_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_2_1)); + if (EventDestinationV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_2_1; + EventDestinationV1_2_1->EventDestination = EventDestinationV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_2_1_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_2_1 *EventDestinationV1_2_1; + + EventDestinationV1_2_1 = (EFI_REDFISH_EVENTDESTINATION_V1_2_1 *)InterpProp; + DestroyEventDestination_V1_2_1_CS (EventDestinationV1_2_1->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_2_1/RedfishEventDestination_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_2_1/RedfishEventDestination_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..9dfc15e2ca8 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_2_1/RedfishEventDestination_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_2_1_Dxe + FILE_GUID = aa25bb37-69d4-4831-8c9c-b910bfa012ec + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_2_2/EventDestination_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_2_2/EventDestination_V1_2_2_Dxe.c new file mode 100644 index 00000000000..02fa2fefd33 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_2_2/EventDestination_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "2", + "2" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_2_2 *EventDestinationV1_2_2; + EFI_REDFISH_EVENTDESTINATION_V1_2_2_CS *EventDestinationV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_2_2_To_CS (ResoruceRaw, &EventDestinationV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_2_2 = (EFI_REDFISH_EVENTDESTINATION_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_2_2)); + if (EventDestinationV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_2_2; + EventDestinationV1_2_2->EventDestination = EventDestinationV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_2_2_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_2_2 *EventDestinationV1_2_2; + + EventDestinationV1_2_2 = (EFI_REDFISH_EVENTDESTINATION_V1_2_2 *)InterpProp; + DestroyEventDestination_V1_2_2_CS (EventDestinationV1_2_2->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_2_2/RedfishEventDestination_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_2_2/RedfishEventDestination_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..bb8043d67ca --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_2_2/RedfishEventDestination_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_2_2_Dxe + FILE_GUID = aaa56698-ef88-4ff5-ab6a-859468ea03b1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_2_3/EventDestination_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_2_3/EventDestination_V1_2_3_Dxe.c new file mode 100644 index 00000000000..12352c8078e --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_2_3/EventDestination_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "2", + "3" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_2_3 *EventDestinationV1_2_3; + EFI_REDFISH_EVENTDESTINATION_V1_2_3_CS *EventDestinationV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_2_3_To_CS (ResoruceRaw, &EventDestinationV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_2_3 = (EFI_REDFISH_EVENTDESTINATION_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_2_3)); + if (EventDestinationV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_2_3; + EventDestinationV1_2_3->EventDestination = EventDestinationV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_2_3_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_2_3 *EventDestinationV1_2_3; + + EventDestinationV1_2_3 = (EFI_REDFISH_EVENTDESTINATION_V1_2_3 *)InterpProp; + DestroyEventDestination_V1_2_3_CS (EventDestinationV1_2_3->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_2_3/RedfishEventDestination_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_2_3/RedfishEventDestination_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..c72af44a6b1 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_2_3/RedfishEventDestination_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_2_3_Dxe + FILE_GUID = faed8e20-ca03-4489-8c72-854a000fdc40 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_2_4/EventDestination_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_2_4/EventDestination_V1_2_4_Dxe.c new file mode 100644 index 00000000000..e1082d0ee7e --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_2_4/EventDestination_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "2", + "4" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_2_4 *EventDestinationV1_2_4; + EFI_REDFISH_EVENTDESTINATION_V1_2_4_CS *EventDestinationV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_2_4_To_CS (ResoruceRaw, &EventDestinationV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_2_4 = (EFI_REDFISH_EVENTDESTINATION_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_2_4)); + if (EventDestinationV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_2_4; + EventDestinationV1_2_4->EventDestination = EventDestinationV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_2_4_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_2_4 *EventDestinationV1_2_4; + + EventDestinationV1_2_4 = (EFI_REDFISH_EVENTDESTINATION_V1_2_4 *)InterpProp; + DestroyEventDestination_V1_2_4_CS (EventDestinationV1_2_4->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_2_4/RedfishEventDestination_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_2_4/RedfishEventDestination_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..ff98296ade5 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_2_4/RedfishEventDestination_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_2_4_Dxe + FILE_GUID = 3fc47f55-f49c-4fd4-9314-f4381d2d2903 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_2_5/EventDestination_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_2_5/EventDestination_V1_2_5_Dxe.c new file mode 100644 index 00000000000..c15f5ce06a1 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_2_5/EventDestination_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "2", + "5" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_2_5 *EventDestinationV1_2_5; + EFI_REDFISH_EVENTDESTINATION_V1_2_5_CS *EventDestinationV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_2_5_To_CS (ResoruceRaw, &EventDestinationV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_2_5 = (EFI_REDFISH_EVENTDESTINATION_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_2_5)); + if (EventDestinationV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_2_5; + EventDestinationV1_2_5->EventDestination = EventDestinationV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_2_5_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_2_5 *EventDestinationV1_2_5; + + EventDestinationV1_2_5 = (EFI_REDFISH_EVENTDESTINATION_V1_2_5 *)InterpProp; + DestroyEventDestination_V1_2_5_CS (EventDestinationV1_2_5->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_2_5/RedfishEventDestination_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_2_5/RedfishEventDestination_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..34a2bd79e75 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_2_5/RedfishEventDestination_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_2_5_Dxe + FILE_GUID = ba2fecdd-3688-48db-ad8d-5e2552aa3d0e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_2_6/EventDestination_V1_2_6_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_2_6/EventDestination_V1_2_6_Dxe.c new file mode 100644 index 00000000000..638a9fc8fd0 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_2_6/EventDestination_V1_2_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_2_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "2", + "6" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_2_6 *EventDestinationV1_2_6; + EFI_REDFISH_EVENTDESTINATION_V1_2_6_CS *EventDestinationV1_2_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_2_6_To_CS (ResoruceRaw, &EventDestinationV1_2_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_2_6 = (EFI_REDFISH_EVENTDESTINATION_V1_2_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_2_6)); + if (EventDestinationV1_2_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_2_6; + EventDestinationV1_2_6->EventDestination = EventDestinationV1_2_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_2_6_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_2_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_2_6 *EventDestinationV1_2_6; + + EventDestinationV1_2_6 = (EFI_REDFISH_EVENTDESTINATION_V1_2_6 *)InterpProp; + DestroyEventDestination_V1_2_6_CS (EventDestinationV1_2_6->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_2_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_2_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_2_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_2_6/RedfishEventDestination_V1_2_6_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_2_6/RedfishEventDestination_V1_2_6_Dxe.inf new file mode 100644 index 00000000000..9ea27f24811 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_2_6/RedfishEventDestination_V1_2_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_2_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_2_6_Dxe + FILE_GUID = 6291916d-a4a6-453b-8e6f-83b5aff6c772 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_2_6EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_2_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_2_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_2_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_3_0/EventDestination_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_3_0/EventDestination_V1_3_0_Dxe.c new file mode 100644 index 00000000000..53461e40a8d --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_3_0/EventDestination_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "3", + "0" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_3_0 *EventDestinationV1_3_0; + EFI_REDFISH_EVENTDESTINATION_V1_3_0_CS *EventDestinationV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_3_0_To_CS (ResoruceRaw, &EventDestinationV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_3_0 = (EFI_REDFISH_EVENTDESTINATION_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_3_0)); + if (EventDestinationV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_3_0; + EventDestinationV1_3_0->EventDestination = EventDestinationV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_3_0_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_3_0 *EventDestinationV1_3_0; + + EventDestinationV1_3_0 = (EFI_REDFISH_EVENTDESTINATION_V1_3_0 *)InterpProp; + DestroyEventDestination_V1_3_0_CS (EventDestinationV1_3_0->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_3_0/RedfishEventDestination_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_3_0/RedfishEventDestination_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..dc5bf1fe063 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_3_0/RedfishEventDestination_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_3_0_Dxe + FILE_GUID = 59302ba5-83b2-43d4-8c29-db88b704cdef + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_3_1/EventDestination_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_3_1/EventDestination_V1_3_1_Dxe.c new file mode 100644 index 00000000000..feeabb1520e --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_3_1/EventDestination_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "3", + "1" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_3_1 *EventDestinationV1_3_1; + EFI_REDFISH_EVENTDESTINATION_V1_3_1_CS *EventDestinationV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_3_1_To_CS (ResoruceRaw, &EventDestinationV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_3_1 = (EFI_REDFISH_EVENTDESTINATION_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_3_1)); + if (EventDestinationV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_3_1; + EventDestinationV1_3_1->EventDestination = EventDestinationV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_3_1_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_3_1 *EventDestinationV1_3_1; + + EventDestinationV1_3_1 = (EFI_REDFISH_EVENTDESTINATION_V1_3_1 *)InterpProp; + DestroyEventDestination_V1_3_1_CS (EventDestinationV1_3_1->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_3_1/RedfishEventDestination_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_3_1/RedfishEventDestination_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..c9c570afcfb --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_3_1/RedfishEventDestination_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_3_1_Dxe + FILE_GUID = 8d1f0f73-05c1-4395-816c-9482210d0e68 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_3_2/EventDestination_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_3_2/EventDestination_V1_3_2_Dxe.c new file mode 100644 index 00000000000..70880ea1eb6 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_3_2/EventDestination_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "3", + "2" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_3_2 *EventDestinationV1_3_2; + EFI_REDFISH_EVENTDESTINATION_V1_3_2_CS *EventDestinationV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_3_2_To_CS (ResoruceRaw, &EventDestinationV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_3_2 = (EFI_REDFISH_EVENTDESTINATION_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_3_2)); + if (EventDestinationV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_3_2; + EventDestinationV1_3_2->EventDestination = EventDestinationV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_3_2_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_3_2 *EventDestinationV1_3_2; + + EventDestinationV1_3_2 = (EFI_REDFISH_EVENTDESTINATION_V1_3_2 *)InterpProp; + DestroyEventDestination_V1_3_2_CS (EventDestinationV1_3_2->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_3_2/RedfishEventDestination_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_3_2/RedfishEventDestination_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..337b67ce02f --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_3_2/RedfishEventDestination_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_3_2_Dxe + FILE_GUID = 8fa6733f-23f6-456f-a54e-f1a2d4a055bb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_3_3/EventDestination_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_3_3/EventDestination_V1_3_3_Dxe.c new file mode 100644 index 00000000000..4eccc333dcd --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_3_3/EventDestination_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "3", + "3" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_3_3 *EventDestinationV1_3_3; + EFI_REDFISH_EVENTDESTINATION_V1_3_3_CS *EventDestinationV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_3_3_To_CS (ResoruceRaw, &EventDestinationV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_3_3 = (EFI_REDFISH_EVENTDESTINATION_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_3_3)); + if (EventDestinationV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_3_3; + EventDestinationV1_3_3->EventDestination = EventDestinationV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_3_3_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_3_3 *EventDestinationV1_3_3; + + EventDestinationV1_3_3 = (EFI_REDFISH_EVENTDESTINATION_V1_3_3 *)InterpProp; + DestroyEventDestination_V1_3_3_CS (EventDestinationV1_3_3->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_3_3/RedfishEventDestination_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_3_3/RedfishEventDestination_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..dd6289a071e --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_3_3/RedfishEventDestination_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_3_3_Dxe + FILE_GUID = c05b56e3-97ac-4975-9440-806ee6ec7aa9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_3_4/EventDestination_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_3_4/EventDestination_V1_3_4_Dxe.c new file mode 100644 index 00000000000..ccc22528e77 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_3_4/EventDestination_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "3", + "4" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_3_4 *EventDestinationV1_3_4; + EFI_REDFISH_EVENTDESTINATION_V1_3_4_CS *EventDestinationV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_3_4_To_CS (ResoruceRaw, &EventDestinationV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_3_4 = (EFI_REDFISH_EVENTDESTINATION_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_3_4)); + if (EventDestinationV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_3_4; + EventDestinationV1_3_4->EventDestination = EventDestinationV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_3_4_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_3_4 *EventDestinationV1_3_4; + + EventDestinationV1_3_4 = (EFI_REDFISH_EVENTDESTINATION_V1_3_4 *)InterpProp; + DestroyEventDestination_V1_3_4_CS (EventDestinationV1_3_4->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_3_4/RedfishEventDestination_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_3_4/RedfishEventDestination_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..9119a598fe8 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_3_4/RedfishEventDestination_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_3_4_Dxe + FILE_GUID = 4b56d16e-283f-4200-bf0c-f928bf0421aa + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_4_0/EventDestination_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_4_0/EventDestination_V1_4_0_Dxe.c new file mode 100644 index 00000000000..916219e2403 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_4_0/EventDestination_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "4", + "0" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_4_0 *EventDestinationV1_4_0; + EFI_REDFISH_EVENTDESTINATION_V1_4_0_CS *EventDestinationV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_4_0_To_CS (ResoruceRaw, &EventDestinationV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_4_0 = (EFI_REDFISH_EVENTDESTINATION_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_4_0)); + if (EventDestinationV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_4_0; + EventDestinationV1_4_0->EventDestination = EventDestinationV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_4_0_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_4_0 *EventDestinationV1_4_0; + + EventDestinationV1_4_0 = (EFI_REDFISH_EVENTDESTINATION_V1_4_0 *)InterpProp; + DestroyEventDestination_V1_4_0_CS (EventDestinationV1_4_0->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_4_0/RedfishEventDestination_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_4_0/RedfishEventDestination_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..3d3f80b2c91 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_4_0/RedfishEventDestination_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_4_0_Dxe + FILE_GUID = 43d5b41f-670a-4af8-8a14-ca84a1f9d09b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_4_1/EventDestination_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_4_1/EventDestination_V1_4_1_Dxe.c new file mode 100644 index 00000000000..78dd45a2c3c --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_4_1/EventDestination_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "4", + "1" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_4_1 *EventDestinationV1_4_1; + EFI_REDFISH_EVENTDESTINATION_V1_4_1_CS *EventDestinationV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_4_1_To_CS (ResoruceRaw, &EventDestinationV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_4_1 = (EFI_REDFISH_EVENTDESTINATION_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_4_1)); + if (EventDestinationV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_4_1; + EventDestinationV1_4_1->EventDestination = EventDestinationV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_4_1_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_4_1 *EventDestinationV1_4_1; + + EventDestinationV1_4_1 = (EFI_REDFISH_EVENTDESTINATION_V1_4_1 *)InterpProp; + DestroyEventDestination_V1_4_1_CS (EventDestinationV1_4_1->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_4_1/RedfishEventDestination_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_4_1/RedfishEventDestination_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..52bf84febf4 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_4_1/RedfishEventDestination_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_4_1_Dxe + FILE_GUID = 17383717-dba7-47c4-89d6-3ddf3e70fc24 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_4_2/EventDestination_V1_4_2_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_4_2/EventDestination_V1_4_2_Dxe.c new file mode 100644 index 00000000000..5bb58ca4da4 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_4_2/EventDestination_V1_4_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_4_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "4", + "2" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_4_2 *EventDestinationV1_4_2; + EFI_REDFISH_EVENTDESTINATION_V1_4_2_CS *EventDestinationV1_4_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_4_2_To_CS (ResoruceRaw, &EventDestinationV1_4_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_4_2 = (EFI_REDFISH_EVENTDESTINATION_V1_4_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_4_2)); + if (EventDestinationV1_4_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_4_2; + EventDestinationV1_4_2->EventDestination = EventDestinationV1_4_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_4_2_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_4_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_4_2 *EventDestinationV1_4_2; + + EventDestinationV1_4_2 = (EFI_REDFISH_EVENTDESTINATION_V1_4_2 *)InterpProp; + DestroyEventDestination_V1_4_2_CS (EventDestinationV1_4_2->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_4_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_4_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_4_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_4_2/RedfishEventDestination_V1_4_2_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_4_2/RedfishEventDestination_V1_4_2_Dxe.inf new file mode 100644 index 00000000000..3e1c6f452f0 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_4_2/RedfishEventDestination_V1_4_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_4_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_4_2_Dxe + FILE_GUID = 5dca6c62-378b-447b-ad7d-0b7dd4dda1fe + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_4_2EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_4_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_4_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_4_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_4_3/EventDestination_V1_4_3_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_4_3/EventDestination_V1_4_3_Dxe.c new file mode 100644 index 00000000000..9e8413265f9 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_4_3/EventDestination_V1_4_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_4_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "4", + "3" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_4_3 *EventDestinationV1_4_3; + EFI_REDFISH_EVENTDESTINATION_V1_4_3_CS *EventDestinationV1_4_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_4_3_To_CS (ResoruceRaw, &EventDestinationV1_4_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_4_3 = (EFI_REDFISH_EVENTDESTINATION_V1_4_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_4_3)); + if (EventDestinationV1_4_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_4_3; + EventDestinationV1_4_3->EventDestination = EventDestinationV1_4_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_4_3_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_4_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_4_3 *EventDestinationV1_4_3; + + EventDestinationV1_4_3 = (EFI_REDFISH_EVENTDESTINATION_V1_4_3 *)InterpProp; + DestroyEventDestination_V1_4_3_CS (EventDestinationV1_4_3->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_4_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_4_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_4_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_4_3/RedfishEventDestination_V1_4_3_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_4_3/RedfishEventDestination_V1_4_3_Dxe.inf new file mode 100644 index 00000000000..4295e0a0917 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_4_3/RedfishEventDestination_V1_4_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_4_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_4_3_Dxe + FILE_GUID = cd08f1e7-6595-49fc-83a6-82e269dde3b4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_4_3EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_4_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_4_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_4_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_5_0/EventDestination_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_5_0/EventDestination_V1_5_0_Dxe.c new file mode 100644 index 00000000000..f76e797981b --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_5_0/EventDestination_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "5", + "0" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_5_0 *EventDestinationV1_5_0; + EFI_REDFISH_EVENTDESTINATION_V1_5_0_CS *EventDestinationV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_5_0_To_CS (ResoruceRaw, &EventDestinationV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_5_0 = (EFI_REDFISH_EVENTDESTINATION_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_5_0)); + if (EventDestinationV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_5_0; + EventDestinationV1_5_0->EventDestination = EventDestinationV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_5_0_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_5_0 *EventDestinationV1_5_0; + + EventDestinationV1_5_0 = (EFI_REDFISH_EVENTDESTINATION_V1_5_0 *)InterpProp; + DestroyEventDestination_V1_5_0_CS (EventDestinationV1_5_0->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_5_0/RedfishEventDestination_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_5_0/RedfishEventDestination_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..ef6b777fe50 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_5_0/RedfishEventDestination_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_5_0_Dxe + FILE_GUID = 69b670fd-22a7-4a49-911b-c0a6d778eed5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_5_1/EventDestination_V1_5_1_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_5_1/EventDestination_V1_5_1_Dxe.c new file mode 100644 index 00000000000..cbc258b0541 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_5_1/EventDestination_V1_5_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_5_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "5", + "1" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_5_1 *EventDestinationV1_5_1; + EFI_REDFISH_EVENTDESTINATION_V1_5_1_CS *EventDestinationV1_5_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_5_1_To_CS (ResoruceRaw, &EventDestinationV1_5_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_5_1 = (EFI_REDFISH_EVENTDESTINATION_V1_5_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_5_1)); + if (EventDestinationV1_5_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_5_1; + EventDestinationV1_5_1->EventDestination = EventDestinationV1_5_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_5_1_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_5_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_5_1 *EventDestinationV1_5_1; + + EventDestinationV1_5_1 = (EFI_REDFISH_EVENTDESTINATION_V1_5_1 *)InterpProp; + DestroyEventDestination_V1_5_1_CS (EventDestinationV1_5_1->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_5_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_5_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_5_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_5_1/RedfishEventDestination_V1_5_1_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_5_1/RedfishEventDestination_V1_5_1_Dxe.inf new file mode 100644 index 00000000000..f4753e23b0f --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_5_1/RedfishEventDestination_V1_5_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_5_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_5_1_Dxe + FILE_GUID = 8419d199-01d7-45ea-b1ad-d21f82cd24fd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_5_1EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_5_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_5_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_5_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_5_2/EventDestination_V1_5_2_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_5_2/EventDestination_V1_5_2_Dxe.c new file mode 100644 index 00000000000..ed45835c175 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_5_2/EventDestination_V1_5_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_5_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "5", + "2" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_5_2 *EventDestinationV1_5_2; + EFI_REDFISH_EVENTDESTINATION_V1_5_2_CS *EventDestinationV1_5_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_5_2_To_CS (ResoruceRaw, &EventDestinationV1_5_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_5_2 = (EFI_REDFISH_EVENTDESTINATION_V1_5_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_5_2)); + if (EventDestinationV1_5_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_5_2; + EventDestinationV1_5_2->EventDestination = EventDestinationV1_5_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_5_2_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_5_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_5_2 *EventDestinationV1_5_2; + + EventDestinationV1_5_2 = (EFI_REDFISH_EVENTDESTINATION_V1_5_2 *)InterpProp; + DestroyEventDestination_V1_5_2_CS (EventDestinationV1_5_2->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_5_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_5_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_5_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_5_2/RedfishEventDestination_V1_5_2_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_5_2/RedfishEventDestination_V1_5_2_Dxe.inf new file mode 100644 index 00000000000..438d9203b00 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_5_2/RedfishEventDestination_V1_5_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_5_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_5_2_Dxe + FILE_GUID = 4edab030-97a1-438b-977d-d4b10c7739ac + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_5_2EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_5_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_5_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_5_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_6_0/EventDestination_V1_6_0_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_6_0/EventDestination_V1_6_0_Dxe.c new file mode 100644 index 00000000000..6e64010c2c2 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_6_0/EventDestination_V1_6_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_6_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "6", + "0" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_6_0 *EventDestinationV1_6_0; + EFI_REDFISH_EVENTDESTINATION_V1_6_0_CS *EventDestinationV1_6_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_6_0_To_CS (ResoruceRaw, &EventDestinationV1_6_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_6_0 = (EFI_REDFISH_EVENTDESTINATION_V1_6_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_6_0)); + if (EventDestinationV1_6_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_6_0; + EventDestinationV1_6_0->EventDestination = EventDestinationV1_6_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_6_0_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_6_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_6_0 *EventDestinationV1_6_0; + + EventDestinationV1_6_0 = (EFI_REDFISH_EVENTDESTINATION_V1_6_0 *)InterpProp; + DestroyEventDestination_V1_6_0_CS (EventDestinationV1_6_0->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_6_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_6_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_6_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_6_0/RedfishEventDestination_V1_6_0_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_6_0/RedfishEventDestination_V1_6_0_Dxe.inf new file mode 100644 index 00000000000..f049efa9eac --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_6_0/RedfishEventDestination_V1_6_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_6_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_6_0_Dxe + FILE_GUID = 57ab1bcc-3f4e-43ea-ae4f-77e54b0728a0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_6_0EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_6_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_6_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_6_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_6_1/EventDestination_V1_6_1_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_6_1/EventDestination_V1_6_1_Dxe.c new file mode 100644 index 00000000000..440cafebb3f --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_6_1/EventDestination_V1_6_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_6_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "6", + "1" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_6_1 *EventDestinationV1_6_1; + EFI_REDFISH_EVENTDESTINATION_V1_6_1_CS *EventDestinationV1_6_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_6_1_To_CS (ResoruceRaw, &EventDestinationV1_6_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_6_1 = (EFI_REDFISH_EVENTDESTINATION_V1_6_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_6_1)); + if (EventDestinationV1_6_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_6_1; + EventDestinationV1_6_1->EventDestination = EventDestinationV1_6_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_6_1_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_6_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_6_1 *EventDestinationV1_6_1; + + EventDestinationV1_6_1 = (EFI_REDFISH_EVENTDESTINATION_V1_6_1 *)InterpProp; + DestroyEventDestination_V1_6_1_CS (EventDestinationV1_6_1->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_6_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_6_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_6_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_6_1/RedfishEventDestination_V1_6_1_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_6_1/RedfishEventDestination_V1_6_1_Dxe.inf new file mode 100644 index 00000000000..07799fa0ff4 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_6_1/RedfishEventDestination_V1_6_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_6_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_6_1_Dxe + FILE_GUID = 4f60ccde-7391-4d00-a13b-e3b1fbe047de + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_6_1EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_6_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_6_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_6_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_6_2/EventDestination_V1_6_2_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_6_2/EventDestination_V1_6_2_Dxe.c new file mode 100644 index 00000000000..414b3d84724 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_6_2/EventDestination_V1_6_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_6_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "6", + "2" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_6_2 *EventDestinationV1_6_2; + EFI_REDFISH_EVENTDESTINATION_V1_6_2_CS *EventDestinationV1_6_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_6_2_To_CS (ResoruceRaw, &EventDestinationV1_6_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_6_2 = (EFI_REDFISH_EVENTDESTINATION_V1_6_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_6_2)); + if (EventDestinationV1_6_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_6_2; + EventDestinationV1_6_2->EventDestination = EventDestinationV1_6_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_6_2_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_6_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_6_2 *EventDestinationV1_6_2; + + EventDestinationV1_6_2 = (EFI_REDFISH_EVENTDESTINATION_V1_6_2 *)InterpProp; + DestroyEventDestination_V1_6_2_CS (EventDestinationV1_6_2->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_6_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_6_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_6_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_6_2/RedfishEventDestination_V1_6_2_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_6_2/RedfishEventDestination_V1_6_2_Dxe.inf new file mode 100644 index 00000000000..0b616e868d2 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_6_2/RedfishEventDestination_V1_6_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_6_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_6_2_Dxe + FILE_GUID = 2c51bd4f-42ff-498e-8ffe-3ee77594bd0c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_6_2EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_6_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_6_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_6_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_7_0/EventDestination_V1_7_0_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_7_0/EventDestination_V1_7_0_Dxe.c new file mode 100644 index 00000000000..f7c936e21c8 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_7_0/EventDestination_V1_7_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_7_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "7", + "0" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_7_0 *EventDestinationV1_7_0; + EFI_REDFISH_EVENTDESTINATION_V1_7_0_CS *EventDestinationV1_7_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_7_0_To_CS (ResoruceRaw, &EventDestinationV1_7_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_7_0 = (EFI_REDFISH_EVENTDESTINATION_V1_7_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_7_0)); + if (EventDestinationV1_7_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_7_0; + EventDestinationV1_7_0->EventDestination = EventDestinationV1_7_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_7_0_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_7_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_7_0 *EventDestinationV1_7_0; + + EventDestinationV1_7_0 = (EFI_REDFISH_EVENTDESTINATION_V1_7_0 *)InterpProp; + DestroyEventDestination_V1_7_0_CS (EventDestinationV1_7_0->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_7_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_7_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_7_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_7_0/RedfishEventDestination_V1_7_0_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_7_0/RedfishEventDestination_V1_7_0_Dxe.inf new file mode 100644 index 00000000000..0f3ecd85170 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_7_0/RedfishEventDestination_V1_7_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_7_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_7_0_Dxe + FILE_GUID = c5ec9685-d98c-4c5e-8969-f82a36c6617e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_7_0EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_7_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_7_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_7_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_7_1/EventDestination_V1_7_1_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_7_1/EventDestination_V1_7_1_Dxe.c new file mode 100644 index 00000000000..ece536f73cc --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_7_1/EventDestination_V1_7_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_7_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_7_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "7", + "1" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_7_1 *EventDestinationV1_7_1; + EFI_REDFISH_EVENTDESTINATION_V1_7_1_CS *EventDestinationV1_7_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_7_1_To_CS (ResoruceRaw, &EventDestinationV1_7_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_7_1 = (EFI_REDFISH_EVENTDESTINATION_V1_7_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_7_1)); + if (EventDestinationV1_7_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_7_1; + EventDestinationV1_7_1->EventDestination = EventDestinationV1_7_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_7_1_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_7_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_7_1 *EventDestinationV1_7_1; + + EventDestinationV1_7_1 = (EFI_REDFISH_EVENTDESTINATION_V1_7_1 *)InterpProp; + DestroyEventDestination_V1_7_1_CS (EventDestinationV1_7_1->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_7_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_7_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_7_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_7_1/RedfishEventDestination_V1_7_1_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_7_1/RedfishEventDestination_V1_7_1_Dxe.inf new file mode 100644 index 00000000000..2001c7e44ca --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_7_1/RedfishEventDestination_V1_7_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_7_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_7_1_Dxe + FILE_GUID = 391abf98-1dde-47de-b570-ebb5fa3f41d8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_7_1EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_7_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_7_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_7_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_7_2/EventDestination_V1_7_2_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_7_2/EventDestination_V1_7_2_Dxe.c new file mode 100644 index 00000000000..ef3cc632374 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_7_2/EventDestination_V1_7_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_7_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_7_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "7", + "2" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_7_2 *EventDestinationV1_7_2; + EFI_REDFISH_EVENTDESTINATION_V1_7_2_CS *EventDestinationV1_7_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_7_2_To_CS (ResoruceRaw, &EventDestinationV1_7_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_7_2 = (EFI_REDFISH_EVENTDESTINATION_V1_7_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_7_2)); + if (EventDestinationV1_7_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_7_2; + EventDestinationV1_7_2->EventDestination = EventDestinationV1_7_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_7_2_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_7_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_7_2 *EventDestinationV1_7_2; + + EventDestinationV1_7_2 = (EFI_REDFISH_EVENTDESTINATION_V1_7_2 *)InterpProp; + DestroyEventDestination_V1_7_2_CS (EventDestinationV1_7_2->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_7_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_7_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_7_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_7_2/RedfishEventDestination_V1_7_2_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_7_2/RedfishEventDestination_V1_7_2_Dxe.inf new file mode 100644 index 00000000000..1de59ca645d --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_7_2/RedfishEventDestination_V1_7_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_7_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_7_2_Dxe + FILE_GUID = 6cb66cf9-428e-4a35-a8c2-828e87ec1ec8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_7_2EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_7_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_7_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_7_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_8_0/EventDestination_V1_8_0_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_8_0/EventDestination_V1_8_0_Dxe.c new file mode 100644 index 00000000000..1bae2da9089 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_8_0/EventDestination_V1_8_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_8_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_8_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "8", + "0" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_8_0 *EventDestinationV1_8_0; + EFI_REDFISH_EVENTDESTINATION_V1_8_0_CS *EventDestinationV1_8_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_8_0_To_CS (ResoruceRaw, &EventDestinationV1_8_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_8_0 = (EFI_REDFISH_EVENTDESTINATION_V1_8_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_8_0)); + if (EventDestinationV1_8_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_8_0; + EventDestinationV1_8_0->EventDestination = EventDestinationV1_8_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_8_0_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_8_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_8_0 *EventDestinationV1_8_0; + + EventDestinationV1_8_0 = (EFI_REDFISH_EVENTDESTINATION_V1_8_0 *)InterpProp; + DestroyEventDestination_V1_8_0_CS (EventDestinationV1_8_0->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_8_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_8_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_8_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_8_0/RedfishEventDestination_V1_8_0_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_8_0/RedfishEventDestination_V1_8_0_Dxe.inf new file mode 100644 index 00000000000..189e4155442 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_8_0/RedfishEventDestination_V1_8_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_8_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_8_0_Dxe + FILE_GUID = 17634d4a-1c19-4763-88ae-26476c5bc8f5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_8_0EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_8_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_8_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_8_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_8_1/EventDestination_V1_8_1_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_8_1/EventDestination_V1_8_1_Dxe.c new file mode 100644 index 00000000000..7be73bd8f38 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_8_1/EventDestination_V1_8_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_8_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_8_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "8", + "1" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_8_1 *EventDestinationV1_8_1; + EFI_REDFISH_EVENTDESTINATION_V1_8_1_CS *EventDestinationV1_8_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_8_1_To_CS (ResoruceRaw, &EventDestinationV1_8_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_8_1 = (EFI_REDFISH_EVENTDESTINATION_V1_8_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_8_1)); + if (EventDestinationV1_8_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_8_1; + EventDestinationV1_8_1->EventDestination = EventDestinationV1_8_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_8_1_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_8_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_8_1 *EventDestinationV1_8_1; + + EventDestinationV1_8_1 = (EFI_REDFISH_EVENTDESTINATION_V1_8_1 *)InterpProp; + DestroyEventDestination_V1_8_1_CS (EventDestinationV1_8_1->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_8_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_8_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_8_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_8_1/RedfishEventDestination_V1_8_1_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_8_1/RedfishEventDestination_V1_8_1_Dxe.inf new file mode 100644 index 00000000000..0336813bbfe --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_8_1/RedfishEventDestination_V1_8_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_8_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_8_1_Dxe + FILE_GUID = e53f9073-477e-46f9-9767-0ce2abfa35b9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_8_1EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_8_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_8_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_8_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_8_2/EventDestination_V1_8_2_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_8_2/EventDestination_V1_8_2_Dxe.c new file mode 100644 index 00000000000..94668cbbffd --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_8_2/EventDestination_V1_8_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_8_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_8_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "8", + "2" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_8_2 *EventDestinationV1_8_2; + EFI_REDFISH_EVENTDESTINATION_V1_8_2_CS *EventDestinationV1_8_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_8_2_To_CS (ResoruceRaw, &EventDestinationV1_8_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_8_2 = (EFI_REDFISH_EVENTDESTINATION_V1_8_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_8_2)); + if (EventDestinationV1_8_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_8_2; + EventDestinationV1_8_2->EventDestination = EventDestinationV1_8_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_8_2_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_8_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_8_2 *EventDestinationV1_8_2; + + EventDestinationV1_8_2 = (EFI_REDFISH_EVENTDESTINATION_V1_8_2 *)InterpProp; + DestroyEventDestination_V1_8_2_CS (EventDestinationV1_8_2->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_8_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_8_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_8_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_8_2/RedfishEventDestination_V1_8_2_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_8_2/RedfishEventDestination_V1_8_2_Dxe.inf new file mode 100644 index 00000000000..c65b1a71bd1 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_8_2/RedfishEventDestination_V1_8_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_8_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_8_2_Dxe + FILE_GUID = 6e2ca0ce-80b3-49a6-9f03-65a78feffb9e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_8_2EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_8_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_8_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_8_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_9_0/EventDestination_V1_9_0_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_9_0/EventDestination_V1_9_0_Dxe.c new file mode 100644 index 00000000000..dad3b310afb --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_9_0/EventDestination_V1_9_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_9_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_9_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "9", + "0" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_9_0 *EventDestinationV1_9_0; + EFI_REDFISH_EVENTDESTINATION_V1_9_0_CS *EventDestinationV1_9_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_9_0_To_CS (ResoruceRaw, &EventDestinationV1_9_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_9_0 = (EFI_REDFISH_EVENTDESTINATION_V1_9_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_9_0)); + if (EventDestinationV1_9_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_9_0; + EventDestinationV1_9_0->EventDestination = EventDestinationV1_9_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_9_0_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_9_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_9_0 *EventDestinationV1_9_0; + + EventDestinationV1_9_0 = (EFI_REDFISH_EVENTDESTINATION_V1_9_0 *)InterpProp; + DestroyEventDestination_V1_9_0_CS (EventDestinationV1_9_0->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_9_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_9_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_9_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_9_0/RedfishEventDestination_V1_9_0_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_9_0/RedfishEventDestination_V1_9_0_Dxe.inf new file mode 100644 index 00000000000..daf89351b29 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_9_0/RedfishEventDestination_V1_9_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_9_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_9_0_Dxe + FILE_GUID = c71e86d2-b14f-480c-bdb8-700404dee686 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_9_0EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_9_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_9_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_9_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestination/v1_9_1/EventDestination_V1_9_1_Dxe.c b/RedfishClientPkg/Converter/EventDestination/v1_9_1/EventDestination_V1_9_1_Dxe.c new file mode 100644 index 00000000000..78fb2e2bde9 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_9_1/EventDestination_V1_9_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestination.v1_9_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestination"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventDestination V1_9_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestination", + "1", + "9", + "1" + }, + "EventDestination" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_9_1 *EventDestinationV1_9_1; + EFI_REDFISH_EVENTDESTINATION_V1_9_1_CS *EventDestinationV1_9_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestination") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestination_V1_9_1_To_CS (ResoruceRaw, &EventDestinationV1_9_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationV1_9_1 = (EFI_REDFISH_EVENTDESTINATION_V1_9_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATION_V1_9_1)); + if (EventDestinationV1_9_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationV1_9_1; + EventDestinationV1_9_1->EventDestination = EventDestinationV1_9_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestination"), "EventDestination"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestination")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestination"), "EventDestination"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestination_V1_9_1_JSON (*((EFI_REDFISH_EVENTDESTINATION_V1_9_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATION_V1_9_1 *EventDestinationV1_9_1; + + EventDestinationV1_9_1 = (EFI_REDFISH_EVENTDESTINATION_V1_9_1 *)InterpProp; + DestroyEventDestination_V1_9_1_CS (EventDestinationV1_9_1->EventDestination); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestination_V1_9_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_9_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationToStructWrapper, + EventDestinationToJson, + EventDestinationDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestination_V1_9_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestination/v1_9_1/RedfishEventDestination_V1_9_1_Dxe.inf b/RedfishClientPkg/Converter/EventDestination/v1_9_1/RedfishEventDestination_V1_9_1_Dxe.inf new file mode 100644 index 00000000000..301f6b60b83 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestination/v1_9_1/RedfishEventDestination_V1_9_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestination.v1_9_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestination_V1_9_1_Dxe + FILE_GUID = f340f07c-7bc5-4169-a656-31af259a32dd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestination_V1_9_1EntryPoint + UNLOAD_IMAGE = RedfishEventDestination_V1_9_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestination_V1_9_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationV1_9_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventDestinationCollection/EventDestinationCollection_Dxe.c b/RedfishClientPkg/Converter/EventDestinationCollection/EventDestinationCollection_Dxe.c new file mode 100644 index 00000000000..2107aaf270a --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestinationCollection/EventDestinationCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventDestinationCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventDestinationCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support EventDestinationCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventDestinationCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "EventDestinationCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATIONCOLLECTION *EventDestinationCollection; + EFI_REDFISH_EVENTDESTINATIONCOLLECTION_CS *EventDestinationCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventDestinationCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventDestinationCollection_To_CS (ResoruceRaw, &EventDestinationCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + EventDestinationCollection = (EFI_REDFISH_EVENTDESTINATIONCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTDESTINATIONCOLLECTION)); + if (EventDestinationCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventDestinationCollection; + EventDestinationCollection->EventDestinationCollection = EventDestinationCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestinationCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventDestinationCollection"), "EventDestinationCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventDestinationCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventDestinationCollection"), "EventDestinationCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventDestinationCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventDestinationCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventDestinationCollection_JSON (*((EFI_REDFISH_EVENTDESTINATIONCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventDestinationCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTDESTINATIONCOLLECTION *EventDestinationCollection; + + EventDestinationCollection = (EFI_REDFISH_EVENTDESTINATIONCOLLECTION *)InterpProp; + DestroyEventDestinationCollection_CS (EventDestinationCollection->EventDestinationCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventDestinationCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventDestinationCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventDestinationCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventDestinationCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventDestinationCollectionToStructWrapper, + EventDestinationCollectionToJson, + EventDestinationCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventDestinationCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventDestinationCollection/RedfishEventDestinationCollection_Dxe.inf b/RedfishClientPkg/Converter/EventDestinationCollection/RedfishEventDestinationCollection_Dxe.inf new file mode 100644 index 00000000000..9cb7d45bc14 --- /dev/null +++ b/RedfishClientPkg/Converter/EventDestinationCollection/RedfishEventDestinationCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventDestinationCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventDestinationCollection_Dxe + FILE_GUID = 6e2f32e2-20d9-47ae-8eca-98edaa49f4fa + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventDestinationCollectionEntryPoint + UNLOAD_IMAGE = RedfishEventDestinationCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventDestinationCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventDestinationCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_0_0/EventService_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_0_0/EventService_V1_0_0_Dxe.c new file mode 100644 index 00000000000..3fa231994f9 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_0/EventService_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "0", + "0" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_0 *EventServiceV1_0_0; + EFI_REDFISH_EVENTSERVICE_V1_0_0_CS *EventServiceV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_0_0_To_CS (ResoruceRaw, &EventServiceV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_0_0 = (EFI_REDFISH_EVENTSERVICE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_0_0)); + if (EventServiceV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_0_0; + EventServiceV1_0_0->EventService = EventServiceV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_0_0_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_0 *EventServiceV1_0_0; + + EventServiceV1_0_0 = (EFI_REDFISH_EVENTSERVICE_V1_0_0 *)InterpProp; + DestroyEventService_V1_0_0_CS (EventServiceV1_0_0->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_0_0/RedfishEventService_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_0_0/RedfishEventService_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..5275f37a7f0 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_0/RedfishEventService_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_0_0_Dxe + FILE_GUID = a67008c5-7531-43d2-a4f0-0cb5279d981a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_0_10/EventService_V1_0_10_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_0_10/EventService_V1_0_10_Dxe.c new file mode 100644 index 00000000000..0e2165b023e --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_10/EventService_V1_0_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_0_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "0", + "10" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_10 *EventServiceV1_0_10; + EFI_REDFISH_EVENTSERVICE_V1_0_10_CS *EventServiceV1_0_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_0_10_To_CS (ResoruceRaw, &EventServiceV1_0_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_0_10 = (EFI_REDFISH_EVENTSERVICE_V1_0_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_0_10)); + if (EventServiceV1_0_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_0_10; + EventServiceV1_0_10->EventService = EventServiceV1_0_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_0_10_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_0_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_10 *EventServiceV1_0_10; + + EventServiceV1_0_10 = (EFI_REDFISH_EVENTSERVICE_V1_0_10 *)InterpProp; + DestroyEventService_V1_0_10_CS (EventServiceV1_0_10->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_0_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_0_10/RedfishEventService_V1_0_10_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_0_10/RedfishEventService_V1_0_10_Dxe.inf new file mode 100644 index 00000000000..3da2ffb31b1 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_10/RedfishEventService_V1_0_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_0_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_0_10_Dxe + FILE_GUID = 4c9a7f36-3276-4b66-8289-5da78bcf502a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_0_10EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_0_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_0_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_0_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_0_11/EventService_V1_0_11_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_0_11/EventService_V1_0_11_Dxe.c new file mode 100644 index 00000000000..0d2cc9ec2c9 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_11/EventService_V1_0_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_0_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "0", + "11" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_11 *EventServiceV1_0_11; + EFI_REDFISH_EVENTSERVICE_V1_0_11_CS *EventServiceV1_0_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_0_11_To_CS (ResoruceRaw, &EventServiceV1_0_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_0_11 = (EFI_REDFISH_EVENTSERVICE_V1_0_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_0_11)); + if (EventServiceV1_0_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_0_11; + EventServiceV1_0_11->EventService = EventServiceV1_0_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_0_11_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_0_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_11 *EventServiceV1_0_11; + + EventServiceV1_0_11 = (EFI_REDFISH_EVENTSERVICE_V1_0_11 *)InterpProp; + DestroyEventService_V1_0_11_CS (EventServiceV1_0_11->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_0_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_0_11/RedfishEventService_V1_0_11_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_0_11/RedfishEventService_V1_0_11_Dxe.inf new file mode 100644 index 00000000000..ae9eccbdb55 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_11/RedfishEventService_V1_0_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_0_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_0_11_Dxe + FILE_GUID = cc6a278c-13a3-49ea-85e9-36d0c0ee0aea + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_0_11EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_0_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_0_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_0_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_0_12/EventService_V1_0_12_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_0_12/EventService_V1_0_12_Dxe.c new file mode 100644 index 00000000000..d4c9df9c36c --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_12/EventService_V1_0_12_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_0_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_0_12 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "0", + "12" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_12 *EventServiceV1_0_12; + EFI_REDFISH_EVENTSERVICE_V1_0_12_CS *EventServiceV1_0_12Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "12") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_0_12_To_CS (ResoruceRaw, &EventServiceV1_0_12Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_0_12 = (EFI_REDFISH_EVENTSERVICE_V1_0_12 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_0_12)); + if (EventServiceV1_0_12 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_0_12; + EventServiceV1_0_12->EventService = EventServiceV1_0_12Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "12"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_0_12_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_0_12_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_12 *EventServiceV1_0_12; + + EventServiceV1_0_12 = (EFI_REDFISH_EVENTSERVICE_V1_0_12 *)InterpProp; + DestroyEventService_V1_0_12_CS (EventServiceV1_0_12->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_0_12_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_12EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_12Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_0_12/RedfishEventService_V1_0_12_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_0_12/RedfishEventService_V1_0_12_Dxe.inf new file mode 100644 index 00000000000..67925e949b7 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_12/RedfishEventService_V1_0_12_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_0_12 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_0_12_Dxe + FILE_GUID = 3fc4e0d6-1c79-443c-87f9-325b17f877f4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_0_12EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_0_12Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_0_12_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_0_12Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_0_13/EventService_V1_0_13_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_0_13/EventService_V1_0_13_Dxe.c new file mode 100644 index 00000000000..ef88eaea411 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_13/EventService_V1_0_13_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_0_13 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_0_13 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "0", + "13" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_13 *EventServiceV1_0_13; + EFI_REDFISH_EVENTSERVICE_V1_0_13_CS *EventServiceV1_0_13Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "13") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_0_13_To_CS (ResoruceRaw, &EventServiceV1_0_13Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_0_13 = (EFI_REDFISH_EVENTSERVICE_V1_0_13 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_0_13)); + if (EventServiceV1_0_13 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_0_13; + EventServiceV1_0_13->EventService = EventServiceV1_0_13Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "13"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_0_13_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_0_13_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_13 *EventServiceV1_0_13; + + EventServiceV1_0_13 = (EFI_REDFISH_EVENTSERVICE_V1_0_13 *)InterpProp; + DestroyEventService_V1_0_13_CS (EventServiceV1_0_13->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_0_13_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_13EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_13Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_0_13/RedfishEventService_V1_0_13_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_0_13/RedfishEventService_V1_0_13_Dxe.inf new file mode 100644 index 00000000000..9315bba28b1 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_13/RedfishEventService_V1_0_13_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_0_13 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_0_13_Dxe + FILE_GUID = d6b4cd28-c3d5-46b1-9cee-0f5ac8fbd0bc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_0_13EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_0_13Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_0_13_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_0_13Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_0_2/EventService_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_0_2/EventService_V1_0_2_Dxe.c new file mode 100644 index 00000000000..4ef1247f389 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_2/EventService_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "0", + "2" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_2 *EventServiceV1_0_2; + EFI_REDFISH_EVENTSERVICE_V1_0_2_CS *EventServiceV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_0_2_To_CS (ResoruceRaw, &EventServiceV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_0_2 = (EFI_REDFISH_EVENTSERVICE_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_0_2)); + if (EventServiceV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_0_2; + EventServiceV1_0_2->EventService = EventServiceV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_0_2_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_2 *EventServiceV1_0_2; + + EventServiceV1_0_2 = (EFI_REDFISH_EVENTSERVICE_V1_0_2 *)InterpProp; + DestroyEventService_V1_0_2_CS (EventServiceV1_0_2->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_0_2/RedfishEventService_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_0_2/RedfishEventService_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..9fcb563df0a --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_2/RedfishEventService_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_0_2_Dxe + FILE_GUID = 56ae1cdf-587a-4229-9356-45f0751d1180 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_0_3/EventService_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_0_3/EventService_V1_0_3_Dxe.c new file mode 100644 index 00000000000..f27c7b24403 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_3/EventService_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "0", + "3" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_3 *EventServiceV1_0_3; + EFI_REDFISH_EVENTSERVICE_V1_0_3_CS *EventServiceV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_0_3_To_CS (ResoruceRaw, &EventServiceV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_0_3 = (EFI_REDFISH_EVENTSERVICE_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_0_3)); + if (EventServiceV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_0_3; + EventServiceV1_0_3->EventService = EventServiceV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_0_3_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_3 *EventServiceV1_0_3; + + EventServiceV1_0_3 = (EFI_REDFISH_EVENTSERVICE_V1_0_3 *)InterpProp; + DestroyEventService_V1_0_3_CS (EventServiceV1_0_3->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_0_3/RedfishEventService_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_0_3/RedfishEventService_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..cfb197fc455 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_3/RedfishEventService_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_0_3_Dxe + FILE_GUID = c21fc513-801b-4ff6-a126-4930abd0654d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_0_4/EventService_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_0_4/EventService_V1_0_4_Dxe.c new file mode 100644 index 00000000000..b372bbcd345 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_4/EventService_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "0", + "4" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_4 *EventServiceV1_0_4; + EFI_REDFISH_EVENTSERVICE_V1_0_4_CS *EventServiceV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_0_4_To_CS (ResoruceRaw, &EventServiceV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_0_4 = (EFI_REDFISH_EVENTSERVICE_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_0_4)); + if (EventServiceV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_0_4; + EventServiceV1_0_4->EventService = EventServiceV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_0_4_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_4 *EventServiceV1_0_4; + + EventServiceV1_0_4 = (EFI_REDFISH_EVENTSERVICE_V1_0_4 *)InterpProp; + DestroyEventService_V1_0_4_CS (EventServiceV1_0_4->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_0_4/RedfishEventService_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_0_4/RedfishEventService_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..ff0cdd8497d --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_4/RedfishEventService_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_0_4_Dxe + FILE_GUID = d91106cd-0383-4a1d-9428-914dcb0b88cd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_0_5/EventService_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_0_5/EventService_V1_0_5_Dxe.c new file mode 100644 index 00000000000..aec382f019b --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_5/EventService_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "0", + "5" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_5 *EventServiceV1_0_5; + EFI_REDFISH_EVENTSERVICE_V1_0_5_CS *EventServiceV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_0_5_To_CS (ResoruceRaw, &EventServiceV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_0_5 = (EFI_REDFISH_EVENTSERVICE_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_0_5)); + if (EventServiceV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_0_5; + EventServiceV1_0_5->EventService = EventServiceV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_0_5_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_5 *EventServiceV1_0_5; + + EventServiceV1_0_5 = (EFI_REDFISH_EVENTSERVICE_V1_0_5 *)InterpProp; + DestroyEventService_V1_0_5_CS (EventServiceV1_0_5->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_0_5/RedfishEventService_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_0_5/RedfishEventService_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..37e10368005 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_5/RedfishEventService_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_0_5_Dxe + FILE_GUID = a1a0862a-89e7-4b21-a226-e51d5aa91585 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_0_6/EventService_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_0_6/EventService_V1_0_6_Dxe.c new file mode 100644 index 00000000000..bafa4fd9c58 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_6/EventService_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "0", + "6" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_6 *EventServiceV1_0_6; + EFI_REDFISH_EVENTSERVICE_V1_0_6_CS *EventServiceV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_0_6_To_CS (ResoruceRaw, &EventServiceV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_0_6 = (EFI_REDFISH_EVENTSERVICE_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_0_6)); + if (EventServiceV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_0_6; + EventServiceV1_0_6->EventService = EventServiceV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_0_6_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_6 *EventServiceV1_0_6; + + EventServiceV1_0_6 = (EFI_REDFISH_EVENTSERVICE_V1_0_6 *)InterpProp; + DestroyEventService_V1_0_6_CS (EventServiceV1_0_6->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_0_6/RedfishEventService_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_0_6/RedfishEventService_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..db798c10464 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_6/RedfishEventService_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_0_6_Dxe + FILE_GUID = 9554b152-3dfc-41aa-b740-5298ea46e57c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_0_7/EventService_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_0_7/EventService_V1_0_7_Dxe.c new file mode 100644 index 00000000000..1f46e958490 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_7/EventService_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "0", + "7" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_7 *EventServiceV1_0_7; + EFI_REDFISH_EVENTSERVICE_V1_0_7_CS *EventServiceV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_0_7_To_CS (ResoruceRaw, &EventServiceV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_0_7 = (EFI_REDFISH_EVENTSERVICE_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_0_7)); + if (EventServiceV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_0_7; + EventServiceV1_0_7->EventService = EventServiceV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_0_7_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_7 *EventServiceV1_0_7; + + EventServiceV1_0_7 = (EFI_REDFISH_EVENTSERVICE_V1_0_7 *)InterpProp; + DestroyEventService_V1_0_7_CS (EventServiceV1_0_7->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_0_7/RedfishEventService_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_0_7/RedfishEventService_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..6a9416fac21 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_7/RedfishEventService_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_0_7_Dxe + FILE_GUID = 0a5498be-f9e8-40e4-81c8-b708bd83c0fd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_0_8/EventService_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_0_8/EventService_V1_0_8_Dxe.c new file mode 100644 index 00000000000..a4c78fc6bc0 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_8/EventService_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "0", + "8" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_8 *EventServiceV1_0_8; + EFI_REDFISH_EVENTSERVICE_V1_0_8_CS *EventServiceV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_0_8_To_CS (ResoruceRaw, &EventServiceV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_0_8 = (EFI_REDFISH_EVENTSERVICE_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_0_8)); + if (EventServiceV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_0_8; + EventServiceV1_0_8->EventService = EventServiceV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_0_8_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_8 *EventServiceV1_0_8; + + EventServiceV1_0_8 = (EFI_REDFISH_EVENTSERVICE_V1_0_8 *)InterpProp; + DestroyEventService_V1_0_8_CS (EventServiceV1_0_8->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_0_8/RedfishEventService_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_0_8/RedfishEventService_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..ed4078743a7 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_8/RedfishEventService_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_0_8_Dxe + FILE_GUID = 1c544e2f-f390-4874-bc4f-25d97e18d8e8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_0_9/EventService_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_0_9/EventService_V1_0_9_Dxe.c new file mode 100644 index 00000000000..b8f8b5fc8d1 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_9/EventService_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "0", + "9" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_9 *EventServiceV1_0_9; + EFI_REDFISH_EVENTSERVICE_V1_0_9_CS *EventServiceV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_0_9_To_CS (ResoruceRaw, &EventServiceV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_0_9 = (EFI_REDFISH_EVENTSERVICE_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_0_9)); + if (EventServiceV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_0_9; + EventServiceV1_0_9->EventService = EventServiceV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_0_9_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_0_9 *EventServiceV1_0_9; + + EventServiceV1_0_9 = (EFI_REDFISH_EVENTSERVICE_V1_0_9 *)InterpProp; + DestroyEventService_V1_0_9_CS (EventServiceV1_0_9->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_0_9/RedfishEventService_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_0_9/RedfishEventService_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..dac42967c44 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_0_9/RedfishEventService_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_0_9_Dxe + FILE_GUID = 278ede14-83df-4596-8b30-351b001ccb7b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_1_0/EventService_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_1_0/EventService_V1_1_0_Dxe.c new file mode 100644 index 00000000000..a1572afeafc --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_1_0/EventService_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "1", + "0" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_1_0 *EventServiceV1_1_0; + EFI_REDFISH_EVENTSERVICE_V1_1_0_CS *EventServiceV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_1_0_To_CS (ResoruceRaw, &EventServiceV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_1_0 = (EFI_REDFISH_EVENTSERVICE_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_1_0)); + if (EventServiceV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_1_0; + EventServiceV1_1_0->EventService = EventServiceV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_1_0_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_1_0 *EventServiceV1_1_0; + + EventServiceV1_1_0 = (EFI_REDFISH_EVENTSERVICE_V1_1_0 *)InterpProp; + DestroyEventService_V1_1_0_CS (EventServiceV1_1_0->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_1_0/RedfishEventService_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_1_0/RedfishEventService_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..5743f8eb2c7 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_1_0/RedfishEventService_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_1_0_Dxe + FILE_GUID = 19f63239-0205-43fa-b4b7-758e23ff79e6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_1_1/EventService_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_1_1/EventService_V1_1_1_Dxe.c new file mode 100644 index 00000000000..e21dc9ee9e4 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_1_1/EventService_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "1", + "1" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_1_1 *EventServiceV1_1_1; + EFI_REDFISH_EVENTSERVICE_V1_1_1_CS *EventServiceV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_1_1_To_CS (ResoruceRaw, &EventServiceV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_1_1 = (EFI_REDFISH_EVENTSERVICE_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_1_1)); + if (EventServiceV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_1_1; + EventServiceV1_1_1->EventService = EventServiceV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_1_1_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_1_1 *EventServiceV1_1_1; + + EventServiceV1_1_1 = (EFI_REDFISH_EVENTSERVICE_V1_1_1 *)InterpProp; + DestroyEventService_V1_1_1_CS (EventServiceV1_1_1->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_1_1/RedfishEventService_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_1_1/RedfishEventService_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..e41c76cb854 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_1_1/RedfishEventService_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_1_1_Dxe + FILE_GUID = 565bf658-c2a2-4399-ab11-e21aed3decd2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_1_2/EventService_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_1_2/EventService_V1_1_2_Dxe.c new file mode 100644 index 00000000000..eceda3f809d --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_1_2/EventService_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "1", + "2" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_1_2 *EventServiceV1_1_2; + EFI_REDFISH_EVENTSERVICE_V1_1_2_CS *EventServiceV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_1_2_To_CS (ResoruceRaw, &EventServiceV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_1_2 = (EFI_REDFISH_EVENTSERVICE_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_1_2)); + if (EventServiceV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_1_2; + EventServiceV1_1_2->EventService = EventServiceV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_1_2_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_1_2 *EventServiceV1_1_2; + + EventServiceV1_1_2 = (EFI_REDFISH_EVENTSERVICE_V1_1_2 *)InterpProp; + DestroyEventService_V1_1_2_CS (EventServiceV1_1_2->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_1_2/RedfishEventService_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_1_2/RedfishEventService_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..c5fee390dc9 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_1_2/RedfishEventService_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_1_2_Dxe + FILE_GUID = 11867255-5c7d-46c8-b9d4-9e2009e1ea4a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_1_3/EventService_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_1_3/EventService_V1_1_3_Dxe.c new file mode 100644 index 00000000000..3780aef81fc --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_1_3/EventService_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "1", + "3" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_1_3 *EventServiceV1_1_3; + EFI_REDFISH_EVENTSERVICE_V1_1_3_CS *EventServiceV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_1_3_To_CS (ResoruceRaw, &EventServiceV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_1_3 = (EFI_REDFISH_EVENTSERVICE_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_1_3)); + if (EventServiceV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_1_3; + EventServiceV1_1_3->EventService = EventServiceV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_1_3_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_1_3 *EventServiceV1_1_3; + + EventServiceV1_1_3 = (EFI_REDFISH_EVENTSERVICE_V1_1_3 *)InterpProp; + DestroyEventService_V1_1_3_CS (EventServiceV1_1_3->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_1_3/RedfishEventService_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_1_3/RedfishEventService_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..4f83900ab9c --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_1_3/RedfishEventService_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_1_3_Dxe + FILE_GUID = d850affd-a354-4fd5-a11d-62190ccdfba7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_1_4/EventService_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_1_4/EventService_V1_1_4_Dxe.c new file mode 100644 index 00000000000..298aa08162f --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_1_4/EventService_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "1", + "4" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_1_4 *EventServiceV1_1_4; + EFI_REDFISH_EVENTSERVICE_V1_1_4_CS *EventServiceV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_1_4_To_CS (ResoruceRaw, &EventServiceV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_1_4 = (EFI_REDFISH_EVENTSERVICE_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_1_4)); + if (EventServiceV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_1_4; + EventServiceV1_1_4->EventService = EventServiceV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_1_4_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_1_4 *EventServiceV1_1_4; + + EventServiceV1_1_4 = (EFI_REDFISH_EVENTSERVICE_V1_1_4 *)InterpProp; + DestroyEventService_V1_1_4_CS (EventServiceV1_1_4->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_1_4/RedfishEventService_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_1_4/RedfishEventService_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..737968635c8 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_1_4/RedfishEventService_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_1_4_Dxe + FILE_GUID = edef847c-3537-45ed-a88c-72d85b5dadb8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_1_5/EventService_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_1_5/EventService_V1_1_5_Dxe.c new file mode 100644 index 00000000000..d10d7d2ca08 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_1_5/EventService_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "1", + "5" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_1_5 *EventServiceV1_1_5; + EFI_REDFISH_EVENTSERVICE_V1_1_5_CS *EventServiceV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_1_5_To_CS (ResoruceRaw, &EventServiceV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_1_5 = (EFI_REDFISH_EVENTSERVICE_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_1_5)); + if (EventServiceV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_1_5; + EventServiceV1_1_5->EventService = EventServiceV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_1_5_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_1_5 *EventServiceV1_1_5; + + EventServiceV1_1_5 = (EFI_REDFISH_EVENTSERVICE_V1_1_5 *)InterpProp; + DestroyEventService_V1_1_5_CS (EventServiceV1_1_5->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_1_5/RedfishEventService_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_1_5/RedfishEventService_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..b2fe95a4c5e --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_1_5/RedfishEventService_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_1_5_Dxe + FILE_GUID = fb447ec9-1504-469d-ad6a-a6d167574c71 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_1_6/EventService_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_1_6/EventService_V1_1_6_Dxe.c new file mode 100644 index 00000000000..fa4f0639b14 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_1_6/EventService_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "1", + "6" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_1_6 *EventServiceV1_1_6; + EFI_REDFISH_EVENTSERVICE_V1_1_6_CS *EventServiceV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_1_6_To_CS (ResoruceRaw, &EventServiceV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_1_6 = (EFI_REDFISH_EVENTSERVICE_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_1_6)); + if (EventServiceV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_1_6; + EventServiceV1_1_6->EventService = EventServiceV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_1_6_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_1_6 *EventServiceV1_1_6; + + EventServiceV1_1_6 = (EFI_REDFISH_EVENTSERVICE_V1_1_6 *)InterpProp; + DestroyEventService_V1_1_6_CS (EventServiceV1_1_6->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_1_6/RedfishEventService_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_1_6/RedfishEventService_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..f1a26517a28 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_1_6/RedfishEventService_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_1_6_Dxe + FILE_GUID = f61bb38d-f75c-4c9e-bedc-abb371a0a87b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_2_0/EventService_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_2_0/EventService_V1_2_0_Dxe.c new file mode 100644 index 00000000000..2fbe7391402 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_2_0/EventService_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "2", + "0" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_2_0 *EventServiceV1_2_0; + EFI_REDFISH_EVENTSERVICE_V1_2_0_CS *EventServiceV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_2_0_To_CS (ResoruceRaw, &EventServiceV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_2_0 = (EFI_REDFISH_EVENTSERVICE_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_2_0)); + if (EventServiceV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_2_0; + EventServiceV1_2_0->EventService = EventServiceV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_2_0_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_2_0 *EventServiceV1_2_0; + + EventServiceV1_2_0 = (EFI_REDFISH_EVENTSERVICE_V1_2_0 *)InterpProp; + DestroyEventService_V1_2_0_CS (EventServiceV1_2_0->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_2_0/RedfishEventService_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_2_0/RedfishEventService_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..4fbe7db9698 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_2_0/RedfishEventService_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_2_0_Dxe + FILE_GUID = 258016ad-7525-4244-a47b-317c4a9b24d8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_2_1/EventService_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_2_1/EventService_V1_2_1_Dxe.c new file mode 100644 index 00000000000..67979b42d2c --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_2_1/EventService_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "2", + "1" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_2_1 *EventServiceV1_2_1; + EFI_REDFISH_EVENTSERVICE_V1_2_1_CS *EventServiceV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_2_1_To_CS (ResoruceRaw, &EventServiceV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_2_1 = (EFI_REDFISH_EVENTSERVICE_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_2_1)); + if (EventServiceV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_2_1; + EventServiceV1_2_1->EventService = EventServiceV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_2_1_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_2_1 *EventServiceV1_2_1; + + EventServiceV1_2_1 = (EFI_REDFISH_EVENTSERVICE_V1_2_1 *)InterpProp; + DestroyEventService_V1_2_1_CS (EventServiceV1_2_1->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_2_1/RedfishEventService_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_2_1/RedfishEventService_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..858abef6b57 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_2_1/RedfishEventService_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_2_1_Dxe + FILE_GUID = dabd4631-7d71-4414-a59a-b1ae4f9f7544 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_2_2/EventService_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_2_2/EventService_V1_2_2_Dxe.c new file mode 100644 index 00000000000..0ad6534c463 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_2_2/EventService_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "2", + "2" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_2_2 *EventServiceV1_2_2; + EFI_REDFISH_EVENTSERVICE_V1_2_2_CS *EventServiceV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_2_2_To_CS (ResoruceRaw, &EventServiceV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_2_2 = (EFI_REDFISH_EVENTSERVICE_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_2_2)); + if (EventServiceV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_2_2; + EventServiceV1_2_2->EventService = EventServiceV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_2_2_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_2_2 *EventServiceV1_2_2; + + EventServiceV1_2_2 = (EFI_REDFISH_EVENTSERVICE_V1_2_2 *)InterpProp; + DestroyEventService_V1_2_2_CS (EventServiceV1_2_2->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_2_2/RedfishEventService_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_2_2/RedfishEventService_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..f89b93141e9 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_2_2/RedfishEventService_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_2_2_Dxe + FILE_GUID = 3dc9ac9a-7c8b-4de0-8aab-04ad46b72b82 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_2_3/EventService_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_2_3/EventService_V1_2_3_Dxe.c new file mode 100644 index 00000000000..f5b3af8f5c5 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_2_3/EventService_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "2", + "3" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_2_3 *EventServiceV1_2_3; + EFI_REDFISH_EVENTSERVICE_V1_2_3_CS *EventServiceV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_2_3_To_CS (ResoruceRaw, &EventServiceV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_2_3 = (EFI_REDFISH_EVENTSERVICE_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_2_3)); + if (EventServiceV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_2_3; + EventServiceV1_2_3->EventService = EventServiceV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_2_3_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_2_3 *EventServiceV1_2_3; + + EventServiceV1_2_3 = (EFI_REDFISH_EVENTSERVICE_V1_2_3 *)InterpProp; + DestroyEventService_V1_2_3_CS (EventServiceV1_2_3->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_2_3/RedfishEventService_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_2_3/RedfishEventService_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..0eb5abae572 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_2_3/RedfishEventService_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_2_3_Dxe + FILE_GUID = 344936dd-b85b-4cf6-a55e-8a2e734e5e0a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_2_4/EventService_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_2_4/EventService_V1_2_4_Dxe.c new file mode 100644 index 00000000000..98ae28778c4 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_2_4/EventService_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "2", + "4" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_2_4 *EventServiceV1_2_4; + EFI_REDFISH_EVENTSERVICE_V1_2_4_CS *EventServiceV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_2_4_To_CS (ResoruceRaw, &EventServiceV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_2_4 = (EFI_REDFISH_EVENTSERVICE_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_2_4)); + if (EventServiceV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_2_4; + EventServiceV1_2_4->EventService = EventServiceV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_2_4_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_2_4 *EventServiceV1_2_4; + + EventServiceV1_2_4 = (EFI_REDFISH_EVENTSERVICE_V1_2_4 *)InterpProp; + DestroyEventService_V1_2_4_CS (EventServiceV1_2_4->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_2_4/RedfishEventService_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_2_4/RedfishEventService_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..88ab242efa9 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_2_4/RedfishEventService_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_2_4_Dxe + FILE_GUID = 78b63f96-0585-41f0-83be-7324b7279d7e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_2_5/EventService_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_2_5/EventService_V1_2_5_Dxe.c new file mode 100644 index 00000000000..5471693f149 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_2_5/EventService_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "2", + "5" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_2_5 *EventServiceV1_2_5; + EFI_REDFISH_EVENTSERVICE_V1_2_5_CS *EventServiceV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_2_5_To_CS (ResoruceRaw, &EventServiceV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_2_5 = (EFI_REDFISH_EVENTSERVICE_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_2_5)); + if (EventServiceV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_2_5; + EventServiceV1_2_5->EventService = EventServiceV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_2_5_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_2_5 *EventServiceV1_2_5; + + EventServiceV1_2_5 = (EFI_REDFISH_EVENTSERVICE_V1_2_5 *)InterpProp; + DestroyEventService_V1_2_5_CS (EventServiceV1_2_5->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_2_5/RedfishEventService_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_2_5/RedfishEventService_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..6098b10f16b --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_2_5/RedfishEventService_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_2_5_Dxe + FILE_GUID = 7ddff4b1-4f0b-428f-9a1b-5a848f58d993 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_3_0/EventService_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_3_0/EventService_V1_3_0_Dxe.c new file mode 100644 index 00000000000..b48a2090e1f --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_3_0/EventService_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "3", + "0" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_3_0 *EventServiceV1_3_0; + EFI_REDFISH_EVENTSERVICE_V1_3_0_CS *EventServiceV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_3_0_To_CS (ResoruceRaw, &EventServiceV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_3_0 = (EFI_REDFISH_EVENTSERVICE_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_3_0)); + if (EventServiceV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_3_0; + EventServiceV1_3_0->EventService = EventServiceV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_3_0_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_3_0 *EventServiceV1_3_0; + + EventServiceV1_3_0 = (EFI_REDFISH_EVENTSERVICE_V1_3_0 *)InterpProp; + DestroyEventService_V1_3_0_CS (EventServiceV1_3_0->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_3_0/RedfishEventService_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_3_0/RedfishEventService_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..a3e2706e908 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_3_0/RedfishEventService_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_3_0_Dxe + FILE_GUID = 705eb48b-6b22-4976-8bec-bb31f15421da + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_3_1/EventService_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_3_1/EventService_V1_3_1_Dxe.c new file mode 100644 index 00000000000..1c844c2da62 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_3_1/EventService_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "3", + "1" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_3_1 *EventServiceV1_3_1; + EFI_REDFISH_EVENTSERVICE_V1_3_1_CS *EventServiceV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_3_1_To_CS (ResoruceRaw, &EventServiceV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_3_1 = (EFI_REDFISH_EVENTSERVICE_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_3_1)); + if (EventServiceV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_3_1; + EventServiceV1_3_1->EventService = EventServiceV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_3_1_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_3_1 *EventServiceV1_3_1; + + EventServiceV1_3_1 = (EFI_REDFISH_EVENTSERVICE_V1_3_1 *)InterpProp; + DestroyEventService_V1_3_1_CS (EventServiceV1_3_1->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_3_1/RedfishEventService_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_3_1/RedfishEventService_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..be9d872c1f8 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_3_1/RedfishEventService_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_3_1_Dxe + FILE_GUID = 30521313-c02f-46da-bf20-8d3e3ebbf55f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_3_2/EventService_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_3_2/EventService_V1_3_2_Dxe.c new file mode 100644 index 00000000000..e8f44311428 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_3_2/EventService_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "3", + "2" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_3_2 *EventServiceV1_3_2; + EFI_REDFISH_EVENTSERVICE_V1_3_2_CS *EventServiceV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_3_2_To_CS (ResoruceRaw, &EventServiceV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_3_2 = (EFI_REDFISH_EVENTSERVICE_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_3_2)); + if (EventServiceV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_3_2; + EventServiceV1_3_2->EventService = EventServiceV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_3_2_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_3_2 *EventServiceV1_3_2; + + EventServiceV1_3_2 = (EFI_REDFISH_EVENTSERVICE_V1_3_2 *)InterpProp; + DestroyEventService_V1_3_2_CS (EventServiceV1_3_2->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_3_2/RedfishEventService_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_3_2/RedfishEventService_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..3f69f165d07 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_3_2/RedfishEventService_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_3_2_Dxe + FILE_GUID = 45f326e8-c659-42e2-9cea-d77dc0617ee3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_3_3/EventService_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_3_3/EventService_V1_3_3_Dxe.c new file mode 100644 index 00000000000..6212138de4e --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_3_3/EventService_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "3", + "3" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_3_3 *EventServiceV1_3_3; + EFI_REDFISH_EVENTSERVICE_V1_3_3_CS *EventServiceV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_3_3_To_CS (ResoruceRaw, &EventServiceV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_3_3 = (EFI_REDFISH_EVENTSERVICE_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_3_3)); + if (EventServiceV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_3_3; + EventServiceV1_3_3->EventService = EventServiceV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_3_3_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_3_3 *EventServiceV1_3_3; + + EventServiceV1_3_3 = (EFI_REDFISH_EVENTSERVICE_V1_3_3 *)InterpProp; + DestroyEventService_V1_3_3_CS (EventServiceV1_3_3->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_3_3/RedfishEventService_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_3_3/RedfishEventService_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..c2946f46296 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_3_3/RedfishEventService_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_3_3_Dxe + FILE_GUID = 154e1745-bbc5-4cf6-b156-0b61498f2e65 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_3_4/EventService_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_3_4/EventService_V1_3_4_Dxe.c new file mode 100644 index 00000000000..4640a8a4ac9 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_3_4/EventService_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "3", + "4" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_3_4 *EventServiceV1_3_4; + EFI_REDFISH_EVENTSERVICE_V1_3_4_CS *EventServiceV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_3_4_To_CS (ResoruceRaw, &EventServiceV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_3_4 = (EFI_REDFISH_EVENTSERVICE_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_3_4)); + if (EventServiceV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_3_4; + EventServiceV1_3_4->EventService = EventServiceV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_3_4_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_3_4 *EventServiceV1_3_4; + + EventServiceV1_3_4 = (EFI_REDFISH_EVENTSERVICE_V1_3_4 *)InterpProp; + DestroyEventService_V1_3_4_CS (EventServiceV1_3_4->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_3_4/RedfishEventService_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_3_4/RedfishEventService_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..425c2db9ffc --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_3_4/RedfishEventService_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_3_4_Dxe + FILE_GUID = ee15fb63-65a9-4712-8944-54d1c7a330ed + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_4_0/EventService_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_4_0/EventService_V1_4_0_Dxe.c new file mode 100644 index 00000000000..e1a0a2fddd9 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_4_0/EventService_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "4", + "0" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_4_0 *EventServiceV1_4_0; + EFI_REDFISH_EVENTSERVICE_V1_4_0_CS *EventServiceV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_4_0_To_CS (ResoruceRaw, &EventServiceV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_4_0 = (EFI_REDFISH_EVENTSERVICE_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_4_0)); + if (EventServiceV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_4_0; + EventServiceV1_4_0->EventService = EventServiceV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_4_0_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_4_0 *EventServiceV1_4_0; + + EventServiceV1_4_0 = (EFI_REDFISH_EVENTSERVICE_V1_4_0 *)InterpProp; + DestroyEventService_V1_4_0_CS (EventServiceV1_4_0->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_4_0/RedfishEventService_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_4_0/RedfishEventService_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..002b757a93f --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_4_0/RedfishEventService_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_4_0_Dxe + FILE_GUID = 8fb3e4a5-72ae-441c-92fb-ab4cd82f8657 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_4_1/EventService_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_4_1/EventService_V1_4_1_Dxe.c new file mode 100644 index 00000000000..7dd1e4cc89f --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_4_1/EventService_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "4", + "1" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_4_1 *EventServiceV1_4_1; + EFI_REDFISH_EVENTSERVICE_V1_4_1_CS *EventServiceV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_4_1_To_CS (ResoruceRaw, &EventServiceV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_4_1 = (EFI_REDFISH_EVENTSERVICE_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_4_1)); + if (EventServiceV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_4_1; + EventServiceV1_4_1->EventService = EventServiceV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_4_1_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_4_1 *EventServiceV1_4_1; + + EventServiceV1_4_1 = (EFI_REDFISH_EVENTSERVICE_V1_4_1 *)InterpProp; + DestroyEventService_V1_4_1_CS (EventServiceV1_4_1->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_4_1/RedfishEventService_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_4_1/RedfishEventService_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..6690890d99c --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_4_1/RedfishEventService_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_4_1_Dxe + FILE_GUID = c478399b-11da-44f6-941f-0f9e83bfae49 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_4_2/EventService_V1_4_2_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_4_2/EventService_V1_4_2_Dxe.c new file mode 100644 index 00000000000..de60d4e4606 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_4_2/EventService_V1_4_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_4_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "4", + "2" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_4_2 *EventServiceV1_4_2; + EFI_REDFISH_EVENTSERVICE_V1_4_2_CS *EventServiceV1_4_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_4_2_To_CS (ResoruceRaw, &EventServiceV1_4_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_4_2 = (EFI_REDFISH_EVENTSERVICE_V1_4_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_4_2)); + if (EventServiceV1_4_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_4_2; + EventServiceV1_4_2->EventService = EventServiceV1_4_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_4_2_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_4_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_4_2 *EventServiceV1_4_2; + + EventServiceV1_4_2 = (EFI_REDFISH_EVENTSERVICE_V1_4_2 *)InterpProp; + DestroyEventService_V1_4_2_CS (EventServiceV1_4_2->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_4_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_4_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_4_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_4_2/RedfishEventService_V1_4_2_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_4_2/RedfishEventService_V1_4_2_Dxe.inf new file mode 100644 index 00000000000..62b0df51017 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_4_2/RedfishEventService_V1_4_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_4_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_4_2_Dxe + FILE_GUID = 222420dc-c058-490b-9b76-c1abd38164df + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_4_2EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_4_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_4_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_4_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_4_3/EventService_V1_4_3_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_4_3/EventService_V1_4_3_Dxe.c new file mode 100644 index 00000000000..989d103e89e --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_4_3/EventService_V1_4_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_4_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "4", + "3" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_4_3 *EventServiceV1_4_3; + EFI_REDFISH_EVENTSERVICE_V1_4_3_CS *EventServiceV1_4_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_4_3_To_CS (ResoruceRaw, &EventServiceV1_4_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_4_3 = (EFI_REDFISH_EVENTSERVICE_V1_4_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_4_3)); + if (EventServiceV1_4_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_4_3; + EventServiceV1_4_3->EventService = EventServiceV1_4_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_4_3_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_4_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_4_3 *EventServiceV1_4_3; + + EventServiceV1_4_3 = (EFI_REDFISH_EVENTSERVICE_V1_4_3 *)InterpProp; + DestroyEventService_V1_4_3_CS (EventServiceV1_4_3->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_4_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_4_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_4_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_4_3/RedfishEventService_V1_4_3_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_4_3/RedfishEventService_V1_4_3_Dxe.inf new file mode 100644 index 00000000000..999d5f008aa --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_4_3/RedfishEventService_V1_4_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_4_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_4_3_Dxe + FILE_GUID = 878c5c53-255a-4e88-9851-1bf66bab68d0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_4_3EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_4_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_4_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_4_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_5_0/EventService_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_5_0/EventService_V1_5_0_Dxe.c new file mode 100644 index 00000000000..4389a246130 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_5_0/EventService_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "5", + "0" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_5_0 *EventServiceV1_5_0; + EFI_REDFISH_EVENTSERVICE_V1_5_0_CS *EventServiceV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_5_0_To_CS (ResoruceRaw, &EventServiceV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_5_0 = (EFI_REDFISH_EVENTSERVICE_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_5_0)); + if (EventServiceV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_5_0; + EventServiceV1_5_0->EventService = EventServiceV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_5_0_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_5_0 *EventServiceV1_5_0; + + EventServiceV1_5_0 = (EFI_REDFISH_EVENTSERVICE_V1_5_0 *)InterpProp; + DestroyEventService_V1_5_0_CS (EventServiceV1_5_0->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_5_0/RedfishEventService_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_5_0/RedfishEventService_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..fa7ac2d9636 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_5_0/RedfishEventService_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_5_0_Dxe + FILE_GUID = cb115818-6eaa-46e3-8410-f5578a355ffd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_5_1/EventService_V1_5_1_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_5_1/EventService_V1_5_1_Dxe.c new file mode 100644 index 00000000000..88a9a812143 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_5_1/EventService_V1_5_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_5_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "5", + "1" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_5_1 *EventServiceV1_5_1; + EFI_REDFISH_EVENTSERVICE_V1_5_1_CS *EventServiceV1_5_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_5_1_To_CS (ResoruceRaw, &EventServiceV1_5_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_5_1 = (EFI_REDFISH_EVENTSERVICE_V1_5_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_5_1)); + if (EventServiceV1_5_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_5_1; + EventServiceV1_5_1->EventService = EventServiceV1_5_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_5_1_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_5_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_5_1 *EventServiceV1_5_1; + + EventServiceV1_5_1 = (EFI_REDFISH_EVENTSERVICE_V1_5_1 *)InterpProp; + DestroyEventService_V1_5_1_CS (EventServiceV1_5_1->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_5_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_5_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_5_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_5_1/RedfishEventService_V1_5_1_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_5_1/RedfishEventService_V1_5_1_Dxe.inf new file mode 100644 index 00000000000..a2649a1ca43 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_5_1/RedfishEventService_V1_5_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_5_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_5_1_Dxe + FILE_GUID = afeb8452-24ff-45b1-a0ec-200732cdf9c3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_5_1EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_5_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_5_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_5_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_5_2/EventService_V1_5_2_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_5_2/EventService_V1_5_2_Dxe.c new file mode 100644 index 00000000000..a22e5b570cd --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_5_2/EventService_V1_5_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_5_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "5", + "2" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_5_2 *EventServiceV1_5_2; + EFI_REDFISH_EVENTSERVICE_V1_5_2_CS *EventServiceV1_5_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_5_2_To_CS (ResoruceRaw, &EventServiceV1_5_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_5_2 = (EFI_REDFISH_EVENTSERVICE_V1_5_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_5_2)); + if (EventServiceV1_5_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_5_2; + EventServiceV1_5_2->EventService = EventServiceV1_5_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_5_2_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_5_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_5_2 *EventServiceV1_5_2; + + EventServiceV1_5_2 = (EFI_REDFISH_EVENTSERVICE_V1_5_2 *)InterpProp; + DestroyEventService_V1_5_2_CS (EventServiceV1_5_2->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_5_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_5_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_5_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_5_2/RedfishEventService_V1_5_2_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_5_2/RedfishEventService_V1_5_2_Dxe.inf new file mode 100644 index 00000000000..7187caf5ac5 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_5_2/RedfishEventService_V1_5_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_5_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_5_2_Dxe + FILE_GUID = 95c2305f-1a34-458b-978a-2b99b50ff1e8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_5_2EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_5_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_5_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_5_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_5_3/EventService_V1_5_3_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_5_3/EventService_V1_5_3_Dxe.c new file mode 100644 index 00000000000..3acd424d741 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_5_3/EventService_V1_5_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_5_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "5", + "3" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_5_3 *EventServiceV1_5_3; + EFI_REDFISH_EVENTSERVICE_V1_5_3_CS *EventServiceV1_5_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_5_3_To_CS (ResoruceRaw, &EventServiceV1_5_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_5_3 = (EFI_REDFISH_EVENTSERVICE_V1_5_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_5_3)); + if (EventServiceV1_5_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_5_3; + EventServiceV1_5_3->EventService = EventServiceV1_5_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_5_3_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_5_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_5_3 *EventServiceV1_5_3; + + EventServiceV1_5_3 = (EFI_REDFISH_EVENTSERVICE_V1_5_3 *)InterpProp; + DestroyEventService_V1_5_3_CS (EventServiceV1_5_3->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_5_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_5_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_5_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_5_3/RedfishEventService_V1_5_3_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_5_3/RedfishEventService_V1_5_3_Dxe.inf new file mode 100644 index 00000000000..4a49ac33472 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_5_3/RedfishEventService_V1_5_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_5_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_5_3_Dxe + FILE_GUID = 3523681a-2a56-4e1d-ad97-18a5fa7dc32f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_5_3EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_5_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_5_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_5_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_6_0/EventService_V1_6_0_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_6_0/EventService_V1_6_0_Dxe.c new file mode 100644 index 00000000000..de7255c82a7 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_6_0/EventService_V1_6_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_6_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "6", + "0" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_6_0 *EventServiceV1_6_0; + EFI_REDFISH_EVENTSERVICE_V1_6_0_CS *EventServiceV1_6_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_6_0_To_CS (ResoruceRaw, &EventServiceV1_6_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_6_0 = (EFI_REDFISH_EVENTSERVICE_V1_6_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_6_0)); + if (EventServiceV1_6_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_6_0; + EventServiceV1_6_0->EventService = EventServiceV1_6_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_6_0_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_6_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_6_0 *EventServiceV1_6_0; + + EventServiceV1_6_0 = (EFI_REDFISH_EVENTSERVICE_V1_6_0 *)InterpProp; + DestroyEventService_V1_6_0_CS (EventServiceV1_6_0->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_6_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_6_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_6_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_6_0/RedfishEventService_V1_6_0_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_6_0/RedfishEventService_V1_6_0_Dxe.inf new file mode 100644 index 00000000000..0a8b88a80f5 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_6_0/RedfishEventService_V1_6_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_6_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_6_0_Dxe + FILE_GUID = bfb7c891-27e7-47aa-b0a2-9e638bc95390 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_6_0EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_6_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_6_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_6_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_6_1/EventService_V1_6_1_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_6_1/EventService_V1_6_1_Dxe.c new file mode 100644 index 00000000000..adb7ea189e3 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_6_1/EventService_V1_6_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_6_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "6", + "1" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_6_1 *EventServiceV1_6_1; + EFI_REDFISH_EVENTSERVICE_V1_6_1_CS *EventServiceV1_6_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_6_1_To_CS (ResoruceRaw, &EventServiceV1_6_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_6_1 = (EFI_REDFISH_EVENTSERVICE_V1_6_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_6_1)); + if (EventServiceV1_6_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_6_1; + EventServiceV1_6_1->EventService = EventServiceV1_6_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_6_1_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_6_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_6_1 *EventServiceV1_6_1; + + EventServiceV1_6_1 = (EFI_REDFISH_EVENTSERVICE_V1_6_1 *)InterpProp; + DestroyEventService_V1_6_1_CS (EventServiceV1_6_1->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_6_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_6_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_6_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_6_1/RedfishEventService_V1_6_1_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_6_1/RedfishEventService_V1_6_1_Dxe.inf new file mode 100644 index 00000000000..34a47954062 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_6_1/RedfishEventService_V1_6_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_6_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_6_1_Dxe + FILE_GUID = dc8ca3a1-5c71-4740-848d-52dc50885551 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_6_1EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_6_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_6_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_6_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_6_2/EventService_V1_6_2_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_6_2/EventService_V1_6_2_Dxe.c new file mode 100644 index 00000000000..fb3e6268258 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_6_2/EventService_V1_6_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_6_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "6", + "2" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_6_2 *EventServiceV1_6_2; + EFI_REDFISH_EVENTSERVICE_V1_6_2_CS *EventServiceV1_6_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_6_2_To_CS (ResoruceRaw, &EventServiceV1_6_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_6_2 = (EFI_REDFISH_EVENTSERVICE_V1_6_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_6_2)); + if (EventServiceV1_6_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_6_2; + EventServiceV1_6_2->EventService = EventServiceV1_6_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_6_2_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_6_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_6_2 *EventServiceV1_6_2; + + EventServiceV1_6_2 = (EFI_REDFISH_EVENTSERVICE_V1_6_2 *)InterpProp; + DestroyEventService_V1_6_2_CS (EventServiceV1_6_2->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_6_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_6_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_6_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_6_2/RedfishEventService_V1_6_2_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_6_2/RedfishEventService_V1_6_2_Dxe.inf new file mode 100644 index 00000000000..12578d360b3 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_6_2/RedfishEventService_V1_6_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_6_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_6_2_Dxe + FILE_GUID = 608b7e72-96c2-472b-8421-ea368c118434 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_6_2EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_6_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_6_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_6_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_7_0/EventService_V1_7_0_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_7_0/EventService_V1_7_0_Dxe.c new file mode 100644 index 00000000000..1fba13fdf2a --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_7_0/EventService_V1_7_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_7_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "7", + "0" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_7_0 *EventServiceV1_7_0; + EFI_REDFISH_EVENTSERVICE_V1_7_0_CS *EventServiceV1_7_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_7_0_To_CS (ResoruceRaw, &EventServiceV1_7_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_7_0 = (EFI_REDFISH_EVENTSERVICE_V1_7_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_7_0)); + if (EventServiceV1_7_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_7_0; + EventServiceV1_7_0->EventService = EventServiceV1_7_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_7_0_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_7_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_7_0 *EventServiceV1_7_0; + + EventServiceV1_7_0 = (EFI_REDFISH_EVENTSERVICE_V1_7_0 *)InterpProp; + DestroyEventService_V1_7_0_CS (EventServiceV1_7_0->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_7_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_7_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_7_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_7_0/RedfishEventService_V1_7_0_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_7_0/RedfishEventService_V1_7_0_Dxe.inf new file mode 100644 index 00000000000..4148094f8e0 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_7_0/RedfishEventService_V1_7_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_7_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_7_0_Dxe + FILE_GUID = 8ecd4c3c-2b7c-4d44-931b-d391fb14e98f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_7_0EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_7_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_7_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_7_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/EventService/v1_7_1/EventService_V1_7_1_Dxe.c b/RedfishClientPkg/Converter/EventService/v1_7_1/EventService_V1_7_1_Dxe.c new file mode 100644 index 00000000000..fec25f6b253 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_7_1/EventService_V1_7_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - EventService.v1_7_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#EventService"; +BOOLEAN IsRevisonController = TRUE; + +// Support EventService V1_7_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "EventService", + "1", + "7", + "1" + }, + "EventService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_7_1 *EventServiceV1_7_1; + EFI_REDFISH_EVENTSERVICE_V1_7_1_CS *EventServiceV1_7_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "EventService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_EventService_V1_7_1_To_CS (ResoruceRaw, &EventServiceV1_7_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + EventServiceV1_7_1 = (EFI_REDFISH_EVENTSERVICE_V1_7_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EVENTSERVICE_V1_7_1)); + if (EventServiceV1_7_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)EventServiceV1_7_1; + EventServiceV1_7_1->EventService = EventServiceV1_7_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("EventService"), "EventService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("EventService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("EventService"), "EventService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of EventServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return EventServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_EventService_V1_7_1_JSON (*((EFI_REDFISH_EVENTSERVICE_V1_7_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in EventServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EVENTSERVICE_V1_7_1 *EventServiceV1_7_1; + + EventServiceV1_7_1 = (EFI_REDFISH_EVENTSERVICE_V1_7_1 *)InterpProp; + DestroyEventService_V1_7_1_CS (EventServiceV1_7_1->EventService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from EventServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +EventServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyEventService_V1_7_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_7_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + EventServiceToStructWrapper, + EventServiceToJson, + EventServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishEventService_V1_7_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/EventService/v1_7_1/RedfishEventService_V1_7_1_Dxe.inf b/RedfishClientPkg/Converter/EventService/v1_7_1/RedfishEventService_V1_7_1_Dxe.inf new file mode 100644 index 00000000000..39626586ef9 --- /dev/null +++ b/RedfishClientPkg/Converter/EventService/v1_7_1/RedfishEventService_V1_7_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of EventService.v1_7_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishEventService_V1_7_1_Dxe + FILE_GUID = f5abc2e3-e85c-4399-a570-c544b10ad81c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishEventService_V1_7_1EntryPoint + UNLOAD_IMAGE = RedfishEventService_V1_7_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + EventService_V1_7_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + EventServiceV1_7_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_0/ExternalAccountProvider_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_0/ExternalAccountProvider_V1_0_0_Dxe.c new file mode 100644 index 00000000000..75280f18551 --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_0/ExternalAccountProvider_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ExternalAccountProvider.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ExternalAccountProvider"; +BOOLEAN IsRevisonController = TRUE; + +// Support ExternalAccountProvider V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ExternalAccountProvider", + "1", + "0", + "0" + }, + "ExternalAccountProvider" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_0 *ExternalAccountProviderV1_0_0; + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_0_CS *ExternalAccountProviderV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ExternalAccountProvider") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ExternalAccountProvider_V1_0_0_To_CS (ResoruceRaw, &ExternalAccountProviderV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ExternalAccountProviderV1_0_0 = (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_0)); + if (ExternalAccountProviderV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ExternalAccountProviderV1_0_0; + ExternalAccountProviderV1_0_0->ExternalAccountProvider = ExternalAccountProviderV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProvider")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ExternalAccountProvider"), "ExternalAccountProvider"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProvider")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ExternalAccountProvider"), "ExternalAccountProvider"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ExternalAccountProviderToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ExternalAccountProviderToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ExternalAccountProvider_V1_0_0_JSON (*((EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ExternalAccountProviderToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_0 *ExternalAccountProviderV1_0_0; + + ExternalAccountProviderV1_0_0 = (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_0 *)InterpProp; + DestroyExternalAccountProvider_V1_0_0_CS (ExternalAccountProviderV1_0_0->ExternalAccountProvider); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ExternalAccountProviderFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyExternalAccountProvider_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProvider_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ExternalAccountProviderToStructWrapper, + ExternalAccountProviderToJson, + ExternalAccountProviderDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProvider_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_0/RedfishExternalAccountProvider_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_0/RedfishExternalAccountProvider_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..0086076a25b --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_0/RedfishExternalAccountProvider_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ExternalAccountProvider.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishExternalAccountProvider_V1_0_0_Dxe + FILE_GUID = 9aff0a6a-ad8e-4dae-bc4f-28519e393f74 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishExternalAccountProvider_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishExternalAccountProvider_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ExternalAccountProvider_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ExternalAccountProviderV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_1/ExternalAccountProvider_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_1/ExternalAccountProvider_V1_0_1_Dxe.c new file mode 100644 index 00000000000..26f0995f433 --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_1/ExternalAccountProvider_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ExternalAccountProvider.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ExternalAccountProvider"; +BOOLEAN IsRevisonController = TRUE; + +// Support ExternalAccountProvider V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ExternalAccountProvider", + "1", + "0", + "1" + }, + "ExternalAccountProvider" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_1 *ExternalAccountProviderV1_0_1; + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_1_CS *ExternalAccountProviderV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ExternalAccountProvider") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ExternalAccountProvider_V1_0_1_To_CS (ResoruceRaw, &ExternalAccountProviderV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ExternalAccountProviderV1_0_1 = (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_1)); + if (ExternalAccountProviderV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ExternalAccountProviderV1_0_1; + ExternalAccountProviderV1_0_1->ExternalAccountProvider = ExternalAccountProviderV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProvider")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ExternalAccountProvider"), "ExternalAccountProvider"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProvider")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ExternalAccountProvider"), "ExternalAccountProvider"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ExternalAccountProviderToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ExternalAccountProviderToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ExternalAccountProvider_V1_0_1_JSON (*((EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ExternalAccountProviderToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_1 *ExternalAccountProviderV1_0_1; + + ExternalAccountProviderV1_0_1 = (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_1 *)InterpProp; + DestroyExternalAccountProvider_V1_0_1_CS (ExternalAccountProviderV1_0_1->ExternalAccountProvider); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ExternalAccountProviderFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyExternalAccountProvider_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProvider_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ExternalAccountProviderToStructWrapper, + ExternalAccountProviderToJson, + ExternalAccountProviderDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProvider_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_1/RedfishExternalAccountProvider_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_1/RedfishExternalAccountProvider_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..3e6ae6d2553 --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_1/RedfishExternalAccountProvider_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ExternalAccountProvider.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishExternalAccountProvider_V1_0_1_Dxe + FILE_GUID = c5e9dec7-4ff0-4949-9a69-741f2909e868 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishExternalAccountProvider_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishExternalAccountProvider_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ExternalAccountProvider_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ExternalAccountProviderV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_2/ExternalAccountProvider_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_2/ExternalAccountProvider_V1_0_2_Dxe.c new file mode 100644 index 00000000000..9a2cd378061 --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_2/ExternalAccountProvider_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ExternalAccountProvider.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ExternalAccountProvider"; +BOOLEAN IsRevisonController = TRUE; + +// Support ExternalAccountProvider V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ExternalAccountProvider", + "1", + "0", + "2" + }, + "ExternalAccountProvider" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_2 *ExternalAccountProviderV1_0_2; + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_2_CS *ExternalAccountProviderV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ExternalAccountProvider") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ExternalAccountProvider_V1_0_2_To_CS (ResoruceRaw, &ExternalAccountProviderV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ExternalAccountProviderV1_0_2 = (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_2)); + if (ExternalAccountProviderV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ExternalAccountProviderV1_0_2; + ExternalAccountProviderV1_0_2->ExternalAccountProvider = ExternalAccountProviderV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProvider")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ExternalAccountProvider"), "ExternalAccountProvider"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProvider")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ExternalAccountProvider"), "ExternalAccountProvider"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ExternalAccountProviderToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ExternalAccountProviderToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ExternalAccountProvider_V1_0_2_JSON (*((EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ExternalAccountProviderToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_2 *ExternalAccountProviderV1_0_2; + + ExternalAccountProviderV1_0_2 = (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_2 *)InterpProp; + DestroyExternalAccountProvider_V1_0_2_CS (ExternalAccountProviderV1_0_2->ExternalAccountProvider); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ExternalAccountProviderFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyExternalAccountProvider_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProvider_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ExternalAccountProviderToStructWrapper, + ExternalAccountProviderToJson, + ExternalAccountProviderDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProvider_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_2/RedfishExternalAccountProvider_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_2/RedfishExternalAccountProvider_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..cb14e4020a5 --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_2/RedfishExternalAccountProvider_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ExternalAccountProvider.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishExternalAccountProvider_V1_0_2_Dxe + FILE_GUID = d677414b-43ef-4b45-af5b-66d764cd6825 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishExternalAccountProvider_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishExternalAccountProvider_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ExternalAccountProvider_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ExternalAccountProviderV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_3/ExternalAccountProvider_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_3/ExternalAccountProvider_V1_0_3_Dxe.c new file mode 100644 index 00000000000..cd89754247b --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_3/ExternalAccountProvider_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ExternalAccountProvider.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ExternalAccountProvider"; +BOOLEAN IsRevisonController = TRUE; + +// Support ExternalAccountProvider V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ExternalAccountProvider", + "1", + "0", + "3" + }, + "ExternalAccountProvider" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_3 *ExternalAccountProviderV1_0_3; + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_3_CS *ExternalAccountProviderV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ExternalAccountProvider") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ExternalAccountProvider_V1_0_3_To_CS (ResoruceRaw, &ExternalAccountProviderV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ExternalAccountProviderV1_0_3 = (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_3)); + if (ExternalAccountProviderV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ExternalAccountProviderV1_0_3; + ExternalAccountProviderV1_0_3->ExternalAccountProvider = ExternalAccountProviderV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProvider")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ExternalAccountProvider"), "ExternalAccountProvider"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProvider")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ExternalAccountProvider"), "ExternalAccountProvider"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ExternalAccountProviderToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ExternalAccountProviderToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ExternalAccountProvider_V1_0_3_JSON (*((EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ExternalAccountProviderToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_3 *ExternalAccountProviderV1_0_3; + + ExternalAccountProviderV1_0_3 = (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_3 *)InterpProp; + DestroyExternalAccountProvider_V1_0_3_CS (ExternalAccountProviderV1_0_3->ExternalAccountProvider); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ExternalAccountProviderFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyExternalAccountProvider_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProvider_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ExternalAccountProviderToStructWrapper, + ExternalAccountProviderToJson, + ExternalAccountProviderDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProvider_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_3/RedfishExternalAccountProvider_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_3/RedfishExternalAccountProvider_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..b508f7279b3 --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_3/RedfishExternalAccountProvider_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ExternalAccountProvider.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishExternalAccountProvider_V1_0_3_Dxe + FILE_GUID = 4fdc06d4-d6a6-4bc3-a4fc-1a9c7f731cde + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishExternalAccountProvider_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishExternalAccountProvider_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ExternalAccountProvider_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ExternalAccountProviderV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_4/ExternalAccountProvider_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_4/ExternalAccountProvider_V1_0_4_Dxe.c new file mode 100644 index 00000000000..d870b5f6f38 --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_4/ExternalAccountProvider_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ExternalAccountProvider.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ExternalAccountProvider"; +BOOLEAN IsRevisonController = TRUE; + +// Support ExternalAccountProvider V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ExternalAccountProvider", + "1", + "0", + "4" + }, + "ExternalAccountProvider" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_4 *ExternalAccountProviderV1_0_4; + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_4_CS *ExternalAccountProviderV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ExternalAccountProvider") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ExternalAccountProvider_V1_0_4_To_CS (ResoruceRaw, &ExternalAccountProviderV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ExternalAccountProviderV1_0_4 = (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_4)); + if (ExternalAccountProviderV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ExternalAccountProviderV1_0_4; + ExternalAccountProviderV1_0_4->ExternalAccountProvider = ExternalAccountProviderV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProvider")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ExternalAccountProvider"), "ExternalAccountProvider"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProvider")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ExternalAccountProvider"), "ExternalAccountProvider"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ExternalAccountProviderToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ExternalAccountProviderToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ExternalAccountProvider_V1_0_4_JSON (*((EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ExternalAccountProviderToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_4 *ExternalAccountProviderV1_0_4; + + ExternalAccountProviderV1_0_4 = (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_4 *)InterpProp; + DestroyExternalAccountProvider_V1_0_4_CS (ExternalAccountProviderV1_0_4->ExternalAccountProvider); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ExternalAccountProviderFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyExternalAccountProvider_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProvider_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ExternalAccountProviderToStructWrapper, + ExternalAccountProviderToJson, + ExternalAccountProviderDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProvider_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_4/RedfishExternalAccountProvider_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_4/RedfishExternalAccountProvider_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..ff1683adbb2 --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_4/RedfishExternalAccountProvider_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ExternalAccountProvider.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishExternalAccountProvider_V1_0_4_Dxe + FILE_GUID = c3cfa3bc-0e08-4b5a-8157-d1cd106aceb0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishExternalAccountProvider_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishExternalAccountProvider_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ExternalAccountProvider_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ExternalAccountProviderV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_5/ExternalAccountProvider_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_5/ExternalAccountProvider_V1_0_5_Dxe.c new file mode 100644 index 00000000000..ec4f3dde43e --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_5/ExternalAccountProvider_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ExternalAccountProvider.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ExternalAccountProvider"; +BOOLEAN IsRevisonController = TRUE; + +// Support ExternalAccountProvider V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ExternalAccountProvider", + "1", + "0", + "5" + }, + "ExternalAccountProvider" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_5 *ExternalAccountProviderV1_0_5; + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_5_CS *ExternalAccountProviderV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ExternalAccountProvider") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ExternalAccountProvider_V1_0_5_To_CS (ResoruceRaw, &ExternalAccountProviderV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ExternalAccountProviderV1_0_5 = (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_5)); + if (ExternalAccountProviderV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ExternalAccountProviderV1_0_5; + ExternalAccountProviderV1_0_5->ExternalAccountProvider = ExternalAccountProviderV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProvider")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ExternalAccountProvider"), "ExternalAccountProvider"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProvider")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ExternalAccountProvider"), "ExternalAccountProvider"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ExternalAccountProviderToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ExternalAccountProviderToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ExternalAccountProvider_V1_0_5_JSON (*((EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ExternalAccountProviderToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_5 *ExternalAccountProviderV1_0_5; + + ExternalAccountProviderV1_0_5 = (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_5 *)InterpProp; + DestroyExternalAccountProvider_V1_0_5_CS (ExternalAccountProviderV1_0_5->ExternalAccountProvider); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ExternalAccountProviderFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyExternalAccountProvider_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProvider_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ExternalAccountProviderToStructWrapper, + ExternalAccountProviderToJson, + ExternalAccountProviderDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProvider_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_5/RedfishExternalAccountProvider_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_5/RedfishExternalAccountProvider_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..65dc12e9abc --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_0_5/RedfishExternalAccountProvider_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ExternalAccountProvider.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishExternalAccountProvider_V1_0_5_Dxe + FILE_GUID = f0ac735b-e722-4a45-b159-f185fd37ef12 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishExternalAccountProvider_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishExternalAccountProvider_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ExternalAccountProvider_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ExternalAccountProviderV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_0/ExternalAccountProvider_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_0/ExternalAccountProvider_V1_1_0_Dxe.c new file mode 100644 index 00000000000..2574f464c79 --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_0/ExternalAccountProvider_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ExternalAccountProvider.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ExternalAccountProvider"; +BOOLEAN IsRevisonController = TRUE; + +// Support ExternalAccountProvider V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ExternalAccountProvider", + "1", + "1", + "0" + }, + "ExternalAccountProvider" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_0 *ExternalAccountProviderV1_1_0; + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_0_CS *ExternalAccountProviderV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ExternalAccountProvider") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ExternalAccountProvider_V1_1_0_To_CS (ResoruceRaw, &ExternalAccountProviderV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ExternalAccountProviderV1_1_0 = (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_0)); + if (ExternalAccountProviderV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ExternalAccountProviderV1_1_0; + ExternalAccountProviderV1_1_0->ExternalAccountProvider = ExternalAccountProviderV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProvider")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ExternalAccountProvider"), "ExternalAccountProvider"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProvider")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ExternalAccountProvider"), "ExternalAccountProvider"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ExternalAccountProviderToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ExternalAccountProviderToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ExternalAccountProvider_V1_1_0_JSON (*((EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ExternalAccountProviderToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_0 *ExternalAccountProviderV1_1_0; + + ExternalAccountProviderV1_1_0 = (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_0 *)InterpProp; + DestroyExternalAccountProvider_V1_1_0_CS (ExternalAccountProviderV1_1_0->ExternalAccountProvider); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ExternalAccountProviderFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyExternalAccountProvider_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProvider_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ExternalAccountProviderToStructWrapper, + ExternalAccountProviderToJson, + ExternalAccountProviderDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProvider_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_0/RedfishExternalAccountProvider_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_0/RedfishExternalAccountProvider_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..f8e4f9cac76 --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_0/RedfishExternalAccountProvider_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ExternalAccountProvider.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishExternalAccountProvider_V1_1_0_Dxe + FILE_GUID = 562d4c4b-593c-4e4f-9a55-583c88d1d2b8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishExternalAccountProvider_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishExternalAccountProvider_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ExternalAccountProvider_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ExternalAccountProviderV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_1/ExternalAccountProvider_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_1/ExternalAccountProvider_V1_1_1_Dxe.c new file mode 100644 index 00000000000..f92c0c5e1c0 --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_1/ExternalAccountProvider_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ExternalAccountProvider.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ExternalAccountProvider"; +BOOLEAN IsRevisonController = TRUE; + +// Support ExternalAccountProvider V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ExternalAccountProvider", + "1", + "1", + "1" + }, + "ExternalAccountProvider" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_1 *ExternalAccountProviderV1_1_1; + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_1_CS *ExternalAccountProviderV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ExternalAccountProvider") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ExternalAccountProvider_V1_1_1_To_CS (ResoruceRaw, &ExternalAccountProviderV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ExternalAccountProviderV1_1_1 = (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_1)); + if (ExternalAccountProviderV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ExternalAccountProviderV1_1_1; + ExternalAccountProviderV1_1_1->ExternalAccountProvider = ExternalAccountProviderV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProvider")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ExternalAccountProvider"), "ExternalAccountProvider"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProvider")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ExternalAccountProvider"), "ExternalAccountProvider"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ExternalAccountProviderToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ExternalAccountProviderToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ExternalAccountProvider_V1_1_1_JSON (*((EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ExternalAccountProviderToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_1 *ExternalAccountProviderV1_1_1; + + ExternalAccountProviderV1_1_1 = (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_1 *)InterpProp; + DestroyExternalAccountProvider_V1_1_1_CS (ExternalAccountProviderV1_1_1->ExternalAccountProvider); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ExternalAccountProviderFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyExternalAccountProvider_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProvider_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ExternalAccountProviderToStructWrapper, + ExternalAccountProviderToJson, + ExternalAccountProviderDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProvider_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_1/RedfishExternalAccountProvider_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_1/RedfishExternalAccountProvider_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..79652407950 --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_1/RedfishExternalAccountProvider_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ExternalAccountProvider.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishExternalAccountProvider_V1_1_1_Dxe + FILE_GUID = ef302b90-5223-435d-9a96-eef2610c686a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishExternalAccountProvider_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishExternalAccountProvider_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ExternalAccountProvider_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ExternalAccountProviderV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_2/ExternalAccountProvider_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_2/ExternalAccountProvider_V1_1_2_Dxe.c new file mode 100644 index 00000000000..1dc2a3365f4 --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_2/ExternalAccountProvider_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ExternalAccountProvider.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ExternalAccountProvider"; +BOOLEAN IsRevisonController = TRUE; + +// Support ExternalAccountProvider V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ExternalAccountProvider", + "1", + "1", + "2" + }, + "ExternalAccountProvider" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_2 *ExternalAccountProviderV1_1_2; + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_2_CS *ExternalAccountProviderV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ExternalAccountProvider") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ExternalAccountProvider_V1_1_2_To_CS (ResoruceRaw, &ExternalAccountProviderV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ExternalAccountProviderV1_1_2 = (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_2)); + if (ExternalAccountProviderV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ExternalAccountProviderV1_1_2; + ExternalAccountProviderV1_1_2->ExternalAccountProvider = ExternalAccountProviderV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProvider")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ExternalAccountProvider"), "ExternalAccountProvider"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProvider")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ExternalAccountProvider"), "ExternalAccountProvider"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ExternalAccountProviderToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ExternalAccountProviderToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ExternalAccountProvider_V1_1_2_JSON (*((EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ExternalAccountProviderToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_2 *ExternalAccountProviderV1_1_2; + + ExternalAccountProviderV1_1_2 = (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_2 *)InterpProp; + DestroyExternalAccountProvider_V1_1_2_CS (ExternalAccountProviderV1_1_2->ExternalAccountProvider); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ExternalAccountProviderFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyExternalAccountProvider_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProvider_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ExternalAccountProviderToStructWrapper, + ExternalAccountProviderToJson, + ExternalAccountProviderDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProvider_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_2/RedfishExternalAccountProvider_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_2/RedfishExternalAccountProvider_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..ca03e027ce6 --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_2/RedfishExternalAccountProvider_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ExternalAccountProvider.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishExternalAccountProvider_V1_1_2_Dxe + FILE_GUID = 50a35fe0-3fa5-4e42-b066-6e9c7c41fd49 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishExternalAccountProvider_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishExternalAccountProvider_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ExternalAccountProvider_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ExternalAccountProviderV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_3/ExternalAccountProvider_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_3/ExternalAccountProvider_V1_1_3_Dxe.c new file mode 100644 index 00000000000..3ef0583c9c5 --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_3/ExternalAccountProvider_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ExternalAccountProvider.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ExternalAccountProvider"; +BOOLEAN IsRevisonController = TRUE; + +// Support ExternalAccountProvider V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ExternalAccountProvider", + "1", + "1", + "3" + }, + "ExternalAccountProvider" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_3 *ExternalAccountProviderV1_1_3; + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_3_CS *ExternalAccountProviderV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ExternalAccountProvider") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ExternalAccountProvider_V1_1_3_To_CS (ResoruceRaw, &ExternalAccountProviderV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ExternalAccountProviderV1_1_3 = (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_3)); + if (ExternalAccountProviderV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ExternalAccountProviderV1_1_3; + ExternalAccountProviderV1_1_3->ExternalAccountProvider = ExternalAccountProviderV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProvider")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ExternalAccountProvider"), "ExternalAccountProvider"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProvider")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ExternalAccountProvider"), "ExternalAccountProvider"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ExternalAccountProviderToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ExternalAccountProviderToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ExternalAccountProvider_V1_1_3_JSON (*((EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ExternalAccountProviderToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_3 *ExternalAccountProviderV1_1_3; + + ExternalAccountProviderV1_1_3 = (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_3 *)InterpProp; + DestroyExternalAccountProvider_V1_1_3_CS (ExternalAccountProviderV1_1_3->ExternalAccountProvider); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ExternalAccountProviderFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyExternalAccountProvider_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProvider_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ExternalAccountProviderToStructWrapper, + ExternalAccountProviderToJson, + ExternalAccountProviderDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProvider_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_3/RedfishExternalAccountProvider_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_3/RedfishExternalAccountProvider_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..380ef81c094 --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_3/RedfishExternalAccountProvider_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ExternalAccountProvider.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishExternalAccountProvider_V1_1_3_Dxe + FILE_GUID = c2fcd65c-57dc-45dc-b892-99c33f0559b0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishExternalAccountProvider_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishExternalAccountProvider_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ExternalAccountProvider_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ExternalAccountProviderV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_4/ExternalAccountProvider_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_4/ExternalAccountProvider_V1_1_4_Dxe.c new file mode 100644 index 00000000000..65de7dd01b5 --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_4/ExternalAccountProvider_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ExternalAccountProvider.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ExternalAccountProvider"; +BOOLEAN IsRevisonController = TRUE; + +// Support ExternalAccountProvider V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ExternalAccountProvider", + "1", + "1", + "4" + }, + "ExternalAccountProvider" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_4 *ExternalAccountProviderV1_1_4; + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_4_CS *ExternalAccountProviderV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ExternalAccountProvider") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ExternalAccountProvider_V1_1_4_To_CS (ResoruceRaw, &ExternalAccountProviderV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ExternalAccountProviderV1_1_4 = (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_4)); + if (ExternalAccountProviderV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ExternalAccountProviderV1_1_4; + ExternalAccountProviderV1_1_4->ExternalAccountProvider = ExternalAccountProviderV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProvider")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ExternalAccountProvider"), "ExternalAccountProvider"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProvider")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ExternalAccountProvider"), "ExternalAccountProvider"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ExternalAccountProviderToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ExternalAccountProviderToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ExternalAccountProvider_V1_1_4_JSON (*((EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ExternalAccountProviderToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_4 *ExternalAccountProviderV1_1_4; + + ExternalAccountProviderV1_1_4 = (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_4 *)InterpProp; + DestroyExternalAccountProvider_V1_1_4_CS (ExternalAccountProviderV1_1_4->ExternalAccountProvider); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ExternalAccountProviderFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyExternalAccountProvider_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProvider_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ExternalAccountProviderToStructWrapper, + ExternalAccountProviderToJson, + ExternalAccountProviderDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProvider_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_4/RedfishExternalAccountProvider_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_4/RedfishExternalAccountProvider_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..054674d7a32 --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_1_4/RedfishExternalAccountProvider_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ExternalAccountProvider.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishExternalAccountProvider_V1_1_4_Dxe + FILE_GUID = 84587734-8df7-459b-9ca4-27eac64354e8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishExternalAccountProvider_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishExternalAccountProvider_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ExternalAccountProvider_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ExternalAccountProviderV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ExternalAccountProvider/v1_2_0/ExternalAccountProvider_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_2_0/ExternalAccountProvider_V1_2_0_Dxe.c new file mode 100644 index 00000000000..acdae063339 --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_2_0/ExternalAccountProvider_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ExternalAccountProvider.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ExternalAccountProvider"; +BOOLEAN IsRevisonController = TRUE; + +// Support ExternalAccountProvider V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ExternalAccountProvider", + "1", + "2", + "0" + }, + "ExternalAccountProvider" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_2_0 *ExternalAccountProviderV1_2_0; + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_2_0_CS *ExternalAccountProviderV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ExternalAccountProvider") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ExternalAccountProvider_V1_2_0_To_CS (ResoruceRaw, &ExternalAccountProviderV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ExternalAccountProviderV1_2_0 = (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_2_0)); + if (ExternalAccountProviderV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ExternalAccountProviderV1_2_0; + ExternalAccountProviderV1_2_0->ExternalAccountProvider = ExternalAccountProviderV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProvider")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ExternalAccountProvider"), "ExternalAccountProvider"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProvider")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ExternalAccountProvider"), "ExternalAccountProvider"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ExternalAccountProviderToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ExternalAccountProviderToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ExternalAccountProvider_V1_2_0_JSON (*((EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ExternalAccountProviderToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_2_0 *ExternalAccountProviderV1_2_0; + + ExternalAccountProviderV1_2_0 = (EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_2_0 *)InterpProp; + DestroyExternalAccountProvider_V1_2_0_CS (ExternalAccountProviderV1_2_0->ExternalAccountProvider); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ExternalAccountProviderFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyExternalAccountProvider_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProvider_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ExternalAccountProviderToStructWrapper, + ExternalAccountProviderToJson, + ExternalAccountProviderDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProvider_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ExternalAccountProvider/v1_2_0/RedfishExternalAccountProvider_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_2_0/RedfishExternalAccountProvider_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..7e354608524 --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProvider/v1_2_0/RedfishExternalAccountProvider_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ExternalAccountProvider.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishExternalAccountProvider_V1_2_0_Dxe + FILE_GUID = bf2663f3-93c1-4ba5-a8a3-7c6e6f7a5cef + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishExternalAccountProvider_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishExternalAccountProvider_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ExternalAccountProvider_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ExternalAccountProviderV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ExternalAccountProviderCollection/ExternalAccountProviderCollection_Dxe.c b/RedfishClientPkg/Converter/ExternalAccountProviderCollection/ExternalAccountProviderCollection_Dxe.c new file mode 100644 index 00000000000..c71e4626e83 --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProviderCollection/ExternalAccountProviderCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ExternalAccountProviderCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ExternalAccountProviderCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support ExternalAccountProviderCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ExternalAccountProviderCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "ExternalAccountProviderCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDERCOLLECTION *ExternalAccountProviderCollection; + EFI_REDFISH_EXTERNALACCOUNTPROVIDERCOLLECTION_CS *ExternalAccountProviderCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ExternalAccountProviderCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ExternalAccountProviderCollection_To_CS (ResoruceRaw, &ExternalAccountProviderCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + ExternalAccountProviderCollection = (EFI_REDFISH_EXTERNALACCOUNTPROVIDERCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_EXTERNALACCOUNTPROVIDERCOLLECTION)); + if (ExternalAccountProviderCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ExternalAccountProviderCollection; + ExternalAccountProviderCollection->ExternalAccountProviderCollection = ExternalAccountProviderCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProviderCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ExternalAccountProviderCollection"), "ExternalAccountProviderCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ExternalAccountProviderCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ExternalAccountProviderCollection"), "ExternalAccountProviderCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ExternalAccountProviderCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ExternalAccountProviderCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ExternalAccountProviderCollection_JSON (*((EFI_REDFISH_EXTERNALACCOUNTPROVIDERCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ExternalAccountProviderCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_EXTERNALACCOUNTPROVIDERCOLLECTION *ExternalAccountProviderCollection; + + ExternalAccountProviderCollection = (EFI_REDFISH_EXTERNALACCOUNTPROVIDERCOLLECTION *)InterpProp; + DestroyExternalAccountProviderCollection_CS (ExternalAccountProviderCollection->ExternalAccountProviderCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ExternalAccountProviderCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ExternalAccountProviderCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyExternalAccountProviderCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProviderCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ExternalAccountProviderCollectionToStructWrapper, + ExternalAccountProviderCollectionToJson, + ExternalAccountProviderCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishExternalAccountProviderCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ExternalAccountProviderCollection/RedfishExternalAccountProviderCollection_Dxe.inf b/RedfishClientPkg/Converter/ExternalAccountProviderCollection/RedfishExternalAccountProviderCollection_Dxe.inf new file mode 100644 index 00000000000..889d69585a3 --- /dev/null +++ b/RedfishClientPkg/Converter/ExternalAccountProviderCollection/RedfishExternalAccountProviderCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ExternalAccountProviderCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishExternalAccountProviderCollection_Dxe + FILE_GUID = 6963edad-21e4-467d-8a2a-9563c51801e2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishExternalAccountProviderCollectionEntryPoint + UNLOAD_IMAGE = RedfishExternalAccountProviderCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ExternalAccountProviderCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ExternalAccountProviderCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Fabric/v1_0_0/Fabric_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Fabric/v1_0_0/Fabric_V1_0_0_Dxe.c new file mode 100644 index 00000000000..3748115a9c6 --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_0_0/Fabric_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Fabric.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Fabric"; +BOOLEAN IsRevisonController = TRUE; + +// Support Fabric V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Fabric", + "1", + "0", + "0" + }, + "Fabric" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_0_0 *FabricV1_0_0; + EFI_REDFISH_FABRIC_V1_0_0_CS *FabricV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Fabric") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Fabric_V1_0_0_To_CS (ResoruceRaw, &FabricV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + FabricV1_0_0 = (EFI_REDFISH_FABRIC_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_FABRIC_V1_0_0)); + if (FabricV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)FabricV1_0_0; + FabricV1_0_0->Fabric = FabricV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Fabric"), "Fabric"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Fabric"), "Fabric"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of FabricToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return FabricToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Fabric_V1_0_0_JSON (*((EFI_REDFISH_FABRIC_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in FabricToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_0_0 *FabricV1_0_0; + + FabricV1_0_0 = (EFI_REDFISH_FABRIC_V1_0_0 *)InterpProp; + DestroyFabric_V1_0_0_CS (FabricV1_0_0->Fabric); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from FabricFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyFabric_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + FabricToStructWrapper, + FabricToJson, + FabricDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Fabric/v1_0_0/RedfishFabric_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Fabric/v1_0_0/RedfishFabric_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..7190baa2f8a --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_0_0/RedfishFabric_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Fabric.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishFabric_V1_0_0_Dxe + FILE_GUID = 3551cf2f-655d-4ff8-8940-c03f98611a4e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishFabric_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishFabric_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Fabric_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + FabricV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Fabric/v1_0_1/Fabric_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/Fabric/v1_0_1/Fabric_V1_0_1_Dxe.c new file mode 100644 index 00000000000..ee9e0232dd6 --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_0_1/Fabric_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Fabric.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Fabric"; +BOOLEAN IsRevisonController = TRUE; + +// Support Fabric V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Fabric", + "1", + "0", + "1" + }, + "Fabric" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_0_1 *FabricV1_0_1; + EFI_REDFISH_FABRIC_V1_0_1_CS *FabricV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Fabric") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Fabric_V1_0_1_To_CS (ResoruceRaw, &FabricV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + FabricV1_0_1 = (EFI_REDFISH_FABRIC_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_FABRIC_V1_0_1)); + if (FabricV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)FabricV1_0_1; + FabricV1_0_1->Fabric = FabricV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Fabric"), "Fabric"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Fabric"), "Fabric"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of FabricToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return FabricToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Fabric_V1_0_1_JSON (*((EFI_REDFISH_FABRIC_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in FabricToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_0_1 *FabricV1_0_1; + + FabricV1_0_1 = (EFI_REDFISH_FABRIC_V1_0_1 *)InterpProp; + DestroyFabric_V1_0_1_CS (FabricV1_0_1->Fabric); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from FabricFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyFabric_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + FabricToStructWrapper, + FabricToJson, + FabricDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Fabric/v1_0_1/RedfishFabric_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/Fabric/v1_0_1/RedfishFabric_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..f454c854949 --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_0_1/RedfishFabric_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Fabric.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishFabric_V1_0_1_Dxe + FILE_GUID = b5524ecc-f223-4393-960d-2fb60d2091d6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishFabric_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishFabric_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Fabric_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + FabricV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Fabric/v1_0_2/Fabric_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Fabric/v1_0_2/Fabric_V1_0_2_Dxe.c new file mode 100644 index 00000000000..76156aeee55 --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_0_2/Fabric_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Fabric.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Fabric"; +BOOLEAN IsRevisonController = TRUE; + +// Support Fabric V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Fabric", + "1", + "0", + "2" + }, + "Fabric" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_0_2 *FabricV1_0_2; + EFI_REDFISH_FABRIC_V1_0_2_CS *FabricV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Fabric") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Fabric_V1_0_2_To_CS (ResoruceRaw, &FabricV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + FabricV1_0_2 = (EFI_REDFISH_FABRIC_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_FABRIC_V1_0_2)); + if (FabricV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)FabricV1_0_2; + FabricV1_0_2->Fabric = FabricV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Fabric"), "Fabric"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Fabric"), "Fabric"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of FabricToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return FabricToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Fabric_V1_0_2_JSON (*((EFI_REDFISH_FABRIC_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in FabricToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_0_2 *FabricV1_0_2; + + FabricV1_0_2 = (EFI_REDFISH_FABRIC_V1_0_2 *)InterpProp; + DestroyFabric_V1_0_2_CS (FabricV1_0_2->Fabric); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from FabricFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyFabric_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + FabricToStructWrapper, + FabricToJson, + FabricDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Fabric/v1_0_2/RedfishFabric_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Fabric/v1_0_2/RedfishFabric_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..65aad27cc92 --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_0_2/RedfishFabric_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Fabric.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishFabric_V1_0_2_Dxe + FILE_GUID = 0fee8d3d-fe65-4c1d-9cf6-61e18425f50d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishFabric_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishFabric_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Fabric_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + FabricV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Fabric/v1_0_3/Fabric_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/Fabric/v1_0_3/Fabric_V1_0_3_Dxe.c new file mode 100644 index 00000000000..2e2f60eb9a8 --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_0_3/Fabric_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Fabric.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Fabric"; +BOOLEAN IsRevisonController = TRUE; + +// Support Fabric V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Fabric", + "1", + "0", + "3" + }, + "Fabric" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_0_3 *FabricV1_0_3; + EFI_REDFISH_FABRIC_V1_0_3_CS *FabricV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Fabric") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Fabric_V1_0_3_To_CS (ResoruceRaw, &FabricV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + FabricV1_0_3 = (EFI_REDFISH_FABRIC_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_FABRIC_V1_0_3)); + if (FabricV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)FabricV1_0_3; + FabricV1_0_3->Fabric = FabricV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Fabric"), "Fabric"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Fabric"), "Fabric"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of FabricToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return FabricToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Fabric_V1_0_3_JSON (*((EFI_REDFISH_FABRIC_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in FabricToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_0_3 *FabricV1_0_3; + + FabricV1_0_3 = (EFI_REDFISH_FABRIC_V1_0_3 *)InterpProp; + DestroyFabric_V1_0_3_CS (FabricV1_0_3->Fabric); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from FabricFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyFabric_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + FabricToStructWrapper, + FabricToJson, + FabricDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Fabric/v1_0_3/RedfishFabric_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/Fabric/v1_0_3/RedfishFabric_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..b2d29ea1ccc --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_0_3/RedfishFabric_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Fabric.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishFabric_V1_0_3_Dxe + FILE_GUID = 389ea0cc-a15e-47b3-9471-d7b65872e211 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishFabric_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishFabric_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Fabric_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + FabricV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Fabric/v1_0_4/Fabric_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/Fabric/v1_0_4/Fabric_V1_0_4_Dxe.c new file mode 100644 index 00000000000..a2629896cfe --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_0_4/Fabric_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Fabric.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Fabric"; +BOOLEAN IsRevisonController = TRUE; + +// Support Fabric V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Fabric", + "1", + "0", + "4" + }, + "Fabric" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_0_4 *FabricV1_0_4; + EFI_REDFISH_FABRIC_V1_0_4_CS *FabricV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Fabric") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Fabric_V1_0_4_To_CS (ResoruceRaw, &FabricV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + FabricV1_0_4 = (EFI_REDFISH_FABRIC_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_FABRIC_V1_0_4)); + if (FabricV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)FabricV1_0_4; + FabricV1_0_4->Fabric = FabricV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Fabric"), "Fabric"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Fabric"), "Fabric"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of FabricToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return FabricToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Fabric_V1_0_4_JSON (*((EFI_REDFISH_FABRIC_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in FabricToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_0_4 *FabricV1_0_4; + + FabricV1_0_4 = (EFI_REDFISH_FABRIC_V1_0_4 *)InterpProp; + DestroyFabric_V1_0_4_CS (FabricV1_0_4->Fabric); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from FabricFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyFabric_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + FabricToStructWrapper, + FabricToJson, + FabricDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Fabric/v1_0_4/RedfishFabric_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/Fabric/v1_0_4/RedfishFabric_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..c43c672b414 --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_0_4/RedfishFabric_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Fabric.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishFabric_V1_0_4_Dxe + FILE_GUID = 40b0d1e1-21a2-4522-b563-67c5dc5f8649 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishFabric_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishFabric_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Fabric_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + FabricV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Fabric/v1_0_5/Fabric_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/Fabric/v1_0_5/Fabric_V1_0_5_Dxe.c new file mode 100644 index 00000000000..72f3b48e631 --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_0_5/Fabric_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Fabric.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Fabric"; +BOOLEAN IsRevisonController = TRUE; + +// Support Fabric V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Fabric", + "1", + "0", + "5" + }, + "Fabric" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_0_5 *FabricV1_0_5; + EFI_REDFISH_FABRIC_V1_0_5_CS *FabricV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Fabric") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Fabric_V1_0_5_To_CS (ResoruceRaw, &FabricV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + FabricV1_0_5 = (EFI_REDFISH_FABRIC_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_FABRIC_V1_0_5)); + if (FabricV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)FabricV1_0_5; + FabricV1_0_5->Fabric = FabricV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Fabric"), "Fabric"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Fabric"), "Fabric"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of FabricToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return FabricToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Fabric_V1_0_5_JSON (*((EFI_REDFISH_FABRIC_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in FabricToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_0_5 *FabricV1_0_5; + + FabricV1_0_5 = (EFI_REDFISH_FABRIC_V1_0_5 *)InterpProp; + DestroyFabric_V1_0_5_CS (FabricV1_0_5->Fabric); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from FabricFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyFabric_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + FabricToStructWrapper, + FabricToJson, + FabricDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Fabric/v1_0_5/RedfishFabric_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/Fabric/v1_0_5/RedfishFabric_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..ce676327964 --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_0_5/RedfishFabric_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Fabric.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishFabric_V1_0_5_Dxe + FILE_GUID = 7ea7d724-4714-4615-b859-858db6a1b8a9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishFabric_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishFabric_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Fabric_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + FabricV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Fabric/v1_0_6/Fabric_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/Fabric/v1_0_6/Fabric_V1_0_6_Dxe.c new file mode 100644 index 00000000000..637a230c7fe --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_0_6/Fabric_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Fabric.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Fabric"; +BOOLEAN IsRevisonController = TRUE; + +// Support Fabric V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Fabric", + "1", + "0", + "6" + }, + "Fabric" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_0_6 *FabricV1_0_6; + EFI_REDFISH_FABRIC_V1_0_6_CS *FabricV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Fabric") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Fabric_V1_0_6_To_CS (ResoruceRaw, &FabricV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + FabricV1_0_6 = (EFI_REDFISH_FABRIC_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_FABRIC_V1_0_6)); + if (FabricV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)FabricV1_0_6; + FabricV1_0_6->Fabric = FabricV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Fabric"), "Fabric"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Fabric"), "Fabric"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of FabricToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return FabricToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Fabric_V1_0_6_JSON (*((EFI_REDFISH_FABRIC_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in FabricToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_0_6 *FabricV1_0_6; + + FabricV1_0_6 = (EFI_REDFISH_FABRIC_V1_0_6 *)InterpProp; + DestroyFabric_V1_0_6_CS (FabricV1_0_6->Fabric); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from FabricFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyFabric_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + FabricToStructWrapper, + FabricToJson, + FabricDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Fabric/v1_0_6/RedfishFabric_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/Fabric/v1_0_6/RedfishFabric_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..8e6be9ada96 --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_0_6/RedfishFabric_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Fabric.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishFabric_V1_0_6_Dxe + FILE_GUID = 725ea169-e1c4-4326-8a05-1213936ae450 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishFabric_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishFabric_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Fabric_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + FabricV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Fabric/v1_0_7/Fabric_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/Fabric/v1_0_7/Fabric_V1_0_7_Dxe.c new file mode 100644 index 00000000000..429dbbbf07b --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_0_7/Fabric_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Fabric.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Fabric"; +BOOLEAN IsRevisonController = TRUE; + +// Support Fabric V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Fabric", + "1", + "0", + "7" + }, + "Fabric" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_0_7 *FabricV1_0_7; + EFI_REDFISH_FABRIC_V1_0_7_CS *FabricV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Fabric") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Fabric_V1_0_7_To_CS (ResoruceRaw, &FabricV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + FabricV1_0_7 = (EFI_REDFISH_FABRIC_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_FABRIC_V1_0_7)); + if (FabricV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)FabricV1_0_7; + FabricV1_0_7->Fabric = FabricV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Fabric"), "Fabric"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Fabric"), "Fabric"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of FabricToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return FabricToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Fabric_V1_0_7_JSON (*((EFI_REDFISH_FABRIC_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in FabricToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_0_7 *FabricV1_0_7; + + FabricV1_0_7 = (EFI_REDFISH_FABRIC_V1_0_7 *)InterpProp; + DestroyFabric_V1_0_7_CS (FabricV1_0_7->Fabric); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from FabricFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyFabric_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + FabricToStructWrapper, + FabricToJson, + FabricDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Fabric/v1_0_7/RedfishFabric_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/Fabric/v1_0_7/RedfishFabric_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..10750ef2764 --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_0_7/RedfishFabric_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Fabric.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishFabric_V1_0_7_Dxe + FILE_GUID = e64e786d-0d2c-4e2a-b98e-73a3a1bde17b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishFabric_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishFabric_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Fabric_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + FabricV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Fabric/v1_0_8/Fabric_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/Fabric/v1_0_8/Fabric_V1_0_8_Dxe.c new file mode 100644 index 00000000000..ca1f9b0ee80 --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_0_8/Fabric_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Fabric.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Fabric"; +BOOLEAN IsRevisonController = TRUE; + +// Support Fabric V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Fabric", + "1", + "0", + "8" + }, + "Fabric" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_0_8 *FabricV1_0_8; + EFI_REDFISH_FABRIC_V1_0_8_CS *FabricV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Fabric") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Fabric_V1_0_8_To_CS (ResoruceRaw, &FabricV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + FabricV1_0_8 = (EFI_REDFISH_FABRIC_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_FABRIC_V1_0_8)); + if (FabricV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)FabricV1_0_8; + FabricV1_0_8->Fabric = FabricV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Fabric"), "Fabric"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Fabric"), "Fabric"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of FabricToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return FabricToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Fabric_V1_0_8_JSON (*((EFI_REDFISH_FABRIC_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in FabricToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_0_8 *FabricV1_0_8; + + FabricV1_0_8 = (EFI_REDFISH_FABRIC_V1_0_8 *)InterpProp; + DestroyFabric_V1_0_8_CS (FabricV1_0_8->Fabric); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from FabricFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyFabric_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + FabricToStructWrapper, + FabricToJson, + FabricDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Fabric/v1_0_8/RedfishFabric_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/Fabric/v1_0_8/RedfishFabric_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..cea47ca8bd8 --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_0_8/RedfishFabric_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Fabric.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishFabric_V1_0_8_Dxe + FILE_GUID = 3289a76c-6313-4d62-a04a-89e42a6559af + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishFabric_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishFabric_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Fabric_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + FabricV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Fabric/v1_1_0/Fabric_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/Fabric/v1_1_0/Fabric_V1_1_0_Dxe.c new file mode 100644 index 00000000000..bfde0471ac8 --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_1_0/Fabric_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Fabric.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Fabric"; +BOOLEAN IsRevisonController = TRUE; + +// Support Fabric V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Fabric", + "1", + "1", + "0" + }, + "Fabric" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_1_0 *FabricV1_1_0; + EFI_REDFISH_FABRIC_V1_1_0_CS *FabricV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Fabric") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Fabric_V1_1_0_To_CS (ResoruceRaw, &FabricV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + FabricV1_1_0 = (EFI_REDFISH_FABRIC_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_FABRIC_V1_1_0)); + if (FabricV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)FabricV1_1_0; + FabricV1_1_0->Fabric = FabricV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Fabric"), "Fabric"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Fabric"), "Fabric"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of FabricToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return FabricToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Fabric_V1_1_0_JSON (*((EFI_REDFISH_FABRIC_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in FabricToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_1_0 *FabricV1_1_0; + + FabricV1_1_0 = (EFI_REDFISH_FABRIC_V1_1_0 *)InterpProp; + DestroyFabric_V1_1_0_CS (FabricV1_1_0->Fabric); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from FabricFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyFabric_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + FabricToStructWrapper, + FabricToJson, + FabricDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Fabric/v1_1_0/RedfishFabric_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/Fabric/v1_1_0/RedfishFabric_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..3a16f3a90e8 --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_1_0/RedfishFabric_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Fabric.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishFabric_V1_1_0_Dxe + FILE_GUID = 1f2100d6-1ea4-4729-90ba-34c2faca84f7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishFabric_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishFabric_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Fabric_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + FabricV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Fabric/v1_1_1/Fabric_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/Fabric/v1_1_1/Fabric_V1_1_1_Dxe.c new file mode 100644 index 00000000000..813d219bda4 --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_1_1/Fabric_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Fabric.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Fabric"; +BOOLEAN IsRevisonController = TRUE; + +// Support Fabric V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Fabric", + "1", + "1", + "1" + }, + "Fabric" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_1_1 *FabricV1_1_1; + EFI_REDFISH_FABRIC_V1_1_1_CS *FabricV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Fabric") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Fabric_V1_1_1_To_CS (ResoruceRaw, &FabricV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + FabricV1_1_1 = (EFI_REDFISH_FABRIC_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_FABRIC_V1_1_1)); + if (FabricV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)FabricV1_1_1; + FabricV1_1_1->Fabric = FabricV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Fabric"), "Fabric"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Fabric"), "Fabric"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of FabricToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return FabricToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Fabric_V1_1_1_JSON (*((EFI_REDFISH_FABRIC_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in FabricToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_1_1 *FabricV1_1_1; + + FabricV1_1_1 = (EFI_REDFISH_FABRIC_V1_1_1 *)InterpProp; + DestroyFabric_V1_1_1_CS (FabricV1_1_1->Fabric); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from FabricFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyFabric_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + FabricToStructWrapper, + FabricToJson, + FabricDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Fabric/v1_1_1/RedfishFabric_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/Fabric/v1_1_1/RedfishFabric_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..b040920c0d5 --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_1_1/RedfishFabric_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Fabric.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishFabric_V1_1_1_Dxe + FILE_GUID = 3a7cc5e7-a76a-43bc-991a-f04685f60e23 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishFabric_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishFabric_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Fabric_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + FabricV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Fabric/v1_1_2/Fabric_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/Fabric/v1_1_2/Fabric_V1_1_2_Dxe.c new file mode 100644 index 00000000000..086f44e2c7f --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_1_2/Fabric_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Fabric.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Fabric"; +BOOLEAN IsRevisonController = TRUE; + +// Support Fabric V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Fabric", + "1", + "1", + "2" + }, + "Fabric" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_1_2 *FabricV1_1_2; + EFI_REDFISH_FABRIC_V1_1_2_CS *FabricV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Fabric") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Fabric_V1_1_2_To_CS (ResoruceRaw, &FabricV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + FabricV1_1_2 = (EFI_REDFISH_FABRIC_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_FABRIC_V1_1_2)); + if (FabricV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)FabricV1_1_2; + FabricV1_1_2->Fabric = FabricV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Fabric"), "Fabric"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Fabric"), "Fabric"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of FabricToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return FabricToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Fabric_V1_1_2_JSON (*((EFI_REDFISH_FABRIC_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in FabricToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_1_2 *FabricV1_1_2; + + FabricV1_1_2 = (EFI_REDFISH_FABRIC_V1_1_2 *)InterpProp; + DestroyFabric_V1_1_2_CS (FabricV1_1_2->Fabric); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from FabricFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyFabric_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + FabricToStructWrapper, + FabricToJson, + FabricDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Fabric/v1_1_2/RedfishFabric_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/Fabric/v1_1_2/RedfishFabric_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..785811b8f26 --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_1_2/RedfishFabric_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Fabric.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishFabric_V1_1_2_Dxe + FILE_GUID = 256b5fe4-3332-4c11-b863-a6298b21be9f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishFabric_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishFabric_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Fabric_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + FabricV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Fabric/v1_2_0/Fabric_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/Fabric/v1_2_0/Fabric_V1_2_0_Dxe.c new file mode 100644 index 00000000000..6b1aba37f01 --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_2_0/Fabric_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Fabric.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Fabric"; +BOOLEAN IsRevisonController = TRUE; + +// Support Fabric V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Fabric", + "1", + "2", + "0" + }, + "Fabric" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_2_0 *FabricV1_2_0; + EFI_REDFISH_FABRIC_V1_2_0_CS *FabricV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Fabric") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Fabric_V1_2_0_To_CS (ResoruceRaw, &FabricV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + FabricV1_2_0 = (EFI_REDFISH_FABRIC_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_FABRIC_V1_2_0)); + if (FabricV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)FabricV1_2_0; + FabricV1_2_0->Fabric = FabricV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Fabric"), "Fabric"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Fabric"), "Fabric"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of FabricToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return FabricToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Fabric_V1_2_0_JSON (*((EFI_REDFISH_FABRIC_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in FabricToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_2_0 *FabricV1_2_0; + + FabricV1_2_0 = (EFI_REDFISH_FABRIC_V1_2_0 *)InterpProp; + DestroyFabric_V1_2_0_CS (FabricV1_2_0->Fabric); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from FabricFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyFabric_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + FabricToStructWrapper, + FabricToJson, + FabricDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Fabric/v1_2_0/RedfishFabric_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/Fabric/v1_2_0/RedfishFabric_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..d99480aee7b --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_2_0/RedfishFabric_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Fabric.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishFabric_V1_2_0_Dxe + FILE_GUID = 105ad468-eb4b-425b-96ba-720b8ba09ecf + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishFabric_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishFabric_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Fabric_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + FabricV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Fabric/v1_2_1/Fabric_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/Fabric/v1_2_1/Fabric_V1_2_1_Dxe.c new file mode 100644 index 00000000000..fd62caa4ff4 --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_2_1/Fabric_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Fabric.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Fabric"; +BOOLEAN IsRevisonController = TRUE; + +// Support Fabric V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Fabric", + "1", + "2", + "1" + }, + "Fabric" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_2_1 *FabricV1_2_1; + EFI_REDFISH_FABRIC_V1_2_1_CS *FabricV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Fabric") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Fabric_V1_2_1_To_CS (ResoruceRaw, &FabricV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + FabricV1_2_1 = (EFI_REDFISH_FABRIC_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_FABRIC_V1_2_1)); + if (FabricV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)FabricV1_2_1; + FabricV1_2_1->Fabric = FabricV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Fabric"), "Fabric"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Fabric")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Fabric"), "Fabric"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of FabricToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return FabricToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Fabric_V1_2_1_JSON (*((EFI_REDFISH_FABRIC_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in FabricToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_FABRIC_V1_2_1 *FabricV1_2_1; + + FabricV1_2_1 = (EFI_REDFISH_FABRIC_V1_2_1 *)InterpProp; + DestroyFabric_V1_2_1_CS (FabricV1_2_1->Fabric); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from FabricFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyFabric_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + FabricToStructWrapper, + FabricToJson, + FabricDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishFabric_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Fabric/v1_2_1/RedfishFabric_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/Fabric/v1_2_1/RedfishFabric_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..8ca40384893 --- /dev/null +++ b/RedfishClientPkg/Converter/Fabric/v1_2_1/RedfishFabric_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Fabric.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishFabric_V1_2_1_Dxe + FILE_GUID = d2b5dc8a-31c1-4117-a76f-6dccf5b9f64b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishFabric_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishFabric_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Fabric_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + FabricV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/FabricAdapter/v1_0_0/FabricAdapter_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/FabricAdapter/v1_0_0/FabricAdapter_V1_0_0_Dxe.c new file mode 100644 index 00000000000..dd84ba1a53d --- /dev/null +++ b/RedfishClientPkg/Converter/FabricAdapter/v1_0_0/FabricAdapter_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - FabricAdapter.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#FabricAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support FabricAdapter V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "FabricAdapter", + "1", + "0", + "0" + }, + "FabricAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_FABRICADAPTER_V1_0_0 *FabricAdapterV1_0_0; + EFI_REDFISH_FABRICADAPTER_V1_0_0_CS *FabricAdapterV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "FabricAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_FabricAdapter_V1_0_0_To_CS (ResoruceRaw, &FabricAdapterV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + FabricAdapterV1_0_0 = (EFI_REDFISH_FABRICADAPTER_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_FABRICADAPTER_V1_0_0)); + if (FabricAdapterV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)FabricAdapterV1_0_0; + FabricAdapterV1_0_0->FabricAdapter = FabricAdapterV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("FabricAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("FabricAdapter"), "FabricAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("FabricAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("FabricAdapter"), "FabricAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of FabricAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return FabricAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_FabricAdapter_V1_0_0_JSON (*((EFI_REDFISH_FABRICADAPTER_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in FabricAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_FABRICADAPTER_V1_0_0 *FabricAdapterV1_0_0; + + FabricAdapterV1_0_0 = (EFI_REDFISH_FABRICADAPTER_V1_0_0 *)InterpProp; + DestroyFabricAdapter_V1_0_0_CS (FabricAdapterV1_0_0->FabricAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from FabricAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyFabricAdapter_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishFabricAdapter_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + FabricAdapterToStructWrapper, + FabricAdapterToJson, + FabricAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishFabricAdapter_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/FabricAdapter/v1_0_0/RedfishFabricAdapter_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/FabricAdapter/v1_0_0/RedfishFabricAdapter_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..9bf486772b4 --- /dev/null +++ b/RedfishClientPkg/Converter/FabricAdapter/v1_0_0/RedfishFabricAdapter_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of FabricAdapter.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishFabricAdapter_V1_0_0_Dxe + FILE_GUID = fa1a76f7-a45c-480b-95e9-4543c697be6a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishFabricAdapter_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishFabricAdapter_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + FabricAdapter_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + FabricAdapterV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/FabricAdapterCollection/FabricAdapterCollection_Dxe.c b/RedfishClientPkg/Converter/FabricAdapterCollection/FabricAdapterCollection_Dxe.c new file mode 100644 index 00000000000..4790a905a40 --- /dev/null +++ b/RedfishClientPkg/Converter/FabricAdapterCollection/FabricAdapterCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - FabricAdapterCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#FabricAdapterCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support FabricAdapterCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "FabricAdapterCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "FabricAdapterCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricAdapterCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_FABRICADAPTERCOLLECTION *FabricAdapterCollection; + EFI_REDFISH_FABRICADAPTERCOLLECTION_CS *FabricAdapterCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "FabricAdapterCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_FabricAdapterCollection_To_CS (ResoruceRaw, &FabricAdapterCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + FabricAdapterCollection = (EFI_REDFISH_FABRICADAPTERCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_FABRICADAPTERCOLLECTION)); + if (FabricAdapterCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)FabricAdapterCollection; + FabricAdapterCollection->FabricAdapterCollection = FabricAdapterCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("FabricAdapterCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("FabricAdapterCollection"), "FabricAdapterCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("FabricAdapterCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("FabricAdapterCollection"), "FabricAdapterCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of FabricAdapterCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricAdapterCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return FabricAdapterCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricAdapterCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_FabricAdapterCollection_JSON (*((EFI_REDFISH_FABRICADAPTERCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in FabricAdapterCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricAdapterCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_FABRICADAPTERCOLLECTION *FabricAdapterCollection; + + FabricAdapterCollection = (EFI_REDFISH_FABRICADAPTERCOLLECTION *)InterpProp; + DestroyFabricAdapterCollection_CS (FabricAdapterCollection->FabricAdapterCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from FabricAdapterCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricAdapterCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyFabricAdapterCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishFabricAdapterCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + FabricAdapterCollectionToStructWrapper, + FabricAdapterCollectionToJson, + FabricAdapterCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishFabricAdapterCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/FabricAdapterCollection/RedfishFabricAdapterCollection_Dxe.inf b/RedfishClientPkg/Converter/FabricAdapterCollection/RedfishFabricAdapterCollection_Dxe.inf new file mode 100644 index 00000000000..3a401b57d63 --- /dev/null +++ b/RedfishClientPkg/Converter/FabricAdapterCollection/RedfishFabricAdapterCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of FabricAdapterCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishFabricAdapterCollection_Dxe + FILE_GUID = ca1255e8-b23a-4e53-a3c3-b5a37e34dd33 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishFabricAdapterCollectionEntryPoint + UNLOAD_IMAGE = RedfishFabricAdapterCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + FabricAdapterCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + FabricAdapterCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/FabricCollection/FabricCollection_Dxe.c b/RedfishClientPkg/Converter/FabricCollection/FabricCollection_Dxe.c new file mode 100644 index 00000000000..23633e92463 --- /dev/null +++ b/RedfishClientPkg/Converter/FabricCollection/FabricCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - FabricCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#FabricCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support FabricCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "FabricCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "FabricCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_FABRICCOLLECTION *FabricCollection; + EFI_REDFISH_FABRICCOLLECTION_CS *FabricCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "FabricCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_FabricCollection_To_CS (ResoruceRaw, &FabricCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + FabricCollection = (EFI_REDFISH_FABRICCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_FABRICCOLLECTION)); + if (FabricCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)FabricCollection; + FabricCollection->FabricCollection = FabricCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("FabricCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("FabricCollection"), "FabricCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("FabricCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("FabricCollection"), "FabricCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of FabricCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return FabricCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_FabricCollection_JSON (*((EFI_REDFISH_FABRICCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in FabricCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_FABRICCOLLECTION *FabricCollection; + + FabricCollection = (EFI_REDFISH_FABRICCOLLECTION *)InterpProp; + DestroyFabricCollection_CS (FabricCollection->FabricCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from FabricCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FabricCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyFabricCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishFabricCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + FabricCollectionToStructWrapper, + FabricCollectionToJson, + FabricCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishFabricCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/FabricCollection/RedfishFabricCollection_Dxe.inf b/RedfishClientPkg/Converter/FabricCollection/RedfishFabricCollection_Dxe.inf new file mode 100644 index 00000000000..5b73b9b6b0b --- /dev/null +++ b/RedfishClientPkg/Converter/FabricCollection/RedfishFabricCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of FabricCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishFabricCollection_Dxe + FILE_GUID = cef36be2-2f65-40f2-a034-36a217c4760d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishFabricCollectionEntryPoint + UNLOAD_IMAGE = RedfishFabricCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + FabricCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + FabricCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Facility/v1_0_0/Facility_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Facility/v1_0_0/Facility_V1_0_0_Dxe.c new file mode 100644 index 00000000000..108287b047b --- /dev/null +++ b/RedfishClientPkg/Converter/Facility/v1_0_0/Facility_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Facility.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Facility"; +BOOLEAN IsRevisonController = TRUE; + +// Support Facility V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Facility", + "1", + "0", + "0" + }, + "Facility" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FacilityToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_FACILITY_V1_0_0 *FacilityV1_0_0; + EFI_REDFISH_FACILITY_V1_0_0_CS *FacilityV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Facility") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Facility_V1_0_0_To_CS (ResoruceRaw, &FacilityV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + FacilityV1_0_0 = (EFI_REDFISH_FACILITY_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_FACILITY_V1_0_0)); + if (FacilityV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)FacilityV1_0_0; + FacilityV1_0_0->Facility = FacilityV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Facility")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Facility"), "Facility"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Facility")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Facility"), "Facility"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of FacilityToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FacilityToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return FacilityToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FacilityToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Facility_V1_0_0_JSON (*((EFI_REDFISH_FACILITY_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in FacilityToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FacilityDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_FACILITY_V1_0_0 *FacilityV1_0_0; + + FacilityV1_0_0 = (EFI_REDFISH_FACILITY_V1_0_0 *)InterpProp; + DestroyFacility_V1_0_0_CS (FacilityV1_0_0->Facility); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from FacilityFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FacilityDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyFacility_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishFacility_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + FacilityToStructWrapper, + FacilityToJson, + FacilityDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishFacility_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Facility/v1_0_0/RedfishFacility_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Facility/v1_0_0/RedfishFacility_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..7b17d5f4d8b --- /dev/null +++ b/RedfishClientPkg/Converter/Facility/v1_0_0/RedfishFacility_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Facility.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishFacility_V1_0_0_Dxe + FILE_GUID = 5c390e24-406d-4ab7-b4bc-f681cddd9a0e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishFacility_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishFacility_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Facility_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + FacilityV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Facility/v1_0_1/Facility_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/Facility/v1_0_1/Facility_V1_0_1_Dxe.c new file mode 100644 index 00000000000..65070f85437 --- /dev/null +++ b/RedfishClientPkg/Converter/Facility/v1_0_1/Facility_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Facility.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Facility"; +BOOLEAN IsRevisonController = TRUE; + +// Support Facility V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Facility", + "1", + "0", + "1" + }, + "Facility" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FacilityToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_FACILITY_V1_0_1 *FacilityV1_0_1; + EFI_REDFISH_FACILITY_V1_0_1_CS *FacilityV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Facility") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Facility_V1_0_1_To_CS (ResoruceRaw, &FacilityV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + FacilityV1_0_1 = (EFI_REDFISH_FACILITY_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_FACILITY_V1_0_1)); + if (FacilityV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)FacilityV1_0_1; + FacilityV1_0_1->Facility = FacilityV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Facility")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Facility"), "Facility"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Facility")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Facility"), "Facility"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of FacilityToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FacilityToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return FacilityToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FacilityToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Facility_V1_0_1_JSON (*((EFI_REDFISH_FACILITY_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in FacilityToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FacilityDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_FACILITY_V1_0_1 *FacilityV1_0_1; + + FacilityV1_0_1 = (EFI_REDFISH_FACILITY_V1_0_1 *)InterpProp; + DestroyFacility_V1_0_1_CS (FacilityV1_0_1->Facility); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from FacilityFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FacilityDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyFacility_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishFacility_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + FacilityToStructWrapper, + FacilityToJson, + FacilityDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishFacility_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Facility/v1_0_1/RedfishFacility_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/Facility/v1_0_1/RedfishFacility_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..dcab147e975 --- /dev/null +++ b/RedfishClientPkg/Converter/Facility/v1_0_1/RedfishFacility_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Facility.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishFacility_V1_0_1_Dxe + FILE_GUID = e0878752-ff31-4a29-8864-8cf3e50cb587 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishFacility_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishFacility_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Facility_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + FacilityV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Facility/v1_1_0/Facility_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/Facility/v1_1_0/Facility_V1_1_0_Dxe.c new file mode 100644 index 00000000000..e6c8416a9eb --- /dev/null +++ b/RedfishClientPkg/Converter/Facility/v1_1_0/Facility_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Facility.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Facility"; +BOOLEAN IsRevisonController = TRUE; + +// Support Facility V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Facility", + "1", + "1", + "0" + }, + "Facility" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FacilityToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_FACILITY_V1_1_0 *FacilityV1_1_0; + EFI_REDFISH_FACILITY_V1_1_0_CS *FacilityV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Facility") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Facility_V1_1_0_To_CS (ResoruceRaw, &FacilityV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + FacilityV1_1_0 = (EFI_REDFISH_FACILITY_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_FACILITY_V1_1_0)); + if (FacilityV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)FacilityV1_1_0; + FacilityV1_1_0->Facility = FacilityV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Facility")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Facility"), "Facility"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Facility")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Facility"), "Facility"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of FacilityToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FacilityToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return FacilityToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FacilityToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Facility_V1_1_0_JSON (*((EFI_REDFISH_FACILITY_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in FacilityToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FacilityDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_FACILITY_V1_1_0 *FacilityV1_1_0; + + FacilityV1_1_0 = (EFI_REDFISH_FACILITY_V1_1_0 *)InterpProp; + DestroyFacility_V1_1_0_CS (FacilityV1_1_0->Facility); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from FacilityFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FacilityDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyFacility_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishFacility_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + FacilityToStructWrapper, + FacilityToJson, + FacilityDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishFacility_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Facility/v1_1_0/RedfishFacility_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/Facility/v1_1_0/RedfishFacility_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..bd1f9ee40de --- /dev/null +++ b/RedfishClientPkg/Converter/Facility/v1_1_0/RedfishFacility_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Facility.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishFacility_V1_1_0_Dxe + FILE_GUID = 9eb4e929-f410-4dd4-82aa-1c1f0f8ef1f2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishFacility_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishFacility_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Facility_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + FacilityV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/FacilityCollection/FacilityCollection_Dxe.c b/RedfishClientPkg/Converter/FacilityCollection/FacilityCollection_Dxe.c new file mode 100644 index 00000000000..1038f81e96d --- /dev/null +++ b/RedfishClientPkg/Converter/FacilityCollection/FacilityCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - FacilityCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#FacilityCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support FacilityCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "FacilityCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "FacilityCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FacilityCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_FACILITYCOLLECTION *FacilityCollection; + EFI_REDFISH_FACILITYCOLLECTION_CS *FacilityCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "FacilityCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_FacilityCollection_To_CS (ResoruceRaw, &FacilityCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + FacilityCollection = (EFI_REDFISH_FACILITYCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_FACILITYCOLLECTION)); + if (FacilityCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)FacilityCollection; + FacilityCollection->FacilityCollection = FacilityCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("FacilityCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("FacilityCollection"), "FacilityCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("FacilityCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("FacilityCollection"), "FacilityCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of FacilityCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FacilityCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return FacilityCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FacilityCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_FacilityCollection_JSON (*((EFI_REDFISH_FACILITYCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in FacilityCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FacilityCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_FACILITYCOLLECTION *FacilityCollection; + + FacilityCollection = (EFI_REDFISH_FACILITYCOLLECTION *)InterpProp; + DestroyFacilityCollection_CS (FacilityCollection->FacilityCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from FacilityCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FacilityCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyFacilityCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishFacilityCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + FacilityCollectionToStructWrapper, + FacilityCollectionToJson, + FacilityCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishFacilityCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/FacilityCollection/RedfishFacilityCollection_Dxe.inf b/RedfishClientPkg/Converter/FacilityCollection/RedfishFacilityCollection_Dxe.inf new file mode 100644 index 00000000000..8c2185a6982 --- /dev/null +++ b/RedfishClientPkg/Converter/FacilityCollection/RedfishFacilityCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of FacilityCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishFacilityCollection_Dxe + FILE_GUID = dd7c9fd4-aa3d-4a21-95ec-c0a16910e6ef + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishFacilityCollectionEntryPoint + UNLOAD_IMAGE = RedfishFacilityCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + FacilityCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + FacilityCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Fan/v1_0_0/Fan_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Fan/v1_0_0/Fan_V1_0_0_Dxe.c new file mode 100644 index 00000000000..b4037940901 --- /dev/null +++ b/RedfishClientPkg/Converter/Fan/v1_0_0/Fan_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Fan.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Fan"; +BOOLEAN IsRevisonController = TRUE; + +// Support Fan V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Fan", + "1", + "0", + "0" + }, + "Fan" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FanToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_FAN_V1_0_0 *FanV1_0_0; + EFI_REDFISH_FAN_V1_0_0_CS *FanV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Fan") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Fan_V1_0_0_To_CS (ResoruceRaw, &FanV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + FanV1_0_0 = (EFI_REDFISH_FAN_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_FAN_V1_0_0)); + if (FanV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)FanV1_0_0; + FanV1_0_0->Fan = FanV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Fan")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Fan"), "Fan"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Fan")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Fan"), "Fan"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of FanToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FanToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return FanToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FanToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Fan_V1_0_0_JSON (*((EFI_REDFISH_FAN_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in FanToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FanDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_FAN_V1_0_0 *FanV1_0_0; + + FanV1_0_0 = (EFI_REDFISH_FAN_V1_0_0 *)InterpProp; + DestroyFan_V1_0_0_CS (FanV1_0_0->Fan); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from FanFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FanDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyFan_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishFan_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + FanToStructWrapper, + FanToJson, + FanDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishFan_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Fan/v1_0_0/RedfishFan_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Fan/v1_0_0/RedfishFan_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..c690d9d0509 --- /dev/null +++ b/RedfishClientPkg/Converter/Fan/v1_0_0/RedfishFan_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Fan.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishFan_V1_0_0_Dxe + FILE_GUID = cced5b49-a6b8-46a3-a68d-6e597affc2e1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishFan_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishFan_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Fan_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + FanV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/FanCollection/FanCollection_Dxe.c b/RedfishClientPkg/Converter/FanCollection/FanCollection_Dxe.c new file mode 100644 index 00000000000..e90d34ab3e3 --- /dev/null +++ b/RedfishClientPkg/Converter/FanCollection/FanCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - FanCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#FanCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support FanCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "FanCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "FanCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FanCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_FANCOLLECTION *FanCollection; + EFI_REDFISH_FANCOLLECTION_CS *FanCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "FanCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_FanCollection_To_CS (ResoruceRaw, &FanCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + FanCollection = (EFI_REDFISH_FANCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_FANCOLLECTION)); + if (FanCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)FanCollection; + FanCollection->FanCollection = FanCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("FanCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("FanCollection"), "FanCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("FanCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("FanCollection"), "FanCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of FanCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FanCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return FanCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FanCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_FanCollection_JSON (*((EFI_REDFISH_FANCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in FanCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FanCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_FANCOLLECTION *FanCollection; + + FanCollection = (EFI_REDFISH_FANCOLLECTION *)InterpProp; + DestroyFanCollection_CS (FanCollection->FanCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from FanCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +FanCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyFanCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishFanCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + FanCollectionToStructWrapper, + FanCollectionToJson, + FanCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishFanCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/FanCollection/RedfishFanCollection_Dxe.inf b/RedfishClientPkg/Converter/FanCollection/RedfishFanCollection_Dxe.inf new file mode 100644 index 00000000000..ad82e882f2e --- /dev/null +++ b/RedfishClientPkg/Converter/FanCollection/RedfishFanCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of FanCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishFanCollection_Dxe + FILE_GUID = df681626-d843-4e58-8013-1dccecfe5b66 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishFanCollectionEntryPoint + UNLOAD_IMAGE = RedfishFanCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + FanCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + FanCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/HostInterface/v1_0_0/HostInterface_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/HostInterface/v1_0_0/HostInterface_V1_0_0_Dxe.c new file mode 100644 index 00000000000..29aef5b38c4 --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_0_0/HostInterface_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - HostInterface.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#HostInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support HostInterface V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "HostInterface", + "1", + "0", + "0" + }, + "HostInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_0_0 *HostInterfaceV1_0_0; + EFI_REDFISH_HOSTINTERFACE_V1_0_0_CS *HostInterfaceV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "HostInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_HostInterface_V1_0_0_To_CS (ResoruceRaw, &HostInterfaceV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + HostInterfaceV1_0_0 = (EFI_REDFISH_HOSTINTERFACE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_HOSTINTERFACE_V1_0_0)); + if (HostInterfaceV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)HostInterfaceV1_0_0; + HostInterfaceV1_0_0->HostInterface = HostInterfaceV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("HostInterface"), "HostInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("HostInterface"), "HostInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of HostInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return HostInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_HostInterface_V1_0_0_JSON (*((EFI_REDFISH_HOSTINTERFACE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in HostInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_0_0 *HostInterfaceV1_0_0; + + HostInterfaceV1_0_0 = (EFI_REDFISH_HOSTINTERFACE_V1_0_0 *)InterpProp; + DestroyHostInterface_V1_0_0_CS (HostInterfaceV1_0_0->HostInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from HostInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyHostInterface_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + HostInterfaceToStructWrapper, + HostInterfaceToJson, + HostInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/HostInterface/v1_0_0/RedfishHostInterface_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/HostInterface/v1_0_0/RedfishHostInterface_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..2ea43408fcb --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_0_0/RedfishHostInterface_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of HostInterface.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishHostInterface_V1_0_0_Dxe + FILE_GUID = 725afa3a-5730-4161-98b9-2447963e39da + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishHostInterface_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishHostInterface_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + HostInterface_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + HostInterfaceV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/HostInterface/v1_0_1/HostInterface_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/HostInterface/v1_0_1/HostInterface_V1_0_1_Dxe.c new file mode 100644 index 00000000000..2ebaac0b0ce --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_0_1/HostInterface_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - HostInterface.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#HostInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support HostInterface V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "HostInterface", + "1", + "0", + "1" + }, + "HostInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_0_1 *HostInterfaceV1_0_1; + EFI_REDFISH_HOSTINTERFACE_V1_0_1_CS *HostInterfaceV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "HostInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_HostInterface_V1_0_1_To_CS (ResoruceRaw, &HostInterfaceV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + HostInterfaceV1_0_1 = (EFI_REDFISH_HOSTINTERFACE_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_HOSTINTERFACE_V1_0_1)); + if (HostInterfaceV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)HostInterfaceV1_0_1; + HostInterfaceV1_0_1->HostInterface = HostInterfaceV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("HostInterface"), "HostInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("HostInterface"), "HostInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of HostInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return HostInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_HostInterface_V1_0_1_JSON (*((EFI_REDFISH_HOSTINTERFACE_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in HostInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_0_1 *HostInterfaceV1_0_1; + + HostInterfaceV1_0_1 = (EFI_REDFISH_HOSTINTERFACE_V1_0_1 *)InterpProp; + DestroyHostInterface_V1_0_1_CS (HostInterfaceV1_0_1->HostInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from HostInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyHostInterface_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + HostInterfaceToStructWrapper, + HostInterfaceToJson, + HostInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/HostInterface/v1_0_1/RedfishHostInterface_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/HostInterface/v1_0_1/RedfishHostInterface_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..239e0dbae70 --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_0_1/RedfishHostInterface_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of HostInterface.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishHostInterface_V1_0_1_Dxe + FILE_GUID = ffd1e619-87f9-41bb-911d-082ef943ae8b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishHostInterface_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishHostInterface_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + HostInterface_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + HostInterfaceV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/HostInterface/v1_0_2/HostInterface_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/HostInterface/v1_0_2/HostInterface_V1_0_2_Dxe.c new file mode 100644 index 00000000000..d2a327dc5bf --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_0_2/HostInterface_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - HostInterface.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#HostInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support HostInterface V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "HostInterface", + "1", + "0", + "2" + }, + "HostInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_0_2 *HostInterfaceV1_0_2; + EFI_REDFISH_HOSTINTERFACE_V1_0_2_CS *HostInterfaceV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "HostInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_HostInterface_V1_0_2_To_CS (ResoruceRaw, &HostInterfaceV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + HostInterfaceV1_0_2 = (EFI_REDFISH_HOSTINTERFACE_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_HOSTINTERFACE_V1_0_2)); + if (HostInterfaceV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)HostInterfaceV1_0_2; + HostInterfaceV1_0_2->HostInterface = HostInterfaceV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("HostInterface"), "HostInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("HostInterface"), "HostInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of HostInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return HostInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_HostInterface_V1_0_2_JSON (*((EFI_REDFISH_HOSTINTERFACE_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in HostInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_0_2 *HostInterfaceV1_0_2; + + HostInterfaceV1_0_2 = (EFI_REDFISH_HOSTINTERFACE_V1_0_2 *)InterpProp; + DestroyHostInterface_V1_0_2_CS (HostInterfaceV1_0_2->HostInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from HostInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyHostInterface_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + HostInterfaceToStructWrapper, + HostInterfaceToJson, + HostInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/HostInterface/v1_0_2/RedfishHostInterface_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/HostInterface/v1_0_2/RedfishHostInterface_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..6fbede6ddd7 --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_0_2/RedfishHostInterface_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of HostInterface.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishHostInterface_V1_0_2_Dxe + FILE_GUID = ad2ba705-ced3-457c-9ac3-d3773aec9655 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishHostInterface_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishHostInterface_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + HostInterface_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + HostInterfaceV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/HostInterface/v1_0_3/HostInterface_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/HostInterface/v1_0_3/HostInterface_V1_0_3_Dxe.c new file mode 100644 index 00000000000..0cac85aa177 --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_0_3/HostInterface_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - HostInterface.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#HostInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support HostInterface V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "HostInterface", + "1", + "0", + "3" + }, + "HostInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_0_3 *HostInterfaceV1_0_3; + EFI_REDFISH_HOSTINTERFACE_V1_0_3_CS *HostInterfaceV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "HostInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_HostInterface_V1_0_3_To_CS (ResoruceRaw, &HostInterfaceV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + HostInterfaceV1_0_3 = (EFI_REDFISH_HOSTINTERFACE_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_HOSTINTERFACE_V1_0_3)); + if (HostInterfaceV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)HostInterfaceV1_0_3; + HostInterfaceV1_0_3->HostInterface = HostInterfaceV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("HostInterface"), "HostInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("HostInterface"), "HostInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of HostInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return HostInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_HostInterface_V1_0_3_JSON (*((EFI_REDFISH_HOSTINTERFACE_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in HostInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_0_3 *HostInterfaceV1_0_3; + + HostInterfaceV1_0_3 = (EFI_REDFISH_HOSTINTERFACE_V1_0_3 *)InterpProp; + DestroyHostInterface_V1_0_3_CS (HostInterfaceV1_0_3->HostInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from HostInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyHostInterface_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + HostInterfaceToStructWrapper, + HostInterfaceToJson, + HostInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/HostInterface/v1_0_3/RedfishHostInterface_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/HostInterface/v1_0_3/RedfishHostInterface_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..669b9dc4e4b --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_0_3/RedfishHostInterface_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of HostInterface.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishHostInterface_V1_0_3_Dxe + FILE_GUID = 9b77ae94-174b-4442-9466-8942c2843e16 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishHostInterface_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishHostInterface_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + HostInterface_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + HostInterfaceV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/HostInterface/v1_0_4/HostInterface_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/HostInterface/v1_0_4/HostInterface_V1_0_4_Dxe.c new file mode 100644 index 00000000000..953f3e56ce0 --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_0_4/HostInterface_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - HostInterface.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#HostInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support HostInterface V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "HostInterface", + "1", + "0", + "4" + }, + "HostInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_0_4 *HostInterfaceV1_0_4; + EFI_REDFISH_HOSTINTERFACE_V1_0_4_CS *HostInterfaceV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "HostInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_HostInterface_V1_0_4_To_CS (ResoruceRaw, &HostInterfaceV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + HostInterfaceV1_0_4 = (EFI_REDFISH_HOSTINTERFACE_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_HOSTINTERFACE_V1_0_4)); + if (HostInterfaceV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)HostInterfaceV1_0_4; + HostInterfaceV1_0_4->HostInterface = HostInterfaceV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("HostInterface"), "HostInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("HostInterface"), "HostInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of HostInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return HostInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_HostInterface_V1_0_4_JSON (*((EFI_REDFISH_HOSTINTERFACE_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in HostInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_0_4 *HostInterfaceV1_0_4; + + HostInterfaceV1_0_4 = (EFI_REDFISH_HOSTINTERFACE_V1_0_4 *)InterpProp; + DestroyHostInterface_V1_0_4_CS (HostInterfaceV1_0_4->HostInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from HostInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyHostInterface_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + HostInterfaceToStructWrapper, + HostInterfaceToJson, + HostInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/HostInterface/v1_0_4/RedfishHostInterface_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/HostInterface/v1_0_4/RedfishHostInterface_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..d43e68ec774 --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_0_4/RedfishHostInterface_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of HostInterface.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishHostInterface_V1_0_4_Dxe + FILE_GUID = e53d4191-f021-4cdf-894e-d154732068ad + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishHostInterface_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishHostInterface_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + HostInterface_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + HostInterfaceV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/HostInterface/v1_0_5/HostInterface_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/HostInterface/v1_0_5/HostInterface_V1_0_5_Dxe.c new file mode 100644 index 00000000000..fa8fd1e377c --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_0_5/HostInterface_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - HostInterface.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#HostInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support HostInterface V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "HostInterface", + "1", + "0", + "5" + }, + "HostInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_0_5 *HostInterfaceV1_0_5; + EFI_REDFISH_HOSTINTERFACE_V1_0_5_CS *HostInterfaceV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "HostInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_HostInterface_V1_0_5_To_CS (ResoruceRaw, &HostInterfaceV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + HostInterfaceV1_0_5 = (EFI_REDFISH_HOSTINTERFACE_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_HOSTINTERFACE_V1_0_5)); + if (HostInterfaceV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)HostInterfaceV1_0_5; + HostInterfaceV1_0_5->HostInterface = HostInterfaceV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("HostInterface"), "HostInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("HostInterface"), "HostInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of HostInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return HostInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_HostInterface_V1_0_5_JSON (*((EFI_REDFISH_HOSTINTERFACE_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in HostInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_0_5 *HostInterfaceV1_0_5; + + HostInterfaceV1_0_5 = (EFI_REDFISH_HOSTINTERFACE_V1_0_5 *)InterpProp; + DestroyHostInterface_V1_0_5_CS (HostInterfaceV1_0_5->HostInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from HostInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyHostInterface_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + HostInterfaceToStructWrapper, + HostInterfaceToJson, + HostInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/HostInterface/v1_0_5/RedfishHostInterface_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/HostInterface/v1_0_5/RedfishHostInterface_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..b8d41489c6f --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_0_5/RedfishHostInterface_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of HostInterface.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishHostInterface_V1_0_5_Dxe + FILE_GUID = a33190f2-01cf-40fc-9d37-3cffe028cf21 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishHostInterface_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishHostInterface_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + HostInterface_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + HostInterfaceV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/HostInterface/v1_1_0/HostInterface_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/HostInterface/v1_1_0/HostInterface_V1_1_0_Dxe.c new file mode 100644 index 00000000000..bb9b646ea92 --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_1_0/HostInterface_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - HostInterface.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#HostInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support HostInterface V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "HostInterface", + "1", + "1", + "0" + }, + "HostInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_1_0 *HostInterfaceV1_1_0; + EFI_REDFISH_HOSTINTERFACE_V1_1_0_CS *HostInterfaceV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "HostInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_HostInterface_V1_1_0_To_CS (ResoruceRaw, &HostInterfaceV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + HostInterfaceV1_1_0 = (EFI_REDFISH_HOSTINTERFACE_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_HOSTINTERFACE_V1_1_0)); + if (HostInterfaceV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)HostInterfaceV1_1_0; + HostInterfaceV1_1_0->HostInterface = HostInterfaceV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("HostInterface"), "HostInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("HostInterface"), "HostInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of HostInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return HostInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_HostInterface_V1_1_0_JSON (*((EFI_REDFISH_HOSTINTERFACE_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in HostInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_1_0 *HostInterfaceV1_1_0; + + HostInterfaceV1_1_0 = (EFI_REDFISH_HOSTINTERFACE_V1_1_0 *)InterpProp; + DestroyHostInterface_V1_1_0_CS (HostInterfaceV1_1_0->HostInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from HostInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyHostInterface_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + HostInterfaceToStructWrapper, + HostInterfaceToJson, + HostInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/HostInterface/v1_1_0/RedfishHostInterface_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/HostInterface/v1_1_0/RedfishHostInterface_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..5414a5c0ede --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_1_0/RedfishHostInterface_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of HostInterface.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishHostInterface_V1_1_0_Dxe + FILE_GUID = 172a60ad-e285-4f31-864b-2d4903b15410 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishHostInterface_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishHostInterface_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + HostInterface_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + HostInterfaceV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/HostInterface/v1_1_1/HostInterface_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/HostInterface/v1_1_1/HostInterface_V1_1_1_Dxe.c new file mode 100644 index 00000000000..49d9ee19047 --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_1_1/HostInterface_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - HostInterface.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#HostInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support HostInterface V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "HostInterface", + "1", + "1", + "1" + }, + "HostInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_1_1 *HostInterfaceV1_1_1; + EFI_REDFISH_HOSTINTERFACE_V1_1_1_CS *HostInterfaceV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "HostInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_HostInterface_V1_1_1_To_CS (ResoruceRaw, &HostInterfaceV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + HostInterfaceV1_1_1 = (EFI_REDFISH_HOSTINTERFACE_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_HOSTINTERFACE_V1_1_1)); + if (HostInterfaceV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)HostInterfaceV1_1_1; + HostInterfaceV1_1_1->HostInterface = HostInterfaceV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("HostInterface"), "HostInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("HostInterface"), "HostInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of HostInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return HostInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_HostInterface_V1_1_1_JSON (*((EFI_REDFISH_HOSTINTERFACE_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in HostInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_1_1 *HostInterfaceV1_1_1; + + HostInterfaceV1_1_1 = (EFI_REDFISH_HOSTINTERFACE_V1_1_1 *)InterpProp; + DestroyHostInterface_V1_1_1_CS (HostInterfaceV1_1_1->HostInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from HostInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyHostInterface_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + HostInterfaceToStructWrapper, + HostInterfaceToJson, + HostInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/HostInterface/v1_1_1/RedfishHostInterface_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/HostInterface/v1_1_1/RedfishHostInterface_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..15f36df6fdf --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_1_1/RedfishHostInterface_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of HostInterface.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishHostInterface_V1_1_1_Dxe + FILE_GUID = d410764d-9f0d-4bdb-8e9e-d3bc66d746a2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishHostInterface_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishHostInterface_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + HostInterface_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + HostInterfaceV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/HostInterface/v1_1_2/HostInterface_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/HostInterface/v1_1_2/HostInterface_V1_1_2_Dxe.c new file mode 100644 index 00000000000..00da9eef398 --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_1_2/HostInterface_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - HostInterface.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#HostInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support HostInterface V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "HostInterface", + "1", + "1", + "2" + }, + "HostInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_1_2 *HostInterfaceV1_1_2; + EFI_REDFISH_HOSTINTERFACE_V1_1_2_CS *HostInterfaceV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "HostInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_HostInterface_V1_1_2_To_CS (ResoruceRaw, &HostInterfaceV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + HostInterfaceV1_1_2 = (EFI_REDFISH_HOSTINTERFACE_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_HOSTINTERFACE_V1_1_2)); + if (HostInterfaceV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)HostInterfaceV1_1_2; + HostInterfaceV1_1_2->HostInterface = HostInterfaceV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("HostInterface"), "HostInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("HostInterface"), "HostInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of HostInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return HostInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_HostInterface_V1_1_2_JSON (*((EFI_REDFISH_HOSTINTERFACE_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in HostInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_1_2 *HostInterfaceV1_1_2; + + HostInterfaceV1_1_2 = (EFI_REDFISH_HOSTINTERFACE_V1_1_2 *)InterpProp; + DestroyHostInterface_V1_1_2_CS (HostInterfaceV1_1_2->HostInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from HostInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyHostInterface_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + HostInterfaceToStructWrapper, + HostInterfaceToJson, + HostInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/HostInterface/v1_1_2/RedfishHostInterface_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/HostInterface/v1_1_2/RedfishHostInterface_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..b25daa19430 --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_1_2/RedfishHostInterface_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of HostInterface.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishHostInterface_V1_1_2_Dxe + FILE_GUID = 88c688ea-71ac-4bfb-8600-219e59e4bc15 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishHostInterface_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishHostInterface_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + HostInterface_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + HostInterfaceV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/HostInterface/v1_1_3/HostInterface_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/HostInterface/v1_1_3/HostInterface_V1_1_3_Dxe.c new file mode 100644 index 00000000000..4f0fd813ccd --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_1_3/HostInterface_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - HostInterface.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#HostInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support HostInterface V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "HostInterface", + "1", + "1", + "3" + }, + "HostInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_1_3 *HostInterfaceV1_1_3; + EFI_REDFISH_HOSTINTERFACE_V1_1_3_CS *HostInterfaceV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "HostInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_HostInterface_V1_1_3_To_CS (ResoruceRaw, &HostInterfaceV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + HostInterfaceV1_1_3 = (EFI_REDFISH_HOSTINTERFACE_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_HOSTINTERFACE_V1_1_3)); + if (HostInterfaceV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)HostInterfaceV1_1_3; + HostInterfaceV1_1_3->HostInterface = HostInterfaceV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("HostInterface"), "HostInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("HostInterface"), "HostInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of HostInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return HostInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_HostInterface_V1_1_3_JSON (*((EFI_REDFISH_HOSTINTERFACE_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in HostInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_1_3 *HostInterfaceV1_1_3; + + HostInterfaceV1_1_3 = (EFI_REDFISH_HOSTINTERFACE_V1_1_3 *)InterpProp; + DestroyHostInterface_V1_1_3_CS (HostInterfaceV1_1_3->HostInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from HostInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyHostInterface_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + HostInterfaceToStructWrapper, + HostInterfaceToJson, + HostInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/HostInterface/v1_1_3/RedfishHostInterface_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/HostInterface/v1_1_3/RedfishHostInterface_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..5faf24b0882 --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_1_3/RedfishHostInterface_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of HostInterface.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishHostInterface_V1_1_3_Dxe + FILE_GUID = 08744676-f32c-4869-a31f-ae9b37a448e0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishHostInterface_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishHostInterface_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + HostInterface_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + HostInterfaceV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/HostInterface/v1_1_4/HostInterface_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/HostInterface/v1_1_4/HostInterface_V1_1_4_Dxe.c new file mode 100644 index 00000000000..f572d6fe100 --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_1_4/HostInterface_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - HostInterface.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#HostInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support HostInterface V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "HostInterface", + "1", + "1", + "4" + }, + "HostInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_1_4 *HostInterfaceV1_1_4; + EFI_REDFISH_HOSTINTERFACE_V1_1_4_CS *HostInterfaceV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "HostInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_HostInterface_V1_1_4_To_CS (ResoruceRaw, &HostInterfaceV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + HostInterfaceV1_1_4 = (EFI_REDFISH_HOSTINTERFACE_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_HOSTINTERFACE_V1_1_4)); + if (HostInterfaceV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)HostInterfaceV1_1_4; + HostInterfaceV1_1_4->HostInterface = HostInterfaceV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("HostInterface"), "HostInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("HostInterface"), "HostInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of HostInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return HostInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_HostInterface_V1_1_4_JSON (*((EFI_REDFISH_HOSTINTERFACE_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in HostInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_1_4 *HostInterfaceV1_1_4; + + HostInterfaceV1_1_4 = (EFI_REDFISH_HOSTINTERFACE_V1_1_4 *)InterpProp; + DestroyHostInterface_V1_1_4_CS (HostInterfaceV1_1_4->HostInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from HostInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyHostInterface_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + HostInterfaceToStructWrapper, + HostInterfaceToJson, + HostInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/HostInterface/v1_1_4/RedfishHostInterface_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/HostInterface/v1_1_4/RedfishHostInterface_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..fcbeb3b69fa --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_1_4/RedfishHostInterface_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of HostInterface.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishHostInterface_V1_1_4_Dxe + FILE_GUID = 2b19f449-d5a7-4cac-bfa9-c719e9440f81 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishHostInterface_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishHostInterface_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + HostInterface_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + HostInterfaceV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/HostInterface/v1_1_5/HostInterface_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/HostInterface/v1_1_5/HostInterface_V1_1_5_Dxe.c new file mode 100644 index 00000000000..da6e1bb1626 --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_1_5/HostInterface_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - HostInterface.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#HostInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support HostInterface V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "HostInterface", + "1", + "1", + "5" + }, + "HostInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_1_5 *HostInterfaceV1_1_5; + EFI_REDFISH_HOSTINTERFACE_V1_1_5_CS *HostInterfaceV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "HostInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_HostInterface_V1_1_5_To_CS (ResoruceRaw, &HostInterfaceV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + HostInterfaceV1_1_5 = (EFI_REDFISH_HOSTINTERFACE_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_HOSTINTERFACE_V1_1_5)); + if (HostInterfaceV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)HostInterfaceV1_1_5; + HostInterfaceV1_1_5->HostInterface = HostInterfaceV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("HostInterface"), "HostInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("HostInterface"), "HostInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of HostInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return HostInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_HostInterface_V1_1_5_JSON (*((EFI_REDFISH_HOSTINTERFACE_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in HostInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_1_5 *HostInterfaceV1_1_5; + + HostInterfaceV1_1_5 = (EFI_REDFISH_HOSTINTERFACE_V1_1_5 *)InterpProp; + DestroyHostInterface_V1_1_5_CS (HostInterfaceV1_1_5->HostInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from HostInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyHostInterface_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + HostInterfaceToStructWrapper, + HostInterfaceToJson, + HostInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/HostInterface/v1_1_5/RedfishHostInterface_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/HostInterface/v1_1_5/RedfishHostInterface_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..5a51c1e506e --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_1_5/RedfishHostInterface_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of HostInterface.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishHostInterface_V1_1_5_Dxe + FILE_GUID = 2dd99fc9-8fec-439a-8c7a-5bb03d4d94bb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishHostInterface_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishHostInterface_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + HostInterface_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + HostInterfaceV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/HostInterface/v1_2_0/HostInterface_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/HostInterface/v1_2_0/HostInterface_V1_2_0_Dxe.c new file mode 100644 index 00000000000..0dbe2c9e950 --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_2_0/HostInterface_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - HostInterface.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#HostInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support HostInterface V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "HostInterface", + "1", + "2", + "0" + }, + "HostInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_2_0 *HostInterfaceV1_2_0; + EFI_REDFISH_HOSTINTERFACE_V1_2_0_CS *HostInterfaceV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "HostInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_HostInterface_V1_2_0_To_CS (ResoruceRaw, &HostInterfaceV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + HostInterfaceV1_2_0 = (EFI_REDFISH_HOSTINTERFACE_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_HOSTINTERFACE_V1_2_0)); + if (HostInterfaceV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)HostInterfaceV1_2_0; + HostInterfaceV1_2_0->HostInterface = HostInterfaceV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("HostInterface"), "HostInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("HostInterface"), "HostInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of HostInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return HostInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_HostInterface_V1_2_0_JSON (*((EFI_REDFISH_HOSTINTERFACE_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in HostInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_2_0 *HostInterfaceV1_2_0; + + HostInterfaceV1_2_0 = (EFI_REDFISH_HOSTINTERFACE_V1_2_0 *)InterpProp; + DestroyHostInterface_V1_2_0_CS (HostInterfaceV1_2_0->HostInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from HostInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyHostInterface_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + HostInterfaceToStructWrapper, + HostInterfaceToJson, + HostInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/HostInterface/v1_2_0/RedfishHostInterface_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/HostInterface/v1_2_0/RedfishHostInterface_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..12ffb5c4075 --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_2_0/RedfishHostInterface_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of HostInterface.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishHostInterface_V1_2_0_Dxe + FILE_GUID = dce9bc34-e5c8-4b00-a74a-2d65510a3aeb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishHostInterface_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishHostInterface_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + HostInterface_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + HostInterfaceV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/HostInterface/v1_2_1/HostInterface_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/HostInterface/v1_2_1/HostInterface_V1_2_1_Dxe.c new file mode 100644 index 00000000000..2f73aa4a083 --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_2_1/HostInterface_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - HostInterface.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#HostInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support HostInterface V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "HostInterface", + "1", + "2", + "1" + }, + "HostInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_2_1 *HostInterfaceV1_2_1; + EFI_REDFISH_HOSTINTERFACE_V1_2_1_CS *HostInterfaceV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "HostInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_HostInterface_V1_2_1_To_CS (ResoruceRaw, &HostInterfaceV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + HostInterfaceV1_2_1 = (EFI_REDFISH_HOSTINTERFACE_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_HOSTINTERFACE_V1_2_1)); + if (HostInterfaceV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)HostInterfaceV1_2_1; + HostInterfaceV1_2_1->HostInterface = HostInterfaceV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("HostInterface"), "HostInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("HostInterface"), "HostInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of HostInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return HostInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_HostInterface_V1_2_1_JSON (*((EFI_REDFISH_HOSTINTERFACE_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in HostInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_2_1 *HostInterfaceV1_2_1; + + HostInterfaceV1_2_1 = (EFI_REDFISH_HOSTINTERFACE_V1_2_1 *)InterpProp; + DestroyHostInterface_V1_2_1_CS (HostInterfaceV1_2_1->HostInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from HostInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyHostInterface_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + HostInterfaceToStructWrapper, + HostInterfaceToJson, + HostInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/HostInterface/v1_2_1/RedfishHostInterface_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/HostInterface/v1_2_1/RedfishHostInterface_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..23cda030797 --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_2_1/RedfishHostInterface_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of HostInterface.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishHostInterface_V1_2_1_Dxe + FILE_GUID = e8733716-9cb8-4297-82de-9559228132df + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishHostInterface_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishHostInterface_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + HostInterface_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + HostInterfaceV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/HostInterface/v1_2_2/HostInterface_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/HostInterface/v1_2_2/HostInterface_V1_2_2_Dxe.c new file mode 100644 index 00000000000..c26cc88f239 --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_2_2/HostInterface_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - HostInterface.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#HostInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support HostInterface V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "HostInterface", + "1", + "2", + "2" + }, + "HostInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_2_2 *HostInterfaceV1_2_2; + EFI_REDFISH_HOSTINTERFACE_V1_2_2_CS *HostInterfaceV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "HostInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_HostInterface_V1_2_2_To_CS (ResoruceRaw, &HostInterfaceV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + HostInterfaceV1_2_2 = (EFI_REDFISH_HOSTINTERFACE_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_HOSTINTERFACE_V1_2_2)); + if (HostInterfaceV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)HostInterfaceV1_2_2; + HostInterfaceV1_2_2->HostInterface = HostInterfaceV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("HostInterface"), "HostInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("HostInterface"), "HostInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of HostInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return HostInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_HostInterface_V1_2_2_JSON (*((EFI_REDFISH_HOSTINTERFACE_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in HostInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_2_2 *HostInterfaceV1_2_2; + + HostInterfaceV1_2_2 = (EFI_REDFISH_HOSTINTERFACE_V1_2_2 *)InterpProp; + DestroyHostInterface_V1_2_2_CS (HostInterfaceV1_2_2->HostInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from HostInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyHostInterface_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + HostInterfaceToStructWrapper, + HostInterfaceToJson, + HostInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/HostInterface/v1_2_2/RedfishHostInterface_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/HostInterface/v1_2_2/RedfishHostInterface_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..fee83025020 --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_2_2/RedfishHostInterface_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of HostInterface.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishHostInterface_V1_2_2_Dxe + FILE_GUID = 3609073c-ca51-422d-8222-7f877c9b49c4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishHostInterface_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishHostInterface_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + HostInterface_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + HostInterfaceV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/HostInterface/v1_3_0/HostInterface_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/HostInterface/v1_3_0/HostInterface_V1_3_0_Dxe.c new file mode 100644 index 00000000000..d247b30ee53 --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_3_0/HostInterface_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - HostInterface.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#HostInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support HostInterface V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "HostInterface", + "1", + "3", + "0" + }, + "HostInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_3_0 *HostInterfaceV1_3_0; + EFI_REDFISH_HOSTINTERFACE_V1_3_0_CS *HostInterfaceV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "HostInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_HostInterface_V1_3_0_To_CS (ResoruceRaw, &HostInterfaceV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + HostInterfaceV1_3_0 = (EFI_REDFISH_HOSTINTERFACE_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_HOSTINTERFACE_V1_3_0)); + if (HostInterfaceV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)HostInterfaceV1_3_0; + HostInterfaceV1_3_0->HostInterface = HostInterfaceV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("HostInterface"), "HostInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("HostInterface"), "HostInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of HostInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return HostInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_HostInterface_V1_3_0_JSON (*((EFI_REDFISH_HOSTINTERFACE_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in HostInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACE_V1_3_0 *HostInterfaceV1_3_0; + + HostInterfaceV1_3_0 = (EFI_REDFISH_HOSTINTERFACE_V1_3_0 *)InterpProp; + DestroyHostInterface_V1_3_0_CS (HostInterfaceV1_3_0->HostInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from HostInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyHostInterface_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + HostInterfaceToStructWrapper, + HostInterfaceToJson, + HostInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishHostInterface_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/HostInterface/v1_3_0/RedfishHostInterface_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/HostInterface/v1_3_0/RedfishHostInterface_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..83a4cc662fd --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterface/v1_3_0/RedfishHostInterface_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of HostInterface.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishHostInterface_V1_3_0_Dxe + FILE_GUID = 0fca8910-0767-4864-a06b-12eda282398c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishHostInterface_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishHostInterface_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + HostInterface_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + HostInterfaceV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/HostInterfaceCollection/HostInterfaceCollection_Dxe.c b/RedfishClientPkg/Converter/HostInterfaceCollection/HostInterfaceCollection_Dxe.c new file mode 100644 index 00000000000..74c2c77cbaa --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterfaceCollection/HostInterfaceCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - HostInterfaceCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#HostInterfaceCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support HostInterfaceCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "HostInterfaceCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "HostInterfaceCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACECOLLECTION *HostInterfaceCollection; + EFI_REDFISH_HOSTINTERFACECOLLECTION_CS *HostInterfaceCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "HostInterfaceCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_HostInterfaceCollection_To_CS (ResoruceRaw, &HostInterfaceCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + HostInterfaceCollection = (EFI_REDFISH_HOSTINTERFACECOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_HOSTINTERFACECOLLECTION)); + if (HostInterfaceCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)HostInterfaceCollection; + HostInterfaceCollection->HostInterfaceCollection = HostInterfaceCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterfaceCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("HostInterfaceCollection"), "HostInterfaceCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("HostInterfaceCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("HostInterfaceCollection"), "HostInterfaceCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of HostInterfaceCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return HostInterfaceCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_HostInterfaceCollection_JSON (*((EFI_REDFISH_HOSTINTERFACECOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in HostInterfaceCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_HOSTINTERFACECOLLECTION *HostInterfaceCollection; + + HostInterfaceCollection = (EFI_REDFISH_HOSTINTERFACECOLLECTION *)InterpProp; + DestroyHostInterfaceCollection_CS (HostInterfaceCollection->HostInterfaceCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from HostInterfaceCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +HostInterfaceCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyHostInterfaceCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishHostInterfaceCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + HostInterfaceCollectionToStructWrapper, + HostInterfaceCollectionToJson, + HostInterfaceCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishHostInterfaceCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/HostInterfaceCollection/RedfishHostInterfaceCollection_Dxe.inf b/RedfishClientPkg/Converter/HostInterfaceCollection/RedfishHostInterfaceCollection_Dxe.inf new file mode 100644 index 00000000000..a5ee678c2f2 --- /dev/null +++ b/RedfishClientPkg/Converter/HostInterfaceCollection/RedfishHostInterfaceCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of HostInterfaceCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishHostInterfaceCollection_Dxe + FILE_GUID = 369357e7-0667-4441-89dc-41c5b6bcedf0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishHostInterfaceCollectionEntryPoint + UNLOAD_IMAGE = RedfishHostInterfaceCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + HostInterfaceCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + HostInterfaceCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Job/v1_0_0/Job_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Job/v1_0_0/Job_V1_0_0_Dxe.c new file mode 100644 index 00000000000..7c4f447b30a --- /dev/null +++ b/RedfishClientPkg/Converter/Job/v1_0_0/Job_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Job.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Job"; +BOOLEAN IsRevisonController = TRUE; + +// Support Job V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Job", + "1", + "0", + "0" + }, + "Job" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JOB_V1_0_0 *JobV1_0_0; + EFI_REDFISH_JOB_V1_0_0_CS *JobV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Job") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Job_V1_0_0_To_CS (ResoruceRaw, &JobV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + JobV1_0_0 = (EFI_REDFISH_JOB_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JOB_V1_0_0)); + if (JobV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JobV1_0_0; + JobV1_0_0->Job = JobV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Job")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Job"), "Job"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Job")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Job"), "Job"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JobToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JobToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Job_V1_0_0_JSON (*((EFI_REDFISH_JOB_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JobToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JOB_V1_0_0 *JobV1_0_0; + + JobV1_0_0 = (EFI_REDFISH_JOB_V1_0_0 *)InterpProp; + DestroyJob_V1_0_0_CS (JobV1_0_0->Job); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JobFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJob_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJob_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JobToStructWrapper, + JobToJson, + JobDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJob_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Job/v1_0_0/RedfishJob_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Job/v1_0_0/RedfishJob_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..6a121379b85 --- /dev/null +++ b/RedfishClientPkg/Converter/Job/v1_0_0/RedfishJob_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Job.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJob_V1_0_0_Dxe + FILE_GUID = 66daabeb-306e-426f-bdf1-cb10ce71090d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJob_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishJob_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Job_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JobV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Job/v1_0_1/Job_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/Job/v1_0_1/Job_V1_0_1_Dxe.c new file mode 100644 index 00000000000..9c07956c6b6 --- /dev/null +++ b/RedfishClientPkg/Converter/Job/v1_0_1/Job_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Job.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Job"; +BOOLEAN IsRevisonController = TRUE; + +// Support Job V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Job", + "1", + "0", + "1" + }, + "Job" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JOB_V1_0_1 *JobV1_0_1; + EFI_REDFISH_JOB_V1_0_1_CS *JobV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Job") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Job_V1_0_1_To_CS (ResoruceRaw, &JobV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + JobV1_0_1 = (EFI_REDFISH_JOB_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JOB_V1_0_1)); + if (JobV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JobV1_0_1; + JobV1_0_1->Job = JobV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Job")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Job"), "Job"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Job")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Job"), "Job"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JobToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JobToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Job_V1_0_1_JSON (*((EFI_REDFISH_JOB_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JobToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JOB_V1_0_1 *JobV1_0_1; + + JobV1_0_1 = (EFI_REDFISH_JOB_V1_0_1 *)InterpProp; + DestroyJob_V1_0_1_CS (JobV1_0_1->Job); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JobFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJob_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJob_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JobToStructWrapper, + JobToJson, + JobDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJob_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Job/v1_0_1/RedfishJob_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/Job/v1_0_1/RedfishJob_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..c65649156fb --- /dev/null +++ b/RedfishClientPkg/Converter/Job/v1_0_1/RedfishJob_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Job.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJob_V1_0_1_Dxe + FILE_GUID = 7a0f67c4-66ef-4351-9923-2af33861696c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJob_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishJob_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Job_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JobV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Job/v1_0_2/Job_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Job/v1_0_2/Job_V1_0_2_Dxe.c new file mode 100644 index 00000000000..681881840d6 --- /dev/null +++ b/RedfishClientPkg/Converter/Job/v1_0_2/Job_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Job.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Job"; +BOOLEAN IsRevisonController = TRUE; + +// Support Job V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Job", + "1", + "0", + "2" + }, + "Job" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JOB_V1_0_2 *JobV1_0_2; + EFI_REDFISH_JOB_V1_0_2_CS *JobV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Job") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Job_V1_0_2_To_CS (ResoruceRaw, &JobV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + JobV1_0_2 = (EFI_REDFISH_JOB_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JOB_V1_0_2)); + if (JobV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JobV1_0_2; + JobV1_0_2->Job = JobV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Job")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Job"), "Job"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Job")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Job"), "Job"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JobToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JobToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Job_V1_0_2_JSON (*((EFI_REDFISH_JOB_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JobToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JOB_V1_0_2 *JobV1_0_2; + + JobV1_0_2 = (EFI_REDFISH_JOB_V1_0_2 *)InterpProp; + DestroyJob_V1_0_2_CS (JobV1_0_2->Job); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JobFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJob_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJob_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JobToStructWrapper, + JobToJson, + JobDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJob_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Job/v1_0_2/RedfishJob_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Job/v1_0_2/RedfishJob_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..8d39b5e5067 --- /dev/null +++ b/RedfishClientPkg/Converter/Job/v1_0_2/RedfishJob_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Job.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJob_V1_0_2_Dxe + FILE_GUID = 282cb994-541a-4591-bfb7-a55c886ad874 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJob_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishJob_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Job_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JobV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Job/v1_0_3/Job_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/Job/v1_0_3/Job_V1_0_3_Dxe.c new file mode 100644 index 00000000000..b77b9dd5d8b --- /dev/null +++ b/RedfishClientPkg/Converter/Job/v1_0_3/Job_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Job.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Job"; +BOOLEAN IsRevisonController = TRUE; + +// Support Job V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Job", + "1", + "0", + "3" + }, + "Job" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JOB_V1_0_3 *JobV1_0_3; + EFI_REDFISH_JOB_V1_0_3_CS *JobV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Job") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Job_V1_0_3_To_CS (ResoruceRaw, &JobV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + JobV1_0_3 = (EFI_REDFISH_JOB_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JOB_V1_0_3)); + if (JobV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JobV1_0_3; + JobV1_0_3->Job = JobV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Job")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Job"), "Job"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Job")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Job"), "Job"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JobToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JobToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Job_V1_0_3_JSON (*((EFI_REDFISH_JOB_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JobToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JOB_V1_0_3 *JobV1_0_3; + + JobV1_0_3 = (EFI_REDFISH_JOB_V1_0_3 *)InterpProp; + DestroyJob_V1_0_3_CS (JobV1_0_3->Job); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JobFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJob_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJob_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JobToStructWrapper, + JobToJson, + JobDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJob_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Job/v1_0_3/RedfishJob_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/Job/v1_0_3/RedfishJob_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..9dd9ec0d696 --- /dev/null +++ b/RedfishClientPkg/Converter/Job/v1_0_3/RedfishJob_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Job.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJob_V1_0_3_Dxe + FILE_GUID = 4700563a-3993-4cc7-835b-62de89349662 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJob_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishJob_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Job_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JobV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Job/v1_0_4/Job_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/Job/v1_0_4/Job_V1_0_4_Dxe.c new file mode 100644 index 00000000000..3d3afc366eb --- /dev/null +++ b/RedfishClientPkg/Converter/Job/v1_0_4/Job_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Job.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Job"; +BOOLEAN IsRevisonController = TRUE; + +// Support Job V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Job", + "1", + "0", + "4" + }, + "Job" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JOB_V1_0_4 *JobV1_0_4; + EFI_REDFISH_JOB_V1_0_4_CS *JobV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Job") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Job_V1_0_4_To_CS (ResoruceRaw, &JobV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + JobV1_0_4 = (EFI_REDFISH_JOB_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JOB_V1_0_4)); + if (JobV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JobV1_0_4; + JobV1_0_4->Job = JobV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Job")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Job"), "Job"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Job")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Job"), "Job"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JobToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JobToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Job_V1_0_4_JSON (*((EFI_REDFISH_JOB_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JobToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JOB_V1_0_4 *JobV1_0_4; + + JobV1_0_4 = (EFI_REDFISH_JOB_V1_0_4 *)InterpProp; + DestroyJob_V1_0_4_CS (JobV1_0_4->Job); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JobFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJob_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJob_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JobToStructWrapper, + JobToJson, + JobDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJob_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Job/v1_0_4/RedfishJob_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/Job/v1_0_4/RedfishJob_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..02fc5019236 --- /dev/null +++ b/RedfishClientPkg/Converter/Job/v1_0_4/RedfishJob_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Job.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJob_V1_0_4_Dxe + FILE_GUID = 71b15896-13ed-4c45-9c99-c1cd679a1a04 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJob_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishJob_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Job_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JobV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Job/v1_0_5/Job_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/Job/v1_0_5/Job_V1_0_5_Dxe.c new file mode 100644 index 00000000000..3e9f243e3e6 --- /dev/null +++ b/RedfishClientPkg/Converter/Job/v1_0_5/Job_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Job.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Job"; +BOOLEAN IsRevisonController = TRUE; + +// Support Job V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Job", + "1", + "0", + "5" + }, + "Job" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JOB_V1_0_5 *JobV1_0_5; + EFI_REDFISH_JOB_V1_0_5_CS *JobV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Job") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Job_V1_0_5_To_CS (ResoruceRaw, &JobV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + JobV1_0_5 = (EFI_REDFISH_JOB_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JOB_V1_0_5)); + if (JobV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JobV1_0_5; + JobV1_0_5->Job = JobV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Job")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Job"), "Job"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Job")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Job"), "Job"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JobToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JobToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Job_V1_0_5_JSON (*((EFI_REDFISH_JOB_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JobToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JOB_V1_0_5 *JobV1_0_5; + + JobV1_0_5 = (EFI_REDFISH_JOB_V1_0_5 *)InterpProp; + DestroyJob_V1_0_5_CS (JobV1_0_5->Job); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JobFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJob_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJob_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JobToStructWrapper, + JobToJson, + JobDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJob_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Job/v1_0_5/RedfishJob_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/Job/v1_0_5/RedfishJob_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..536850297eb --- /dev/null +++ b/RedfishClientPkg/Converter/Job/v1_0_5/RedfishJob_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Job.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJob_V1_0_5_Dxe + FILE_GUID = d2686059-8e94-4e6b-ae35-4bfced016434 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJob_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishJob_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Job_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JobV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Job/v1_0_6/Job_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/Job/v1_0_6/Job_V1_0_6_Dxe.c new file mode 100644 index 00000000000..9a54bca343e --- /dev/null +++ b/RedfishClientPkg/Converter/Job/v1_0_6/Job_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Job.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Job"; +BOOLEAN IsRevisonController = TRUE; + +// Support Job V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Job", + "1", + "0", + "6" + }, + "Job" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JOB_V1_0_6 *JobV1_0_6; + EFI_REDFISH_JOB_V1_0_6_CS *JobV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Job") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Job_V1_0_6_To_CS (ResoruceRaw, &JobV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + JobV1_0_6 = (EFI_REDFISH_JOB_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JOB_V1_0_6)); + if (JobV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JobV1_0_6; + JobV1_0_6->Job = JobV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Job")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Job"), "Job"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Job")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Job"), "Job"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JobToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JobToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Job_V1_0_6_JSON (*((EFI_REDFISH_JOB_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JobToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JOB_V1_0_6 *JobV1_0_6; + + JobV1_0_6 = (EFI_REDFISH_JOB_V1_0_6 *)InterpProp; + DestroyJob_V1_0_6_CS (JobV1_0_6->Job); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JobFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJob_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJob_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JobToStructWrapper, + JobToJson, + JobDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJob_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Job/v1_0_6/RedfishJob_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/Job/v1_0_6/RedfishJob_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..a4a83d06772 --- /dev/null +++ b/RedfishClientPkg/Converter/Job/v1_0_6/RedfishJob_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Job.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJob_V1_0_6_Dxe + FILE_GUID = ae05c1c0-4852-4235-a935-269a9572e37e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJob_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishJob_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Job_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JobV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/JobCollection/JobCollection_Dxe.c b/RedfishClientPkg/Converter/JobCollection/JobCollection_Dxe.c new file mode 100644 index 00000000000..d7de3a20005 --- /dev/null +++ b/RedfishClientPkg/Converter/JobCollection/JobCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - JobCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#JobCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support JobCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "JobCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "JobCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JOBCOLLECTION *JobCollection; + EFI_REDFISH_JOBCOLLECTION_CS *JobCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "JobCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_JobCollection_To_CS (ResoruceRaw, &JobCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + JobCollection = (EFI_REDFISH_JOBCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JOBCOLLECTION)); + if (JobCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JobCollection; + JobCollection->JobCollection = JobCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("JobCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("JobCollection"), "JobCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("JobCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("JobCollection"), "JobCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JobCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JobCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_JobCollection_JSON (*((EFI_REDFISH_JOBCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JobCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JOBCOLLECTION *JobCollection; + + JobCollection = (EFI_REDFISH_JOBCOLLECTION *)InterpProp; + DestroyJobCollection_CS (JobCollection->JobCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JobCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJobCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJobCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JobCollectionToStructWrapper, + JobCollectionToJson, + JobCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJobCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/JobCollection/RedfishJobCollection_Dxe.inf b/RedfishClientPkg/Converter/JobCollection/RedfishJobCollection_Dxe.inf new file mode 100644 index 00000000000..b5d5c10ac4c --- /dev/null +++ b/RedfishClientPkg/Converter/JobCollection/RedfishJobCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of JobCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJobCollection_Dxe + FILE_GUID = dfe9c5af-9c4e-4f69-bb9e-3d6003414dab + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJobCollectionEntryPoint + UNLOAD_IMAGE = RedfishJobCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + JobCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JobCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/JobService/v1_0_0/JobService_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/JobService/v1_0_0/JobService_V1_0_0_Dxe.c new file mode 100644 index 00000000000..4c1577a9582 --- /dev/null +++ b/RedfishClientPkg/Converter/JobService/v1_0_0/JobService_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - JobService.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#JobService"; +BOOLEAN IsRevisonController = TRUE; + +// Support JobService V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "JobService", + "1", + "0", + "0" + }, + "JobService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JOBSERVICE_V1_0_0 *JobServiceV1_0_0; + EFI_REDFISH_JOBSERVICE_V1_0_0_CS *JobServiceV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "JobService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_JobService_V1_0_0_To_CS (ResoruceRaw, &JobServiceV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + JobServiceV1_0_0 = (EFI_REDFISH_JOBSERVICE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JOBSERVICE_V1_0_0)); + if (JobServiceV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JobServiceV1_0_0; + JobServiceV1_0_0->JobService = JobServiceV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("JobService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("JobService"), "JobService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("JobService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("JobService"), "JobService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JobServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JobServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_JobService_V1_0_0_JSON (*((EFI_REDFISH_JOBSERVICE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JobServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JOBSERVICE_V1_0_0 *JobServiceV1_0_0; + + JobServiceV1_0_0 = (EFI_REDFISH_JOBSERVICE_V1_0_0 *)InterpProp; + DestroyJobService_V1_0_0_CS (JobServiceV1_0_0->JobService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JobServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJobService_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJobService_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JobServiceToStructWrapper, + JobServiceToJson, + JobServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJobService_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/JobService/v1_0_0/RedfishJobService_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/JobService/v1_0_0/RedfishJobService_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..1266b25257b --- /dev/null +++ b/RedfishClientPkg/Converter/JobService/v1_0_0/RedfishJobService_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of JobService.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJobService_V1_0_0_Dxe + FILE_GUID = 51048159-183e-491c-9017-7e5160732907 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJobService_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishJobService_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + JobService_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JobServiceV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/JobService/v1_0_1/JobService_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/JobService/v1_0_1/JobService_V1_0_1_Dxe.c new file mode 100644 index 00000000000..6342078bd48 --- /dev/null +++ b/RedfishClientPkg/Converter/JobService/v1_0_1/JobService_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - JobService.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#JobService"; +BOOLEAN IsRevisonController = TRUE; + +// Support JobService V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "JobService", + "1", + "0", + "1" + }, + "JobService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JOBSERVICE_V1_0_1 *JobServiceV1_0_1; + EFI_REDFISH_JOBSERVICE_V1_0_1_CS *JobServiceV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "JobService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_JobService_V1_0_1_To_CS (ResoruceRaw, &JobServiceV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + JobServiceV1_0_1 = (EFI_REDFISH_JOBSERVICE_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JOBSERVICE_V1_0_1)); + if (JobServiceV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JobServiceV1_0_1; + JobServiceV1_0_1->JobService = JobServiceV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("JobService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("JobService"), "JobService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("JobService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("JobService"), "JobService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JobServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JobServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_JobService_V1_0_1_JSON (*((EFI_REDFISH_JOBSERVICE_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JobServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JOBSERVICE_V1_0_1 *JobServiceV1_0_1; + + JobServiceV1_0_1 = (EFI_REDFISH_JOBSERVICE_V1_0_1 *)InterpProp; + DestroyJobService_V1_0_1_CS (JobServiceV1_0_1->JobService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JobServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJobService_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJobService_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JobServiceToStructWrapper, + JobServiceToJson, + JobServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJobService_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/JobService/v1_0_1/RedfishJobService_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/JobService/v1_0_1/RedfishJobService_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..22c318e8877 --- /dev/null +++ b/RedfishClientPkg/Converter/JobService/v1_0_1/RedfishJobService_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of JobService.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJobService_V1_0_1_Dxe + FILE_GUID = b80ca98b-cd52-4834-b067-2b9bb1493ff5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJobService_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishJobService_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + JobService_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JobServiceV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/JobService/v1_0_2/JobService_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/JobService/v1_0_2/JobService_V1_0_2_Dxe.c new file mode 100644 index 00000000000..28f428836da --- /dev/null +++ b/RedfishClientPkg/Converter/JobService/v1_0_2/JobService_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - JobService.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#JobService"; +BOOLEAN IsRevisonController = TRUE; + +// Support JobService V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "JobService", + "1", + "0", + "2" + }, + "JobService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JOBSERVICE_V1_0_2 *JobServiceV1_0_2; + EFI_REDFISH_JOBSERVICE_V1_0_2_CS *JobServiceV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "JobService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_JobService_V1_0_2_To_CS (ResoruceRaw, &JobServiceV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + JobServiceV1_0_2 = (EFI_REDFISH_JOBSERVICE_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JOBSERVICE_V1_0_2)); + if (JobServiceV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JobServiceV1_0_2; + JobServiceV1_0_2->JobService = JobServiceV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("JobService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("JobService"), "JobService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("JobService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("JobService"), "JobService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JobServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JobServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_JobService_V1_0_2_JSON (*((EFI_REDFISH_JOBSERVICE_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JobServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JOBSERVICE_V1_0_2 *JobServiceV1_0_2; + + JobServiceV1_0_2 = (EFI_REDFISH_JOBSERVICE_V1_0_2 *)InterpProp; + DestroyJobService_V1_0_2_CS (JobServiceV1_0_2->JobService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JobServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJobService_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJobService_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JobServiceToStructWrapper, + JobServiceToJson, + JobServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJobService_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/JobService/v1_0_2/RedfishJobService_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/JobService/v1_0_2/RedfishJobService_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..6f9666a45ca --- /dev/null +++ b/RedfishClientPkg/Converter/JobService/v1_0_2/RedfishJobService_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of JobService.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJobService_V1_0_2_Dxe + FILE_GUID = 80fb01e7-2d18-48ba-83f1-239984cb0da4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJobService_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishJobService_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + JobService_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JobServiceV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/JobService/v1_0_3/JobService_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/JobService/v1_0_3/JobService_V1_0_3_Dxe.c new file mode 100644 index 00000000000..d67dd2785e4 --- /dev/null +++ b/RedfishClientPkg/Converter/JobService/v1_0_3/JobService_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - JobService.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#JobService"; +BOOLEAN IsRevisonController = TRUE; + +// Support JobService V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "JobService", + "1", + "0", + "3" + }, + "JobService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JOBSERVICE_V1_0_3 *JobServiceV1_0_3; + EFI_REDFISH_JOBSERVICE_V1_0_3_CS *JobServiceV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "JobService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_JobService_V1_0_3_To_CS (ResoruceRaw, &JobServiceV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + JobServiceV1_0_3 = (EFI_REDFISH_JOBSERVICE_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JOBSERVICE_V1_0_3)); + if (JobServiceV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JobServiceV1_0_3; + JobServiceV1_0_3->JobService = JobServiceV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("JobService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("JobService"), "JobService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("JobService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("JobService"), "JobService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JobServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JobServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_JobService_V1_0_3_JSON (*((EFI_REDFISH_JOBSERVICE_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JobServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JOBSERVICE_V1_0_3 *JobServiceV1_0_3; + + JobServiceV1_0_3 = (EFI_REDFISH_JOBSERVICE_V1_0_3 *)InterpProp; + DestroyJobService_V1_0_3_CS (JobServiceV1_0_3->JobService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JobServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJobService_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJobService_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JobServiceToStructWrapper, + JobServiceToJson, + JobServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJobService_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/JobService/v1_0_3/RedfishJobService_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/JobService/v1_0_3/RedfishJobService_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..ddf1ab1c3fb --- /dev/null +++ b/RedfishClientPkg/Converter/JobService/v1_0_3/RedfishJobService_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of JobService.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJobService_V1_0_3_Dxe + FILE_GUID = 3d4270f1-72f7-4068-9245-9b321d690f60 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJobService_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishJobService_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + JobService_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JobServiceV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/JobService/v1_0_4/JobService_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/JobService/v1_0_4/JobService_V1_0_4_Dxe.c new file mode 100644 index 00000000000..0be5f7a03ef --- /dev/null +++ b/RedfishClientPkg/Converter/JobService/v1_0_4/JobService_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - JobService.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#JobService"; +BOOLEAN IsRevisonController = TRUE; + +// Support JobService V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "JobService", + "1", + "0", + "4" + }, + "JobService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JOBSERVICE_V1_0_4 *JobServiceV1_0_4; + EFI_REDFISH_JOBSERVICE_V1_0_4_CS *JobServiceV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "JobService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_JobService_V1_0_4_To_CS (ResoruceRaw, &JobServiceV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + JobServiceV1_0_4 = (EFI_REDFISH_JOBSERVICE_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JOBSERVICE_V1_0_4)); + if (JobServiceV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JobServiceV1_0_4; + JobServiceV1_0_4->JobService = JobServiceV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("JobService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("JobService"), "JobService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("JobService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("JobService"), "JobService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JobServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JobServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_JobService_V1_0_4_JSON (*((EFI_REDFISH_JOBSERVICE_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JobServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JOBSERVICE_V1_0_4 *JobServiceV1_0_4; + + JobServiceV1_0_4 = (EFI_REDFISH_JOBSERVICE_V1_0_4 *)InterpProp; + DestroyJobService_V1_0_4_CS (JobServiceV1_0_4->JobService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JobServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JobServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJobService_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJobService_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JobServiceToStructWrapper, + JobServiceToJson, + JobServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJobService_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/JobService/v1_0_4/RedfishJobService_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/JobService/v1_0_4/RedfishJobService_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..10b3e7687e3 --- /dev/null +++ b/RedfishClientPkg/Converter/JobService/v1_0_4/RedfishJobService_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of JobService.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJobService_V1_0_4_Dxe + FILE_GUID = 4952e23f-3b14-437e-940e-ca6e3ee9ab64 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJobService_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishJobService_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + JobService_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JobServiceV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_0/JsonSchemaFile_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_0/JsonSchemaFile_V1_0_0_Dxe.c new file mode 100644 index 00000000000..0a983f742e2 --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_0/JsonSchemaFile_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - JsonSchemaFile.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#JsonSchemaFile"; +BOOLEAN IsRevisonController = TRUE; + +// Support JsonSchemaFile V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "JsonSchemaFile", + "1", + "0", + "0" + }, + "JsonSchemaFile" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_0_0 *JsonSchemaFileV1_0_0; + EFI_REDFISH_JSONSCHEMAFILE_V1_0_0_CS *JsonSchemaFileV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "JsonSchemaFile") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_JsonSchemaFile_V1_0_0_To_CS (ResoruceRaw, &JsonSchemaFileV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + JsonSchemaFileV1_0_0 = (EFI_REDFISH_JSONSCHEMAFILE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JSONSCHEMAFILE_V1_0_0)); + if (JsonSchemaFileV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JsonSchemaFileV1_0_0; + JsonSchemaFileV1_0_0->JsonSchemaFile = JsonSchemaFileV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JsonSchemaFileToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JsonSchemaFileToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_JsonSchemaFile_V1_0_0_JSON (*((EFI_REDFISH_JSONSCHEMAFILE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JsonSchemaFileToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_0_0 *JsonSchemaFileV1_0_0; + + JsonSchemaFileV1_0_0 = (EFI_REDFISH_JSONSCHEMAFILE_V1_0_0 *)InterpProp; + DestroyJsonSchemaFile_V1_0_0_CS (JsonSchemaFileV1_0_0->JsonSchemaFile); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JsonSchemaFileFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJsonSchemaFile_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JsonSchemaFileToStructWrapper, + JsonSchemaFileToJson, + JsonSchemaFileDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_0/RedfishJsonSchemaFile_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_0/RedfishJsonSchemaFile_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..fc0b16bc5c2 --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_0/RedfishJsonSchemaFile_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of JsonSchemaFile.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJsonSchemaFile_V1_0_0_Dxe + FILE_GUID = 42d22a50-cbd7-40b5-92a9-f49b6485634f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJsonSchemaFile_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishJsonSchemaFile_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + JsonSchemaFile_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JsonSchemaFileV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_2/JsonSchemaFile_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_2/JsonSchemaFile_V1_0_2_Dxe.c new file mode 100644 index 00000000000..835ac1652a0 --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_2/JsonSchemaFile_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - JsonSchemaFile.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#JsonSchemaFile"; +BOOLEAN IsRevisonController = TRUE; + +// Support JsonSchemaFile V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "JsonSchemaFile", + "1", + "0", + "2" + }, + "JsonSchemaFile" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_0_2 *JsonSchemaFileV1_0_2; + EFI_REDFISH_JSONSCHEMAFILE_V1_0_2_CS *JsonSchemaFileV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "JsonSchemaFile") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_JsonSchemaFile_V1_0_2_To_CS (ResoruceRaw, &JsonSchemaFileV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + JsonSchemaFileV1_0_2 = (EFI_REDFISH_JSONSCHEMAFILE_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JSONSCHEMAFILE_V1_0_2)); + if (JsonSchemaFileV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JsonSchemaFileV1_0_2; + JsonSchemaFileV1_0_2->JsonSchemaFile = JsonSchemaFileV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JsonSchemaFileToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JsonSchemaFileToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_JsonSchemaFile_V1_0_2_JSON (*((EFI_REDFISH_JSONSCHEMAFILE_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JsonSchemaFileToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_0_2 *JsonSchemaFileV1_0_2; + + JsonSchemaFileV1_0_2 = (EFI_REDFISH_JSONSCHEMAFILE_V1_0_2 *)InterpProp; + DestroyJsonSchemaFile_V1_0_2_CS (JsonSchemaFileV1_0_2->JsonSchemaFile); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JsonSchemaFileFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJsonSchemaFile_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JsonSchemaFileToStructWrapper, + JsonSchemaFileToJson, + JsonSchemaFileDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_2/RedfishJsonSchemaFile_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_2/RedfishJsonSchemaFile_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..808af9b763d --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_2/RedfishJsonSchemaFile_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of JsonSchemaFile.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJsonSchemaFile_V1_0_2_Dxe + FILE_GUID = 7b50f768-7df0-44ef-9025-3b1444b18d48 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJsonSchemaFile_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishJsonSchemaFile_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + JsonSchemaFile_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JsonSchemaFileV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_3/JsonSchemaFile_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_3/JsonSchemaFile_V1_0_3_Dxe.c new file mode 100644 index 00000000000..3db1a219d1f --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_3/JsonSchemaFile_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - JsonSchemaFile.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#JsonSchemaFile"; +BOOLEAN IsRevisonController = TRUE; + +// Support JsonSchemaFile V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "JsonSchemaFile", + "1", + "0", + "3" + }, + "JsonSchemaFile" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_0_3 *JsonSchemaFileV1_0_3; + EFI_REDFISH_JSONSCHEMAFILE_V1_0_3_CS *JsonSchemaFileV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "JsonSchemaFile") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_JsonSchemaFile_V1_0_3_To_CS (ResoruceRaw, &JsonSchemaFileV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + JsonSchemaFileV1_0_3 = (EFI_REDFISH_JSONSCHEMAFILE_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JSONSCHEMAFILE_V1_0_3)); + if (JsonSchemaFileV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JsonSchemaFileV1_0_3; + JsonSchemaFileV1_0_3->JsonSchemaFile = JsonSchemaFileV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JsonSchemaFileToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JsonSchemaFileToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_JsonSchemaFile_V1_0_3_JSON (*((EFI_REDFISH_JSONSCHEMAFILE_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JsonSchemaFileToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_0_3 *JsonSchemaFileV1_0_3; + + JsonSchemaFileV1_0_3 = (EFI_REDFISH_JSONSCHEMAFILE_V1_0_3 *)InterpProp; + DestroyJsonSchemaFile_V1_0_3_CS (JsonSchemaFileV1_0_3->JsonSchemaFile); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JsonSchemaFileFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJsonSchemaFile_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JsonSchemaFileToStructWrapper, + JsonSchemaFileToJson, + JsonSchemaFileDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_3/RedfishJsonSchemaFile_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_3/RedfishJsonSchemaFile_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..269d85035cd --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_3/RedfishJsonSchemaFile_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of JsonSchemaFile.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJsonSchemaFile_V1_0_3_Dxe + FILE_GUID = 6fa6ff08-17e8-428b-a322-42eef892d643 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJsonSchemaFile_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishJsonSchemaFile_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + JsonSchemaFile_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JsonSchemaFileV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_4/JsonSchemaFile_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_4/JsonSchemaFile_V1_0_4_Dxe.c new file mode 100644 index 00000000000..95920a7537b --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_4/JsonSchemaFile_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - JsonSchemaFile.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#JsonSchemaFile"; +BOOLEAN IsRevisonController = TRUE; + +// Support JsonSchemaFile V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "JsonSchemaFile", + "1", + "0", + "4" + }, + "JsonSchemaFile" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_0_4 *JsonSchemaFileV1_0_4; + EFI_REDFISH_JSONSCHEMAFILE_V1_0_4_CS *JsonSchemaFileV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "JsonSchemaFile") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_JsonSchemaFile_V1_0_4_To_CS (ResoruceRaw, &JsonSchemaFileV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + JsonSchemaFileV1_0_4 = (EFI_REDFISH_JSONSCHEMAFILE_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JSONSCHEMAFILE_V1_0_4)); + if (JsonSchemaFileV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JsonSchemaFileV1_0_4; + JsonSchemaFileV1_0_4->JsonSchemaFile = JsonSchemaFileV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JsonSchemaFileToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JsonSchemaFileToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_JsonSchemaFile_V1_0_4_JSON (*((EFI_REDFISH_JSONSCHEMAFILE_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JsonSchemaFileToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_0_4 *JsonSchemaFileV1_0_4; + + JsonSchemaFileV1_0_4 = (EFI_REDFISH_JSONSCHEMAFILE_V1_0_4 *)InterpProp; + DestroyJsonSchemaFile_V1_0_4_CS (JsonSchemaFileV1_0_4->JsonSchemaFile); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JsonSchemaFileFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJsonSchemaFile_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JsonSchemaFileToStructWrapper, + JsonSchemaFileToJson, + JsonSchemaFileDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_4/RedfishJsonSchemaFile_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_4/RedfishJsonSchemaFile_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..a5bbadfd837 --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_4/RedfishJsonSchemaFile_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of JsonSchemaFile.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJsonSchemaFile_V1_0_4_Dxe + FILE_GUID = 78082696-cd9f-493c-9d56-c8790fa83d7f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJsonSchemaFile_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishJsonSchemaFile_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + JsonSchemaFile_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JsonSchemaFileV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_5/JsonSchemaFile_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_5/JsonSchemaFile_V1_0_5_Dxe.c new file mode 100644 index 00000000000..5ec90af6a05 --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_5/JsonSchemaFile_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - JsonSchemaFile.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#JsonSchemaFile"; +BOOLEAN IsRevisonController = TRUE; + +// Support JsonSchemaFile V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "JsonSchemaFile", + "1", + "0", + "5" + }, + "JsonSchemaFile" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_0_5 *JsonSchemaFileV1_0_5; + EFI_REDFISH_JSONSCHEMAFILE_V1_0_5_CS *JsonSchemaFileV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "JsonSchemaFile") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_JsonSchemaFile_V1_0_5_To_CS (ResoruceRaw, &JsonSchemaFileV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + JsonSchemaFileV1_0_5 = (EFI_REDFISH_JSONSCHEMAFILE_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JSONSCHEMAFILE_V1_0_5)); + if (JsonSchemaFileV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JsonSchemaFileV1_0_5; + JsonSchemaFileV1_0_5->JsonSchemaFile = JsonSchemaFileV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JsonSchemaFileToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JsonSchemaFileToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_JsonSchemaFile_V1_0_5_JSON (*((EFI_REDFISH_JSONSCHEMAFILE_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JsonSchemaFileToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_0_5 *JsonSchemaFileV1_0_5; + + JsonSchemaFileV1_0_5 = (EFI_REDFISH_JSONSCHEMAFILE_V1_0_5 *)InterpProp; + DestroyJsonSchemaFile_V1_0_5_CS (JsonSchemaFileV1_0_5->JsonSchemaFile); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JsonSchemaFileFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJsonSchemaFile_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JsonSchemaFileToStructWrapper, + JsonSchemaFileToJson, + JsonSchemaFileDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_5/RedfishJsonSchemaFile_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_5/RedfishJsonSchemaFile_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..eea7ffa73e8 --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_5/RedfishJsonSchemaFile_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of JsonSchemaFile.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJsonSchemaFile_V1_0_5_Dxe + FILE_GUID = 1bf636c8-8f93-4434-a628-ff39b2d9271d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJsonSchemaFile_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishJsonSchemaFile_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + JsonSchemaFile_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JsonSchemaFileV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_6/JsonSchemaFile_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_6/JsonSchemaFile_V1_0_6_Dxe.c new file mode 100644 index 00000000000..351a37e9477 --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_6/JsonSchemaFile_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - JsonSchemaFile.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#JsonSchemaFile"; +BOOLEAN IsRevisonController = TRUE; + +// Support JsonSchemaFile V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "JsonSchemaFile", + "1", + "0", + "6" + }, + "JsonSchemaFile" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_0_6 *JsonSchemaFileV1_0_6; + EFI_REDFISH_JSONSCHEMAFILE_V1_0_6_CS *JsonSchemaFileV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "JsonSchemaFile") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_JsonSchemaFile_V1_0_6_To_CS (ResoruceRaw, &JsonSchemaFileV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + JsonSchemaFileV1_0_6 = (EFI_REDFISH_JSONSCHEMAFILE_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JSONSCHEMAFILE_V1_0_6)); + if (JsonSchemaFileV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JsonSchemaFileV1_0_6; + JsonSchemaFileV1_0_6->JsonSchemaFile = JsonSchemaFileV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JsonSchemaFileToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JsonSchemaFileToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_JsonSchemaFile_V1_0_6_JSON (*((EFI_REDFISH_JSONSCHEMAFILE_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JsonSchemaFileToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_0_6 *JsonSchemaFileV1_0_6; + + JsonSchemaFileV1_0_6 = (EFI_REDFISH_JSONSCHEMAFILE_V1_0_6 *)InterpProp; + DestroyJsonSchemaFile_V1_0_6_CS (JsonSchemaFileV1_0_6->JsonSchemaFile); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JsonSchemaFileFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJsonSchemaFile_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JsonSchemaFileToStructWrapper, + JsonSchemaFileToJson, + JsonSchemaFileDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_6/RedfishJsonSchemaFile_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_6/RedfishJsonSchemaFile_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..53119f50749 --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_6/RedfishJsonSchemaFile_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of JsonSchemaFile.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJsonSchemaFile_V1_0_6_Dxe + FILE_GUID = 99412909-e6f8-4cec-9aa9-2a3cc9e000c1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJsonSchemaFile_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishJsonSchemaFile_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + JsonSchemaFile_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JsonSchemaFileV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_7/JsonSchemaFile_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_7/JsonSchemaFile_V1_0_7_Dxe.c new file mode 100644 index 00000000000..3ead5492266 --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_7/JsonSchemaFile_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - JsonSchemaFile.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#JsonSchemaFile"; +BOOLEAN IsRevisonController = TRUE; + +// Support JsonSchemaFile V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "JsonSchemaFile", + "1", + "0", + "7" + }, + "JsonSchemaFile" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_0_7 *JsonSchemaFileV1_0_7; + EFI_REDFISH_JSONSCHEMAFILE_V1_0_7_CS *JsonSchemaFileV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "JsonSchemaFile") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_JsonSchemaFile_V1_0_7_To_CS (ResoruceRaw, &JsonSchemaFileV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + JsonSchemaFileV1_0_7 = (EFI_REDFISH_JSONSCHEMAFILE_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JSONSCHEMAFILE_V1_0_7)); + if (JsonSchemaFileV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JsonSchemaFileV1_0_7; + JsonSchemaFileV1_0_7->JsonSchemaFile = JsonSchemaFileV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JsonSchemaFileToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JsonSchemaFileToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_JsonSchemaFile_V1_0_7_JSON (*((EFI_REDFISH_JSONSCHEMAFILE_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JsonSchemaFileToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_0_7 *JsonSchemaFileV1_0_7; + + JsonSchemaFileV1_0_7 = (EFI_REDFISH_JSONSCHEMAFILE_V1_0_7 *)InterpProp; + DestroyJsonSchemaFile_V1_0_7_CS (JsonSchemaFileV1_0_7->JsonSchemaFile); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JsonSchemaFileFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJsonSchemaFile_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JsonSchemaFileToStructWrapper, + JsonSchemaFileToJson, + JsonSchemaFileDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_7/RedfishJsonSchemaFile_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_7/RedfishJsonSchemaFile_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..a5a8a610e38 --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_7/RedfishJsonSchemaFile_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of JsonSchemaFile.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJsonSchemaFile_V1_0_7_Dxe + FILE_GUID = 4bf5b33c-3e48-482b-90de-90b4940b63a7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJsonSchemaFile_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishJsonSchemaFile_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + JsonSchemaFile_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JsonSchemaFileV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_8/JsonSchemaFile_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_8/JsonSchemaFile_V1_0_8_Dxe.c new file mode 100644 index 00000000000..a70aec704d0 --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_8/JsonSchemaFile_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - JsonSchemaFile.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#JsonSchemaFile"; +BOOLEAN IsRevisonController = TRUE; + +// Support JsonSchemaFile V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "JsonSchemaFile", + "1", + "0", + "8" + }, + "JsonSchemaFile" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_0_8 *JsonSchemaFileV1_0_8; + EFI_REDFISH_JSONSCHEMAFILE_V1_0_8_CS *JsonSchemaFileV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "JsonSchemaFile") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_JsonSchemaFile_V1_0_8_To_CS (ResoruceRaw, &JsonSchemaFileV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + JsonSchemaFileV1_0_8 = (EFI_REDFISH_JSONSCHEMAFILE_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JSONSCHEMAFILE_V1_0_8)); + if (JsonSchemaFileV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JsonSchemaFileV1_0_8; + JsonSchemaFileV1_0_8->JsonSchemaFile = JsonSchemaFileV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JsonSchemaFileToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JsonSchemaFileToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_JsonSchemaFile_V1_0_8_JSON (*((EFI_REDFISH_JSONSCHEMAFILE_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JsonSchemaFileToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_0_8 *JsonSchemaFileV1_0_8; + + JsonSchemaFileV1_0_8 = (EFI_REDFISH_JSONSCHEMAFILE_V1_0_8 *)InterpProp; + DestroyJsonSchemaFile_V1_0_8_CS (JsonSchemaFileV1_0_8->JsonSchemaFile); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JsonSchemaFileFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJsonSchemaFile_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JsonSchemaFileToStructWrapper, + JsonSchemaFileToJson, + JsonSchemaFileDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_8/RedfishJsonSchemaFile_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_8/RedfishJsonSchemaFile_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..ecbeeed4ca8 --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_0_8/RedfishJsonSchemaFile_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of JsonSchemaFile.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJsonSchemaFile_V1_0_8_Dxe + FILE_GUID = d550f6f5-7324-4e45-80d8-fa83718d3546 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJsonSchemaFile_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishJsonSchemaFile_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + JsonSchemaFile_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JsonSchemaFileV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_0/JsonSchemaFile_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_0/JsonSchemaFile_V1_1_0_Dxe.c new file mode 100644 index 00000000000..349a0d1bac4 --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_0/JsonSchemaFile_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - JsonSchemaFile.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#JsonSchemaFile"; +BOOLEAN IsRevisonController = TRUE; + +// Support JsonSchemaFile V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "JsonSchemaFile", + "1", + "1", + "0" + }, + "JsonSchemaFile" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_1_0 *JsonSchemaFileV1_1_0; + EFI_REDFISH_JSONSCHEMAFILE_V1_1_0_CS *JsonSchemaFileV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "JsonSchemaFile") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_JsonSchemaFile_V1_1_0_To_CS (ResoruceRaw, &JsonSchemaFileV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + JsonSchemaFileV1_1_0 = (EFI_REDFISH_JSONSCHEMAFILE_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JSONSCHEMAFILE_V1_1_0)); + if (JsonSchemaFileV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JsonSchemaFileV1_1_0; + JsonSchemaFileV1_1_0->JsonSchemaFile = JsonSchemaFileV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JsonSchemaFileToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JsonSchemaFileToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_JsonSchemaFile_V1_1_0_JSON (*((EFI_REDFISH_JSONSCHEMAFILE_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JsonSchemaFileToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_1_0 *JsonSchemaFileV1_1_0; + + JsonSchemaFileV1_1_0 = (EFI_REDFISH_JSONSCHEMAFILE_V1_1_0 *)InterpProp; + DestroyJsonSchemaFile_V1_1_0_CS (JsonSchemaFileV1_1_0->JsonSchemaFile); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JsonSchemaFileFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJsonSchemaFile_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JsonSchemaFileToStructWrapper, + JsonSchemaFileToJson, + JsonSchemaFileDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_0/RedfishJsonSchemaFile_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_0/RedfishJsonSchemaFile_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..df3a68237bd --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_0/RedfishJsonSchemaFile_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of JsonSchemaFile.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJsonSchemaFile_V1_1_0_Dxe + FILE_GUID = 8ce13985-216b-4fa5-a983-de119f666891 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJsonSchemaFile_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishJsonSchemaFile_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + JsonSchemaFile_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JsonSchemaFileV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_1/JsonSchemaFile_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_1/JsonSchemaFile_V1_1_1_Dxe.c new file mode 100644 index 00000000000..e4d3b4bf274 --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_1/JsonSchemaFile_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - JsonSchemaFile.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#JsonSchemaFile"; +BOOLEAN IsRevisonController = TRUE; + +// Support JsonSchemaFile V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "JsonSchemaFile", + "1", + "1", + "1" + }, + "JsonSchemaFile" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_1_1 *JsonSchemaFileV1_1_1; + EFI_REDFISH_JSONSCHEMAFILE_V1_1_1_CS *JsonSchemaFileV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "JsonSchemaFile") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_JsonSchemaFile_V1_1_1_To_CS (ResoruceRaw, &JsonSchemaFileV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + JsonSchemaFileV1_1_1 = (EFI_REDFISH_JSONSCHEMAFILE_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JSONSCHEMAFILE_V1_1_1)); + if (JsonSchemaFileV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JsonSchemaFileV1_1_1; + JsonSchemaFileV1_1_1->JsonSchemaFile = JsonSchemaFileV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JsonSchemaFileToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JsonSchemaFileToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_JsonSchemaFile_V1_1_1_JSON (*((EFI_REDFISH_JSONSCHEMAFILE_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JsonSchemaFileToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_1_1 *JsonSchemaFileV1_1_1; + + JsonSchemaFileV1_1_1 = (EFI_REDFISH_JSONSCHEMAFILE_V1_1_1 *)InterpProp; + DestroyJsonSchemaFile_V1_1_1_CS (JsonSchemaFileV1_1_1->JsonSchemaFile); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JsonSchemaFileFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJsonSchemaFile_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JsonSchemaFileToStructWrapper, + JsonSchemaFileToJson, + JsonSchemaFileDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_1/RedfishJsonSchemaFile_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_1/RedfishJsonSchemaFile_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..9f0b2f18aba --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_1/RedfishJsonSchemaFile_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of JsonSchemaFile.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJsonSchemaFile_V1_1_1_Dxe + FILE_GUID = 7e7b4282-2b25-43d5-9e50-d8b4a9d7221d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJsonSchemaFile_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishJsonSchemaFile_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + JsonSchemaFile_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JsonSchemaFileV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_2/JsonSchemaFile_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_2/JsonSchemaFile_V1_1_2_Dxe.c new file mode 100644 index 00000000000..172684f91ea --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_2/JsonSchemaFile_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - JsonSchemaFile.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#JsonSchemaFile"; +BOOLEAN IsRevisonController = TRUE; + +// Support JsonSchemaFile V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "JsonSchemaFile", + "1", + "1", + "2" + }, + "JsonSchemaFile" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_1_2 *JsonSchemaFileV1_1_2; + EFI_REDFISH_JSONSCHEMAFILE_V1_1_2_CS *JsonSchemaFileV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "JsonSchemaFile") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_JsonSchemaFile_V1_1_2_To_CS (ResoruceRaw, &JsonSchemaFileV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + JsonSchemaFileV1_1_2 = (EFI_REDFISH_JSONSCHEMAFILE_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JSONSCHEMAFILE_V1_1_2)); + if (JsonSchemaFileV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JsonSchemaFileV1_1_2; + JsonSchemaFileV1_1_2->JsonSchemaFile = JsonSchemaFileV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JsonSchemaFileToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JsonSchemaFileToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_JsonSchemaFile_V1_1_2_JSON (*((EFI_REDFISH_JSONSCHEMAFILE_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JsonSchemaFileToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_1_2 *JsonSchemaFileV1_1_2; + + JsonSchemaFileV1_1_2 = (EFI_REDFISH_JSONSCHEMAFILE_V1_1_2 *)InterpProp; + DestroyJsonSchemaFile_V1_1_2_CS (JsonSchemaFileV1_1_2->JsonSchemaFile); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JsonSchemaFileFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJsonSchemaFile_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JsonSchemaFileToStructWrapper, + JsonSchemaFileToJson, + JsonSchemaFileDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_2/RedfishJsonSchemaFile_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_2/RedfishJsonSchemaFile_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..edbdd6443df --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_2/RedfishJsonSchemaFile_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of JsonSchemaFile.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJsonSchemaFile_V1_1_2_Dxe + FILE_GUID = a9d476bf-24fc-4a25-b70b-17a1ad85b3da + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJsonSchemaFile_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishJsonSchemaFile_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + JsonSchemaFile_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JsonSchemaFileV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_3/JsonSchemaFile_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_3/JsonSchemaFile_V1_1_3_Dxe.c new file mode 100644 index 00000000000..468c1f9dbfc --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_3/JsonSchemaFile_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - JsonSchemaFile.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#JsonSchemaFile"; +BOOLEAN IsRevisonController = TRUE; + +// Support JsonSchemaFile V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "JsonSchemaFile", + "1", + "1", + "3" + }, + "JsonSchemaFile" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_1_3 *JsonSchemaFileV1_1_3; + EFI_REDFISH_JSONSCHEMAFILE_V1_1_3_CS *JsonSchemaFileV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "JsonSchemaFile") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_JsonSchemaFile_V1_1_3_To_CS (ResoruceRaw, &JsonSchemaFileV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + JsonSchemaFileV1_1_3 = (EFI_REDFISH_JSONSCHEMAFILE_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JSONSCHEMAFILE_V1_1_3)); + if (JsonSchemaFileV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JsonSchemaFileV1_1_3; + JsonSchemaFileV1_1_3->JsonSchemaFile = JsonSchemaFileV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JsonSchemaFileToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JsonSchemaFileToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_JsonSchemaFile_V1_1_3_JSON (*((EFI_REDFISH_JSONSCHEMAFILE_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JsonSchemaFileToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_1_3 *JsonSchemaFileV1_1_3; + + JsonSchemaFileV1_1_3 = (EFI_REDFISH_JSONSCHEMAFILE_V1_1_3 *)InterpProp; + DestroyJsonSchemaFile_V1_1_3_CS (JsonSchemaFileV1_1_3->JsonSchemaFile); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JsonSchemaFileFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJsonSchemaFile_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JsonSchemaFileToStructWrapper, + JsonSchemaFileToJson, + JsonSchemaFileDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_3/RedfishJsonSchemaFile_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_3/RedfishJsonSchemaFile_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..12d7d234082 --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_3/RedfishJsonSchemaFile_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of JsonSchemaFile.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJsonSchemaFile_V1_1_3_Dxe + FILE_GUID = b096ff5a-72c2-47f6-8c06-f6b8c299b110 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJsonSchemaFile_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishJsonSchemaFile_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + JsonSchemaFile_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JsonSchemaFileV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_4/JsonSchemaFile_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_4/JsonSchemaFile_V1_1_4_Dxe.c new file mode 100644 index 00000000000..ddeb713ba5a --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_4/JsonSchemaFile_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - JsonSchemaFile.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#JsonSchemaFile"; +BOOLEAN IsRevisonController = TRUE; + +// Support JsonSchemaFile V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "JsonSchemaFile", + "1", + "1", + "4" + }, + "JsonSchemaFile" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_1_4 *JsonSchemaFileV1_1_4; + EFI_REDFISH_JSONSCHEMAFILE_V1_1_4_CS *JsonSchemaFileV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "JsonSchemaFile") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_JsonSchemaFile_V1_1_4_To_CS (ResoruceRaw, &JsonSchemaFileV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + JsonSchemaFileV1_1_4 = (EFI_REDFISH_JSONSCHEMAFILE_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JSONSCHEMAFILE_V1_1_4)); + if (JsonSchemaFileV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JsonSchemaFileV1_1_4; + JsonSchemaFileV1_1_4->JsonSchemaFile = JsonSchemaFileV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("JsonSchemaFile"), "JsonSchemaFile"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JsonSchemaFileToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JsonSchemaFileToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_JsonSchemaFile_V1_1_4_JSON (*((EFI_REDFISH_JSONSCHEMAFILE_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JsonSchemaFileToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILE_V1_1_4 *JsonSchemaFileV1_1_4; + + JsonSchemaFileV1_1_4 = (EFI_REDFISH_JSONSCHEMAFILE_V1_1_4 *)InterpProp; + DestroyJsonSchemaFile_V1_1_4_CS (JsonSchemaFileV1_1_4->JsonSchemaFile); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JsonSchemaFileFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJsonSchemaFile_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JsonSchemaFileToStructWrapper, + JsonSchemaFileToJson, + JsonSchemaFileDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFile_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_4/RedfishJsonSchemaFile_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_4/RedfishJsonSchemaFile_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..2d67413d143 --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFile/v1_1_4/RedfishJsonSchemaFile_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of JsonSchemaFile.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJsonSchemaFile_V1_1_4_Dxe + FILE_GUID = 6fea5865-dc80-466d-b008-be0088fe04e8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJsonSchemaFile_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishJsonSchemaFile_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + JsonSchemaFile_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JsonSchemaFileV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/JsonSchemaFileCollection/JsonSchemaFileCollection_Dxe.c b/RedfishClientPkg/Converter/JsonSchemaFileCollection/JsonSchemaFileCollection_Dxe.c new file mode 100644 index 00000000000..3745b903a24 --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFileCollection/JsonSchemaFileCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - JsonSchemaFileCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#JsonSchemaFileCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support JsonSchemaFileCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "JsonSchemaFileCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "JsonSchemaFileCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILECOLLECTION *JsonSchemaFileCollection; + EFI_REDFISH_JSONSCHEMAFILECOLLECTION_CS *JsonSchemaFileCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "JsonSchemaFileCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_JsonSchemaFileCollection_To_CS (ResoruceRaw, &JsonSchemaFileCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + JsonSchemaFileCollection = (EFI_REDFISH_JSONSCHEMAFILECOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_JSONSCHEMAFILECOLLECTION)); + if (JsonSchemaFileCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)JsonSchemaFileCollection; + JsonSchemaFileCollection->JsonSchemaFileCollection = JsonSchemaFileCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFileCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("JsonSchemaFileCollection"), "JsonSchemaFileCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("JsonSchemaFileCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("JsonSchemaFileCollection"), "JsonSchemaFileCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of JsonSchemaFileCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return JsonSchemaFileCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_JsonSchemaFileCollection_JSON (*((EFI_REDFISH_JSONSCHEMAFILECOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in JsonSchemaFileCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_JSONSCHEMAFILECOLLECTION *JsonSchemaFileCollection; + + JsonSchemaFileCollection = (EFI_REDFISH_JSONSCHEMAFILECOLLECTION *)InterpProp; + DestroyJsonSchemaFileCollection_CS (JsonSchemaFileCollection->JsonSchemaFileCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from JsonSchemaFileCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +JsonSchemaFileCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyJsonSchemaFileCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFileCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + JsonSchemaFileCollectionToStructWrapper, + JsonSchemaFileCollectionToJson, + JsonSchemaFileCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishJsonSchemaFileCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/JsonSchemaFileCollection/RedfishJsonSchemaFileCollection_Dxe.inf b/RedfishClientPkg/Converter/JsonSchemaFileCollection/RedfishJsonSchemaFileCollection_Dxe.inf new file mode 100644 index 00000000000..a04e585ba9e --- /dev/null +++ b/RedfishClientPkg/Converter/JsonSchemaFileCollection/RedfishJsonSchemaFileCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of JsonSchemaFileCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishJsonSchemaFileCollection_Dxe + FILE_GUID = 618c28f7-a60e-45c0-bd02-dc8a6dbbf124 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishJsonSchemaFileCollectionEntryPoint + UNLOAD_IMAGE = RedfishJsonSchemaFileCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + JsonSchemaFileCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + JsonSchemaFileCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_0/LogEntry_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_0_0/LogEntry_V1_0_0_Dxe.c new file mode 100644 index 00000000000..1cce68316bd --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_0/LogEntry_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "0", + "0" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_0 *LogEntryV1_0_0; + EFI_REDFISH_LOGENTRY_V1_0_0_CS *LogEntryV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_0_0_To_CS (ResoruceRaw, &LogEntryV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_0_0 = (EFI_REDFISH_LOGENTRY_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_0_0)); + if (LogEntryV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_0_0; + LogEntryV1_0_0->LogEntry = LogEntryV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_0_0_JSON (*((EFI_REDFISH_LOGENTRY_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_0 *LogEntryV1_0_0; + + LogEntryV1_0_0 = (EFI_REDFISH_LOGENTRY_V1_0_0 *)InterpProp; + DestroyLogEntry_V1_0_0_CS (LogEntryV1_0_0->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_0/RedfishLogEntry_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_0_0/RedfishLogEntry_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..aabeb8cf968 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_0/RedfishLogEntry_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_0_0_Dxe + FILE_GUID = 63d1e097-0bce-4d01-a06b-93a0350361f7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_10/LogEntry_V1_0_10_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_0_10/LogEntry_V1_0_10_Dxe.c new file mode 100644 index 00000000000..053ce9d7101 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_10/LogEntry_V1_0_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_0_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "0", + "10" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_10 *LogEntryV1_0_10; + EFI_REDFISH_LOGENTRY_V1_0_10_CS *LogEntryV1_0_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_0_10_To_CS (ResoruceRaw, &LogEntryV1_0_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_0_10 = (EFI_REDFISH_LOGENTRY_V1_0_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_0_10)); + if (LogEntryV1_0_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_0_10; + LogEntryV1_0_10->LogEntry = LogEntryV1_0_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_0_10_JSON (*((EFI_REDFISH_LOGENTRY_V1_0_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_10 *LogEntryV1_0_10; + + LogEntryV1_0_10 = (EFI_REDFISH_LOGENTRY_V1_0_10 *)InterpProp; + DestroyLogEntry_V1_0_10_CS (LogEntryV1_0_10->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_0_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_10/RedfishLogEntry_V1_0_10_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_0_10/RedfishLogEntry_V1_0_10_Dxe.inf new file mode 100644 index 00000000000..c7812acdae1 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_10/RedfishLogEntry_V1_0_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_0_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_0_10_Dxe + FILE_GUID = 27b4741e-0524-4d6d-ae0b-f4577b264614 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_0_10EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_0_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_0_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_0_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_11/LogEntry_V1_0_11_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_0_11/LogEntry_V1_0_11_Dxe.c new file mode 100644 index 00000000000..6d5a2f345b6 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_11/LogEntry_V1_0_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_0_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "0", + "11" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_11 *LogEntryV1_0_11; + EFI_REDFISH_LOGENTRY_V1_0_11_CS *LogEntryV1_0_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_0_11_To_CS (ResoruceRaw, &LogEntryV1_0_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_0_11 = (EFI_REDFISH_LOGENTRY_V1_0_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_0_11)); + if (LogEntryV1_0_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_0_11; + LogEntryV1_0_11->LogEntry = LogEntryV1_0_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_0_11_JSON (*((EFI_REDFISH_LOGENTRY_V1_0_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_11 *LogEntryV1_0_11; + + LogEntryV1_0_11 = (EFI_REDFISH_LOGENTRY_V1_0_11 *)InterpProp; + DestroyLogEntry_V1_0_11_CS (LogEntryV1_0_11->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_0_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_11/RedfishLogEntry_V1_0_11_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_0_11/RedfishLogEntry_V1_0_11_Dxe.inf new file mode 100644 index 00000000000..3860decb3ab --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_11/RedfishLogEntry_V1_0_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_0_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_0_11_Dxe + FILE_GUID = 282a6a59-92ab-4fc0-b60a-f01635bd5753 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_0_11EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_0_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_0_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_0_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_12/LogEntry_V1_0_12_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_0_12/LogEntry_V1_0_12_Dxe.c new file mode 100644 index 00000000000..968716d99c3 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_12/LogEntry_V1_0_12_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_0_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_0_12 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "0", + "12" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_12 *LogEntryV1_0_12; + EFI_REDFISH_LOGENTRY_V1_0_12_CS *LogEntryV1_0_12Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "12") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_0_12_To_CS (ResoruceRaw, &LogEntryV1_0_12Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_0_12 = (EFI_REDFISH_LOGENTRY_V1_0_12 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_0_12)); + if (LogEntryV1_0_12 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_0_12; + LogEntryV1_0_12->LogEntry = LogEntryV1_0_12Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "12"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_0_12_JSON (*((EFI_REDFISH_LOGENTRY_V1_0_12_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_12 *LogEntryV1_0_12; + + LogEntryV1_0_12 = (EFI_REDFISH_LOGENTRY_V1_0_12 *)InterpProp; + DestroyLogEntry_V1_0_12_CS (LogEntryV1_0_12->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_0_12_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_12EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_12Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_12/RedfishLogEntry_V1_0_12_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_0_12/RedfishLogEntry_V1_0_12_Dxe.inf new file mode 100644 index 00000000000..ed086d200ab --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_12/RedfishLogEntry_V1_0_12_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_0_12 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_0_12_Dxe + FILE_GUID = a04a96a0-d46a-4c0f-8ed6-c083055159b2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_0_12EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_0_12Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_0_12_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_0_12Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_13/LogEntry_V1_0_13_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_0_13/LogEntry_V1_0_13_Dxe.c new file mode 100644 index 00000000000..ed3db0756d3 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_13/LogEntry_V1_0_13_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_0_13 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_0_13 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "0", + "13" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_13 *LogEntryV1_0_13; + EFI_REDFISH_LOGENTRY_V1_0_13_CS *LogEntryV1_0_13Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "13") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_0_13_To_CS (ResoruceRaw, &LogEntryV1_0_13Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_0_13 = (EFI_REDFISH_LOGENTRY_V1_0_13 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_0_13)); + if (LogEntryV1_0_13 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_0_13; + LogEntryV1_0_13->LogEntry = LogEntryV1_0_13Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "13"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_0_13_JSON (*((EFI_REDFISH_LOGENTRY_V1_0_13_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_13 *LogEntryV1_0_13; + + LogEntryV1_0_13 = (EFI_REDFISH_LOGENTRY_V1_0_13 *)InterpProp; + DestroyLogEntry_V1_0_13_CS (LogEntryV1_0_13->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_0_13_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_13EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_13Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_13/RedfishLogEntry_V1_0_13_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_0_13/RedfishLogEntry_V1_0_13_Dxe.inf new file mode 100644 index 00000000000..b691b24b3cb --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_13/RedfishLogEntry_V1_0_13_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_0_13 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_0_13_Dxe + FILE_GUID = a7b0ee37-eeda-4e98-aa5e-3e974ab5f806 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_0_13EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_0_13Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_0_13_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_0_13Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_14/LogEntry_V1_0_14_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_0_14/LogEntry_V1_0_14_Dxe.c new file mode 100644 index 00000000000..026d8959bbe --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_14/LogEntry_V1_0_14_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_0_14 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_0_14 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "0", + "14" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_14 *LogEntryV1_0_14; + EFI_REDFISH_LOGENTRY_V1_0_14_CS *LogEntryV1_0_14Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "14") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_0_14_To_CS (ResoruceRaw, &LogEntryV1_0_14Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_0_14 = (EFI_REDFISH_LOGENTRY_V1_0_14 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_0_14)); + if (LogEntryV1_0_14 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_0_14; + LogEntryV1_0_14->LogEntry = LogEntryV1_0_14Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "14"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_0_14_JSON (*((EFI_REDFISH_LOGENTRY_V1_0_14_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_14 *LogEntryV1_0_14; + + LogEntryV1_0_14 = (EFI_REDFISH_LOGENTRY_V1_0_14 *)InterpProp; + DestroyLogEntry_V1_0_14_CS (LogEntryV1_0_14->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_0_14_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_14EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_14Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_14/RedfishLogEntry_V1_0_14_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_0_14/RedfishLogEntry_V1_0_14_Dxe.inf new file mode 100644 index 00000000000..b760cd6c15d --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_14/RedfishLogEntry_V1_0_14_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_0_14 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_0_14_Dxe + FILE_GUID = 67dc1dc9-f6ea-40bb-b94b-000bd2e29210 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_0_14EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_0_14Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_0_14_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_0_14Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_2/LogEntry_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_0_2/LogEntry_V1_0_2_Dxe.c new file mode 100644 index 00000000000..2ea2bf84a5f --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_2/LogEntry_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "0", + "2" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_2 *LogEntryV1_0_2; + EFI_REDFISH_LOGENTRY_V1_0_2_CS *LogEntryV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_0_2_To_CS (ResoruceRaw, &LogEntryV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_0_2 = (EFI_REDFISH_LOGENTRY_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_0_2)); + if (LogEntryV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_0_2; + LogEntryV1_0_2->LogEntry = LogEntryV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_0_2_JSON (*((EFI_REDFISH_LOGENTRY_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_2 *LogEntryV1_0_2; + + LogEntryV1_0_2 = (EFI_REDFISH_LOGENTRY_V1_0_2 *)InterpProp; + DestroyLogEntry_V1_0_2_CS (LogEntryV1_0_2->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_2/RedfishLogEntry_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_0_2/RedfishLogEntry_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..86e65d79adf --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_2/RedfishLogEntry_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_0_2_Dxe + FILE_GUID = 87463772-75d8-4bd1-a528-ee7671644890 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_3/LogEntry_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_0_3/LogEntry_V1_0_3_Dxe.c new file mode 100644 index 00000000000..e51e3ef208a --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_3/LogEntry_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "0", + "3" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_3 *LogEntryV1_0_3; + EFI_REDFISH_LOGENTRY_V1_0_3_CS *LogEntryV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_0_3_To_CS (ResoruceRaw, &LogEntryV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_0_3 = (EFI_REDFISH_LOGENTRY_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_0_3)); + if (LogEntryV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_0_3; + LogEntryV1_0_3->LogEntry = LogEntryV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_0_3_JSON (*((EFI_REDFISH_LOGENTRY_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_3 *LogEntryV1_0_3; + + LogEntryV1_0_3 = (EFI_REDFISH_LOGENTRY_V1_0_3 *)InterpProp; + DestroyLogEntry_V1_0_3_CS (LogEntryV1_0_3->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_3/RedfishLogEntry_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_0_3/RedfishLogEntry_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..f84d5daa23e --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_3/RedfishLogEntry_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_0_3_Dxe + FILE_GUID = 091eefa1-8a1c-47f2-a44f-b4a2064a870a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_4/LogEntry_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_0_4/LogEntry_V1_0_4_Dxe.c new file mode 100644 index 00000000000..b1845fc3acd --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_4/LogEntry_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "0", + "4" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_4 *LogEntryV1_0_4; + EFI_REDFISH_LOGENTRY_V1_0_4_CS *LogEntryV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_0_4_To_CS (ResoruceRaw, &LogEntryV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_0_4 = (EFI_REDFISH_LOGENTRY_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_0_4)); + if (LogEntryV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_0_4; + LogEntryV1_0_4->LogEntry = LogEntryV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_0_4_JSON (*((EFI_REDFISH_LOGENTRY_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_4 *LogEntryV1_0_4; + + LogEntryV1_0_4 = (EFI_REDFISH_LOGENTRY_V1_0_4 *)InterpProp; + DestroyLogEntry_V1_0_4_CS (LogEntryV1_0_4->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_4/RedfishLogEntry_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_0_4/RedfishLogEntry_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..32d124deab7 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_4/RedfishLogEntry_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_0_4_Dxe + FILE_GUID = 154438d2-1759-428e-88d3-77018354fe5d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_5/LogEntry_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_0_5/LogEntry_V1_0_5_Dxe.c new file mode 100644 index 00000000000..ce7aa8f8f7b --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_5/LogEntry_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "0", + "5" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_5 *LogEntryV1_0_5; + EFI_REDFISH_LOGENTRY_V1_0_5_CS *LogEntryV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_0_5_To_CS (ResoruceRaw, &LogEntryV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_0_5 = (EFI_REDFISH_LOGENTRY_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_0_5)); + if (LogEntryV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_0_5; + LogEntryV1_0_5->LogEntry = LogEntryV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_0_5_JSON (*((EFI_REDFISH_LOGENTRY_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_5 *LogEntryV1_0_5; + + LogEntryV1_0_5 = (EFI_REDFISH_LOGENTRY_V1_0_5 *)InterpProp; + DestroyLogEntry_V1_0_5_CS (LogEntryV1_0_5->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_5/RedfishLogEntry_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_0_5/RedfishLogEntry_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..da57ed67ba8 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_5/RedfishLogEntry_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_0_5_Dxe + FILE_GUID = 6e41da51-435d-49ab-8f2a-76a15b47f620 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_6/LogEntry_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_0_6/LogEntry_V1_0_6_Dxe.c new file mode 100644 index 00000000000..74b86b2ddef --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_6/LogEntry_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "0", + "6" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_6 *LogEntryV1_0_6; + EFI_REDFISH_LOGENTRY_V1_0_6_CS *LogEntryV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_0_6_To_CS (ResoruceRaw, &LogEntryV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_0_6 = (EFI_REDFISH_LOGENTRY_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_0_6)); + if (LogEntryV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_0_6; + LogEntryV1_0_6->LogEntry = LogEntryV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_0_6_JSON (*((EFI_REDFISH_LOGENTRY_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_6 *LogEntryV1_0_6; + + LogEntryV1_0_6 = (EFI_REDFISH_LOGENTRY_V1_0_6 *)InterpProp; + DestroyLogEntry_V1_0_6_CS (LogEntryV1_0_6->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_6/RedfishLogEntry_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_0_6/RedfishLogEntry_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..1c2fdcade90 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_6/RedfishLogEntry_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_0_6_Dxe + FILE_GUID = 5c057b7d-16a4-4b42-a0f3-0b30b608cc1b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_7/LogEntry_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_0_7/LogEntry_V1_0_7_Dxe.c new file mode 100644 index 00000000000..f9dcdf7a63c --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_7/LogEntry_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "0", + "7" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_7 *LogEntryV1_0_7; + EFI_REDFISH_LOGENTRY_V1_0_7_CS *LogEntryV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_0_7_To_CS (ResoruceRaw, &LogEntryV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_0_7 = (EFI_REDFISH_LOGENTRY_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_0_7)); + if (LogEntryV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_0_7; + LogEntryV1_0_7->LogEntry = LogEntryV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_0_7_JSON (*((EFI_REDFISH_LOGENTRY_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_7 *LogEntryV1_0_7; + + LogEntryV1_0_7 = (EFI_REDFISH_LOGENTRY_V1_0_7 *)InterpProp; + DestroyLogEntry_V1_0_7_CS (LogEntryV1_0_7->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_7/RedfishLogEntry_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_0_7/RedfishLogEntry_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..6f6b0209aa1 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_7/RedfishLogEntry_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_0_7_Dxe + FILE_GUID = ce093997-905f-4311-bea2-f1e79e957708 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_8/LogEntry_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_0_8/LogEntry_V1_0_8_Dxe.c new file mode 100644 index 00000000000..523457ed4df --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_8/LogEntry_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "0", + "8" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_8 *LogEntryV1_0_8; + EFI_REDFISH_LOGENTRY_V1_0_8_CS *LogEntryV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_0_8_To_CS (ResoruceRaw, &LogEntryV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_0_8 = (EFI_REDFISH_LOGENTRY_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_0_8)); + if (LogEntryV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_0_8; + LogEntryV1_0_8->LogEntry = LogEntryV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_0_8_JSON (*((EFI_REDFISH_LOGENTRY_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_8 *LogEntryV1_0_8; + + LogEntryV1_0_8 = (EFI_REDFISH_LOGENTRY_V1_0_8 *)InterpProp; + DestroyLogEntry_V1_0_8_CS (LogEntryV1_0_8->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_8/RedfishLogEntry_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_0_8/RedfishLogEntry_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..8a73291a2cf --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_8/RedfishLogEntry_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_0_8_Dxe + FILE_GUID = a8b5d37a-f3df-44fb-9f17-5bcca1fd96cb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_9/LogEntry_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_0_9/LogEntry_V1_0_9_Dxe.c new file mode 100644 index 00000000000..c23bd6faa68 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_9/LogEntry_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "0", + "9" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_9 *LogEntryV1_0_9; + EFI_REDFISH_LOGENTRY_V1_0_9_CS *LogEntryV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_0_9_To_CS (ResoruceRaw, &LogEntryV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_0_9 = (EFI_REDFISH_LOGENTRY_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_0_9)); + if (LogEntryV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_0_9; + LogEntryV1_0_9->LogEntry = LogEntryV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_0_9_JSON (*((EFI_REDFISH_LOGENTRY_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_0_9 *LogEntryV1_0_9; + + LogEntryV1_0_9 = (EFI_REDFISH_LOGENTRY_V1_0_9 *)InterpProp; + DestroyLogEntry_V1_0_9_CS (LogEntryV1_0_9->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_0_9/RedfishLogEntry_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_0_9/RedfishLogEntry_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..47b9f1d0a36 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_0_9/RedfishLogEntry_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_0_9_Dxe + FILE_GUID = 392dbda0-ac5e-466f-893e-4c08ba545eea + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_0/LogEntry_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_1_0/LogEntry_V1_1_0_Dxe.c new file mode 100644 index 00000000000..fb28b0b00cd --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_0/LogEntry_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "1", + "0" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_0 *LogEntryV1_1_0; + EFI_REDFISH_LOGENTRY_V1_1_0_CS *LogEntryV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_1_0_To_CS (ResoruceRaw, &LogEntryV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_1_0 = (EFI_REDFISH_LOGENTRY_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_1_0)); + if (LogEntryV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_1_0; + LogEntryV1_1_0->LogEntry = LogEntryV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_1_0_JSON (*((EFI_REDFISH_LOGENTRY_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_0 *LogEntryV1_1_0; + + LogEntryV1_1_0 = (EFI_REDFISH_LOGENTRY_V1_1_0 *)InterpProp; + DestroyLogEntry_V1_1_0_CS (LogEntryV1_1_0->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_0/RedfishLogEntry_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_1_0/RedfishLogEntry_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..0b393adaa2e --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_0/RedfishLogEntry_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_1_0_Dxe + FILE_GUID = 3e997257-1e6b-4b14-920f-7b95b34e6cde + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_1/LogEntry_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_1_1/LogEntry_V1_1_1_Dxe.c new file mode 100644 index 00000000000..b5afd7fb00a --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_1/LogEntry_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "1", + "1" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_1 *LogEntryV1_1_1; + EFI_REDFISH_LOGENTRY_V1_1_1_CS *LogEntryV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_1_1_To_CS (ResoruceRaw, &LogEntryV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_1_1 = (EFI_REDFISH_LOGENTRY_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_1_1)); + if (LogEntryV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_1_1; + LogEntryV1_1_1->LogEntry = LogEntryV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_1_1_JSON (*((EFI_REDFISH_LOGENTRY_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_1 *LogEntryV1_1_1; + + LogEntryV1_1_1 = (EFI_REDFISH_LOGENTRY_V1_1_1 *)InterpProp; + DestroyLogEntry_V1_1_1_CS (LogEntryV1_1_1->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_1/RedfishLogEntry_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_1_1/RedfishLogEntry_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..d3ff164d7b2 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_1/RedfishLogEntry_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_1_1_Dxe + FILE_GUID = 8d4f5626-cc8d-45cd-8a8c-2324119739df + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_10/LogEntry_V1_1_10_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_1_10/LogEntry_V1_1_10_Dxe.c new file mode 100644 index 00000000000..d5496d4fbb8 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_10/LogEntry_V1_1_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_1_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_1_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "1", + "10" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_10 *LogEntryV1_1_10; + EFI_REDFISH_LOGENTRY_V1_1_10_CS *LogEntryV1_1_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_1_10_To_CS (ResoruceRaw, &LogEntryV1_1_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_1_10 = (EFI_REDFISH_LOGENTRY_V1_1_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_1_10)); + if (LogEntryV1_1_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_1_10; + LogEntryV1_1_10->LogEntry = LogEntryV1_1_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_1_10_JSON (*((EFI_REDFISH_LOGENTRY_V1_1_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_10 *LogEntryV1_1_10; + + LogEntryV1_1_10 = (EFI_REDFISH_LOGENTRY_V1_1_10 *)InterpProp; + DestroyLogEntry_V1_1_10_CS (LogEntryV1_1_10->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_1_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_10/RedfishLogEntry_V1_1_10_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_1_10/RedfishLogEntry_V1_1_10_Dxe.inf new file mode 100644 index 00000000000..5842d3750e8 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_10/RedfishLogEntry_V1_1_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_1_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_1_10_Dxe + FILE_GUID = 0626927f-0580-428f-8448-5e8e4588930d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_1_10EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_1_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_1_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_1_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_11/LogEntry_V1_1_11_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_1_11/LogEntry_V1_1_11_Dxe.c new file mode 100644 index 00000000000..37004e33842 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_11/LogEntry_V1_1_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_1_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_1_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "1", + "11" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_11 *LogEntryV1_1_11; + EFI_REDFISH_LOGENTRY_V1_1_11_CS *LogEntryV1_1_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_1_11_To_CS (ResoruceRaw, &LogEntryV1_1_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_1_11 = (EFI_REDFISH_LOGENTRY_V1_1_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_1_11)); + if (LogEntryV1_1_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_1_11; + LogEntryV1_1_11->LogEntry = LogEntryV1_1_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_1_11_JSON (*((EFI_REDFISH_LOGENTRY_V1_1_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_11 *LogEntryV1_1_11; + + LogEntryV1_1_11 = (EFI_REDFISH_LOGENTRY_V1_1_11 *)InterpProp; + DestroyLogEntry_V1_1_11_CS (LogEntryV1_1_11->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_1_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_11/RedfishLogEntry_V1_1_11_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_1_11/RedfishLogEntry_V1_1_11_Dxe.inf new file mode 100644 index 00000000000..7f2ed10cf78 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_11/RedfishLogEntry_V1_1_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_1_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_1_11_Dxe + FILE_GUID = 7af0353c-02e8-4275-9195-d03a13ff70d1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_1_11EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_1_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_1_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_1_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_12/LogEntry_V1_1_12_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_1_12/LogEntry_V1_1_12_Dxe.c new file mode 100644 index 00000000000..cb614fb2f8c --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_12/LogEntry_V1_1_12_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_1_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_1_12 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "1", + "12" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_12 *LogEntryV1_1_12; + EFI_REDFISH_LOGENTRY_V1_1_12_CS *LogEntryV1_1_12Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "12") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_1_12_To_CS (ResoruceRaw, &LogEntryV1_1_12Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_1_12 = (EFI_REDFISH_LOGENTRY_V1_1_12 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_1_12)); + if (LogEntryV1_1_12 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_1_12; + LogEntryV1_1_12->LogEntry = LogEntryV1_1_12Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "12"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_1_12_JSON (*((EFI_REDFISH_LOGENTRY_V1_1_12_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_12 *LogEntryV1_1_12; + + LogEntryV1_1_12 = (EFI_REDFISH_LOGENTRY_V1_1_12 *)InterpProp; + DestroyLogEntry_V1_1_12_CS (LogEntryV1_1_12->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_1_12_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_12EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_12Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_12/RedfishLogEntry_V1_1_12_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_1_12/RedfishLogEntry_V1_1_12_Dxe.inf new file mode 100644 index 00000000000..56774033c55 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_12/RedfishLogEntry_V1_1_12_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_1_12 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_1_12_Dxe + FILE_GUID = f3ada805-ccd2-4906-ab01-ec5a0ef2e635 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_1_12EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_1_12Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_1_12_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_1_12Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_2/LogEntry_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_1_2/LogEntry_V1_1_2_Dxe.c new file mode 100644 index 00000000000..4e3703a954e --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_2/LogEntry_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "1", + "2" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_2 *LogEntryV1_1_2; + EFI_REDFISH_LOGENTRY_V1_1_2_CS *LogEntryV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_1_2_To_CS (ResoruceRaw, &LogEntryV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_1_2 = (EFI_REDFISH_LOGENTRY_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_1_2)); + if (LogEntryV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_1_2; + LogEntryV1_1_2->LogEntry = LogEntryV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_1_2_JSON (*((EFI_REDFISH_LOGENTRY_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_2 *LogEntryV1_1_2; + + LogEntryV1_1_2 = (EFI_REDFISH_LOGENTRY_V1_1_2 *)InterpProp; + DestroyLogEntry_V1_1_2_CS (LogEntryV1_1_2->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_2/RedfishLogEntry_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_1_2/RedfishLogEntry_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..ce2e6d163b9 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_2/RedfishLogEntry_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_1_2_Dxe + FILE_GUID = 66890581-92f0-40f2-8468-b3d793ebd54a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_3/LogEntry_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_1_3/LogEntry_V1_1_3_Dxe.c new file mode 100644 index 00000000000..8c599c57e17 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_3/LogEntry_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "1", + "3" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_3 *LogEntryV1_1_3; + EFI_REDFISH_LOGENTRY_V1_1_3_CS *LogEntryV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_1_3_To_CS (ResoruceRaw, &LogEntryV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_1_3 = (EFI_REDFISH_LOGENTRY_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_1_3)); + if (LogEntryV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_1_3; + LogEntryV1_1_3->LogEntry = LogEntryV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_1_3_JSON (*((EFI_REDFISH_LOGENTRY_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_3 *LogEntryV1_1_3; + + LogEntryV1_1_3 = (EFI_REDFISH_LOGENTRY_V1_1_3 *)InterpProp; + DestroyLogEntry_V1_1_3_CS (LogEntryV1_1_3->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_3/RedfishLogEntry_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_1_3/RedfishLogEntry_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..6caac46b903 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_3/RedfishLogEntry_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_1_3_Dxe + FILE_GUID = 29967085-49bb-444b-a255-ef3edec4f0f5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_4/LogEntry_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_1_4/LogEntry_V1_1_4_Dxe.c new file mode 100644 index 00000000000..7c9be86a7b2 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_4/LogEntry_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "1", + "4" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_4 *LogEntryV1_1_4; + EFI_REDFISH_LOGENTRY_V1_1_4_CS *LogEntryV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_1_4_To_CS (ResoruceRaw, &LogEntryV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_1_4 = (EFI_REDFISH_LOGENTRY_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_1_4)); + if (LogEntryV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_1_4; + LogEntryV1_1_4->LogEntry = LogEntryV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_1_4_JSON (*((EFI_REDFISH_LOGENTRY_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_4 *LogEntryV1_1_4; + + LogEntryV1_1_4 = (EFI_REDFISH_LOGENTRY_V1_1_4 *)InterpProp; + DestroyLogEntry_V1_1_4_CS (LogEntryV1_1_4->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_4/RedfishLogEntry_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_1_4/RedfishLogEntry_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..dfd119e6e9e --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_4/RedfishLogEntry_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_1_4_Dxe + FILE_GUID = 1b52cc35-e9cc-40f9-a379-28d5aefa6b5d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_5/LogEntry_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_1_5/LogEntry_V1_1_5_Dxe.c new file mode 100644 index 00000000000..484436b5497 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_5/LogEntry_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "1", + "5" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_5 *LogEntryV1_1_5; + EFI_REDFISH_LOGENTRY_V1_1_5_CS *LogEntryV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_1_5_To_CS (ResoruceRaw, &LogEntryV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_1_5 = (EFI_REDFISH_LOGENTRY_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_1_5)); + if (LogEntryV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_1_5; + LogEntryV1_1_5->LogEntry = LogEntryV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_1_5_JSON (*((EFI_REDFISH_LOGENTRY_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_5 *LogEntryV1_1_5; + + LogEntryV1_1_5 = (EFI_REDFISH_LOGENTRY_V1_1_5 *)InterpProp; + DestroyLogEntry_V1_1_5_CS (LogEntryV1_1_5->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_5/RedfishLogEntry_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_1_5/RedfishLogEntry_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..955a4874ce5 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_5/RedfishLogEntry_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_1_5_Dxe + FILE_GUID = d5e2a874-087d-4ed8-8c09-30829a2a3ba5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_6/LogEntry_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_1_6/LogEntry_V1_1_6_Dxe.c new file mode 100644 index 00000000000..a4801c511cc --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_6/LogEntry_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "1", + "6" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_6 *LogEntryV1_1_6; + EFI_REDFISH_LOGENTRY_V1_1_6_CS *LogEntryV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_1_6_To_CS (ResoruceRaw, &LogEntryV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_1_6 = (EFI_REDFISH_LOGENTRY_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_1_6)); + if (LogEntryV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_1_6; + LogEntryV1_1_6->LogEntry = LogEntryV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_1_6_JSON (*((EFI_REDFISH_LOGENTRY_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_6 *LogEntryV1_1_6; + + LogEntryV1_1_6 = (EFI_REDFISH_LOGENTRY_V1_1_6 *)InterpProp; + DestroyLogEntry_V1_1_6_CS (LogEntryV1_1_6->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_6/RedfishLogEntry_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_1_6/RedfishLogEntry_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..6ea91521c19 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_6/RedfishLogEntry_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_1_6_Dxe + FILE_GUID = f6b2a2eb-ff31-414a-b9d8-293bc9386d0e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_7/LogEntry_V1_1_7_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_1_7/LogEntry_V1_1_7_Dxe.c new file mode 100644 index 00000000000..20d570259d3 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_7/LogEntry_V1_1_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_1_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "1", + "7" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_7 *LogEntryV1_1_7; + EFI_REDFISH_LOGENTRY_V1_1_7_CS *LogEntryV1_1_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_1_7_To_CS (ResoruceRaw, &LogEntryV1_1_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_1_7 = (EFI_REDFISH_LOGENTRY_V1_1_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_1_7)); + if (LogEntryV1_1_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_1_7; + LogEntryV1_1_7->LogEntry = LogEntryV1_1_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_1_7_JSON (*((EFI_REDFISH_LOGENTRY_V1_1_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_7 *LogEntryV1_1_7; + + LogEntryV1_1_7 = (EFI_REDFISH_LOGENTRY_V1_1_7 *)InterpProp; + DestroyLogEntry_V1_1_7_CS (LogEntryV1_1_7->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_1_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_7/RedfishLogEntry_V1_1_7_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_1_7/RedfishLogEntry_V1_1_7_Dxe.inf new file mode 100644 index 00000000000..f0480ac3624 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_7/RedfishLogEntry_V1_1_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_1_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_1_7_Dxe + FILE_GUID = 11d008ac-f12a-40de-b418-e14d7a9d3b3b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_1_7EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_1_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_1_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_1_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_8/LogEntry_V1_1_8_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_1_8/LogEntry_V1_1_8_Dxe.c new file mode 100644 index 00000000000..72e766b5871 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_8/LogEntry_V1_1_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_1_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "1", + "8" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_8 *LogEntryV1_1_8; + EFI_REDFISH_LOGENTRY_V1_1_8_CS *LogEntryV1_1_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_1_8_To_CS (ResoruceRaw, &LogEntryV1_1_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_1_8 = (EFI_REDFISH_LOGENTRY_V1_1_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_1_8)); + if (LogEntryV1_1_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_1_8; + LogEntryV1_1_8->LogEntry = LogEntryV1_1_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_1_8_JSON (*((EFI_REDFISH_LOGENTRY_V1_1_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_8 *LogEntryV1_1_8; + + LogEntryV1_1_8 = (EFI_REDFISH_LOGENTRY_V1_1_8 *)InterpProp; + DestroyLogEntry_V1_1_8_CS (LogEntryV1_1_8->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_1_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_8/RedfishLogEntry_V1_1_8_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_1_8/RedfishLogEntry_V1_1_8_Dxe.inf new file mode 100644 index 00000000000..02d21a5c308 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_8/RedfishLogEntry_V1_1_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_1_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_1_8_Dxe + FILE_GUID = 266581f8-9168-44b6-b4e1-a1a692cacf37 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_1_8EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_1_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_1_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_1_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_9/LogEntry_V1_1_9_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_1_9/LogEntry_V1_1_9_Dxe.c new file mode 100644 index 00000000000..f64a60b69a3 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_9/LogEntry_V1_1_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_1_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "1", + "9" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_9 *LogEntryV1_1_9; + EFI_REDFISH_LOGENTRY_V1_1_9_CS *LogEntryV1_1_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_1_9_To_CS (ResoruceRaw, &LogEntryV1_1_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_1_9 = (EFI_REDFISH_LOGENTRY_V1_1_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_1_9)); + if (LogEntryV1_1_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_1_9; + LogEntryV1_1_9->LogEntry = LogEntryV1_1_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_1_9_JSON (*((EFI_REDFISH_LOGENTRY_V1_1_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_1_9 *LogEntryV1_1_9; + + LogEntryV1_1_9 = (EFI_REDFISH_LOGENTRY_V1_1_9 *)InterpProp; + DestroyLogEntry_V1_1_9_CS (LogEntryV1_1_9->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_1_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_1_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_1_9/RedfishLogEntry_V1_1_9_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_1_9/RedfishLogEntry_V1_1_9_Dxe.inf new file mode 100644 index 00000000000..7cf7f348c05 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_1_9/RedfishLogEntry_V1_1_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_1_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_1_9_Dxe + FILE_GUID = 533017bf-7cdf-47ad-80c2-8fc59ddc9027 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_1_9EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_1_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_1_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_1_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_2_0/LogEntry_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_2_0/LogEntry_V1_2_0_Dxe.c new file mode 100644 index 00000000000..9fe96283c4f --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_2_0/LogEntry_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "2", + "0" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_2_0 *LogEntryV1_2_0; + EFI_REDFISH_LOGENTRY_V1_2_0_CS *LogEntryV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_2_0_To_CS (ResoruceRaw, &LogEntryV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_2_0 = (EFI_REDFISH_LOGENTRY_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_2_0)); + if (LogEntryV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_2_0; + LogEntryV1_2_0->LogEntry = LogEntryV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_2_0_JSON (*((EFI_REDFISH_LOGENTRY_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_2_0 *LogEntryV1_2_0; + + LogEntryV1_2_0 = (EFI_REDFISH_LOGENTRY_V1_2_0 *)InterpProp; + DestroyLogEntry_V1_2_0_CS (LogEntryV1_2_0->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_2_0/RedfishLogEntry_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_2_0/RedfishLogEntry_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..368ee8c802b --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_2_0/RedfishLogEntry_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_2_0_Dxe + FILE_GUID = d038b41a-f4c6-4fbc-945d-232c0b833d46 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_2_1/LogEntry_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_2_1/LogEntry_V1_2_1_Dxe.c new file mode 100644 index 00000000000..4b65566de32 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_2_1/LogEntry_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "2", + "1" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_2_1 *LogEntryV1_2_1; + EFI_REDFISH_LOGENTRY_V1_2_1_CS *LogEntryV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_2_1_To_CS (ResoruceRaw, &LogEntryV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_2_1 = (EFI_REDFISH_LOGENTRY_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_2_1)); + if (LogEntryV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_2_1; + LogEntryV1_2_1->LogEntry = LogEntryV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_2_1_JSON (*((EFI_REDFISH_LOGENTRY_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_2_1 *LogEntryV1_2_1; + + LogEntryV1_2_1 = (EFI_REDFISH_LOGENTRY_V1_2_1 *)InterpProp; + DestroyLogEntry_V1_2_1_CS (LogEntryV1_2_1->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_2_1/RedfishLogEntry_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_2_1/RedfishLogEntry_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..ac1945321e3 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_2_1/RedfishLogEntry_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_2_1_Dxe + FILE_GUID = 7e45f446-d3c1-4b04-b355-d996401af745 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_2_10/LogEntry_V1_2_10_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_2_10/LogEntry_V1_2_10_Dxe.c new file mode 100644 index 00000000000..b518fab6518 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_2_10/LogEntry_V1_2_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_2_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_2_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "2", + "10" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_2_10 *LogEntryV1_2_10; + EFI_REDFISH_LOGENTRY_V1_2_10_CS *LogEntryV1_2_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_2_10_To_CS (ResoruceRaw, &LogEntryV1_2_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_2_10 = (EFI_REDFISH_LOGENTRY_V1_2_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_2_10)); + if (LogEntryV1_2_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_2_10; + LogEntryV1_2_10->LogEntry = LogEntryV1_2_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_2_10_JSON (*((EFI_REDFISH_LOGENTRY_V1_2_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_2_10 *LogEntryV1_2_10; + + LogEntryV1_2_10 = (EFI_REDFISH_LOGENTRY_V1_2_10 *)InterpProp; + DestroyLogEntry_V1_2_10_CS (LogEntryV1_2_10->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_2_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_2_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_2_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_2_10/RedfishLogEntry_V1_2_10_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_2_10/RedfishLogEntry_V1_2_10_Dxe.inf new file mode 100644 index 00000000000..ef68e1ac207 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_2_10/RedfishLogEntry_V1_2_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_2_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_2_10_Dxe + FILE_GUID = 88572db5-1604-45bf-b3f0-6b12eb0219a0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_2_10EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_2_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_2_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_2_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_2_2/LogEntry_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_2_2/LogEntry_V1_2_2_Dxe.c new file mode 100644 index 00000000000..665cf51ee1d --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_2_2/LogEntry_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "2", + "2" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_2_2 *LogEntryV1_2_2; + EFI_REDFISH_LOGENTRY_V1_2_2_CS *LogEntryV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_2_2_To_CS (ResoruceRaw, &LogEntryV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_2_2 = (EFI_REDFISH_LOGENTRY_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_2_2)); + if (LogEntryV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_2_2; + LogEntryV1_2_2->LogEntry = LogEntryV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_2_2_JSON (*((EFI_REDFISH_LOGENTRY_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_2_2 *LogEntryV1_2_2; + + LogEntryV1_2_2 = (EFI_REDFISH_LOGENTRY_V1_2_2 *)InterpProp; + DestroyLogEntry_V1_2_2_CS (LogEntryV1_2_2->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_2_2/RedfishLogEntry_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_2_2/RedfishLogEntry_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..fb0ffbdc6a2 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_2_2/RedfishLogEntry_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_2_2_Dxe + FILE_GUID = a069556b-8999-4446-9951-f33a77eaee0f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_2_3/LogEntry_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_2_3/LogEntry_V1_2_3_Dxe.c new file mode 100644 index 00000000000..46c0f1a611c --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_2_3/LogEntry_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "2", + "3" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_2_3 *LogEntryV1_2_3; + EFI_REDFISH_LOGENTRY_V1_2_3_CS *LogEntryV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_2_3_To_CS (ResoruceRaw, &LogEntryV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_2_3 = (EFI_REDFISH_LOGENTRY_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_2_3)); + if (LogEntryV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_2_3; + LogEntryV1_2_3->LogEntry = LogEntryV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_2_3_JSON (*((EFI_REDFISH_LOGENTRY_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_2_3 *LogEntryV1_2_3; + + LogEntryV1_2_3 = (EFI_REDFISH_LOGENTRY_V1_2_3 *)InterpProp; + DestroyLogEntry_V1_2_3_CS (LogEntryV1_2_3->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_2_3/RedfishLogEntry_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_2_3/RedfishLogEntry_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..2d0a57e0771 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_2_3/RedfishLogEntry_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_2_3_Dxe + FILE_GUID = 272922d2-df5b-4de7-b07f-369d73a42387 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_2_4/LogEntry_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_2_4/LogEntry_V1_2_4_Dxe.c new file mode 100644 index 00000000000..0c5773898cf --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_2_4/LogEntry_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "2", + "4" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_2_4 *LogEntryV1_2_4; + EFI_REDFISH_LOGENTRY_V1_2_4_CS *LogEntryV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_2_4_To_CS (ResoruceRaw, &LogEntryV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_2_4 = (EFI_REDFISH_LOGENTRY_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_2_4)); + if (LogEntryV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_2_4; + LogEntryV1_2_4->LogEntry = LogEntryV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_2_4_JSON (*((EFI_REDFISH_LOGENTRY_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_2_4 *LogEntryV1_2_4; + + LogEntryV1_2_4 = (EFI_REDFISH_LOGENTRY_V1_2_4 *)InterpProp; + DestroyLogEntry_V1_2_4_CS (LogEntryV1_2_4->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_2_4/RedfishLogEntry_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_2_4/RedfishLogEntry_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..22931865499 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_2_4/RedfishLogEntry_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_2_4_Dxe + FILE_GUID = 436f07e4-cc6e-4a0b-afee-fd16cd293087 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_2_5/LogEntry_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_2_5/LogEntry_V1_2_5_Dxe.c new file mode 100644 index 00000000000..03dc5383933 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_2_5/LogEntry_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "2", + "5" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_2_5 *LogEntryV1_2_5; + EFI_REDFISH_LOGENTRY_V1_2_5_CS *LogEntryV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_2_5_To_CS (ResoruceRaw, &LogEntryV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_2_5 = (EFI_REDFISH_LOGENTRY_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_2_5)); + if (LogEntryV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_2_5; + LogEntryV1_2_5->LogEntry = LogEntryV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_2_5_JSON (*((EFI_REDFISH_LOGENTRY_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_2_5 *LogEntryV1_2_5; + + LogEntryV1_2_5 = (EFI_REDFISH_LOGENTRY_V1_2_5 *)InterpProp; + DestroyLogEntry_V1_2_5_CS (LogEntryV1_2_5->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_2_5/RedfishLogEntry_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_2_5/RedfishLogEntry_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..ec5cc6cdb85 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_2_5/RedfishLogEntry_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_2_5_Dxe + FILE_GUID = 5d6f19dd-2445-46e3-83b3-7f3c4ee0965d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_2_6/LogEntry_V1_2_6_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_2_6/LogEntry_V1_2_6_Dxe.c new file mode 100644 index 00000000000..46f55904ffe --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_2_6/LogEntry_V1_2_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_2_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "2", + "6" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_2_6 *LogEntryV1_2_6; + EFI_REDFISH_LOGENTRY_V1_2_6_CS *LogEntryV1_2_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_2_6_To_CS (ResoruceRaw, &LogEntryV1_2_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_2_6 = (EFI_REDFISH_LOGENTRY_V1_2_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_2_6)); + if (LogEntryV1_2_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_2_6; + LogEntryV1_2_6->LogEntry = LogEntryV1_2_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_2_6_JSON (*((EFI_REDFISH_LOGENTRY_V1_2_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_2_6 *LogEntryV1_2_6; + + LogEntryV1_2_6 = (EFI_REDFISH_LOGENTRY_V1_2_6 *)InterpProp; + DestroyLogEntry_V1_2_6_CS (LogEntryV1_2_6->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_2_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_2_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_2_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_2_6/RedfishLogEntry_V1_2_6_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_2_6/RedfishLogEntry_V1_2_6_Dxe.inf new file mode 100644 index 00000000000..43f7c86a4df --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_2_6/RedfishLogEntry_V1_2_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_2_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_2_6_Dxe + FILE_GUID = 7e5bd8ad-b6d7-4865-9fab-135f1ae07856 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_2_6EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_2_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_2_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_2_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_2_7/LogEntry_V1_2_7_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_2_7/LogEntry_V1_2_7_Dxe.c new file mode 100644 index 00000000000..9da65e12521 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_2_7/LogEntry_V1_2_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_2_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "2", + "7" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_2_7 *LogEntryV1_2_7; + EFI_REDFISH_LOGENTRY_V1_2_7_CS *LogEntryV1_2_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_2_7_To_CS (ResoruceRaw, &LogEntryV1_2_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_2_7 = (EFI_REDFISH_LOGENTRY_V1_2_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_2_7)); + if (LogEntryV1_2_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_2_7; + LogEntryV1_2_7->LogEntry = LogEntryV1_2_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_2_7_JSON (*((EFI_REDFISH_LOGENTRY_V1_2_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_2_7 *LogEntryV1_2_7; + + LogEntryV1_2_7 = (EFI_REDFISH_LOGENTRY_V1_2_7 *)InterpProp; + DestroyLogEntry_V1_2_7_CS (LogEntryV1_2_7->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_2_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_2_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_2_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_2_7/RedfishLogEntry_V1_2_7_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_2_7/RedfishLogEntry_V1_2_7_Dxe.inf new file mode 100644 index 00000000000..d7cb77d7516 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_2_7/RedfishLogEntry_V1_2_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_2_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_2_7_Dxe + FILE_GUID = c06af7c5-afa0-4b1e-87a2-0170d32e7d4c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_2_7EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_2_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_2_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_2_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_2_8/LogEntry_V1_2_8_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_2_8/LogEntry_V1_2_8_Dxe.c new file mode 100644 index 00000000000..84d1834f7b7 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_2_8/LogEntry_V1_2_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_2_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "2", + "8" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_2_8 *LogEntryV1_2_8; + EFI_REDFISH_LOGENTRY_V1_2_8_CS *LogEntryV1_2_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_2_8_To_CS (ResoruceRaw, &LogEntryV1_2_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_2_8 = (EFI_REDFISH_LOGENTRY_V1_2_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_2_8)); + if (LogEntryV1_2_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_2_8; + LogEntryV1_2_8->LogEntry = LogEntryV1_2_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_2_8_JSON (*((EFI_REDFISH_LOGENTRY_V1_2_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_2_8 *LogEntryV1_2_8; + + LogEntryV1_2_8 = (EFI_REDFISH_LOGENTRY_V1_2_8 *)InterpProp; + DestroyLogEntry_V1_2_8_CS (LogEntryV1_2_8->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_2_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_2_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_2_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_2_8/RedfishLogEntry_V1_2_8_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_2_8/RedfishLogEntry_V1_2_8_Dxe.inf new file mode 100644 index 00000000000..d7a1a8ae913 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_2_8/RedfishLogEntry_V1_2_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_2_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_2_8_Dxe + FILE_GUID = fab88da6-15eb-4921-a9cb-401ca5095508 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_2_8EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_2_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_2_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_2_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_2_9/LogEntry_V1_2_9_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_2_9/LogEntry_V1_2_9_Dxe.c new file mode 100644 index 00000000000..102b6ef879e --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_2_9/LogEntry_V1_2_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_2_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_2_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "2", + "9" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_2_9 *LogEntryV1_2_9; + EFI_REDFISH_LOGENTRY_V1_2_9_CS *LogEntryV1_2_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_2_9_To_CS (ResoruceRaw, &LogEntryV1_2_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_2_9 = (EFI_REDFISH_LOGENTRY_V1_2_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_2_9)); + if (LogEntryV1_2_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_2_9; + LogEntryV1_2_9->LogEntry = LogEntryV1_2_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_2_9_JSON (*((EFI_REDFISH_LOGENTRY_V1_2_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_2_9 *LogEntryV1_2_9; + + LogEntryV1_2_9 = (EFI_REDFISH_LOGENTRY_V1_2_9 *)InterpProp; + DestroyLogEntry_V1_2_9_CS (LogEntryV1_2_9->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_2_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_2_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_2_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_2_9/RedfishLogEntry_V1_2_9_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_2_9/RedfishLogEntry_V1_2_9_Dxe.inf new file mode 100644 index 00000000000..c760d9a2d6b --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_2_9/RedfishLogEntry_V1_2_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_2_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_2_9_Dxe + FILE_GUID = 26d47942-cc52-49b5-87cf-d5df1941d095 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_2_9EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_2_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_2_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_2_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_3_0/LogEntry_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_3_0/LogEntry_V1_3_0_Dxe.c new file mode 100644 index 00000000000..f09ac375ddd --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_3_0/LogEntry_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "3", + "0" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_3_0 *LogEntryV1_3_0; + EFI_REDFISH_LOGENTRY_V1_3_0_CS *LogEntryV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_3_0_To_CS (ResoruceRaw, &LogEntryV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_3_0 = (EFI_REDFISH_LOGENTRY_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_3_0)); + if (LogEntryV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_3_0; + LogEntryV1_3_0->LogEntry = LogEntryV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_3_0_JSON (*((EFI_REDFISH_LOGENTRY_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_3_0 *LogEntryV1_3_0; + + LogEntryV1_3_0 = (EFI_REDFISH_LOGENTRY_V1_3_0 *)InterpProp; + DestroyLogEntry_V1_3_0_CS (LogEntryV1_3_0->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_3_0/RedfishLogEntry_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_3_0/RedfishLogEntry_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..69139981963 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_3_0/RedfishLogEntry_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_3_0_Dxe + FILE_GUID = 78138906-488f-44a6-bae7-59275a3fa23d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_3_1/LogEntry_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_3_1/LogEntry_V1_3_1_Dxe.c new file mode 100644 index 00000000000..f316466e47e --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_3_1/LogEntry_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "3", + "1" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_3_1 *LogEntryV1_3_1; + EFI_REDFISH_LOGENTRY_V1_3_1_CS *LogEntryV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_3_1_To_CS (ResoruceRaw, &LogEntryV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_3_1 = (EFI_REDFISH_LOGENTRY_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_3_1)); + if (LogEntryV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_3_1; + LogEntryV1_3_1->LogEntry = LogEntryV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_3_1_JSON (*((EFI_REDFISH_LOGENTRY_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_3_1 *LogEntryV1_3_1; + + LogEntryV1_3_1 = (EFI_REDFISH_LOGENTRY_V1_3_1 *)InterpProp; + DestroyLogEntry_V1_3_1_CS (LogEntryV1_3_1->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_3_1/RedfishLogEntry_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_3_1/RedfishLogEntry_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..6af6dc6a74f --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_3_1/RedfishLogEntry_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_3_1_Dxe + FILE_GUID = 7e1cb991-4b61-40fd-83a8-159122c44714 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_3_2/LogEntry_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_3_2/LogEntry_V1_3_2_Dxe.c new file mode 100644 index 00000000000..6a5c344c9f3 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_3_2/LogEntry_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "3", + "2" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_3_2 *LogEntryV1_3_2; + EFI_REDFISH_LOGENTRY_V1_3_2_CS *LogEntryV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_3_2_To_CS (ResoruceRaw, &LogEntryV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_3_2 = (EFI_REDFISH_LOGENTRY_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_3_2)); + if (LogEntryV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_3_2; + LogEntryV1_3_2->LogEntry = LogEntryV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_3_2_JSON (*((EFI_REDFISH_LOGENTRY_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_3_2 *LogEntryV1_3_2; + + LogEntryV1_3_2 = (EFI_REDFISH_LOGENTRY_V1_3_2 *)InterpProp; + DestroyLogEntry_V1_3_2_CS (LogEntryV1_3_2->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_3_2/RedfishLogEntry_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_3_2/RedfishLogEntry_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..3f25de87136 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_3_2/RedfishLogEntry_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_3_2_Dxe + FILE_GUID = 56e8c780-cd75-47b4-9a3d-05adf3bd11a7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_3_3/LogEntry_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_3_3/LogEntry_V1_3_3_Dxe.c new file mode 100644 index 00000000000..9f7b4a6290a --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_3_3/LogEntry_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "3", + "3" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_3_3 *LogEntryV1_3_3; + EFI_REDFISH_LOGENTRY_V1_3_3_CS *LogEntryV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_3_3_To_CS (ResoruceRaw, &LogEntryV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_3_3 = (EFI_REDFISH_LOGENTRY_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_3_3)); + if (LogEntryV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_3_3; + LogEntryV1_3_3->LogEntry = LogEntryV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_3_3_JSON (*((EFI_REDFISH_LOGENTRY_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_3_3 *LogEntryV1_3_3; + + LogEntryV1_3_3 = (EFI_REDFISH_LOGENTRY_V1_3_3 *)InterpProp; + DestroyLogEntry_V1_3_3_CS (LogEntryV1_3_3->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_3_3/RedfishLogEntry_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_3_3/RedfishLogEntry_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..eacd06512be --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_3_3/RedfishLogEntry_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_3_3_Dxe + FILE_GUID = 7a90b309-57c4-48b9-af72-7b39838768fb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_3_4/LogEntry_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_3_4/LogEntry_V1_3_4_Dxe.c new file mode 100644 index 00000000000..b836bd823b4 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_3_4/LogEntry_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "3", + "4" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_3_4 *LogEntryV1_3_4; + EFI_REDFISH_LOGENTRY_V1_3_4_CS *LogEntryV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_3_4_To_CS (ResoruceRaw, &LogEntryV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_3_4 = (EFI_REDFISH_LOGENTRY_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_3_4)); + if (LogEntryV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_3_4; + LogEntryV1_3_4->LogEntry = LogEntryV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_3_4_JSON (*((EFI_REDFISH_LOGENTRY_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_3_4 *LogEntryV1_3_4; + + LogEntryV1_3_4 = (EFI_REDFISH_LOGENTRY_V1_3_4 *)InterpProp; + DestroyLogEntry_V1_3_4_CS (LogEntryV1_3_4->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_3_4/RedfishLogEntry_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_3_4/RedfishLogEntry_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..79d6eb326f7 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_3_4/RedfishLogEntry_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_3_4_Dxe + FILE_GUID = 293656f2-6848-475f-b8ea-256295b587b4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_3_5/LogEntry_V1_3_5_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_3_5/LogEntry_V1_3_5_Dxe.c new file mode 100644 index 00000000000..8dbbc43eb32 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_3_5/LogEntry_V1_3_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_3_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "3", + "5" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_3_5 *LogEntryV1_3_5; + EFI_REDFISH_LOGENTRY_V1_3_5_CS *LogEntryV1_3_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_3_5_To_CS (ResoruceRaw, &LogEntryV1_3_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_3_5 = (EFI_REDFISH_LOGENTRY_V1_3_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_3_5)); + if (LogEntryV1_3_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_3_5; + LogEntryV1_3_5->LogEntry = LogEntryV1_3_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_3_5_JSON (*((EFI_REDFISH_LOGENTRY_V1_3_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_3_5 *LogEntryV1_3_5; + + LogEntryV1_3_5 = (EFI_REDFISH_LOGENTRY_V1_3_5 *)InterpProp; + DestroyLogEntry_V1_3_5_CS (LogEntryV1_3_5->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_3_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_3_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_3_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_3_5/RedfishLogEntry_V1_3_5_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_3_5/RedfishLogEntry_V1_3_5_Dxe.inf new file mode 100644 index 00000000000..ac8496d8cd2 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_3_5/RedfishLogEntry_V1_3_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_3_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_3_5_Dxe + FILE_GUID = 1b562a27-88a1-482c-9c6c-61e7862e685b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_3_5EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_3_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_3_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_3_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_3_6/LogEntry_V1_3_6_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_3_6/LogEntry_V1_3_6_Dxe.c new file mode 100644 index 00000000000..bb75a13372c --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_3_6/LogEntry_V1_3_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_3_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "3", + "6" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_3_6 *LogEntryV1_3_6; + EFI_REDFISH_LOGENTRY_V1_3_6_CS *LogEntryV1_3_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_3_6_To_CS (ResoruceRaw, &LogEntryV1_3_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_3_6 = (EFI_REDFISH_LOGENTRY_V1_3_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_3_6)); + if (LogEntryV1_3_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_3_6; + LogEntryV1_3_6->LogEntry = LogEntryV1_3_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_3_6_JSON (*((EFI_REDFISH_LOGENTRY_V1_3_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_3_6 *LogEntryV1_3_6; + + LogEntryV1_3_6 = (EFI_REDFISH_LOGENTRY_V1_3_6 *)InterpProp; + DestroyLogEntry_V1_3_6_CS (LogEntryV1_3_6->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_3_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_3_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_3_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_3_6/RedfishLogEntry_V1_3_6_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_3_6/RedfishLogEntry_V1_3_6_Dxe.inf new file mode 100644 index 00000000000..4a1e13b7018 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_3_6/RedfishLogEntry_V1_3_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_3_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_3_6_Dxe + FILE_GUID = 9ca9981a-850d-4174-970d-e37750128a61 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_3_6EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_3_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_3_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_3_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_3_7/LogEntry_V1_3_7_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_3_7/LogEntry_V1_3_7_Dxe.c new file mode 100644 index 00000000000..bb00964bf80 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_3_7/LogEntry_V1_3_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_3_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_3_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "3", + "7" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_3_7 *LogEntryV1_3_7; + EFI_REDFISH_LOGENTRY_V1_3_7_CS *LogEntryV1_3_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_3_7_To_CS (ResoruceRaw, &LogEntryV1_3_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_3_7 = (EFI_REDFISH_LOGENTRY_V1_3_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_3_7)); + if (LogEntryV1_3_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_3_7; + LogEntryV1_3_7->LogEntry = LogEntryV1_3_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_3_7_JSON (*((EFI_REDFISH_LOGENTRY_V1_3_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_3_7 *LogEntryV1_3_7; + + LogEntryV1_3_7 = (EFI_REDFISH_LOGENTRY_V1_3_7 *)InterpProp; + DestroyLogEntry_V1_3_7_CS (LogEntryV1_3_7->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_3_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_3_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_3_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_3_7/RedfishLogEntry_V1_3_7_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_3_7/RedfishLogEntry_V1_3_7_Dxe.inf new file mode 100644 index 00000000000..6c0a6269091 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_3_7/RedfishLogEntry_V1_3_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_3_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_3_7_Dxe + FILE_GUID = 0b9af2af-d332-4b2a-a79a-5dfc8248c133 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_3_7EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_3_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_3_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_3_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_3_8/LogEntry_V1_3_8_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_3_8/LogEntry_V1_3_8_Dxe.c new file mode 100644 index 00000000000..7030d5541d8 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_3_8/LogEntry_V1_3_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_3_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_3_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "3", + "8" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_3_8 *LogEntryV1_3_8; + EFI_REDFISH_LOGENTRY_V1_3_8_CS *LogEntryV1_3_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_3_8_To_CS (ResoruceRaw, &LogEntryV1_3_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_3_8 = (EFI_REDFISH_LOGENTRY_V1_3_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_3_8)); + if (LogEntryV1_3_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_3_8; + LogEntryV1_3_8->LogEntry = LogEntryV1_3_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_3_8_JSON (*((EFI_REDFISH_LOGENTRY_V1_3_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_3_8 *LogEntryV1_3_8; + + LogEntryV1_3_8 = (EFI_REDFISH_LOGENTRY_V1_3_8 *)InterpProp; + DestroyLogEntry_V1_3_8_CS (LogEntryV1_3_8->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_3_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_3_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_3_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_3_8/RedfishLogEntry_V1_3_8_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_3_8/RedfishLogEntry_V1_3_8_Dxe.inf new file mode 100644 index 00000000000..917197c28c6 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_3_8/RedfishLogEntry_V1_3_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_3_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_3_8_Dxe + FILE_GUID = 01f4f28e-b62b-45cf-ba50-519d0812f3dc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_3_8EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_3_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_3_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_3_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_3_9/LogEntry_V1_3_9_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_3_9/LogEntry_V1_3_9_Dxe.c new file mode 100644 index 00000000000..79264774f84 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_3_9/LogEntry_V1_3_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_3_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_3_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "3", + "9" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_3_9 *LogEntryV1_3_9; + EFI_REDFISH_LOGENTRY_V1_3_9_CS *LogEntryV1_3_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_3_9_To_CS (ResoruceRaw, &LogEntryV1_3_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_3_9 = (EFI_REDFISH_LOGENTRY_V1_3_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_3_9)); + if (LogEntryV1_3_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_3_9; + LogEntryV1_3_9->LogEntry = LogEntryV1_3_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_3_9_JSON (*((EFI_REDFISH_LOGENTRY_V1_3_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_3_9 *LogEntryV1_3_9; + + LogEntryV1_3_9 = (EFI_REDFISH_LOGENTRY_V1_3_9 *)InterpProp; + DestroyLogEntry_V1_3_9_CS (LogEntryV1_3_9->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_3_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_3_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_3_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_3_9/RedfishLogEntry_V1_3_9_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_3_9/RedfishLogEntry_V1_3_9_Dxe.inf new file mode 100644 index 00000000000..674f5716a71 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_3_9/RedfishLogEntry_V1_3_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_3_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_3_9_Dxe + FILE_GUID = 0d7f43a9-a43b-4cbc-a374-f3a7cf6a5467 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_3_9EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_3_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_3_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_3_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_4_0/LogEntry_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_4_0/LogEntry_V1_4_0_Dxe.c new file mode 100644 index 00000000000..0fb84239a5a --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_4_0/LogEntry_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "4", + "0" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_4_0 *LogEntryV1_4_0; + EFI_REDFISH_LOGENTRY_V1_4_0_CS *LogEntryV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_4_0_To_CS (ResoruceRaw, &LogEntryV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_4_0 = (EFI_REDFISH_LOGENTRY_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_4_0)); + if (LogEntryV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_4_0; + LogEntryV1_4_0->LogEntry = LogEntryV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_4_0_JSON (*((EFI_REDFISH_LOGENTRY_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_4_0 *LogEntryV1_4_0; + + LogEntryV1_4_0 = (EFI_REDFISH_LOGENTRY_V1_4_0 *)InterpProp; + DestroyLogEntry_V1_4_0_CS (LogEntryV1_4_0->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_4_0/RedfishLogEntry_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_4_0/RedfishLogEntry_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..b573b1d1237 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_4_0/RedfishLogEntry_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_4_0_Dxe + FILE_GUID = eb39dc13-a452-4519-9374-cae224a255a3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_4_1/LogEntry_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_4_1/LogEntry_V1_4_1_Dxe.c new file mode 100644 index 00000000000..99c961ce220 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_4_1/LogEntry_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "4", + "1" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_4_1 *LogEntryV1_4_1; + EFI_REDFISH_LOGENTRY_V1_4_1_CS *LogEntryV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_4_1_To_CS (ResoruceRaw, &LogEntryV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_4_1 = (EFI_REDFISH_LOGENTRY_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_4_1)); + if (LogEntryV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_4_1; + LogEntryV1_4_1->LogEntry = LogEntryV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_4_1_JSON (*((EFI_REDFISH_LOGENTRY_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_4_1 *LogEntryV1_4_1; + + LogEntryV1_4_1 = (EFI_REDFISH_LOGENTRY_V1_4_1 *)InterpProp; + DestroyLogEntry_V1_4_1_CS (LogEntryV1_4_1->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_4_1/RedfishLogEntry_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_4_1/RedfishLogEntry_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..8c29d4776a3 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_4_1/RedfishLogEntry_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_4_1_Dxe + FILE_GUID = 74f23eea-30ef-46d3-aa3e-b8edca7f7e03 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_4_2/LogEntry_V1_4_2_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_4_2/LogEntry_V1_4_2_Dxe.c new file mode 100644 index 00000000000..4a53eab2538 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_4_2/LogEntry_V1_4_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_4_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "4", + "2" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_4_2 *LogEntryV1_4_2; + EFI_REDFISH_LOGENTRY_V1_4_2_CS *LogEntryV1_4_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_4_2_To_CS (ResoruceRaw, &LogEntryV1_4_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_4_2 = (EFI_REDFISH_LOGENTRY_V1_4_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_4_2)); + if (LogEntryV1_4_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_4_2; + LogEntryV1_4_2->LogEntry = LogEntryV1_4_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_4_2_JSON (*((EFI_REDFISH_LOGENTRY_V1_4_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_4_2 *LogEntryV1_4_2; + + LogEntryV1_4_2 = (EFI_REDFISH_LOGENTRY_V1_4_2 *)InterpProp; + DestroyLogEntry_V1_4_2_CS (LogEntryV1_4_2->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_4_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_4_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_4_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_4_2/RedfishLogEntry_V1_4_2_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_4_2/RedfishLogEntry_V1_4_2_Dxe.inf new file mode 100644 index 00000000000..65c344853c5 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_4_2/RedfishLogEntry_V1_4_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_4_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_4_2_Dxe + FILE_GUID = 8d8a6448-9680-42ca-8fa8-a3b7e125f2b1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_4_2EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_4_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_4_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_4_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_4_3/LogEntry_V1_4_3_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_4_3/LogEntry_V1_4_3_Dxe.c new file mode 100644 index 00000000000..79b36395652 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_4_3/LogEntry_V1_4_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_4_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "4", + "3" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_4_3 *LogEntryV1_4_3; + EFI_REDFISH_LOGENTRY_V1_4_3_CS *LogEntryV1_4_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_4_3_To_CS (ResoruceRaw, &LogEntryV1_4_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_4_3 = (EFI_REDFISH_LOGENTRY_V1_4_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_4_3)); + if (LogEntryV1_4_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_4_3; + LogEntryV1_4_3->LogEntry = LogEntryV1_4_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_4_3_JSON (*((EFI_REDFISH_LOGENTRY_V1_4_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_4_3 *LogEntryV1_4_3; + + LogEntryV1_4_3 = (EFI_REDFISH_LOGENTRY_V1_4_3 *)InterpProp; + DestroyLogEntry_V1_4_3_CS (LogEntryV1_4_3->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_4_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_4_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_4_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_4_3/RedfishLogEntry_V1_4_3_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_4_3/RedfishLogEntry_V1_4_3_Dxe.inf new file mode 100644 index 00000000000..4489e1937f4 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_4_3/RedfishLogEntry_V1_4_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_4_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_4_3_Dxe + FILE_GUID = 9ef87bef-4133-441d-882e-0218cdc2e8b8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_4_3EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_4_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_4_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_4_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_4_4/LogEntry_V1_4_4_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_4_4/LogEntry_V1_4_4_Dxe.c new file mode 100644 index 00000000000..a99f5e50cd5 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_4_4/LogEntry_V1_4_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_4_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "4", + "4" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_4_4 *LogEntryV1_4_4; + EFI_REDFISH_LOGENTRY_V1_4_4_CS *LogEntryV1_4_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_4_4_To_CS (ResoruceRaw, &LogEntryV1_4_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_4_4 = (EFI_REDFISH_LOGENTRY_V1_4_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_4_4)); + if (LogEntryV1_4_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_4_4; + LogEntryV1_4_4->LogEntry = LogEntryV1_4_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_4_4_JSON (*((EFI_REDFISH_LOGENTRY_V1_4_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_4_4 *LogEntryV1_4_4; + + LogEntryV1_4_4 = (EFI_REDFISH_LOGENTRY_V1_4_4 *)InterpProp; + DestroyLogEntry_V1_4_4_CS (LogEntryV1_4_4->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_4_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_4_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_4_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_4_4/RedfishLogEntry_V1_4_4_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_4_4/RedfishLogEntry_V1_4_4_Dxe.inf new file mode 100644 index 00000000000..a2ef54e725f --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_4_4/RedfishLogEntry_V1_4_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_4_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_4_4_Dxe + FILE_GUID = 5fdfcac5-3d9a-41ca-b1a3-42b5aefd1afe + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_4_4EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_4_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_4_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_4_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_4_5/LogEntry_V1_4_5_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_4_5/LogEntry_V1_4_5_Dxe.c new file mode 100644 index 00000000000..3999fbd5f1c --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_4_5/LogEntry_V1_4_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_4_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "4", + "5" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_4_5 *LogEntryV1_4_5; + EFI_REDFISH_LOGENTRY_V1_4_5_CS *LogEntryV1_4_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_4_5_To_CS (ResoruceRaw, &LogEntryV1_4_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_4_5 = (EFI_REDFISH_LOGENTRY_V1_4_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_4_5)); + if (LogEntryV1_4_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_4_5; + LogEntryV1_4_5->LogEntry = LogEntryV1_4_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_4_5_JSON (*((EFI_REDFISH_LOGENTRY_V1_4_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_4_5 *LogEntryV1_4_5; + + LogEntryV1_4_5 = (EFI_REDFISH_LOGENTRY_V1_4_5 *)InterpProp; + DestroyLogEntry_V1_4_5_CS (LogEntryV1_4_5->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_4_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_4_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_4_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_4_5/RedfishLogEntry_V1_4_5_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_4_5/RedfishLogEntry_V1_4_5_Dxe.inf new file mode 100644 index 00000000000..2b84e86142f --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_4_5/RedfishLogEntry_V1_4_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_4_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_4_5_Dxe + FILE_GUID = 89774914-700b-4379-aeb0-8d5c4ff3696d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_4_5EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_4_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_4_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_4_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_4_6/LogEntry_V1_4_6_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_4_6/LogEntry_V1_4_6_Dxe.c new file mode 100644 index 00000000000..ee59dd802e1 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_4_6/LogEntry_V1_4_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_4_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_4_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "4", + "6" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_4_6 *LogEntryV1_4_6; + EFI_REDFISH_LOGENTRY_V1_4_6_CS *LogEntryV1_4_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_4_6_To_CS (ResoruceRaw, &LogEntryV1_4_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_4_6 = (EFI_REDFISH_LOGENTRY_V1_4_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_4_6)); + if (LogEntryV1_4_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_4_6; + LogEntryV1_4_6->LogEntry = LogEntryV1_4_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_4_6_JSON (*((EFI_REDFISH_LOGENTRY_V1_4_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_4_6 *LogEntryV1_4_6; + + LogEntryV1_4_6 = (EFI_REDFISH_LOGENTRY_V1_4_6 *)InterpProp; + DestroyLogEntry_V1_4_6_CS (LogEntryV1_4_6->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_4_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_4_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_4_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_4_6/RedfishLogEntry_V1_4_6_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_4_6/RedfishLogEntry_V1_4_6_Dxe.inf new file mode 100644 index 00000000000..f774ff91992 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_4_6/RedfishLogEntry_V1_4_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_4_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_4_6_Dxe + FILE_GUID = 39684055-1b56-46eb-8e98-02dc788b872e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_4_6EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_4_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_4_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_4_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_4_7/LogEntry_V1_4_7_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_4_7/LogEntry_V1_4_7_Dxe.c new file mode 100644 index 00000000000..e08733c428b --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_4_7/LogEntry_V1_4_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_4_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_4_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "4", + "7" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_4_7 *LogEntryV1_4_7; + EFI_REDFISH_LOGENTRY_V1_4_7_CS *LogEntryV1_4_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_4_7_To_CS (ResoruceRaw, &LogEntryV1_4_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_4_7 = (EFI_REDFISH_LOGENTRY_V1_4_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_4_7)); + if (LogEntryV1_4_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_4_7; + LogEntryV1_4_7->LogEntry = LogEntryV1_4_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_4_7_JSON (*((EFI_REDFISH_LOGENTRY_V1_4_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_4_7 *LogEntryV1_4_7; + + LogEntryV1_4_7 = (EFI_REDFISH_LOGENTRY_V1_4_7 *)InterpProp; + DestroyLogEntry_V1_4_7_CS (LogEntryV1_4_7->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_4_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_4_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_4_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_4_7/RedfishLogEntry_V1_4_7_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_4_7/RedfishLogEntry_V1_4_7_Dxe.inf new file mode 100644 index 00000000000..2cf2196f435 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_4_7/RedfishLogEntry_V1_4_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_4_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_4_7_Dxe + FILE_GUID = 43b0f277-489a-40f0-92f0-a8f0d08b364e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_4_7EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_4_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_4_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_4_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_4_8/LogEntry_V1_4_8_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_4_8/LogEntry_V1_4_8_Dxe.c new file mode 100644 index 00000000000..15147e7a81f --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_4_8/LogEntry_V1_4_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_4_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_4_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "4", + "8" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_4_8 *LogEntryV1_4_8; + EFI_REDFISH_LOGENTRY_V1_4_8_CS *LogEntryV1_4_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_4_8_To_CS (ResoruceRaw, &LogEntryV1_4_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_4_8 = (EFI_REDFISH_LOGENTRY_V1_4_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_4_8)); + if (LogEntryV1_4_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_4_8; + LogEntryV1_4_8->LogEntry = LogEntryV1_4_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_4_8_JSON (*((EFI_REDFISH_LOGENTRY_V1_4_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_4_8 *LogEntryV1_4_8; + + LogEntryV1_4_8 = (EFI_REDFISH_LOGENTRY_V1_4_8 *)InterpProp; + DestroyLogEntry_V1_4_8_CS (LogEntryV1_4_8->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_4_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_4_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_4_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_4_8/RedfishLogEntry_V1_4_8_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_4_8/RedfishLogEntry_V1_4_8_Dxe.inf new file mode 100644 index 00000000000..f76133aafa5 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_4_8/RedfishLogEntry_V1_4_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_4_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_4_8_Dxe + FILE_GUID = 46575c7c-4e34-45e7-9827-ca468a4e6dcd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_4_8EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_4_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_4_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_4_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_5_0/LogEntry_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_5_0/LogEntry_V1_5_0_Dxe.c new file mode 100644 index 00000000000..5241717cd9f --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_5_0/LogEntry_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "5", + "0" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_5_0 *LogEntryV1_5_0; + EFI_REDFISH_LOGENTRY_V1_5_0_CS *LogEntryV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_5_0_To_CS (ResoruceRaw, &LogEntryV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_5_0 = (EFI_REDFISH_LOGENTRY_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_5_0)); + if (LogEntryV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_5_0; + LogEntryV1_5_0->LogEntry = LogEntryV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_5_0_JSON (*((EFI_REDFISH_LOGENTRY_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_5_0 *LogEntryV1_5_0; + + LogEntryV1_5_0 = (EFI_REDFISH_LOGENTRY_V1_5_0 *)InterpProp; + DestroyLogEntry_V1_5_0_CS (LogEntryV1_5_0->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_5_0/RedfishLogEntry_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_5_0/RedfishLogEntry_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..9c1e8ec678a --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_5_0/RedfishLogEntry_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_5_0_Dxe + FILE_GUID = 106a4895-ac6c-4931-b024-8f5cd2ff23a7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_5_1/LogEntry_V1_5_1_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_5_1/LogEntry_V1_5_1_Dxe.c new file mode 100644 index 00000000000..9d9e71dc155 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_5_1/LogEntry_V1_5_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_5_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "5", + "1" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_5_1 *LogEntryV1_5_1; + EFI_REDFISH_LOGENTRY_V1_5_1_CS *LogEntryV1_5_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_5_1_To_CS (ResoruceRaw, &LogEntryV1_5_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_5_1 = (EFI_REDFISH_LOGENTRY_V1_5_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_5_1)); + if (LogEntryV1_5_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_5_1; + LogEntryV1_5_1->LogEntry = LogEntryV1_5_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_5_1_JSON (*((EFI_REDFISH_LOGENTRY_V1_5_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_5_1 *LogEntryV1_5_1; + + LogEntryV1_5_1 = (EFI_REDFISH_LOGENTRY_V1_5_1 *)InterpProp; + DestroyLogEntry_V1_5_1_CS (LogEntryV1_5_1->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_5_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_5_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_5_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_5_1/RedfishLogEntry_V1_5_1_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_5_1/RedfishLogEntry_V1_5_1_Dxe.inf new file mode 100644 index 00000000000..5ea4e5250c2 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_5_1/RedfishLogEntry_V1_5_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_5_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_5_1_Dxe + FILE_GUID = b75a6845-e147-4b0d-a341-9be3e5661dbe + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_5_1EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_5_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_5_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_5_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_5_2/LogEntry_V1_5_2_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_5_2/LogEntry_V1_5_2_Dxe.c new file mode 100644 index 00000000000..b153edbc156 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_5_2/LogEntry_V1_5_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_5_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "5", + "2" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_5_2 *LogEntryV1_5_2; + EFI_REDFISH_LOGENTRY_V1_5_2_CS *LogEntryV1_5_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_5_2_To_CS (ResoruceRaw, &LogEntryV1_5_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_5_2 = (EFI_REDFISH_LOGENTRY_V1_5_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_5_2)); + if (LogEntryV1_5_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_5_2; + LogEntryV1_5_2->LogEntry = LogEntryV1_5_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_5_2_JSON (*((EFI_REDFISH_LOGENTRY_V1_5_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_5_2 *LogEntryV1_5_2; + + LogEntryV1_5_2 = (EFI_REDFISH_LOGENTRY_V1_5_2 *)InterpProp; + DestroyLogEntry_V1_5_2_CS (LogEntryV1_5_2->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_5_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_5_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_5_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_5_2/RedfishLogEntry_V1_5_2_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_5_2/RedfishLogEntry_V1_5_2_Dxe.inf new file mode 100644 index 00000000000..de86994e208 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_5_2/RedfishLogEntry_V1_5_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_5_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_5_2_Dxe + FILE_GUID = 13682cf4-a9b7-4d91-abe6-6acd625d727d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_5_2EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_5_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_5_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_5_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_5_3/LogEntry_V1_5_3_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_5_3/LogEntry_V1_5_3_Dxe.c new file mode 100644 index 00000000000..0e943f3a06f --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_5_3/LogEntry_V1_5_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_5_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "5", + "3" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_5_3 *LogEntryV1_5_3; + EFI_REDFISH_LOGENTRY_V1_5_3_CS *LogEntryV1_5_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_5_3_To_CS (ResoruceRaw, &LogEntryV1_5_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_5_3 = (EFI_REDFISH_LOGENTRY_V1_5_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_5_3)); + if (LogEntryV1_5_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_5_3; + LogEntryV1_5_3->LogEntry = LogEntryV1_5_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_5_3_JSON (*((EFI_REDFISH_LOGENTRY_V1_5_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_5_3 *LogEntryV1_5_3; + + LogEntryV1_5_3 = (EFI_REDFISH_LOGENTRY_V1_5_3 *)InterpProp; + DestroyLogEntry_V1_5_3_CS (LogEntryV1_5_3->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_5_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_5_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_5_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_5_3/RedfishLogEntry_V1_5_3_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_5_3/RedfishLogEntry_V1_5_3_Dxe.inf new file mode 100644 index 00000000000..59e991a41ab --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_5_3/RedfishLogEntry_V1_5_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_5_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_5_3_Dxe + FILE_GUID = 328b1875-66b2-4331-b906-bbefe0033dfb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_5_3EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_5_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_5_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_5_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_5_4/LogEntry_V1_5_4_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_5_4/LogEntry_V1_5_4_Dxe.c new file mode 100644 index 00000000000..051d061a7b1 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_5_4/LogEntry_V1_5_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_5_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "5", + "4" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_5_4 *LogEntryV1_5_4; + EFI_REDFISH_LOGENTRY_V1_5_4_CS *LogEntryV1_5_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_5_4_To_CS (ResoruceRaw, &LogEntryV1_5_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_5_4 = (EFI_REDFISH_LOGENTRY_V1_5_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_5_4)); + if (LogEntryV1_5_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_5_4; + LogEntryV1_5_4->LogEntry = LogEntryV1_5_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_5_4_JSON (*((EFI_REDFISH_LOGENTRY_V1_5_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_5_4 *LogEntryV1_5_4; + + LogEntryV1_5_4 = (EFI_REDFISH_LOGENTRY_V1_5_4 *)InterpProp; + DestroyLogEntry_V1_5_4_CS (LogEntryV1_5_4->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_5_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_5_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_5_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_5_4/RedfishLogEntry_V1_5_4_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_5_4/RedfishLogEntry_V1_5_4_Dxe.inf new file mode 100644 index 00000000000..a2627edc857 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_5_4/RedfishLogEntry_V1_5_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_5_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_5_4_Dxe + FILE_GUID = 4fbbd68b-f704-4f1e-a9dc-26959d0bbfd2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_5_4EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_5_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_5_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_5_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_6_0/LogEntry_V1_6_0_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_6_0/LogEntry_V1_6_0_Dxe.c new file mode 100644 index 00000000000..8b568799f3f --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_6_0/LogEntry_V1_6_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_6_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "6", + "0" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_6_0 *LogEntryV1_6_0; + EFI_REDFISH_LOGENTRY_V1_6_0_CS *LogEntryV1_6_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_6_0_To_CS (ResoruceRaw, &LogEntryV1_6_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_6_0 = (EFI_REDFISH_LOGENTRY_V1_6_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_6_0)); + if (LogEntryV1_6_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_6_0; + LogEntryV1_6_0->LogEntry = LogEntryV1_6_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_6_0_JSON (*((EFI_REDFISH_LOGENTRY_V1_6_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_6_0 *LogEntryV1_6_0; + + LogEntryV1_6_0 = (EFI_REDFISH_LOGENTRY_V1_6_0 *)InterpProp; + DestroyLogEntry_V1_6_0_CS (LogEntryV1_6_0->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_6_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_6_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_6_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_6_0/RedfishLogEntry_V1_6_0_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_6_0/RedfishLogEntry_V1_6_0_Dxe.inf new file mode 100644 index 00000000000..e1339898e96 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_6_0/RedfishLogEntry_V1_6_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_6_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_6_0_Dxe + FILE_GUID = 054be2a0-008f-4399-90f4-bd550063dbfd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_6_0EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_6_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_6_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_6_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_6_1/LogEntry_V1_6_1_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_6_1/LogEntry_V1_6_1_Dxe.c new file mode 100644 index 00000000000..e6faf92c22a --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_6_1/LogEntry_V1_6_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_6_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "6", + "1" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_6_1 *LogEntryV1_6_1; + EFI_REDFISH_LOGENTRY_V1_6_1_CS *LogEntryV1_6_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_6_1_To_CS (ResoruceRaw, &LogEntryV1_6_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_6_1 = (EFI_REDFISH_LOGENTRY_V1_6_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_6_1)); + if (LogEntryV1_6_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_6_1; + LogEntryV1_6_1->LogEntry = LogEntryV1_6_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_6_1_JSON (*((EFI_REDFISH_LOGENTRY_V1_6_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_6_1 *LogEntryV1_6_1; + + LogEntryV1_6_1 = (EFI_REDFISH_LOGENTRY_V1_6_1 *)InterpProp; + DestroyLogEntry_V1_6_1_CS (LogEntryV1_6_1->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_6_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_6_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_6_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_6_1/RedfishLogEntry_V1_6_1_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_6_1/RedfishLogEntry_V1_6_1_Dxe.inf new file mode 100644 index 00000000000..64817e8d71c --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_6_1/RedfishLogEntry_V1_6_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_6_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_6_1_Dxe + FILE_GUID = d71c115a-8d0e-4e02-a787-214001f61038 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_6_1EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_6_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_6_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_6_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_6_2/LogEntry_V1_6_2_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_6_2/LogEntry_V1_6_2_Dxe.c new file mode 100644 index 00000000000..33db04a0f85 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_6_2/LogEntry_V1_6_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_6_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "6", + "2" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_6_2 *LogEntryV1_6_2; + EFI_REDFISH_LOGENTRY_V1_6_2_CS *LogEntryV1_6_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_6_2_To_CS (ResoruceRaw, &LogEntryV1_6_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_6_2 = (EFI_REDFISH_LOGENTRY_V1_6_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_6_2)); + if (LogEntryV1_6_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_6_2; + LogEntryV1_6_2->LogEntry = LogEntryV1_6_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_6_2_JSON (*((EFI_REDFISH_LOGENTRY_V1_6_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_6_2 *LogEntryV1_6_2; + + LogEntryV1_6_2 = (EFI_REDFISH_LOGENTRY_V1_6_2 *)InterpProp; + DestroyLogEntry_V1_6_2_CS (LogEntryV1_6_2->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_6_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_6_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_6_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_6_2/RedfishLogEntry_V1_6_2_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_6_2/RedfishLogEntry_V1_6_2_Dxe.inf new file mode 100644 index 00000000000..478b651525e --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_6_2/RedfishLogEntry_V1_6_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_6_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_6_2_Dxe + FILE_GUID = 607e3369-8c73-404a-94d1-71ae8e4ce64c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_6_2EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_6_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_6_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_6_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_6_3/LogEntry_V1_6_3_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_6_3/LogEntry_V1_6_3_Dxe.c new file mode 100644 index 00000000000..49ee8218ffc --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_6_3/LogEntry_V1_6_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_6_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_6_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "6", + "3" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_6_3 *LogEntryV1_6_3; + EFI_REDFISH_LOGENTRY_V1_6_3_CS *LogEntryV1_6_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_6_3_To_CS (ResoruceRaw, &LogEntryV1_6_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_6_3 = (EFI_REDFISH_LOGENTRY_V1_6_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_6_3)); + if (LogEntryV1_6_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_6_3; + LogEntryV1_6_3->LogEntry = LogEntryV1_6_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_6_3_JSON (*((EFI_REDFISH_LOGENTRY_V1_6_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_6_3 *LogEntryV1_6_3; + + LogEntryV1_6_3 = (EFI_REDFISH_LOGENTRY_V1_6_3 *)InterpProp; + DestroyLogEntry_V1_6_3_CS (LogEntryV1_6_3->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_6_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_6_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_6_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_6_3/RedfishLogEntry_V1_6_3_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_6_3/RedfishLogEntry_V1_6_3_Dxe.inf new file mode 100644 index 00000000000..be72f13ab33 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_6_3/RedfishLogEntry_V1_6_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_6_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_6_3_Dxe + FILE_GUID = a5a0aec5-104c-414b-a2d3-2e328cf62769 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_6_3EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_6_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_6_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_6_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_7_0/LogEntry_V1_7_0_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_7_0/LogEntry_V1_7_0_Dxe.c new file mode 100644 index 00000000000..2b87dcfd133 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_7_0/LogEntry_V1_7_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_7_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "7", + "0" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_7_0 *LogEntryV1_7_0; + EFI_REDFISH_LOGENTRY_V1_7_0_CS *LogEntryV1_7_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_7_0_To_CS (ResoruceRaw, &LogEntryV1_7_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_7_0 = (EFI_REDFISH_LOGENTRY_V1_7_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_7_0)); + if (LogEntryV1_7_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_7_0; + LogEntryV1_7_0->LogEntry = LogEntryV1_7_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_7_0_JSON (*((EFI_REDFISH_LOGENTRY_V1_7_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_7_0 *LogEntryV1_7_0; + + LogEntryV1_7_0 = (EFI_REDFISH_LOGENTRY_V1_7_0 *)InterpProp; + DestroyLogEntry_V1_7_0_CS (LogEntryV1_7_0->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_7_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_7_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_7_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_7_0/RedfishLogEntry_V1_7_0_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_7_0/RedfishLogEntry_V1_7_0_Dxe.inf new file mode 100644 index 00000000000..ed81d87ec57 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_7_0/RedfishLogEntry_V1_7_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_7_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_7_0_Dxe + FILE_GUID = e7375af8-25ac-40c0-b380-b95074de9569 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_7_0EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_7_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_7_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_7_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_7_1/LogEntry_V1_7_1_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_7_1/LogEntry_V1_7_1_Dxe.c new file mode 100644 index 00000000000..b6d4adf8e9c --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_7_1/LogEntry_V1_7_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_7_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_7_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "7", + "1" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_7_1 *LogEntryV1_7_1; + EFI_REDFISH_LOGENTRY_V1_7_1_CS *LogEntryV1_7_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_7_1_To_CS (ResoruceRaw, &LogEntryV1_7_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_7_1 = (EFI_REDFISH_LOGENTRY_V1_7_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_7_1)); + if (LogEntryV1_7_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_7_1; + LogEntryV1_7_1->LogEntry = LogEntryV1_7_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_7_1_JSON (*((EFI_REDFISH_LOGENTRY_V1_7_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_7_1 *LogEntryV1_7_1; + + LogEntryV1_7_1 = (EFI_REDFISH_LOGENTRY_V1_7_1 *)InterpProp; + DestroyLogEntry_V1_7_1_CS (LogEntryV1_7_1->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_7_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_7_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_7_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_7_1/RedfishLogEntry_V1_7_1_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_7_1/RedfishLogEntry_V1_7_1_Dxe.inf new file mode 100644 index 00000000000..7915b56b367 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_7_1/RedfishLogEntry_V1_7_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_7_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_7_1_Dxe + FILE_GUID = 1142beee-7d67-4d4f-9650-7c4f19e1f912 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_7_1EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_7_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_7_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_7_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntry/v1_8_0/LogEntry_V1_8_0_Dxe.c b/RedfishClientPkg/Converter/LogEntry/v1_8_0/LogEntry_V1_8_0_Dxe.c new file mode 100644 index 00000000000..af713fadf16 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_8_0/LogEntry_V1_8_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntry.v1_8_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogEntry V1_8_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntry", + "1", + "8", + "0" + }, + "LogEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_8_0 *LogEntryV1_8_0; + EFI_REDFISH_LOGENTRY_V1_8_0_CS *LogEntryV1_8_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntry_V1_8_0_To_CS (ResoruceRaw, &LogEntryV1_8_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryV1_8_0 = (EFI_REDFISH_LOGENTRY_V1_8_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRY_V1_8_0)); + if (LogEntryV1_8_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryV1_8_0; + LogEntryV1_8_0->LogEntry = LogEntryV1_8_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntry"), "LogEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntry"), "LogEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntry_V1_8_0_JSON (*((EFI_REDFISH_LOGENTRY_V1_8_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRY_V1_8_0 *LogEntryV1_8_0; + + LogEntryV1_8_0 = (EFI_REDFISH_LOGENTRY_V1_8_0 *)InterpProp; + DestroyLogEntry_V1_8_0_CS (LogEntryV1_8_0->LogEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntry_V1_8_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_8_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryToStructWrapper, + LogEntryToJson, + LogEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntry_V1_8_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntry/v1_8_0/RedfishLogEntry_V1_8_0_Dxe.inf b/RedfishClientPkg/Converter/LogEntry/v1_8_0/RedfishLogEntry_V1_8_0_Dxe.inf new file mode 100644 index 00000000000..af86d7572ba --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntry/v1_8_0/RedfishLogEntry_V1_8_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntry.v1_8_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntry_V1_8_0_Dxe + FILE_GUID = 95ccd06d-86d1-4fba-bb6e-d2c4dd8ed72e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntry_V1_8_0EntryPoint + UNLOAD_IMAGE = RedfishLogEntry_V1_8_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntry_V1_8_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryV1_8_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogEntryCollection/LogEntryCollection_Dxe.c b/RedfishClientPkg/Converter/LogEntryCollection/LogEntryCollection_Dxe.c new file mode 100644 index 00000000000..d0a114b96df --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntryCollection/LogEntryCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogEntryCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogEntryCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support LogEntryCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogEntryCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "LogEntryCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGENTRYCOLLECTION *LogEntryCollection; + EFI_REDFISH_LOGENTRYCOLLECTION_CS *LogEntryCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogEntryCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogEntryCollection_To_CS (ResoruceRaw, &LogEntryCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + LogEntryCollection = (EFI_REDFISH_LOGENTRYCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGENTRYCOLLECTION)); + if (LogEntryCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogEntryCollection; + LogEntryCollection->LogEntryCollection = LogEntryCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntryCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogEntryCollection"), "LogEntryCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogEntryCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogEntryCollection"), "LogEntryCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogEntryCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogEntryCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogEntryCollection_JSON (*((EFI_REDFISH_LOGENTRYCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogEntryCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGENTRYCOLLECTION *LogEntryCollection; + + LogEntryCollection = (EFI_REDFISH_LOGENTRYCOLLECTION *)InterpProp; + DestroyLogEntryCollection_CS (LogEntryCollection->LogEntryCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogEntryCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogEntryCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogEntryCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogEntryCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogEntryCollectionToStructWrapper, + LogEntryCollectionToJson, + LogEntryCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogEntryCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogEntryCollection/RedfishLogEntryCollection_Dxe.inf b/RedfishClientPkg/Converter/LogEntryCollection/RedfishLogEntryCollection_Dxe.inf new file mode 100644 index 00000000000..cc75c824a07 --- /dev/null +++ b/RedfishClientPkg/Converter/LogEntryCollection/RedfishLogEntryCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogEntryCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogEntryCollection_Dxe + FILE_GUID = a1cd3885-0479-4819-95d9-28fefa5e3fa5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogEntryCollectionEntryPoint + UNLOAD_IMAGE = RedfishLogEntryCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogEntryCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogEntryCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogService/v1_0_0/LogService_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/LogService/v1_0_0/LogService_V1_0_0_Dxe.c new file mode 100644 index 00000000000..2791e0b885c --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_0_0/LogService_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogService.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogService"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogService V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogService", + "1", + "0", + "0" + }, + "LogService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_0_0 *LogServiceV1_0_0; + EFI_REDFISH_LOGSERVICE_V1_0_0_CS *LogServiceV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogService_V1_0_0_To_CS (ResoruceRaw, &LogServiceV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogServiceV1_0_0 = (EFI_REDFISH_LOGSERVICE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGSERVICE_V1_0_0)); + if (LogServiceV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogServiceV1_0_0; + LogServiceV1_0_0->LogService = LogServiceV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogService"), "LogService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogService"), "LogService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogService_V1_0_0_JSON (*((EFI_REDFISH_LOGSERVICE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_0_0 *LogServiceV1_0_0; + + LogServiceV1_0_0 = (EFI_REDFISH_LOGSERVICE_V1_0_0 *)InterpProp; + DestroyLogService_V1_0_0_CS (LogServiceV1_0_0->LogService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogService_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogServiceToStructWrapper, + LogServiceToJson, + LogServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogService/v1_0_0/RedfishLogService_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/LogService/v1_0_0/RedfishLogService_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..226680770a9 --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_0_0/RedfishLogService_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogService.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogService_V1_0_0_Dxe + FILE_GUID = 53d8efb8-31f9-4195-9f15-88f5bca31f62 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogService_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishLogService_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogService_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogServiceV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogService/v1_0_2/LogService_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/LogService/v1_0_2/LogService_V1_0_2_Dxe.c new file mode 100644 index 00000000000..b37d7545c8e --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_0_2/LogService_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogService.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogService"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogService V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogService", + "1", + "0", + "2" + }, + "LogService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_0_2 *LogServiceV1_0_2; + EFI_REDFISH_LOGSERVICE_V1_0_2_CS *LogServiceV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogService_V1_0_2_To_CS (ResoruceRaw, &LogServiceV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogServiceV1_0_2 = (EFI_REDFISH_LOGSERVICE_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGSERVICE_V1_0_2)); + if (LogServiceV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogServiceV1_0_2; + LogServiceV1_0_2->LogService = LogServiceV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogService"), "LogService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogService"), "LogService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogService_V1_0_2_JSON (*((EFI_REDFISH_LOGSERVICE_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_0_2 *LogServiceV1_0_2; + + LogServiceV1_0_2 = (EFI_REDFISH_LOGSERVICE_V1_0_2 *)InterpProp; + DestroyLogService_V1_0_2_CS (LogServiceV1_0_2->LogService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogService_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogServiceToStructWrapper, + LogServiceToJson, + LogServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogService/v1_0_2/RedfishLogService_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/LogService/v1_0_2/RedfishLogService_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..0a6f60367bb --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_0_2/RedfishLogService_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogService.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogService_V1_0_2_Dxe + FILE_GUID = a918f364-3bc8-4679-876b-8e039d59cda6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogService_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishLogService_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogService_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogServiceV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogService/v1_0_3/LogService_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/LogService/v1_0_3/LogService_V1_0_3_Dxe.c new file mode 100644 index 00000000000..e05b75ab613 --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_0_3/LogService_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogService.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogService"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogService V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogService", + "1", + "0", + "3" + }, + "LogService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_0_3 *LogServiceV1_0_3; + EFI_REDFISH_LOGSERVICE_V1_0_3_CS *LogServiceV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogService_V1_0_3_To_CS (ResoruceRaw, &LogServiceV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogServiceV1_0_3 = (EFI_REDFISH_LOGSERVICE_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGSERVICE_V1_0_3)); + if (LogServiceV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogServiceV1_0_3; + LogServiceV1_0_3->LogService = LogServiceV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogService"), "LogService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogService"), "LogService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogService_V1_0_3_JSON (*((EFI_REDFISH_LOGSERVICE_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_0_3 *LogServiceV1_0_3; + + LogServiceV1_0_3 = (EFI_REDFISH_LOGSERVICE_V1_0_3 *)InterpProp; + DestroyLogService_V1_0_3_CS (LogServiceV1_0_3->LogService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogService_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogServiceToStructWrapper, + LogServiceToJson, + LogServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogService/v1_0_3/RedfishLogService_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/LogService/v1_0_3/RedfishLogService_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..dc38161a838 --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_0_3/RedfishLogService_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogService.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogService_V1_0_3_Dxe + FILE_GUID = c5ba973f-24d0-4896-8648-8bbc2b9a4c27 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogService_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishLogService_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogService_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogServiceV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogService/v1_0_4/LogService_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/LogService/v1_0_4/LogService_V1_0_4_Dxe.c new file mode 100644 index 00000000000..320d7b18b31 --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_0_4/LogService_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogService.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogService"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogService V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogService", + "1", + "0", + "4" + }, + "LogService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_0_4 *LogServiceV1_0_4; + EFI_REDFISH_LOGSERVICE_V1_0_4_CS *LogServiceV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogService_V1_0_4_To_CS (ResoruceRaw, &LogServiceV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogServiceV1_0_4 = (EFI_REDFISH_LOGSERVICE_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGSERVICE_V1_0_4)); + if (LogServiceV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogServiceV1_0_4; + LogServiceV1_0_4->LogService = LogServiceV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogService"), "LogService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogService"), "LogService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogService_V1_0_4_JSON (*((EFI_REDFISH_LOGSERVICE_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_0_4 *LogServiceV1_0_4; + + LogServiceV1_0_4 = (EFI_REDFISH_LOGSERVICE_V1_0_4 *)InterpProp; + DestroyLogService_V1_0_4_CS (LogServiceV1_0_4->LogService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogService_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogServiceToStructWrapper, + LogServiceToJson, + LogServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogService/v1_0_4/RedfishLogService_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/LogService/v1_0_4/RedfishLogService_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..161fb259d97 --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_0_4/RedfishLogService_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogService.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogService_V1_0_4_Dxe + FILE_GUID = 0c896a8a-0b8b-4f8d-9445-336b9ad1b602 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogService_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishLogService_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogService_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogServiceV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogService/v1_0_5/LogService_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/LogService/v1_0_5/LogService_V1_0_5_Dxe.c new file mode 100644 index 00000000000..a5540412823 --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_0_5/LogService_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogService.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogService"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogService V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogService", + "1", + "0", + "5" + }, + "LogService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_0_5 *LogServiceV1_0_5; + EFI_REDFISH_LOGSERVICE_V1_0_5_CS *LogServiceV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogService_V1_0_5_To_CS (ResoruceRaw, &LogServiceV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogServiceV1_0_5 = (EFI_REDFISH_LOGSERVICE_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGSERVICE_V1_0_5)); + if (LogServiceV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogServiceV1_0_5; + LogServiceV1_0_5->LogService = LogServiceV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogService"), "LogService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogService"), "LogService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogService_V1_0_5_JSON (*((EFI_REDFISH_LOGSERVICE_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_0_5 *LogServiceV1_0_5; + + LogServiceV1_0_5 = (EFI_REDFISH_LOGSERVICE_V1_0_5 *)InterpProp; + DestroyLogService_V1_0_5_CS (LogServiceV1_0_5->LogService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogService_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogServiceToStructWrapper, + LogServiceToJson, + LogServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogService/v1_0_5/RedfishLogService_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/LogService/v1_0_5/RedfishLogService_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..792770cb5df --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_0_5/RedfishLogService_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogService.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogService_V1_0_5_Dxe + FILE_GUID = 0b9913e1-9006-4109-8a01-0184fc94eb88 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogService_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishLogService_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogService_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogServiceV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogService/v1_0_6/LogService_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/LogService/v1_0_6/LogService_V1_0_6_Dxe.c new file mode 100644 index 00000000000..50f7be88b34 --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_0_6/LogService_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogService.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogService"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogService V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogService", + "1", + "0", + "6" + }, + "LogService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_0_6 *LogServiceV1_0_6; + EFI_REDFISH_LOGSERVICE_V1_0_6_CS *LogServiceV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogService_V1_0_6_To_CS (ResoruceRaw, &LogServiceV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogServiceV1_0_6 = (EFI_REDFISH_LOGSERVICE_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGSERVICE_V1_0_6)); + if (LogServiceV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogServiceV1_0_6; + LogServiceV1_0_6->LogService = LogServiceV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogService"), "LogService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogService"), "LogService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogService_V1_0_6_JSON (*((EFI_REDFISH_LOGSERVICE_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_0_6 *LogServiceV1_0_6; + + LogServiceV1_0_6 = (EFI_REDFISH_LOGSERVICE_V1_0_6 *)InterpProp; + DestroyLogService_V1_0_6_CS (LogServiceV1_0_6->LogService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogService_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogServiceToStructWrapper, + LogServiceToJson, + LogServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogService/v1_0_6/RedfishLogService_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/LogService/v1_0_6/RedfishLogService_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..b0bb74be9f2 --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_0_6/RedfishLogService_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogService.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogService_V1_0_6_Dxe + FILE_GUID = c8988ffd-51bd-4144-a68c-7616d2063836 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogService_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishLogService_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogService_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogServiceV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogService/v1_0_7/LogService_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/LogService/v1_0_7/LogService_V1_0_7_Dxe.c new file mode 100644 index 00000000000..aa24174ab0c --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_0_7/LogService_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogService.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogService"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogService V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogService", + "1", + "0", + "7" + }, + "LogService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_0_7 *LogServiceV1_0_7; + EFI_REDFISH_LOGSERVICE_V1_0_7_CS *LogServiceV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogService_V1_0_7_To_CS (ResoruceRaw, &LogServiceV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogServiceV1_0_7 = (EFI_REDFISH_LOGSERVICE_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGSERVICE_V1_0_7)); + if (LogServiceV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogServiceV1_0_7; + LogServiceV1_0_7->LogService = LogServiceV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogService"), "LogService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogService"), "LogService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogService_V1_0_7_JSON (*((EFI_REDFISH_LOGSERVICE_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_0_7 *LogServiceV1_0_7; + + LogServiceV1_0_7 = (EFI_REDFISH_LOGSERVICE_V1_0_7 *)InterpProp; + DestroyLogService_V1_0_7_CS (LogServiceV1_0_7->LogService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogService_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogServiceToStructWrapper, + LogServiceToJson, + LogServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogService/v1_0_7/RedfishLogService_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/LogService/v1_0_7/RedfishLogService_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..69589e79e8b --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_0_7/RedfishLogService_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogService.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogService_V1_0_7_Dxe + FILE_GUID = baff4c2f-2238-4183-9a11-ef07d263d824 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogService_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishLogService_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogService_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogServiceV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogService/v1_0_8/LogService_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/LogService/v1_0_8/LogService_V1_0_8_Dxe.c new file mode 100644 index 00000000000..14e7194363f --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_0_8/LogService_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogService.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogService"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogService V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogService", + "1", + "0", + "8" + }, + "LogService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_0_8 *LogServiceV1_0_8; + EFI_REDFISH_LOGSERVICE_V1_0_8_CS *LogServiceV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogService_V1_0_8_To_CS (ResoruceRaw, &LogServiceV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogServiceV1_0_8 = (EFI_REDFISH_LOGSERVICE_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGSERVICE_V1_0_8)); + if (LogServiceV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogServiceV1_0_8; + LogServiceV1_0_8->LogService = LogServiceV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogService"), "LogService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogService"), "LogService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogService_V1_0_8_JSON (*((EFI_REDFISH_LOGSERVICE_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_0_8 *LogServiceV1_0_8; + + LogServiceV1_0_8 = (EFI_REDFISH_LOGSERVICE_V1_0_8 *)InterpProp; + DestroyLogService_V1_0_8_CS (LogServiceV1_0_8->LogService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogService_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogServiceToStructWrapper, + LogServiceToJson, + LogServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogService/v1_0_8/RedfishLogService_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/LogService/v1_0_8/RedfishLogService_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..961f6be9855 --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_0_8/RedfishLogService_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogService.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogService_V1_0_8_Dxe + FILE_GUID = be139a4e-20ec-4eff-be3b-7de325e60dbb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogService_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishLogService_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogService_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogServiceV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogService/v1_1_0/LogService_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/LogService/v1_1_0/LogService_V1_1_0_Dxe.c new file mode 100644 index 00000000000..301979bf7e7 --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_1_0/LogService_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogService.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogService"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogService V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogService", + "1", + "1", + "0" + }, + "LogService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_1_0 *LogServiceV1_1_0; + EFI_REDFISH_LOGSERVICE_V1_1_0_CS *LogServiceV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogService_V1_1_0_To_CS (ResoruceRaw, &LogServiceV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogServiceV1_1_0 = (EFI_REDFISH_LOGSERVICE_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGSERVICE_V1_1_0)); + if (LogServiceV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogServiceV1_1_0; + LogServiceV1_1_0->LogService = LogServiceV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogService"), "LogService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogService"), "LogService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogService_V1_1_0_JSON (*((EFI_REDFISH_LOGSERVICE_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_1_0 *LogServiceV1_1_0; + + LogServiceV1_1_0 = (EFI_REDFISH_LOGSERVICE_V1_1_0 *)InterpProp; + DestroyLogService_V1_1_0_CS (LogServiceV1_1_0->LogService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogService_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogServiceToStructWrapper, + LogServiceToJson, + LogServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogService/v1_1_0/RedfishLogService_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/LogService/v1_1_0/RedfishLogService_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..fd5cf75ddee --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_1_0/RedfishLogService_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogService.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogService_V1_1_0_Dxe + FILE_GUID = 11692902-c53c-4978-bd64-37fe74f28b7d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogService_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishLogService_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogService_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogServiceV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogService/v1_1_1/LogService_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/LogService/v1_1_1/LogService_V1_1_1_Dxe.c new file mode 100644 index 00000000000..aeff23acc40 --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_1_1/LogService_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogService.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogService"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogService V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogService", + "1", + "1", + "1" + }, + "LogService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_1_1 *LogServiceV1_1_1; + EFI_REDFISH_LOGSERVICE_V1_1_1_CS *LogServiceV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogService_V1_1_1_To_CS (ResoruceRaw, &LogServiceV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogServiceV1_1_1 = (EFI_REDFISH_LOGSERVICE_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGSERVICE_V1_1_1)); + if (LogServiceV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogServiceV1_1_1; + LogServiceV1_1_1->LogService = LogServiceV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogService"), "LogService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogService"), "LogService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogService_V1_1_1_JSON (*((EFI_REDFISH_LOGSERVICE_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_1_1 *LogServiceV1_1_1; + + LogServiceV1_1_1 = (EFI_REDFISH_LOGSERVICE_V1_1_1 *)InterpProp; + DestroyLogService_V1_1_1_CS (LogServiceV1_1_1->LogService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogService_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogServiceToStructWrapper, + LogServiceToJson, + LogServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogService/v1_1_1/RedfishLogService_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/LogService/v1_1_1/RedfishLogService_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..6da4f82ad42 --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_1_1/RedfishLogService_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogService.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogService_V1_1_1_Dxe + FILE_GUID = 15acf21d-6cb0-4c80-87f9-ed221302800a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogService_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishLogService_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogService_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogServiceV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogService/v1_1_2/LogService_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/LogService/v1_1_2/LogService_V1_1_2_Dxe.c new file mode 100644 index 00000000000..4b3d21b05a0 --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_1_2/LogService_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogService.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogService"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogService V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogService", + "1", + "1", + "2" + }, + "LogService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_1_2 *LogServiceV1_1_2; + EFI_REDFISH_LOGSERVICE_V1_1_2_CS *LogServiceV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogService_V1_1_2_To_CS (ResoruceRaw, &LogServiceV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogServiceV1_1_2 = (EFI_REDFISH_LOGSERVICE_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGSERVICE_V1_1_2)); + if (LogServiceV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogServiceV1_1_2; + LogServiceV1_1_2->LogService = LogServiceV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogService"), "LogService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogService"), "LogService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogService_V1_1_2_JSON (*((EFI_REDFISH_LOGSERVICE_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_1_2 *LogServiceV1_1_2; + + LogServiceV1_1_2 = (EFI_REDFISH_LOGSERVICE_V1_1_2 *)InterpProp; + DestroyLogService_V1_1_2_CS (LogServiceV1_1_2->LogService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogService_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogServiceToStructWrapper, + LogServiceToJson, + LogServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogService/v1_1_2/RedfishLogService_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/LogService/v1_1_2/RedfishLogService_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..bb2b94b071b --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_1_2/RedfishLogService_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogService.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogService_V1_1_2_Dxe + FILE_GUID = 512a64d7-ff8a-4542-95ab-a203a809475b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogService_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishLogService_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogService_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogServiceV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogService/v1_1_3/LogService_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/LogService/v1_1_3/LogService_V1_1_3_Dxe.c new file mode 100644 index 00000000000..fabdf3a1b93 --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_1_3/LogService_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogService.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogService"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogService V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogService", + "1", + "1", + "3" + }, + "LogService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_1_3 *LogServiceV1_1_3; + EFI_REDFISH_LOGSERVICE_V1_1_3_CS *LogServiceV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogService_V1_1_3_To_CS (ResoruceRaw, &LogServiceV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogServiceV1_1_3 = (EFI_REDFISH_LOGSERVICE_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGSERVICE_V1_1_3)); + if (LogServiceV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogServiceV1_1_3; + LogServiceV1_1_3->LogService = LogServiceV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogService"), "LogService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogService"), "LogService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogService_V1_1_3_JSON (*((EFI_REDFISH_LOGSERVICE_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_1_3 *LogServiceV1_1_3; + + LogServiceV1_1_3 = (EFI_REDFISH_LOGSERVICE_V1_1_3 *)InterpProp; + DestroyLogService_V1_1_3_CS (LogServiceV1_1_3->LogService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogService_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogServiceToStructWrapper, + LogServiceToJson, + LogServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogService/v1_1_3/RedfishLogService_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/LogService/v1_1_3/RedfishLogService_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..a3958da462d --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_1_3/RedfishLogService_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogService.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogService_V1_1_3_Dxe + FILE_GUID = ecd7dbed-2743-4a34-a694-509e8ad3119d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogService_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishLogService_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogService_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogServiceV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogService/v1_2_0/LogService_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/LogService/v1_2_0/LogService_V1_2_0_Dxe.c new file mode 100644 index 00000000000..95495b52105 --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_2_0/LogService_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogService.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogService"; +BOOLEAN IsRevisonController = TRUE; + +// Support LogService V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogService", + "1", + "2", + "0" + }, + "LogService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_2_0 *LogServiceV1_2_0; + EFI_REDFISH_LOGSERVICE_V1_2_0_CS *LogServiceV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogService_V1_2_0_To_CS (ResoruceRaw, &LogServiceV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + LogServiceV1_2_0 = (EFI_REDFISH_LOGSERVICE_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGSERVICE_V1_2_0)); + if (LogServiceV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogServiceV1_2_0; + LogServiceV1_2_0->LogService = LogServiceV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogService"), "LogService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogService"), "LogService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogService_V1_2_0_JSON (*((EFI_REDFISH_LOGSERVICE_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGSERVICE_V1_2_0 *LogServiceV1_2_0; + + LogServiceV1_2_0 = (EFI_REDFISH_LOGSERVICE_V1_2_0 *)InterpProp; + DestroyLogService_V1_2_0_CS (LogServiceV1_2_0->LogService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogService_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogServiceToStructWrapper, + LogServiceToJson, + LogServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogService_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogService/v1_2_0/RedfishLogService_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/LogService/v1_2_0/RedfishLogService_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..565f76af0bb --- /dev/null +++ b/RedfishClientPkg/Converter/LogService/v1_2_0/RedfishLogService_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogService.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogService_V1_2_0_Dxe + FILE_GUID = 3119037c-d41b-4e39-9be0-8ae2e1e62989 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogService_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishLogService_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogService_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogServiceV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/LogServiceCollection/LogServiceCollection_Dxe.c b/RedfishClientPkg/Converter/LogServiceCollection/LogServiceCollection_Dxe.c new file mode 100644 index 00000000000..88291a1f4b9 --- /dev/null +++ b/RedfishClientPkg/Converter/LogServiceCollection/LogServiceCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - LogServiceCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#LogServiceCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support LogServiceCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "LogServiceCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "LogServiceCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_LOGSERVICECOLLECTION *LogServiceCollection; + EFI_REDFISH_LOGSERVICECOLLECTION_CS *LogServiceCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "LogServiceCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_LogServiceCollection_To_CS (ResoruceRaw, &LogServiceCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + LogServiceCollection = (EFI_REDFISH_LOGSERVICECOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_LOGSERVICECOLLECTION)); + if (LogServiceCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)LogServiceCollection; + LogServiceCollection->LogServiceCollection = LogServiceCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("LogServiceCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("LogServiceCollection"), "LogServiceCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("LogServiceCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("LogServiceCollection"), "LogServiceCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of LogServiceCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return LogServiceCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_LogServiceCollection_JSON (*((EFI_REDFISH_LOGSERVICECOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in LogServiceCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_LOGSERVICECOLLECTION *LogServiceCollection; + + LogServiceCollection = (EFI_REDFISH_LOGSERVICECOLLECTION *)InterpProp; + DestroyLogServiceCollection_CS (LogServiceCollection->LogServiceCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from LogServiceCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +LogServiceCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyLogServiceCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishLogServiceCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + LogServiceCollectionToStructWrapper, + LogServiceCollectionToJson, + LogServiceCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishLogServiceCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/LogServiceCollection/RedfishLogServiceCollection_Dxe.inf b/RedfishClientPkg/Converter/LogServiceCollection/RedfishLogServiceCollection_Dxe.inf new file mode 100644 index 00000000000..7878dc24f27 --- /dev/null +++ b/RedfishClientPkg/Converter/LogServiceCollection/RedfishLogServiceCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of LogServiceCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishLogServiceCollection_Dxe + FILE_GUID = 2fcbecee-c165-4275-893b-db01879ef78c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishLogServiceCollectionEntryPoint + UNLOAD_IMAGE = RedfishLogServiceCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + LogServiceCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + LogServiceCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_0_0/Manager_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_0_0/Manager_V1_0_0_Dxe.c new file mode 100644 index 00000000000..46018c0b891 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_0/Manager_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "0", + "0" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_0 *ManagerV1_0_0; + EFI_REDFISH_MANAGER_V1_0_0_CS *ManagerV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_0_0_To_CS (ResoruceRaw, &ManagerV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_0_0 = (EFI_REDFISH_MANAGER_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_0_0)); + if (ManagerV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_0_0; + ManagerV1_0_0->Manager = ManagerV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_0_0_JSON (*((EFI_REDFISH_MANAGER_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_0 *ManagerV1_0_0; + + ManagerV1_0_0 = (EFI_REDFISH_MANAGER_V1_0_0 *)InterpProp; + DestroyManager_V1_0_0_CS (ManagerV1_0_0->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_0_0/RedfishManager_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_0_0/RedfishManager_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..ad055e8d397 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_0/RedfishManager_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_0_0_Dxe + FILE_GUID = de45a221-45c1-46fe-90be-7f8e4523abe9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_0_1/Manager_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_0_1/Manager_V1_0_1_Dxe.c new file mode 100644 index 00000000000..7789a8650c9 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_1/Manager_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "0", + "1" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_1 *ManagerV1_0_1; + EFI_REDFISH_MANAGER_V1_0_1_CS *ManagerV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_0_1_To_CS (ResoruceRaw, &ManagerV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_0_1 = (EFI_REDFISH_MANAGER_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_0_1)); + if (ManagerV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_0_1; + ManagerV1_0_1->Manager = ManagerV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_0_1_JSON (*((EFI_REDFISH_MANAGER_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_1 *ManagerV1_0_1; + + ManagerV1_0_1 = (EFI_REDFISH_MANAGER_V1_0_1 *)InterpProp; + DestroyManager_V1_0_1_CS (ManagerV1_0_1->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_0_1/RedfishManager_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_0_1/RedfishManager_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..4489be49a74 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_1/RedfishManager_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_0_1_Dxe + FILE_GUID = fbc05269-297d-40f9-a500-1ba179e74df3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_0_10/Manager_V1_0_10_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_0_10/Manager_V1_0_10_Dxe.c new file mode 100644 index 00000000000..33a7f4fe720 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_10/Manager_V1_0_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_0_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "0", + "10" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_10 *ManagerV1_0_10; + EFI_REDFISH_MANAGER_V1_0_10_CS *ManagerV1_0_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_0_10_To_CS (ResoruceRaw, &ManagerV1_0_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_0_10 = (EFI_REDFISH_MANAGER_V1_0_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_0_10)); + if (ManagerV1_0_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_0_10; + ManagerV1_0_10->Manager = ManagerV1_0_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_0_10_JSON (*((EFI_REDFISH_MANAGER_V1_0_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_10 *ManagerV1_0_10; + + ManagerV1_0_10 = (EFI_REDFISH_MANAGER_V1_0_10 *)InterpProp; + DestroyManager_V1_0_10_CS (ManagerV1_0_10->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_0_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_0_10/RedfishManager_V1_0_10_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_0_10/RedfishManager_V1_0_10_Dxe.inf new file mode 100644 index 00000000000..2b721bc434a --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_10/RedfishManager_V1_0_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_0_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_0_10_Dxe + FILE_GUID = 23ebe021-4ccf-446f-801d-0d50b7ac828a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_0_10EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_0_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_0_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_0_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_0_11/Manager_V1_0_11_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_0_11/Manager_V1_0_11_Dxe.c new file mode 100644 index 00000000000..38bbb90a7d5 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_11/Manager_V1_0_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_0_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "0", + "11" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_11 *ManagerV1_0_11; + EFI_REDFISH_MANAGER_V1_0_11_CS *ManagerV1_0_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_0_11_To_CS (ResoruceRaw, &ManagerV1_0_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_0_11 = (EFI_REDFISH_MANAGER_V1_0_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_0_11)); + if (ManagerV1_0_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_0_11; + ManagerV1_0_11->Manager = ManagerV1_0_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_0_11_JSON (*((EFI_REDFISH_MANAGER_V1_0_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_11 *ManagerV1_0_11; + + ManagerV1_0_11 = (EFI_REDFISH_MANAGER_V1_0_11 *)InterpProp; + DestroyManager_V1_0_11_CS (ManagerV1_0_11->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_0_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_0_11/RedfishManager_V1_0_11_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_0_11/RedfishManager_V1_0_11_Dxe.inf new file mode 100644 index 00000000000..d0d9e32c91e --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_11/RedfishManager_V1_0_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_0_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_0_11_Dxe + FILE_GUID = 4b538e13-c93b-455a-992a-d2cad16d5afd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_0_11EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_0_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_0_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_0_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_0_12/Manager_V1_0_12_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_0_12/Manager_V1_0_12_Dxe.c new file mode 100644 index 00000000000..d5da991e10b --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_12/Manager_V1_0_12_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_0_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_0_12 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "0", + "12" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_12 *ManagerV1_0_12; + EFI_REDFISH_MANAGER_V1_0_12_CS *ManagerV1_0_12Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "12") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_0_12_To_CS (ResoruceRaw, &ManagerV1_0_12Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_0_12 = (EFI_REDFISH_MANAGER_V1_0_12 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_0_12)); + if (ManagerV1_0_12 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_0_12; + ManagerV1_0_12->Manager = ManagerV1_0_12Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "12"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_0_12_JSON (*((EFI_REDFISH_MANAGER_V1_0_12_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_12 *ManagerV1_0_12; + + ManagerV1_0_12 = (EFI_REDFISH_MANAGER_V1_0_12 *)InterpProp; + DestroyManager_V1_0_12_CS (ManagerV1_0_12->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_0_12_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_12EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_12Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_0_12/RedfishManager_V1_0_12_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_0_12/RedfishManager_V1_0_12_Dxe.inf new file mode 100644 index 00000000000..3475f6362d7 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_12/RedfishManager_V1_0_12_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_0_12 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_0_12_Dxe + FILE_GUID = 4b43412b-5637-416e-aeae-b7b1092ef886 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_0_12EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_0_12Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_0_12_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_0_12Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_0_13/Manager_V1_0_13_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_0_13/Manager_V1_0_13_Dxe.c new file mode 100644 index 00000000000..402a9edc748 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_13/Manager_V1_0_13_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_0_13 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_0_13 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "0", + "13" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_13 *ManagerV1_0_13; + EFI_REDFISH_MANAGER_V1_0_13_CS *ManagerV1_0_13Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "13") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_0_13_To_CS (ResoruceRaw, &ManagerV1_0_13Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_0_13 = (EFI_REDFISH_MANAGER_V1_0_13 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_0_13)); + if (ManagerV1_0_13 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_0_13; + ManagerV1_0_13->Manager = ManagerV1_0_13Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "13"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_0_13_JSON (*((EFI_REDFISH_MANAGER_V1_0_13_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_13 *ManagerV1_0_13; + + ManagerV1_0_13 = (EFI_REDFISH_MANAGER_V1_0_13 *)InterpProp; + DestroyManager_V1_0_13_CS (ManagerV1_0_13->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_0_13_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_13EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_13Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_0_13/RedfishManager_V1_0_13_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_0_13/RedfishManager_V1_0_13_Dxe.inf new file mode 100644 index 00000000000..b80ca1da3a7 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_13/RedfishManager_V1_0_13_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_0_13 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_0_13_Dxe + FILE_GUID = 2748423f-5fd0-4348-99c8-bab351a8c3a5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_0_13EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_0_13Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_0_13_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_0_13Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_0_14/Manager_V1_0_14_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_0_14/Manager_V1_0_14_Dxe.c new file mode 100644 index 00000000000..16cb1cd52b8 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_14/Manager_V1_0_14_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_0_14 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_0_14 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "0", + "14" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_14 *ManagerV1_0_14; + EFI_REDFISH_MANAGER_V1_0_14_CS *ManagerV1_0_14Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "14") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_0_14_To_CS (ResoruceRaw, &ManagerV1_0_14Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_0_14 = (EFI_REDFISH_MANAGER_V1_0_14 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_0_14)); + if (ManagerV1_0_14 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_0_14; + ManagerV1_0_14->Manager = ManagerV1_0_14Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "14"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_0_14_JSON (*((EFI_REDFISH_MANAGER_V1_0_14_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_14 *ManagerV1_0_14; + + ManagerV1_0_14 = (EFI_REDFISH_MANAGER_V1_0_14 *)InterpProp; + DestroyManager_V1_0_14_CS (ManagerV1_0_14->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_0_14_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_14EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_14Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_0_14/RedfishManager_V1_0_14_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_0_14/RedfishManager_V1_0_14_Dxe.inf new file mode 100644 index 00000000000..c5d478be55a --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_14/RedfishManager_V1_0_14_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_0_14 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_0_14_Dxe + FILE_GUID = 2f60ff79-526a-408f-a493-d00b99425e63 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_0_14EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_0_14Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_0_14_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_0_14Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_0_2/Manager_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_0_2/Manager_V1_0_2_Dxe.c new file mode 100644 index 00000000000..93f511c4f5a --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_2/Manager_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "0", + "2" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_2 *ManagerV1_0_2; + EFI_REDFISH_MANAGER_V1_0_2_CS *ManagerV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_0_2_To_CS (ResoruceRaw, &ManagerV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_0_2 = (EFI_REDFISH_MANAGER_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_0_2)); + if (ManagerV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_0_2; + ManagerV1_0_2->Manager = ManagerV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_0_2_JSON (*((EFI_REDFISH_MANAGER_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_2 *ManagerV1_0_2; + + ManagerV1_0_2 = (EFI_REDFISH_MANAGER_V1_0_2 *)InterpProp; + DestroyManager_V1_0_2_CS (ManagerV1_0_2->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_0_2/RedfishManager_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_0_2/RedfishManager_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..606570f01e1 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_2/RedfishManager_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_0_2_Dxe + FILE_GUID = c47564c5-5bc2-4870-a757-8e5ee0944ada + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_0_3/Manager_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_0_3/Manager_V1_0_3_Dxe.c new file mode 100644 index 00000000000..e6dbda278ef --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_3/Manager_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "0", + "3" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_3 *ManagerV1_0_3; + EFI_REDFISH_MANAGER_V1_0_3_CS *ManagerV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_0_3_To_CS (ResoruceRaw, &ManagerV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_0_3 = (EFI_REDFISH_MANAGER_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_0_3)); + if (ManagerV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_0_3; + ManagerV1_0_3->Manager = ManagerV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_0_3_JSON (*((EFI_REDFISH_MANAGER_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_3 *ManagerV1_0_3; + + ManagerV1_0_3 = (EFI_REDFISH_MANAGER_V1_0_3 *)InterpProp; + DestroyManager_V1_0_3_CS (ManagerV1_0_3->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_0_3/RedfishManager_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_0_3/RedfishManager_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..d961e3d2849 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_3/RedfishManager_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_0_3_Dxe + FILE_GUID = 2ae4c969-9271-4ec6-873c-d7e76fea9c45 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_0_4/Manager_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_0_4/Manager_V1_0_4_Dxe.c new file mode 100644 index 00000000000..8d56a86f7ac --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_4/Manager_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "0", + "4" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_4 *ManagerV1_0_4; + EFI_REDFISH_MANAGER_V1_0_4_CS *ManagerV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_0_4_To_CS (ResoruceRaw, &ManagerV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_0_4 = (EFI_REDFISH_MANAGER_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_0_4)); + if (ManagerV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_0_4; + ManagerV1_0_4->Manager = ManagerV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_0_4_JSON (*((EFI_REDFISH_MANAGER_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_4 *ManagerV1_0_4; + + ManagerV1_0_4 = (EFI_REDFISH_MANAGER_V1_0_4 *)InterpProp; + DestroyManager_V1_0_4_CS (ManagerV1_0_4->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_0_4/RedfishManager_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_0_4/RedfishManager_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..eda775a3fe1 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_4/RedfishManager_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_0_4_Dxe + FILE_GUID = 0a49bd2b-8b9e-4b10-b915-dcf5bbff6758 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_0_5/Manager_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_0_5/Manager_V1_0_5_Dxe.c new file mode 100644 index 00000000000..af69793da39 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_5/Manager_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "0", + "5" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_5 *ManagerV1_0_5; + EFI_REDFISH_MANAGER_V1_0_5_CS *ManagerV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_0_5_To_CS (ResoruceRaw, &ManagerV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_0_5 = (EFI_REDFISH_MANAGER_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_0_5)); + if (ManagerV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_0_5; + ManagerV1_0_5->Manager = ManagerV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_0_5_JSON (*((EFI_REDFISH_MANAGER_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_5 *ManagerV1_0_5; + + ManagerV1_0_5 = (EFI_REDFISH_MANAGER_V1_0_5 *)InterpProp; + DestroyManager_V1_0_5_CS (ManagerV1_0_5->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_0_5/RedfishManager_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_0_5/RedfishManager_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..767e0977902 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_5/RedfishManager_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_0_5_Dxe + FILE_GUID = 442504cf-b27e-4202-b72c-540669141441 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_0_6/Manager_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_0_6/Manager_V1_0_6_Dxe.c new file mode 100644 index 00000000000..c8a9020610b --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_6/Manager_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "0", + "6" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_6 *ManagerV1_0_6; + EFI_REDFISH_MANAGER_V1_0_6_CS *ManagerV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_0_6_To_CS (ResoruceRaw, &ManagerV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_0_6 = (EFI_REDFISH_MANAGER_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_0_6)); + if (ManagerV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_0_6; + ManagerV1_0_6->Manager = ManagerV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_0_6_JSON (*((EFI_REDFISH_MANAGER_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_6 *ManagerV1_0_6; + + ManagerV1_0_6 = (EFI_REDFISH_MANAGER_V1_0_6 *)InterpProp; + DestroyManager_V1_0_6_CS (ManagerV1_0_6->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_0_6/RedfishManager_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_0_6/RedfishManager_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..7602f8f034b --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_6/RedfishManager_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_0_6_Dxe + FILE_GUID = f806b91b-dcdf-48ab-a7b5-76011a616dbd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_0_7/Manager_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_0_7/Manager_V1_0_7_Dxe.c new file mode 100644 index 00000000000..147ad93b16f --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_7/Manager_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "0", + "7" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_7 *ManagerV1_0_7; + EFI_REDFISH_MANAGER_V1_0_7_CS *ManagerV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_0_7_To_CS (ResoruceRaw, &ManagerV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_0_7 = (EFI_REDFISH_MANAGER_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_0_7)); + if (ManagerV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_0_7; + ManagerV1_0_7->Manager = ManagerV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_0_7_JSON (*((EFI_REDFISH_MANAGER_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_7 *ManagerV1_0_7; + + ManagerV1_0_7 = (EFI_REDFISH_MANAGER_V1_0_7 *)InterpProp; + DestroyManager_V1_0_7_CS (ManagerV1_0_7->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_0_7/RedfishManager_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_0_7/RedfishManager_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..9673b345d50 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_7/RedfishManager_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_0_7_Dxe + FILE_GUID = 1c1bc70d-4ae1-4904-ae94-b1005d2cd61c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_0_8/Manager_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_0_8/Manager_V1_0_8_Dxe.c new file mode 100644 index 00000000000..e70ce05a958 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_8/Manager_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "0", + "8" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_8 *ManagerV1_0_8; + EFI_REDFISH_MANAGER_V1_0_8_CS *ManagerV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_0_8_To_CS (ResoruceRaw, &ManagerV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_0_8 = (EFI_REDFISH_MANAGER_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_0_8)); + if (ManagerV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_0_8; + ManagerV1_0_8->Manager = ManagerV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_0_8_JSON (*((EFI_REDFISH_MANAGER_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_8 *ManagerV1_0_8; + + ManagerV1_0_8 = (EFI_REDFISH_MANAGER_V1_0_8 *)InterpProp; + DestroyManager_V1_0_8_CS (ManagerV1_0_8->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_0_8/RedfishManager_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_0_8/RedfishManager_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..913dd558035 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_8/RedfishManager_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_0_8_Dxe + FILE_GUID = 8b435b09-9535-4f4f-a6cd-9433ac7dc8cc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_0_9/Manager_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_0_9/Manager_V1_0_9_Dxe.c new file mode 100644 index 00000000000..7d6b81e6879 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_9/Manager_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "0", + "9" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_9 *ManagerV1_0_9; + EFI_REDFISH_MANAGER_V1_0_9_CS *ManagerV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_0_9_To_CS (ResoruceRaw, &ManagerV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_0_9 = (EFI_REDFISH_MANAGER_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_0_9)); + if (ManagerV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_0_9; + ManagerV1_0_9->Manager = ManagerV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_0_9_JSON (*((EFI_REDFISH_MANAGER_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_0_9 *ManagerV1_0_9; + + ManagerV1_0_9 = (EFI_REDFISH_MANAGER_V1_0_9 *)InterpProp; + DestroyManager_V1_0_9_CS (ManagerV1_0_9->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_0_9/RedfishManager_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_0_9/RedfishManager_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..4f526511703 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_0_9/RedfishManager_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_0_9_Dxe + FILE_GUID = 1e1b1aec-64c4-4200-acdc-83b2cbf970e4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_10_0/Manager_V1_10_0_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_10_0/Manager_V1_10_0_Dxe.c new file mode 100644 index 00000000000..12ce0a166b9 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_10_0/Manager_V1_10_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_10_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_10_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "10", + "0" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_10_0 *ManagerV1_10_0; + EFI_REDFISH_MANAGER_V1_10_0_CS *ManagerV1_10_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_10_0_To_CS (ResoruceRaw, &ManagerV1_10_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_10_0 = (EFI_REDFISH_MANAGER_V1_10_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_10_0)); + if (ManagerV1_10_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_10_0; + ManagerV1_10_0->Manager = ManagerV1_10_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "10"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_10_0_JSON (*((EFI_REDFISH_MANAGER_V1_10_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_10_0 *ManagerV1_10_0; + + ManagerV1_10_0 = (EFI_REDFISH_MANAGER_V1_10_0 *)InterpProp; + DestroyManager_V1_10_0_CS (ManagerV1_10_0->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_10_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_10_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_10_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_10_0/RedfishManager_V1_10_0_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_10_0/RedfishManager_V1_10_0_Dxe.inf new file mode 100644 index 00000000000..6043242c2cb --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_10_0/RedfishManager_V1_10_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_10_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_10_0_Dxe + FILE_GUID = ce55853f-0d73-4590-b61a-c59feaf1e7c5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_10_0EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_10_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_10_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_10_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_10_1/Manager_V1_10_1_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_10_1/Manager_V1_10_1_Dxe.c new file mode 100644 index 00000000000..37c7cd8050e --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_10_1/Manager_V1_10_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_10_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_10_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "10", + "1" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_10_1 *ManagerV1_10_1; + EFI_REDFISH_MANAGER_V1_10_1_CS *ManagerV1_10_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_10_1_To_CS (ResoruceRaw, &ManagerV1_10_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_10_1 = (EFI_REDFISH_MANAGER_V1_10_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_10_1)); + if (ManagerV1_10_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_10_1; + ManagerV1_10_1->Manager = ManagerV1_10_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "10"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_10_1_JSON (*((EFI_REDFISH_MANAGER_V1_10_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_10_1 *ManagerV1_10_1; + + ManagerV1_10_1 = (EFI_REDFISH_MANAGER_V1_10_1 *)InterpProp; + DestroyManager_V1_10_1_CS (ManagerV1_10_1->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_10_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_10_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_10_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_10_1/RedfishManager_V1_10_1_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_10_1/RedfishManager_V1_10_1_Dxe.inf new file mode 100644 index 00000000000..a8b3b2d70e1 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_10_1/RedfishManager_V1_10_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_10_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_10_1_Dxe + FILE_GUID = 85a37679-fdea-4975-8756-41a66b4d2aef + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_10_1EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_10_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_10_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_10_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_11_0/Manager_V1_11_0_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_11_0/Manager_V1_11_0_Dxe.c new file mode 100644 index 00000000000..94408ddfd97 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_11_0/Manager_V1_11_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_11_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_11_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "11", + "0" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_11_0 *ManagerV1_11_0; + EFI_REDFISH_MANAGER_V1_11_0_CS *ManagerV1_11_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_11_0_To_CS (ResoruceRaw, &ManagerV1_11_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_11_0 = (EFI_REDFISH_MANAGER_V1_11_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_11_0)); + if (ManagerV1_11_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_11_0; + ManagerV1_11_0->Manager = ManagerV1_11_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "11"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_11_0_JSON (*((EFI_REDFISH_MANAGER_V1_11_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_11_0 *ManagerV1_11_0; + + ManagerV1_11_0 = (EFI_REDFISH_MANAGER_V1_11_0 *)InterpProp; + DestroyManager_V1_11_0_CS (ManagerV1_11_0->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_11_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_11_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_11_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_11_0/RedfishManager_V1_11_0_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_11_0/RedfishManager_V1_11_0_Dxe.inf new file mode 100644 index 00000000000..6de6c70af5f --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_11_0/RedfishManager_V1_11_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_11_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_11_0_Dxe + FILE_GUID = b6062c0e-068e-4a44-8357-5560da8ea68c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_11_0EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_11_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_11_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_11_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_1_0/Manager_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_1_0/Manager_V1_1_0_Dxe.c new file mode 100644 index 00000000000..8d6af3896b4 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_0/Manager_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "1", + "0" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_0 *ManagerV1_1_0; + EFI_REDFISH_MANAGER_V1_1_0_CS *ManagerV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_1_0_To_CS (ResoruceRaw, &ManagerV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_1_0 = (EFI_REDFISH_MANAGER_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_1_0)); + if (ManagerV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_1_0; + ManagerV1_1_0->Manager = ManagerV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_1_0_JSON (*((EFI_REDFISH_MANAGER_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_0 *ManagerV1_1_0; + + ManagerV1_1_0 = (EFI_REDFISH_MANAGER_V1_1_0 *)InterpProp; + DestroyManager_V1_1_0_CS (ManagerV1_1_0->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_1_0/RedfishManager_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_1_0/RedfishManager_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..50089732aa9 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_0/RedfishManager_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_1_0_Dxe + FILE_GUID = d5745cbc-65d9-4f35-9386-2f52bb7a3f37 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_1_1/Manager_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_1_1/Manager_V1_1_1_Dxe.c new file mode 100644 index 00000000000..1b8d3bfa6bf --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_1/Manager_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "1", + "1" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_1 *ManagerV1_1_1; + EFI_REDFISH_MANAGER_V1_1_1_CS *ManagerV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_1_1_To_CS (ResoruceRaw, &ManagerV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_1_1 = (EFI_REDFISH_MANAGER_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_1_1)); + if (ManagerV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_1_1; + ManagerV1_1_1->Manager = ManagerV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_1_1_JSON (*((EFI_REDFISH_MANAGER_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_1 *ManagerV1_1_1; + + ManagerV1_1_1 = (EFI_REDFISH_MANAGER_V1_1_1 *)InterpProp; + DestroyManager_V1_1_1_CS (ManagerV1_1_1->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_1_1/RedfishManager_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_1_1/RedfishManager_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..19f1425e5c9 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_1/RedfishManager_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_1_1_Dxe + FILE_GUID = aa0e9229-d0a4-4554-9e87-4e190a535afe + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_1_10/Manager_V1_1_10_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_1_10/Manager_V1_1_10_Dxe.c new file mode 100644 index 00000000000..08227e31121 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_10/Manager_V1_1_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_1_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_1_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "1", + "10" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_10 *ManagerV1_1_10; + EFI_REDFISH_MANAGER_V1_1_10_CS *ManagerV1_1_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_1_10_To_CS (ResoruceRaw, &ManagerV1_1_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_1_10 = (EFI_REDFISH_MANAGER_V1_1_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_1_10)); + if (ManagerV1_1_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_1_10; + ManagerV1_1_10->Manager = ManagerV1_1_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_1_10_JSON (*((EFI_REDFISH_MANAGER_V1_1_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_10 *ManagerV1_1_10; + + ManagerV1_1_10 = (EFI_REDFISH_MANAGER_V1_1_10 *)InterpProp; + DestroyManager_V1_1_10_CS (ManagerV1_1_10->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_1_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_1_10/RedfishManager_V1_1_10_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_1_10/RedfishManager_V1_1_10_Dxe.inf new file mode 100644 index 00000000000..b87a54b38d6 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_10/RedfishManager_V1_1_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_1_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_1_10_Dxe + FILE_GUID = 7a04cf8a-2a04-4b75-b8dc-104ead182a24 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_1_10EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_1_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_1_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_1_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_1_11/Manager_V1_1_11_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_1_11/Manager_V1_1_11_Dxe.c new file mode 100644 index 00000000000..84c2554d956 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_11/Manager_V1_1_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_1_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_1_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "1", + "11" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_11 *ManagerV1_1_11; + EFI_REDFISH_MANAGER_V1_1_11_CS *ManagerV1_1_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_1_11_To_CS (ResoruceRaw, &ManagerV1_1_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_1_11 = (EFI_REDFISH_MANAGER_V1_1_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_1_11)); + if (ManagerV1_1_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_1_11; + ManagerV1_1_11->Manager = ManagerV1_1_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_1_11_JSON (*((EFI_REDFISH_MANAGER_V1_1_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_11 *ManagerV1_1_11; + + ManagerV1_1_11 = (EFI_REDFISH_MANAGER_V1_1_11 *)InterpProp; + DestroyManager_V1_1_11_CS (ManagerV1_1_11->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_1_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_1_11/RedfishManager_V1_1_11_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_1_11/RedfishManager_V1_1_11_Dxe.inf new file mode 100644 index 00000000000..4ad331930dd --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_11/RedfishManager_V1_1_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_1_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_1_11_Dxe + FILE_GUID = 78d6313b-10f6-46c2-8398-67f6c575964a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_1_11EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_1_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_1_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_1_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_1_12/Manager_V1_1_12_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_1_12/Manager_V1_1_12_Dxe.c new file mode 100644 index 00000000000..cfe69092bc9 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_12/Manager_V1_1_12_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_1_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_1_12 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "1", + "12" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_12 *ManagerV1_1_12; + EFI_REDFISH_MANAGER_V1_1_12_CS *ManagerV1_1_12Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "12") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_1_12_To_CS (ResoruceRaw, &ManagerV1_1_12Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_1_12 = (EFI_REDFISH_MANAGER_V1_1_12 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_1_12)); + if (ManagerV1_1_12 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_1_12; + ManagerV1_1_12->Manager = ManagerV1_1_12Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "12"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_1_12_JSON (*((EFI_REDFISH_MANAGER_V1_1_12_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_12 *ManagerV1_1_12; + + ManagerV1_1_12 = (EFI_REDFISH_MANAGER_V1_1_12 *)InterpProp; + DestroyManager_V1_1_12_CS (ManagerV1_1_12->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_1_12_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_12EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_12Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_1_12/RedfishManager_V1_1_12_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_1_12/RedfishManager_V1_1_12_Dxe.inf new file mode 100644 index 00000000000..578bb14ca92 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_12/RedfishManager_V1_1_12_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_1_12 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_1_12_Dxe + FILE_GUID = d4144b3e-811c-4892-aa39-528fb6929bf7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_1_12EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_1_12Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_1_12_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_1_12Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_1_2/Manager_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_1_2/Manager_V1_1_2_Dxe.c new file mode 100644 index 00000000000..de6ab709c3a --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_2/Manager_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "1", + "2" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_2 *ManagerV1_1_2; + EFI_REDFISH_MANAGER_V1_1_2_CS *ManagerV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_1_2_To_CS (ResoruceRaw, &ManagerV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_1_2 = (EFI_REDFISH_MANAGER_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_1_2)); + if (ManagerV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_1_2; + ManagerV1_1_2->Manager = ManagerV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_1_2_JSON (*((EFI_REDFISH_MANAGER_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_2 *ManagerV1_1_2; + + ManagerV1_1_2 = (EFI_REDFISH_MANAGER_V1_1_2 *)InterpProp; + DestroyManager_V1_1_2_CS (ManagerV1_1_2->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_1_2/RedfishManager_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_1_2/RedfishManager_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..70f183339d6 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_2/RedfishManager_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_1_2_Dxe + FILE_GUID = 2e0750cf-3e04-46de-898f-59fff7160bc1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_1_3/Manager_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_1_3/Manager_V1_1_3_Dxe.c new file mode 100644 index 00000000000..fd1633c2e99 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_3/Manager_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "1", + "3" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_3 *ManagerV1_1_3; + EFI_REDFISH_MANAGER_V1_1_3_CS *ManagerV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_1_3_To_CS (ResoruceRaw, &ManagerV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_1_3 = (EFI_REDFISH_MANAGER_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_1_3)); + if (ManagerV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_1_3; + ManagerV1_1_3->Manager = ManagerV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_1_3_JSON (*((EFI_REDFISH_MANAGER_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_3 *ManagerV1_1_3; + + ManagerV1_1_3 = (EFI_REDFISH_MANAGER_V1_1_3 *)InterpProp; + DestroyManager_V1_1_3_CS (ManagerV1_1_3->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_1_3/RedfishManager_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_1_3/RedfishManager_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..51316e1ec6a --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_3/RedfishManager_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_1_3_Dxe + FILE_GUID = e8e844f4-2d1a-4204-b30c-78ad3f67a742 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_1_4/Manager_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_1_4/Manager_V1_1_4_Dxe.c new file mode 100644 index 00000000000..c505610c6a4 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_4/Manager_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "1", + "4" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_4 *ManagerV1_1_4; + EFI_REDFISH_MANAGER_V1_1_4_CS *ManagerV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_1_4_To_CS (ResoruceRaw, &ManagerV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_1_4 = (EFI_REDFISH_MANAGER_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_1_4)); + if (ManagerV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_1_4; + ManagerV1_1_4->Manager = ManagerV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_1_4_JSON (*((EFI_REDFISH_MANAGER_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_4 *ManagerV1_1_4; + + ManagerV1_1_4 = (EFI_REDFISH_MANAGER_V1_1_4 *)InterpProp; + DestroyManager_V1_1_4_CS (ManagerV1_1_4->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_1_4/RedfishManager_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_1_4/RedfishManager_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..3a7b80aa07f --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_4/RedfishManager_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_1_4_Dxe + FILE_GUID = e4da99a2-1c8c-47a6-9811-a7d878ffa0f0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_1_5/Manager_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_1_5/Manager_V1_1_5_Dxe.c new file mode 100644 index 00000000000..0dbd77573c1 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_5/Manager_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "1", + "5" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_5 *ManagerV1_1_5; + EFI_REDFISH_MANAGER_V1_1_5_CS *ManagerV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_1_5_To_CS (ResoruceRaw, &ManagerV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_1_5 = (EFI_REDFISH_MANAGER_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_1_5)); + if (ManagerV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_1_5; + ManagerV1_1_5->Manager = ManagerV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_1_5_JSON (*((EFI_REDFISH_MANAGER_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_5 *ManagerV1_1_5; + + ManagerV1_1_5 = (EFI_REDFISH_MANAGER_V1_1_5 *)InterpProp; + DestroyManager_V1_1_5_CS (ManagerV1_1_5->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_1_5/RedfishManager_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_1_5/RedfishManager_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..bac6bf5b0f3 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_5/RedfishManager_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_1_5_Dxe + FILE_GUID = 48c8ede7-0ed1-4ee7-a3c1-78935d9aa1d6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_1_6/Manager_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_1_6/Manager_V1_1_6_Dxe.c new file mode 100644 index 00000000000..cfdb23cc8ef --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_6/Manager_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "1", + "6" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_6 *ManagerV1_1_6; + EFI_REDFISH_MANAGER_V1_1_6_CS *ManagerV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_1_6_To_CS (ResoruceRaw, &ManagerV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_1_6 = (EFI_REDFISH_MANAGER_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_1_6)); + if (ManagerV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_1_6; + ManagerV1_1_6->Manager = ManagerV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_1_6_JSON (*((EFI_REDFISH_MANAGER_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_6 *ManagerV1_1_6; + + ManagerV1_1_6 = (EFI_REDFISH_MANAGER_V1_1_6 *)InterpProp; + DestroyManager_V1_1_6_CS (ManagerV1_1_6->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_1_6/RedfishManager_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_1_6/RedfishManager_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..62b36617ed0 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_6/RedfishManager_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_1_6_Dxe + FILE_GUID = 32a90554-5a51-461a-84b0-8276950e43d9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_1_7/Manager_V1_1_7_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_1_7/Manager_V1_1_7_Dxe.c new file mode 100644 index 00000000000..c2366de1fe8 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_7/Manager_V1_1_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_1_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "1", + "7" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_7 *ManagerV1_1_7; + EFI_REDFISH_MANAGER_V1_1_7_CS *ManagerV1_1_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_1_7_To_CS (ResoruceRaw, &ManagerV1_1_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_1_7 = (EFI_REDFISH_MANAGER_V1_1_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_1_7)); + if (ManagerV1_1_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_1_7; + ManagerV1_1_7->Manager = ManagerV1_1_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_1_7_JSON (*((EFI_REDFISH_MANAGER_V1_1_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_7 *ManagerV1_1_7; + + ManagerV1_1_7 = (EFI_REDFISH_MANAGER_V1_1_7 *)InterpProp; + DestroyManager_V1_1_7_CS (ManagerV1_1_7->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_1_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_1_7/RedfishManager_V1_1_7_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_1_7/RedfishManager_V1_1_7_Dxe.inf new file mode 100644 index 00000000000..2d2f5d678ac --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_7/RedfishManager_V1_1_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_1_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_1_7_Dxe + FILE_GUID = 52073673-26b4-426c-90b3-5166cb114201 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_1_7EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_1_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_1_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_1_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_1_8/Manager_V1_1_8_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_1_8/Manager_V1_1_8_Dxe.c new file mode 100644 index 00000000000..4f78dfd67fb --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_8/Manager_V1_1_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_1_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "1", + "8" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_8 *ManagerV1_1_8; + EFI_REDFISH_MANAGER_V1_1_8_CS *ManagerV1_1_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_1_8_To_CS (ResoruceRaw, &ManagerV1_1_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_1_8 = (EFI_REDFISH_MANAGER_V1_1_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_1_8)); + if (ManagerV1_1_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_1_8; + ManagerV1_1_8->Manager = ManagerV1_1_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_1_8_JSON (*((EFI_REDFISH_MANAGER_V1_1_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_8 *ManagerV1_1_8; + + ManagerV1_1_8 = (EFI_REDFISH_MANAGER_V1_1_8 *)InterpProp; + DestroyManager_V1_1_8_CS (ManagerV1_1_8->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_1_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_1_8/RedfishManager_V1_1_8_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_1_8/RedfishManager_V1_1_8_Dxe.inf new file mode 100644 index 00000000000..b2c6c154da5 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_8/RedfishManager_V1_1_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_1_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_1_8_Dxe + FILE_GUID = 0b625beb-849a-41dc-8368-aa666eb8896f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_1_8EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_1_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_1_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_1_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_1_9/Manager_V1_1_9_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_1_9/Manager_V1_1_9_Dxe.c new file mode 100644 index 00000000000..35d90c64b31 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_9/Manager_V1_1_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_1_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "1", + "9" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_9 *ManagerV1_1_9; + EFI_REDFISH_MANAGER_V1_1_9_CS *ManagerV1_1_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_1_9_To_CS (ResoruceRaw, &ManagerV1_1_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_1_9 = (EFI_REDFISH_MANAGER_V1_1_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_1_9)); + if (ManagerV1_1_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_1_9; + ManagerV1_1_9->Manager = ManagerV1_1_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_1_9_JSON (*((EFI_REDFISH_MANAGER_V1_1_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_1_9 *ManagerV1_1_9; + + ManagerV1_1_9 = (EFI_REDFISH_MANAGER_V1_1_9 *)InterpProp; + DestroyManager_V1_1_9_CS (ManagerV1_1_9->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_1_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_1_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_1_9/RedfishManager_V1_1_9_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_1_9/RedfishManager_V1_1_9_Dxe.inf new file mode 100644 index 00000000000..f428432d935 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_1_9/RedfishManager_V1_1_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_1_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_1_9_Dxe + FILE_GUID = 1b173abe-e216-4e01-9f9f-26e1ecc085b4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_1_9EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_1_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_1_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_1_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_2_0/Manager_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_2_0/Manager_V1_2_0_Dxe.c new file mode 100644 index 00000000000..86e417d214c --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_0/Manager_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "2", + "0" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_0 *ManagerV1_2_0; + EFI_REDFISH_MANAGER_V1_2_0_CS *ManagerV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_2_0_To_CS (ResoruceRaw, &ManagerV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_2_0 = (EFI_REDFISH_MANAGER_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_2_0)); + if (ManagerV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_2_0; + ManagerV1_2_0->Manager = ManagerV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_2_0_JSON (*((EFI_REDFISH_MANAGER_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_0 *ManagerV1_2_0; + + ManagerV1_2_0 = (EFI_REDFISH_MANAGER_V1_2_0 *)InterpProp; + DestroyManager_V1_2_0_CS (ManagerV1_2_0->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_2_0/RedfishManager_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_2_0/RedfishManager_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..d93a0f8bf4d --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_0/RedfishManager_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_2_0_Dxe + FILE_GUID = e8dff841-9b0b-411c-a634-71dc92c6f59a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_2_1/Manager_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_2_1/Manager_V1_2_1_Dxe.c new file mode 100644 index 00000000000..33c61c09e74 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_1/Manager_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "2", + "1" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_1 *ManagerV1_2_1; + EFI_REDFISH_MANAGER_V1_2_1_CS *ManagerV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_2_1_To_CS (ResoruceRaw, &ManagerV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_2_1 = (EFI_REDFISH_MANAGER_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_2_1)); + if (ManagerV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_2_1; + ManagerV1_2_1->Manager = ManagerV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_2_1_JSON (*((EFI_REDFISH_MANAGER_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_1 *ManagerV1_2_1; + + ManagerV1_2_1 = (EFI_REDFISH_MANAGER_V1_2_1 *)InterpProp; + DestroyManager_V1_2_1_CS (ManagerV1_2_1->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_2_1/RedfishManager_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_2_1/RedfishManager_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..80e76aad5f5 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_1/RedfishManager_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_2_1_Dxe + FILE_GUID = f9f9014b-22ce-46d5-a180-ed27f83930cc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_2_10/Manager_V1_2_10_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_2_10/Manager_V1_2_10_Dxe.c new file mode 100644 index 00000000000..8cc9e7b98c5 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_10/Manager_V1_2_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_2_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_2_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "2", + "10" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_10 *ManagerV1_2_10; + EFI_REDFISH_MANAGER_V1_2_10_CS *ManagerV1_2_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_2_10_To_CS (ResoruceRaw, &ManagerV1_2_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_2_10 = (EFI_REDFISH_MANAGER_V1_2_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_2_10)); + if (ManagerV1_2_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_2_10; + ManagerV1_2_10->Manager = ManagerV1_2_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_2_10_JSON (*((EFI_REDFISH_MANAGER_V1_2_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_10 *ManagerV1_2_10; + + ManagerV1_2_10 = (EFI_REDFISH_MANAGER_V1_2_10 *)InterpProp; + DestroyManager_V1_2_10_CS (ManagerV1_2_10->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_2_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_2_10/RedfishManager_V1_2_10_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_2_10/RedfishManager_V1_2_10_Dxe.inf new file mode 100644 index 00000000000..d9375b477d3 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_10/RedfishManager_V1_2_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_2_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_2_10_Dxe + FILE_GUID = 166e9884-f52f-4284-af84-c04ad8164f8b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_2_10EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_2_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_2_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_2_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_2_11/Manager_V1_2_11_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_2_11/Manager_V1_2_11_Dxe.c new file mode 100644 index 00000000000..66154bde914 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_11/Manager_V1_2_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_2_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_2_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "2", + "11" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_11 *ManagerV1_2_11; + EFI_REDFISH_MANAGER_V1_2_11_CS *ManagerV1_2_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_2_11_To_CS (ResoruceRaw, &ManagerV1_2_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_2_11 = (EFI_REDFISH_MANAGER_V1_2_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_2_11)); + if (ManagerV1_2_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_2_11; + ManagerV1_2_11->Manager = ManagerV1_2_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_2_11_JSON (*((EFI_REDFISH_MANAGER_V1_2_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_11 *ManagerV1_2_11; + + ManagerV1_2_11 = (EFI_REDFISH_MANAGER_V1_2_11 *)InterpProp; + DestroyManager_V1_2_11_CS (ManagerV1_2_11->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_2_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_2_11/RedfishManager_V1_2_11_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_2_11/RedfishManager_V1_2_11_Dxe.inf new file mode 100644 index 00000000000..309af3712ac --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_11/RedfishManager_V1_2_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_2_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_2_11_Dxe + FILE_GUID = 96d2c967-9dd2-43d8-8460-b0af3de7d884 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_2_11EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_2_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_2_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_2_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_2_12/Manager_V1_2_12_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_2_12/Manager_V1_2_12_Dxe.c new file mode 100644 index 00000000000..625b7a54411 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_12/Manager_V1_2_12_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_2_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_2_12 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "2", + "12" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_12 *ManagerV1_2_12; + EFI_REDFISH_MANAGER_V1_2_12_CS *ManagerV1_2_12Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "12") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_2_12_To_CS (ResoruceRaw, &ManagerV1_2_12Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_2_12 = (EFI_REDFISH_MANAGER_V1_2_12 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_2_12)); + if (ManagerV1_2_12 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_2_12; + ManagerV1_2_12->Manager = ManagerV1_2_12Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "12"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_2_12_JSON (*((EFI_REDFISH_MANAGER_V1_2_12_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_12 *ManagerV1_2_12; + + ManagerV1_2_12 = (EFI_REDFISH_MANAGER_V1_2_12 *)InterpProp; + DestroyManager_V1_2_12_CS (ManagerV1_2_12->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_2_12_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_12EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_12Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_2_12/RedfishManager_V1_2_12_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_2_12/RedfishManager_V1_2_12_Dxe.inf new file mode 100644 index 00000000000..bfa4a110d29 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_12/RedfishManager_V1_2_12_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_2_12 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_2_12_Dxe + FILE_GUID = fb016971-9ddd-47bd-a453-0115c8a89420 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_2_12EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_2_12Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_2_12_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_2_12Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_2_2/Manager_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_2_2/Manager_V1_2_2_Dxe.c new file mode 100644 index 00000000000..5db6f3007ec --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_2/Manager_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "2", + "2" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_2 *ManagerV1_2_2; + EFI_REDFISH_MANAGER_V1_2_2_CS *ManagerV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_2_2_To_CS (ResoruceRaw, &ManagerV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_2_2 = (EFI_REDFISH_MANAGER_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_2_2)); + if (ManagerV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_2_2; + ManagerV1_2_2->Manager = ManagerV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_2_2_JSON (*((EFI_REDFISH_MANAGER_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_2 *ManagerV1_2_2; + + ManagerV1_2_2 = (EFI_REDFISH_MANAGER_V1_2_2 *)InterpProp; + DestroyManager_V1_2_2_CS (ManagerV1_2_2->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_2_2/RedfishManager_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_2_2/RedfishManager_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..7eac32e5f70 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_2/RedfishManager_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_2_2_Dxe + FILE_GUID = 2a6f0b19-04c3-4a6c-9a73-d911eebd2ef9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_2_3/Manager_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_2_3/Manager_V1_2_3_Dxe.c new file mode 100644 index 00000000000..e145b64bb04 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_3/Manager_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "2", + "3" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_3 *ManagerV1_2_3; + EFI_REDFISH_MANAGER_V1_2_3_CS *ManagerV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_2_3_To_CS (ResoruceRaw, &ManagerV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_2_3 = (EFI_REDFISH_MANAGER_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_2_3)); + if (ManagerV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_2_3; + ManagerV1_2_3->Manager = ManagerV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_2_3_JSON (*((EFI_REDFISH_MANAGER_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_3 *ManagerV1_2_3; + + ManagerV1_2_3 = (EFI_REDFISH_MANAGER_V1_2_3 *)InterpProp; + DestroyManager_V1_2_3_CS (ManagerV1_2_3->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_2_3/RedfishManager_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_2_3/RedfishManager_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..fe435d36af9 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_3/RedfishManager_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_2_3_Dxe + FILE_GUID = 83ea51d8-8221-443b-9253-28a0acbc48b3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_2_4/Manager_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_2_4/Manager_V1_2_4_Dxe.c new file mode 100644 index 00000000000..c4596f63e6a --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_4/Manager_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "2", + "4" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_4 *ManagerV1_2_4; + EFI_REDFISH_MANAGER_V1_2_4_CS *ManagerV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_2_4_To_CS (ResoruceRaw, &ManagerV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_2_4 = (EFI_REDFISH_MANAGER_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_2_4)); + if (ManagerV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_2_4; + ManagerV1_2_4->Manager = ManagerV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_2_4_JSON (*((EFI_REDFISH_MANAGER_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_4 *ManagerV1_2_4; + + ManagerV1_2_4 = (EFI_REDFISH_MANAGER_V1_2_4 *)InterpProp; + DestroyManager_V1_2_4_CS (ManagerV1_2_4->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_2_4/RedfishManager_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_2_4/RedfishManager_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..2a86c5f1cbe --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_4/RedfishManager_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_2_4_Dxe + FILE_GUID = 4ef1434e-8ba6-4739-b6de-730475337849 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_2_5/Manager_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_2_5/Manager_V1_2_5_Dxe.c new file mode 100644 index 00000000000..fb8352df82b --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_5/Manager_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "2", + "5" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_5 *ManagerV1_2_5; + EFI_REDFISH_MANAGER_V1_2_5_CS *ManagerV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_2_5_To_CS (ResoruceRaw, &ManagerV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_2_5 = (EFI_REDFISH_MANAGER_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_2_5)); + if (ManagerV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_2_5; + ManagerV1_2_5->Manager = ManagerV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_2_5_JSON (*((EFI_REDFISH_MANAGER_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_5 *ManagerV1_2_5; + + ManagerV1_2_5 = (EFI_REDFISH_MANAGER_V1_2_5 *)InterpProp; + DestroyManager_V1_2_5_CS (ManagerV1_2_5->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_2_5/RedfishManager_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_2_5/RedfishManager_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..48f47d0842f --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_5/RedfishManager_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_2_5_Dxe + FILE_GUID = 4c45a5f9-7386-4d70-9e27-3262b3a73fde + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_2_6/Manager_V1_2_6_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_2_6/Manager_V1_2_6_Dxe.c new file mode 100644 index 00000000000..1bde6e07cb9 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_6/Manager_V1_2_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_2_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "2", + "6" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_6 *ManagerV1_2_6; + EFI_REDFISH_MANAGER_V1_2_6_CS *ManagerV1_2_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_2_6_To_CS (ResoruceRaw, &ManagerV1_2_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_2_6 = (EFI_REDFISH_MANAGER_V1_2_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_2_6)); + if (ManagerV1_2_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_2_6; + ManagerV1_2_6->Manager = ManagerV1_2_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_2_6_JSON (*((EFI_REDFISH_MANAGER_V1_2_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_6 *ManagerV1_2_6; + + ManagerV1_2_6 = (EFI_REDFISH_MANAGER_V1_2_6 *)InterpProp; + DestroyManager_V1_2_6_CS (ManagerV1_2_6->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_2_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_2_6/RedfishManager_V1_2_6_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_2_6/RedfishManager_V1_2_6_Dxe.inf new file mode 100644 index 00000000000..83a63cce3eb --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_6/RedfishManager_V1_2_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_2_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_2_6_Dxe + FILE_GUID = 81c5ad10-4825-482f-936e-1836135eff44 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_2_6EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_2_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_2_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_2_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_2_7/Manager_V1_2_7_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_2_7/Manager_V1_2_7_Dxe.c new file mode 100644 index 00000000000..d8316c486f1 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_7/Manager_V1_2_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_2_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "2", + "7" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_7 *ManagerV1_2_7; + EFI_REDFISH_MANAGER_V1_2_7_CS *ManagerV1_2_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_2_7_To_CS (ResoruceRaw, &ManagerV1_2_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_2_7 = (EFI_REDFISH_MANAGER_V1_2_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_2_7)); + if (ManagerV1_2_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_2_7; + ManagerV1_2_7->Manager = ManagerV1_2_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_2_7_JSON (*((EFI_REDFISH_MANAGER_V1_2_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_7 *ManagerV1_2_7; + + ManagerV1_2_7 = (EFI_REDFISH_MANAGER_V1_2_7 *)InterpProp; + DestroyManager_V1_2_7_CS (ManagerV1_2_7->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_2_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_2_7/RedfishManager_V1_2_7_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_2_7/RedfishManager_V1_2_7_Dxe.inf new file mode 100644 index 00000000000..cdd9385c01f --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_7/RedfishManager_V1_2_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_2_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_2_7_Dxe + FILE_GUID = 77731eea-f220-40bb-b92c-c0308d155045 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_2_7EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_2_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_2_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_2_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_2_8/Manager_V1_2_8_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_2_8/Manager_V1_2_8_Dxe.c new file mode 100644 index 00000000000..4959b57ecb7 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_8/Manager_V1_2_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_2_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "2", + "8" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_8 *ManagerV1_2_8; + EFI_REDFISH_MANAGER_V1_2_8_CS *ManagerV1_2_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_2_8_To_CS (ResoruceRaw, &ManagerV1_2_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_2_8 = (EFI_REDFISH_MANAGER_V1_2_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_2_8)); + if (ManagerV1_2_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_2_8; + ManagerV1_2_8->Manager = ManagerV1_2_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_2_8_JSON (*((EFI_REDFISH_MANAGER_V1_2_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_8 *ManagerV1_2_8; + + ManagerV1_2_8 = (EFI_REDFISH_MANAGER_V1_2_8 *)InterpProp; + DestroyManager_V1_2_8_CS (ManagerV1_2_8->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_2_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_2_8/RedfishManager_V1_2_8_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_2_8/RedfishManager_V1_2_8_Dxe.inf new file mode 100644 index 00000000000..e07bfcb1b3e --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_8/RedfishManager_V1_2_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_2_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_2_8_Dxe + FILE_GUID = 4fb5d10b-447d-4241-923d-f1935cc98fc4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_2_8EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_2_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_2_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_2_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_2_9/Manager_V1_2_9_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_2_9/Manager_V1_2_9_Dxe.c new file mode 100644 index 00000000000..fce6a920290 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_9/Manager_V1_2_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_2_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_2_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "2", + "9" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_9 *ManagerV1_2_9; + EFI_REDFISH_MANAGER_V1_2_9_CS *ManagerV1_2_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_2_9_To_CS (ResoruceRaw, &ManagerV1_2_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_2_9 = (EFI_REDFISH_MANAGER_V1_2_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_2_9)); + if (ManagerV1_2_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_2_9; + ManagerV1_2_9->Manager = ManagerV1_2_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_2_9_JSON (*((EFI_REDFISH_MANAGER_V1_2_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_2_9 *ManagerV1_2_9; + + ManagerV1_2_9 = (EFI_REDFISH_MANAGER_V1_2_9 *)InterpProp; + DestroyManager_V1_2_9_CS (ManagerV1_2_9->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_2_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_2_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_2_9/RedfishManager_V1_2_9_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_2_9/RedfishManager_V1_2_9_Dxe.inf new file mode 100644 index 00000000000..dfb690752c7 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_2_9/RedfishManager_V1_2_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_2_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_2_9_Dxe + FILE_GUID = 95d90a32-c1fb-4315-a8ea-97be302a15fa + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_2_9EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_2_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_2_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_2_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_3_0/Manager_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_3_0/Manager_V1_3_0_Dxe.c new file mode 100644 index 00000000000..d70bd13543e --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_3_0/Manager_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "3", + "0" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_3_0 *ManagerV1_3_0; + EFI_REDFISH_MANAGER_V1_3_0_CS *ManagerV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_3_0_To_CS (ResoruceRaw, &ManagerV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_3_0 = (EFI_REDFISH_MANAGER_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_3_0)); + if (ManagerV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_3_0; + ManagerV1_3_0->Manager = ManagerV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_3_0_JSON (*((EFI_REDFISH_MANAGER_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_3_0 *ManagerV1_3_0; + + ManagerV1_3_0 = (EFI_REDFISH_MANAGER_V1_3_0 *)InterpProp; + DestroyManager_V1_3_0_CS (ManagerV1_3_0->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_3_0/RedfishManager_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_3_0/RedfishManager_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..62ef2cdd5a1 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_3_0/RedfishManager_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_3_0_Dxe + FILE_GUID = b9f8535f-ff70-4619-90d4-10332cd422f7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_3_1/Manager_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_3_1/Manager_V1_3_1_Dxe.c new file mode 100644 index 00000000000..17a7397de76 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_3_1/Manager_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "3", + "1" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_3_1 *ManagerV1_3_1; + EFI_REDFISH_MANAGER_V1_3_1_CS *ManagerV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_3_1_To_CS (ResoruceRaw, &ManagerV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_3_1 = (EFI_REDFISH_MANAGER_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_3_1)); + if (ManagerV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_3_1; + ManagerV1_3_1->Manager = ManagerV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_3_1_JSON (*((EFI_REDFISH_MANAGER_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_3_1 *ManagerV1_3_1; + + ManagerV1_3_1 = (EFI_REDFISH_MANAGER_V1_3_1 *)InterpProp; + DestroyManager_V1_3_1_CS (ManagerV1_3_1->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_3_1/RedfishManager_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_3_1/RedfishManager_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..768c6ecb415 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_3_1/RedfishManager_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_3_1_Dxe + FILE_GUID = b291d7eb-5068-4b62-8864-a85b511637c8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_3_10/Manager_V1_3_10_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_3_10/Manager_V1_3_10_Dxe.c new file mode 100644 index 00000000000..47200759cad --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_3_10/Manager_V1_3_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_3_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_3_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "3", + "10" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_3_10 *ManagerV1_3_10; + EFI_REDFISH_MANAGER_V1_3_10_CS *ManagerV1_3_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_3_10_To_CS (ResoruceRaw, &ManagerV1_3_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_3_10 = (EFI_REDFISH_MANAGER_V1_3_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_3_10)); + if (ManagerV1_3_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_3_10; + ManagerV1_3_10->Manager = ManagerV1_3_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_3_10_JSON (*((EFI_REDFISH_MANAGER_V1_3_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_3_10 *ManagerV1_3_10; + + ManagerV1_3_10 = (EFI_REDFISH_MANAGER_V1_3_10 *)InterpProp; + DestroyManager_V1_3_10_CS (ManagerV1_3_10->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_3_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_3_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_3_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_3_10/RedfishManager_V1_3_10_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_3_10/RedfishManager_V1_3_10_Dxe.inf new file mode 100644 index 00000000000..9d0d43b66e7 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_3_10/RedfishManager_V1_3_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_3_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_3_10_Dxe + FILE_GUID = f9daf0ea-2b7a-4064-8958-e9fd41076f99 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_3_10EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_3_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_3_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_3_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_3_11/Manager_V1_3_11_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_3_11/Manager_V1_3_11_Dxe.c new file mode 100644 index 00000000000..b334a6ebebd --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_3_11/Manager_V1_3_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_3_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_3_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "3", + "11" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_3_11 *ManagerV1_3_11; + EFI_REDFISH_MANAGER_V1_3_11_CS *ManagerV1_3_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_3_11_To_CS (ResoruceRaw, &ManagerV1_3_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_3_11 = (EFI_REDFISH_MANAGER_V1_3_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_3_11)); + if (ManagerV1_3_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_3_11; + ManagerV1_3_11->Manager = ManagerV1_3_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_3_11_JSON (*((EFI_REDFISH_MANAGER_V1_3_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_3_11 *ManagerV1_3_11; + + ManagerV1_3_11 = (EFI_REDFISH_MANAGER_V1_3_11 *)InterpProp; + DestroyManager_V1_3_11_CS (ManagerV1_3_11->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_3_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_3_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_3_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_3_11/RedfishManager_V1_3_11_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_3_11/RedfishManager_V1_3_11_Dxe.inf new file mode 100644 index 00000000000..2004edfd6d0 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_3_11/RedfishManager_V1_3_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_3_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_3_11_Dxe + FILE_GUID = cfaf723d-94ca-4d7d-baeb-ceacf67e50c7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_3_11EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_3_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_3_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_3_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_3_2/Manager_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_3_2/Manager_V1_3_2_Dxe.c new file mode 100644 index 00000000000..33843e7c431 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_3_2/Manager_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "3", + "2" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_3_2 *ManagerV1_3_2; + EFI_REDFISH_MANAGER_V1_3_2_CS *ManagerV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_3_2_To_CS (ResoruceRaw, &ManagerV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_3_2 = (EFI_REDFISH_MANAGER_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_3_2)); + if (ManagerV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_3_2; + ManagerV1_3_2->Manager = ManagerV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_3_2_JSON (*((EFI_REDFISH_MANAGER_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_3_2 *ManagerV1_3_2; + + ManagerV1_3_2 = (EFI_REDFISH_MANAGER_V1_3_2 *)InterpProp; + DestroyManager_V1_3_2_CS (ManagerV1_3_2->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_3_2/RedfishManager_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_3_2/RedfishManager_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..7c3b26bdfd5 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_3_2/RedfishManager_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_3_2_Dxe + FILE_GUID = 612df4a0-95e3-43e0-a1ab-4971beaaaf39 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_3_3/Manager_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_3_3/Manager_V1_3_3_Dxe.c new file mode 100644 index 00000000000..433c4ffee5e --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_3_3/Manager_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "3", + "3" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_3_3 *ManagerV1_3_3; + EFI_REDFISH_MANAGER_V1_3_3_CS *ManagerV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_3_3_To_CS (ResoruceRaw, &ManagerV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_3_3 = (EFI_REDFISH_MANAGER_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_3_3)); + if (ManagerV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_3_3; + ManagerV1_3_3->Manager = ManagerV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_3_3_JSON (*((EFI_REDFISH_MANAGER_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_3_3 *ManagerV1_3_3; + + ManagerV1_3_3 = (EFI_REDFISH_MANAGER_V1_3_3 *)InterpProp; + DestroyManager_V1_3_3_CS (ManagerV1_3_3->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_3_3/RedfishManager_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_3_3/RedfishManager_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..729699ccbac --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_3_3/RedfishManager_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_3_3_Dxe + FILE_GUID = 8d05f6aa-e391-493b-9ee0-e4c12addf355 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_3_4/Manager_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_3_4/Manager_V1_3_4_Dxe.c new file mode 100644 index 00000000000..2efcee6bdc4 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_3_4/Manager_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "3", + "4" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_3_4 *ManagerV1_3_4; + EFI_REDFISH_MANAGER_V1_3_4_CS *ManagerV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_3_4_To_CS (ResoruceRaw, &ManagerV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_3_4 = (EFI_REDFISH_MANAGER_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_3_4)); + if (ManagerV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_3_4; + ManagerV1_3_4->Manager = ManagerV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_3_4_JSON (*((EFI_REDFISH_MANAGER_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_3_4 *ManagerV1_3_4; + + ManagerV1_3_4 = (EFI_REDFISH_MANAGER_V1_3_4 *)InterpProp; + DestroyManager_V1_3_4_CS (ManagerV1_3_4->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_3_4/RedfishManager_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_3_4/RedfishManager_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..88ebc7a489b --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_3_4/RedfishManager_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_3_4_Dxe + FILE_GUID = a0ef8316-8a11-4c8e-8988-1eea570d23ae + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_3_5/Manager_V1_3_5_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_3_5/Manager_V1_3_5_Dxe.c new file mode 100644 index 00000000000..c45ee69bd21 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_3_5/Manager_V1_3_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_3_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "3", + "5" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_3_5 *ManagerV1_3_5; + EFI_REDFISH_MANAGER_V1_3_5_CS *ManagerV1_3_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_3_5_To_CS (ResoruceRaw, &ManagerV1_3_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_3_5 = (EFI_REDFISH_MANAGER_V1_3_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_3_5)); + if (ManagerV1_3_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_3_5; + ManagerV1_3_5->Manager = ManagerV1_3_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_3_5_JSON (*((EFI_REDFISH_MANAGER_V1_3_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_3_5 *ManagerV1_3_5; + + ManagerV1_3_5 = (EFI_REDFISH_MANAGER_V1_3_5 *)InterpProp; + DestroyManager_V1_3_5_CS (ManagerV1_3_5->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_3_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_3_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_3_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_3_5/RedfishManager_V1_3_5_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_3_5/RedfishManager_V1_3_5_Dxe.inf new file mode 100644 index 00000000000..c4e9b49891f --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_3_5/RedfishManager_V1_3_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_3_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_3_5_Dxe + FILE_GUID = 948710dc-c4a0-468b-a99e-f6c5b7b1545f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_3_5EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_3_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_3_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_3_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_3_6/Manager_V1_3_6_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_3_6/Manager_V1_3_6_Dxe.c new file mode 100644 index 00000000000..04051a6ebcd --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_3_6/Manager_V1_3_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_3_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "3", + "6" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_3_6 *ManagerV1_3_6; + EFI_REDFISH_MANAGER_V1_3_6_CS *ManagerV1_3_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_3_6_To_CS (ResoruceRaw, &ManagerV1_3_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_3_6 = (EFI_REDFISH_MANAGER_V1_3_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_3_6)); + if (ManagerV1_3_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_3_6; + ManagerV1_3_6->Manager = ManagerV1_3_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_3_6_JSON (*((EFI_REDFISH_MANAGER_V1_3_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_3_6 *ManagerV1_3_6; + + ManagerV1_3_6 = (EFI_REDFISH_MANAGER_V1_3_6 *)InterpProp; + DestroyManager_V1_3_6_CS (ManagerV1_3_6->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_3_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_3_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_3_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_3_6/RedfishManager_V1_3_6_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_3_6/RedfishManager_V1_3_6_Dxe.inf new file mode 100644 index 00000000000..bb1f7f610ab --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_3_6/RedfishManager_V1_3_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_3_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_3_6_Dxe + FILE_GUID = da239f81-2277-4b97-b57c-683e0562fb59 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_3_6EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_3_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_3_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_3_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_3_7/Manager_V1_3_7_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_3_7/Manager_V1_3_7_Dxe.c new file mode 100644 index 00000000000..7448e05188e --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_3_7/Manager_V1_3_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_3_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_3_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "3", + "7" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_3_7 *ManagerV1_3_7; + EFI_REDFISH_MANAGER_V1_3_7_CS *ManagerV1_3_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_3_7_To_CS (ResoruceRaw, &ManagerV1_3_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_3_7 = (EFI_REDFISH_MANAGER_V1_3_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_3_7)); + if (ManagerV1_3_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_3_7; + ManagerV1_3_7->Manager = ManagerV1_3_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_3_7_JSON (*((EFI_REDFISH_MANAGER_V1_3_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_3_7 *ManagerV1_3_7; + + ManagerV1_3_7 = (EFI_REDFISH_MANAGER_V1_3_7 *)InterpProp; + DestroyManager_V1_3_7_CS (ManagerV1_3_7->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_3_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_3_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_3_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_3_7/RedfishManager_V1_3_7_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_3_7/RedfishManager_V1_3_7_Dxe.inf new file mode 100644 index 00000000000..c6b74d9a596 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_3_7/RedfishManager_V1_3_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_3_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_3_7_Dxe + FILE_GUID = 9a9b6191-53a8-448b-87e9-2a0008dff5b4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_3_7EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_3_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_3_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_3_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_3_8/Manager_V1_3_8_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_3_8/Manager_V1_3_8_Dxe.c new file mode 100644 index 00000000000..dc541aab3a7 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_3_8/Manager_V1_3_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_3_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_3_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "3", + "8" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_3_8 *ManagerV1_3_8; + EFI_REDFISH_MANAGER_V1_3_8_CS *ManagerV1_3_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_3_8_To_CS (ResoruceRaw, &ManagerV1_3_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_3_8 = (EFI_REDFISH_MANAGER_V1_3_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_3_8)); + if (ManagerV1_3_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_3_8; + ManagerV1_3_8->Manager = ManagerV1_3_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_3_8_JSON (*((EFI_REDFISH_MANAGER_V1_3_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_3_8 *ManagerV1_3_8; + + ManagerV1_3_8 = (EFI_REDFISH_MANAGER_V1_3_8 *)InterpProp; + DestroyManager_V1_3_8_CS (ManagerV1_3_8->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_3_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_3_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_3_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_3_8/RedfishManager_V1_3_8_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_3_8/RedfishManager_V1_3_8_Dxe.inf new file mode 100644 index 00000000000..87869d53980 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_3_8/RedfishManager_V1_3_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_3_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_3_8_Dxe + FILE_GUID = 2b4bae94-5a42-4c92-9eb1-5e80a4f74c50 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_3_8EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_3_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_3_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_3_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_3_9/Manager_V1_3_9_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_3_9/Manager_V1_3_9_Dxe.c new file mode 100644 index 00000000000..7fd2147bba9 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_3_9/Manager_V1_3_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_3_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_3_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "3", + "9" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_3_9 *ManagerV1_3_9; + EFI_REDFISH_MANAGER_V1_3_9_CS *ManagerV1_3_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_3_9_To_CS (ResoruceRaw, &ManagerV1_3_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_3_9 = (EFI_REDFISH_MANAGER_V1_3_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_3_9)); + if (ManagerV1_3_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_3_9; + ManagerV1_3_9->Manager = ManagerV1_3_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_3_9_JSON (*((EFI_REDFISH_MANAGER_V1_3_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_3_9 *ManagerV1_3_9; + + ManagerV1_3_9 = (EFI_REDFISH_MANAGER_V1_3_9 *)InterpProp; + DestroyManager_V1_3_9_CS (ManagerV1_3_9->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_3_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_3_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_3_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_3_9/RedfishManager_V1_3_9_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_3_9/RedfishManager_V1_3_9_Dxe.inf new file mode 100644 index 00000000000..ceb53d1aadf --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_3_9/RedfishManager_V1_3_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_3_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_3_9_Dxe + FILE_GUID = 89b1c0f0-72c4-43bb-8b12-3f64ebebd8e6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_3_9EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_3_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_3_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_3_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_4_0/Manager_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_4_0/Manager_V1_4_0_Dxe.c new file mode 100644 index 00000000000..72d85964ba3 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_4_0/Manager_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "4", + "0" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_4_0 *ManagerV1_4_0; + EFI_REDFISH_MANAGER_V1_4_0_CS *ManagerV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_4_0_To_CS (ResoruceRaw, &ManagerV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_4_0 = (EFI_REDFISH_MANAGER_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_4_0)); + if (ManagerV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_4_0; + ManagerV1_4_0->Manager = ManagerV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_4_0_JSON (*((EFI_REDFISH_MANAGER_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_4_0 *ManagerV1_4_0; + + ManagerV1_4_0 = (EFI_REDFISH_MANAGER_V1_4_0 *)InterpProp; + DestroyManager_V1_4_0_CS (ManagerV1_4_0->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_4_0/RedfishManager_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_4_0/RedfishManager_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..057ec905d31 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_4_0/RedfishManager_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_4_0_Dxe + FILE_GUID = c8a1c21d-5440-4e81-b74f-9b384370f4d3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_4_1/Manager_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_4_1/Manager_V1_4_1_Dxe.c new file mode 100644 index 00000000000..a600d52d3cc --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_4_1/Manager_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "4", + "1" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_4_1 *ManagerV1_4_1; + EFI_REDFISH_MANAGER_V1_4_1_CS *ManagerV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_4_1_To_CS (ResoruceRaw, &ManagerV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_4_1 = (EFI_REDFISH_MANAGER_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_4_1)); + if (ManagerV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_4_1; + ManagerV1_4_1->Manager = ManagerV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_4_1_JSON (*((EFI_REDFISH_MANAGER_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_4_1 *ManagerV1_4_1; + + ManagerV1_4_1 = (EFI_REDFISH_MANAGER_V1_4_1 *)InterpProp; + DestroyManager_V1_4_1_CS (ManagerV1_4_1->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_4_1/RedfishManager_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_4_1/RedfishManager_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..7bb39af4350 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_4_1/RedfishManager_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_4_1_Dxe + FILE_GUID = bebc57a9-eacb-4a1c-8da3-82102a48ef76 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_4_2/Manager_V1_4_2_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_4_2/Manager_V1_4_2_Dxe.c new file mode 100644 index 00000000000..968c18044c8 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_4_2/Manager_V1_4_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_4_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "4", + "2" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_4_2 *ManagerV1_4_2; + EFI_REDFISH_MANAGER_V1_4_2_CS *ManagerV1_4_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_4_2_To_CS (ResoruceRaw, &ManagerV1_4_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_4_2 = (EFI_REDFISH_MANAGER_V1_4_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_4_2)); + if (ManagerV1_4_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_4_2; + ManagerV1_4_2->Manager = ManagerV1_4_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_4_2_JSON (*((EFI_REDFISH_MANAGER_V1_4_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_4_2 *ManagerV1_4_2; + + ManagerV1_4_2 = (EFI_REDFISH_MANAGER_V1_4_2 *)InterpProp; + DestroyManager_V1_4_2_CS (ManagerV1_4_2->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_4_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_4_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_4_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_4_2/RedfishManager_V1_4_2_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_4_2/RedfishManager_V1_4_2_Dxe.inf new file mode 100644 index 00000000000..8e0574d95e2 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_4_2/RedfishManager_V1_4_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_4_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_4_2_Dxe + FILE_GUID = 7484f6e9-41e2-4580-96a3-c56ece718fa9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_4_2EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_4_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_4_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_4_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_4_3/Manager_V1_4_3_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_4_3/Manager_V1_4_3_Dxe.c new file mode 100644 index 00000000000..04c30cc6d83 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_4_3/Manager_V1_4_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_4_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "4", + "3" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_4_3 *ManagerV1_4_3; + EFI_REDFISH_MANAGER_V1_4_3_CS *ManagerV1_4_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_4_3_To_CS (ResoruceRaw, &ManagerV1_4_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_4_3 = (EFI_REDFISH_MANAGER_V1_4_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_4_3)); + if (ManagerV1_4_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_4_3; + ManagerV1_4_3->Manager = ManagerV1_4_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_4_3_JSON (*((EFI_REDFISH_MANAGER_V1_4_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_4_3 *ManagerV1_4_3; + + ManagerV1_4_3 = (EFI_REDFISH_MANAGER_V1_4_3 *)InterpProp; + DestroyManager_V1_4_3_CS (ManagerV1_4_3->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_4_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_4_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_4_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_4_3/RedfishManager_V1_4_3_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_4_3/RedfishManager_V1_4_3_Dxe.inf new file mode 100644 index 00000000000..30d3c24b01b --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_4_3/RedfishManager_V1_4_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_4_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_4_3_Dxe + FILE_GUID = 0947903c-0a4e-4262-800c-e267712cfdf6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_4_3EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_4_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_4_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_4_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_4_4/Manager_V1_4_4_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_4_4/Manager_V1_4_4_Dxe.c new file mode 100644 index 00000000000..7820d5e15e4 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_4_4/Manager_V1_4_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_4_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "4", + "4" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_4_4 *ManagerV1_4_4; + EFI_REDFISH_MANAGER_V1_4_4_CS *ManagerV1_4_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_4_4_To_CS (ResoruceRaw, &ManagerV1_4_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_4_4 = (EFI_REDFISH_MANAGER_V1_4_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_4_4)); + if (ManagerV1_4_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_4_4; + ManagerV1_4_4->Manager = ManagerV1_4_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_4_4_JSON (*((EFI_REDFISH_MANAGER_V1_4_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_4_4 *ManagerV1_4_4; + + ManagerV1_4_4 = (EFI_REDFISH_MANAGER_V1_4_4 *)InterpProp; + DestroyManager_V1_4_4_CS (ManagerV1_4_4->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_4_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_4_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_4_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_4_4/RedfishManager_V1_4_4_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_4_4/RedfishManager_V1_4_4_Dxe.inf new file mode 100644 index 00000000000..ae2b538e57a --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_4_4/RedfishManager_V1_4_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_4_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_4_4_Dxe + FILE_GUID = 70b85f99-64ec-4910-b6fc-76a2c157efb2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_4_4EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_4_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_4_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_4_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_4_5/Manager_V1_4_5_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_4_5/Manager_V1_4_5_Dxe.c new file mode 100644 index 00000000000..cf7a4cf85e5 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_4_5/Manager_V1_4_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_4_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "4", + "5" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_4_5 *ManagerV1_4_5; + EFI_REDFISH_MANAGER_V1_4_5_CS *ManagerV1_4_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_4_5_To_CS (ResoruceRaw, &ManagerV1_4_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_4_5 = (EFI_REDFISH_MANAGER_V1_4_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_4_5)); + if (ManagerV1_4_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_4_5; + ManagerV1_4_5->Manager = ManagerV1_4_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_4_5_JSON (*((EFI_REDFISH_MANAGER_V1_4_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_4_5 *ManagerV1_4_5; + + ManagerV1_4_5 = (EFI_REDFISH_MANAGER_V1_4_5 *)InterpProp; + DestroyManager_V1_4_5_CS (ManagerV1_4_5->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_4_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_4_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_4_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_4_5/RedfishManager_V1_4_5_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_4_5/RedfishManager_V1_4_5_Dxe.inf new file mode 100644 index 00000000000..e19f1e60f22 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_4_5/RedfishManager_V1_4_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_4_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_4_5_Dxe + FILE_GUID = 2a42ca14-9a4b-4357-af81-526a4f38561e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_4_5EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_4_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_4_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_4_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_4_6/Manager_V1_4_6_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_4_6/Manager_V1_4_6_Dxe.c new file mode 100644 index 00000000000..4fbb5d3a11f --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_4_6/Manager_V1_4_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_4_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_4_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "4", + "6" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_4_6 *ManagerV1_4_6; + EFI_REDFISH_MANAGER_V1_4_6_CS *ManagerV1_4_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_4_6_To_CS (ResoruceRaw, &ManagerV1_4_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_4_6 = (EFI_REDFISH_MANAGER_V1_4_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_4_6)); + if (ManagerV1_4_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_4_6; + ManagerV1_4_6->Manager = ManagerV1_4_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_4_6_JSON (*((EFI_REDFISH_MANAGER_V1_4_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_4_6 *ManagerV1_4_6; + + ManagerV1_4_6 = (EFI_REDFISH_MANAGER_V1_4_6 *)InterpProp; + DestroyManager_V1_4_6_CS (ManagerV1_4_6->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_4_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_4_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_4_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_4_6/RedfishManager_V1_4_6_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_4_6/RedfishManager_V1_4_6_Dxe.inf new file mode 100644 index 00000000000..7d3293c0ed6 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_4_6/RedfishManager_V1_4_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_4_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_4_6_Dxe + FILE_GUID = 608bd7ad-21f3-4f4a-8531-998f5975cc19 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_4_6EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_4_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_4_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_4_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_4_7/Manager_V1_4_7_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_4_7/Manager_V1_4_7_Dxe.c new file mode 100644 index 00000000000..f6aecf00045 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_4_7/Manager_V1_4_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_4_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_4_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "4", + "7" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_4_7 *ManagerV1_4_7; + EFI_REDFISH_MANAGER_V1_4_7_CS *ManagerV1_4_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_4_7_To_CS (ResoruceRaw, &ManagerV1_4_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_4_7 = (EFI_REDFISH_MANAGER_V1_4_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_4_7)); + if (ManagerV1_4_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_4_7; + ManagerV1_4_7->Manager = ManagerV1_4_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_4_7_JSON (*((EFI_REDFISH_MANAGER_V1_4_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_4_7 *ManagerV1_4_7; + + ManagerV1_4_7 = (EFI_REDFISH_MANAGER_V1_4_7 *)InterpProp; + DestroyManager_V1_4_7_CS (ManagerV1_4_7->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_4_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_4_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_4_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_4_7/RedfishManager_V1_4_7_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_4_7/RedfishManager_V1_4_7_Dxe.inf new file mode 100644 index 00000000000..ee0588bb1f3 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_4_7/RedfishManager_V1_4_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_4_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_4_7_Dxe + FILE_GUID = 52e3c762-a999-4262-b4d5-271384ce2771 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_4_7EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_4_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_4_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_4_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_4_8/Manager_V1_4_8_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_4_8/Manager_V1_4_8_Dxe.c new file mode 100644 index 00000000000..fdb3963cad2 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_4_8/Manager_V1_4_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_4_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_4_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "4", + "8" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_4_8 *ManagerV1_4_8; + EFI_REDFISH_MANAGER_V1_4_8_CS *ManagerV1_4_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_4_8_To_CS (ResoruceRaw, &ManagerV1_4_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_4_8 = (EFI_REDFISH_MANAGER_V1_4_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_4_8)); + if (ManagerV1_4_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_4_8; + ManagerV1_4_8->Manager = ManagerV1_4_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_4_8_JSON (*((EFI_REDFISH_MANAGER_V1_4_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_4_8 *ManagerV1_4_8; + + ManagerV1_4_8 = (EFI_REDFISH_MANAGER_V1_4_8 *)InterpProp; + DestroyManager_V1_4_8_CS (ManagerV1_4_8->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_4_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_4_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_4_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_4_8/RedfishManager_V1_4_8_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_4_8/RedfishManager_V1_4_8_Dxe.inf new file mode 100644 index 00000000000..c7d59d74bdc --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_4_8/RedfishManager_V1_4_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_4_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_4_8_Dxe + FILE_GUID = 9064eb4b-c27c-4cc6-bc85-7824ec6cc2bc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_4_8EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_4_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_4_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_4_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_5_0/Manager_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_5_0/Manager_V1_5_0_Dxe.c new file mode 100644 index 00000000000..9b7287abe32 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_5_0/Manager_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "5", + "0" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_5_0 *ManagerV1_5_0; + EFI_REDFISH_MANAGER_V1_5_0_CS *ManagerV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_5_0_To_CS (ResoruceRaw, &ManagerV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_5_0 = (EFI_REDFISH_MANAGER_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_5_0)); + if (ManagerV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_5_0; + ManagerV1_5_0->Manager = ManagerV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_5_0_JSON (*((EFI_REDFISH_MANAGER_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_5_0 *ManagerV1_5_0; + + ManagerV1_5_0 = (EFI_REDFISH_MANAGER_V1_5_0 *)InterpProp; + DestroyManager_V1_5_0_CS (ManagerV1_5_0->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_5_0/RedfishManager_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_5_0/RedfishManager_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..da0b2213bc7 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_5_0/RedfishManager_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_5_0_Dxe + FILE_GUID = 6f3752b4-2eb1-48ff-81f4-a5e967b0e724 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_5_1/Manager_V1_5_1_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_5_1/Manager_V1_5_1_Dxe.c new file mode 100644 index 00000000000..8cbee90df68 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_5_1/Manager_V1_5_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_5_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "5", + "1" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_5_1 *ManagerV1_5_1; + EFI_REDFISH_MANAGER_V1_5_1_CS *ManagerV1_5_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_5_1_To_CS (ResoruceRaw, &ManagerV1_5_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_5_1 = (EFI_REDFISH_MANAGER_V1_5_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_5_1)); + if (ManagerV1_5_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_5_1; + ManagerV1_5_1->Manager = ManagerV1_5_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_5_1_JSON (*((EFI_REDFISH_MANAGER_V1_5_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_5_1 *ManagerV1_5_1; + + ManagerV1_5_1 = (EFI_REDFISH_MANAGER_V1_5_1 *)InterpProp; + DestroyManager_V1_5_1_CS (ManagerV1_5_1->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_5_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_5_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_5_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_5_1/RedfishManager_V1_5_1_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_5_1/RedfishManager_V1_5_1_Dxe.inf new file mode 100644 index 00000000000..5c3a153a364 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_5_1/RedfishManager_V1_5_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_5_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_5_1_Dxe + FILE_GUID = d29ee5af-c2e5-4ae8-9d73-e4d16932ad15 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_5_1EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_5_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_5_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_5_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_5_2/Manager_V1_5_2_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_5_2/Manager_V1_5_2_Dxe.c new file mode 100644 index 00000000000..8dc804f8a39 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_5_2/Manager_V1_5_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_5_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "5", + "2" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_5_2 *ManagerV1_5_2; + EFI_REDFISH_MANAGER_V1_5_2_CS *ManagerV1_5_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_5_2_To_CS (ResoruceRaw, &ManagerV1_5_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_5_2 = (EFI_REDFISH_MANAGER_V1_5_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_5_2)); + if (ManagerV1_5_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_5_2; + ManagerV1_5_2->Manager = ManagerV1_5_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_5_2_JSON (*((EFI_REDFISH_MANAGER_V1_5_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_5_2 *ManagerV1_5_2; + + ManagerV1_5_2 = (EFI_REDFISH_MANAGER_V1_5_2 *)InterpProp; + DestroyManager_V1_5_2_CS (ManagerV1_5_2->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_5_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_5_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_5_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_5_2/RedfishManager_V1_5_2_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_5_2/RedfishManager_V1_5_2_Dxe.inf new file mode 100644 index 00000000000..25bf07bfa2f --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_5_2/RedfishManager_V1_5_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_5_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_5_2_Dxe + FILE_GUID = e8150a0e-972e-4938-941e-b497ed92ff3e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_5_2EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_5_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_5_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_5_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_5_3/Manager_V1_5_3_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_5_3/Manager_V1_5_3_Dxe.c new file mode 100644 index 00000000000..7b94085a4df --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_5_3/Manager_V1_5_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_5_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "5", + "3" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_5_3 *ManagerV1_5_3; + EFI_REDFISH_MANAGER_V1_5_3_CS *ManagerV1_5_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_5_3_To_CS (ResoruceRaw, &ManagerV1_5_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_5_3 = (EFI_REDFISH_MANAGER_V1_5_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_5_3)); + if (ManagerV1_5_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_5_3; + ManagerV1_5_3->Manager = ManagerV1_5_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_5_3_JSON (*((EFI_REDFISH_MANAGER_V1_5_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_5_3 *ManagerV1_5_3; + + ManagerV1_5_3 = (EFI_REDFISH_MANAGER_V1_5_3 *)InterpProp; + DestroyManager_V1_5_3_CS (ManagerV1_5_3->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_5_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_5_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_5_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_5_3/RedfishManager_V1_5_3_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_5_3/RedfishManager_V1_5_3_Dxe.inf new file mode 100644 index 00000000000..a65d0920ffb --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_5_3/RedfishManager_V1_5_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_5_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_5_3_Dxe + FILE_GUID = 1bc2ad4a-d973-4372-8e0a-76afda23ad5e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_5_3EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_5_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_5_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_5_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_5_4/Manager_V1_5_4_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_5_4/Manager_V1_5_4_Dxe.c new file mode 100644 index 00000000000..5cb78a7f8bf --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_5_4/Manager_V1_5_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_5_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "5", + "4" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_5_4 *ManagerV1_5_4; + EFI_REDFISH_MANAGER_V1_5_4_CS *ManagerV1_5_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_5_4_To_CS (ResoruceRaw, &ManagerV1_5_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_5_4 = (EFI_REDFISH_MANAGER_V1_5_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_5_4)); + if (ManagerV1_5_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_5_4; + ManagerV1_5_4->Manager = ManagerV1_5_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_5_4_JSON (*((EFI_REDFISH_MANAGER_V1_5_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_5_4 *ManagerV1_5_4; + + ManagerV1_5_4 = (EFI_REDFISH_MANAGER_V1_5_4 *)InterpProp; + DestroyManager_V1_5_4_CS (ManagerV1_5_4->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_5_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_5_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_5_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_5_4/RedfishManager_V1_5_4_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_5_4/RedfishManager_V1_5_4_Dxe.inf new file mode 100644 index 00000000000..2e30f9ce162 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_5_4/RedfishManager_V1_5_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_5_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_5_4_Dxe + FILE_GUID = 7b5c4789-bef5-457c-bad1-f60cb785e067 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_5_4EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_5_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_5_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_5_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_5_5/Manager_V1_5_5_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_5_5/Manager_V1_5_5_Dxe.c new file mode 100644 index 00000000000..67cf5550e78 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_5_5/Manager_V1_5_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_5_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_5_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "5", + "5" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_5_5 *ManagerV1_5_5; + EFI_REDFISH_MANAGER_V1_5_5_CS *ManagerV1_5_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_5_5_To_CS (ResoruceRaw, &ManagerV1_5_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_5_5 = (EFI_REDFISH_MANAGER_V1_5_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_5_5)); + if (ManagerV1_5_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_5_5; + ManagerV1_5_5->Manager = ManagerV1_5_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_5_5_JSON (*((EFI_REDFISH_MANAGER_V1_5_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_5_5 *ManagerV1_5_5; + + ManagerV1_5_5 = (EFI_REDFISH_MANAGER_V1_5_5 *)InterpProp; + DestroyManager_V1_5_5_CS (ManagerV1_5_5->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_5_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_5_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_5_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_5_5/RedfishManager_V1_5_5_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_5_5/RedfishManager_V1_5_5_Dxe.inf new file mode 100644 index 00000000000..f0c10941f93 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_5_5/RedfishManager_V1_5_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_5_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_5_5_Dxe + FILE_GUID = 1f2cc7f4-b684-4274-a21b-5dd2bcc600fd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_5_5EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_5_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_5_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_5_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_5_6/Manager_V1_5_6_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_5_6/Manager_V1_5_6_Dxe.c new file mode 100644 index 00000000000..f63dcc358ff --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_5_6/Manager_V1_5_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_5_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_5_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "5", + "6" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_5_6 *ManagerV1_5_6; + EFI_REDFISH_MANAGER_V1_5_6_CS *ManagerV1_5_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_5_6_To_CS (ResoruceRaw, &ManagerV1_5_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_5_6 = (EFI_REDFISH_MANAGER_V1_5_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_5_6)); + if (ManagerV1_5_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_5_6; + ManagerV1_5_6->Manager = ManagerV1_5_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_5_6_JSON (*((EFI_REDFISH_MANAGER_V1_5_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_5_6 *ManagerV1_5_6; + + ManagerV1_5_6 = (EFI_REDFISH_MANAGER_V1_5_6 *)InterpProp; + DestroyManager_V1_5_6_CS (ManagerV1_5_6->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_5_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_5_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_5_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_5_6/RedfishManager_V1_5_6_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_5_6/RedfishManager_V1_5_6_Dxe.inf new file mode 100644 index 00000000000..ea6d611a009 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_5_6/RedfishManager_V1_5_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_5_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_5_6_Dxe + FILE_GUID = fb9c23bf-2e75-4208-a8c6-3dd15f1c60d8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_5_6EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_5_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_5_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_5_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_5_7/Manager_V1_5_7_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_5_7/Manager_V1_5_7_Dxe.c new file mode 100644 index 00000000000..2c88090b125 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_5_7/Manager_V1_5_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_5_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_5_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "5", + "7" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_5_7 *ManagerV1_5_7; + EFI_REDFISH_MANAGER_V1_5_7_CS *ManagerV1_5_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_5_7_To_CS (ResoruceRaw, &ManagerV1_5_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_5_7 = (EFI_REDFISH_MANAGER_V1_5_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_5_7)); + if (ManagerV1_5_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_5_7; + ManagerV1_5_7->Manager = ManagerV1_5_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_5_7_JSON (*((EFI_REDFISH_MANAGER_V1_5_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_5_7 *ManagerV1_5_7; + + ManagerV1_5_7 = (EFI_REDFISH_MANAGER_V1_5_7 *)InterpProp; + DestroyManager_V1_5_7_CS (ManagerV1_5_7->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_5_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_5_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_5_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_5_7/RedfishManager_V1_5_7_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_5_7/RedfishManager_V1_5_7_Dxe.inf new file mode 100644 index 00000000000..bab9ce7e54c --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_5_7/RedfishManager_V1_5_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_5_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_5_7_Dxe + FILE_GUID = eabcc092-d183-48a9-b590-cafed0ca7644 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_5_7EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_5_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_5_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_5_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_6_0/Manager_V1_6_0_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_6_0/Manager_V1_6_0_Dxe.c new file mode 100644 index 00000000000..b11db45f3f6 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_6_0/Manager_V1_6_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_6_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "6", + "0" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_6_0 *ManagerV1_6_0; + EFI_REDFISH_MANAGER_V1_6_0_CS *ManagerV1_6_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_6_0_To_CS (ResoruceRaw, &ManagerV1_6_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_6_0 = (EFI_REDFISH_MANAGER_V1_6_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_6_0)); + if (ManagerV1_6_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_6_0; + ManagerV1_6_0->Manager = ManagerV1_6_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_6_0_JSON (*((EFI_REDFISH_MANAGER_V1_6_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_6_0 *ManagerV1_6_0; + + ManagerV1_6_0 = (EFI_REDFISH_MANAGER_V1_6_0 *)InterpProp; + DestroyManager_V1_6_0_CS (ManagerV1_6_0->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_6_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_6_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_6_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_6_0/RedfishManager_V1_6_0_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_6_0/RedfishManager_V1_6_0_Dxe.inf new file mode 100644 index 00000000000..e94c8f6aa4b --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_6_0/RedfishManager_V1_6_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_6_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_6_0_Dxe + FILE_GUID = f13de20e-148f-444d-8a2c-fae981048027 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_6_0EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_6_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_6_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_6_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_6_1/Manager_V1_6_1_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_6_1/Manager_V1_6_1_Dxe.c new file mode 100644 index 00000000000..b7954cda3da --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_6_1/Manager_V1_6_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_6_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "6", + "1" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_6_1 *ManagerV1_6_1; + EFI_REDFISH_MANAGER_V1_6_1_CS *ManagerV1_6_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_6_1_To_CS (ResoruceRaw, &ManagerV1_6_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_6_1 = (EFI_REDFISH_MANAGER_V1_6_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_6_1)); + if (ManagerV1_6_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_6_1; + ManagerV1_6_1->Manager = ManagerV1_6_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_6_1_JSON (*((EFI_REDFISH_MANAGER_V1_6_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_6_1 *ManagerV1_6_1; + + ManagerV1_6_1 = (EFI_REDFISH_MANAGER_V1_6_1 *)InterpProp; + DestroyManager_V1_6_1_CS (ManagerV1_6_1->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_6_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_6_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_6_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_6_1/RedfishManager_V1_6_1_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_6_1/RedfishManager_V1_6_1_Dxe.inf new file mode 100644 index 00000000000..80158cf6d53 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_6_1/RedfishManager_V1_6_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_6_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_6_1_Dxe + FILE_GUID = c149832f-30e9-4760-9eea-d544a41d3fe1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_6_1EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_6_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_6_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_6_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_6_2/Manager_V1_6_2_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_6_2/Manager_V1_6_2_Dxe.c new file mode 100644 index 00000000000..7fd7c6f74e5 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_6_2/Manager_V1_6_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_6_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "6", + "2" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_6_2 *ManagerV1_6_2; + EFI_REDFISH_MANAGER_V1_6_2_CS *ManagerV1_6_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_6_2_To_CS (ResoruceRaw, &ManagerV1_6_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_6_2 = (EFI_REDFISH_MANAGER_V1_6_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_6_2)); + if (ManagerV1_6_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_6_2; + ManagerV1_6_2->Manager = ManagerV1_6_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_6_2_JSON (*((EFI_REDFISH_MANAGER_V1_6_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_6_2 *ManagerV1_6_2; + + ManagerV1_6_2 = (EFI_REDFISH_MANAGER_V1_6_2 *)InterpProp; + DestroyManager_V1_6_2_CS (ManagerV1_6_2->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_6_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_6_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_6_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_6_2/RedfishManager_V1_6_2_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_6_2/RedfishManager_V1_6_2_Dxe.inf new file mode 100644 index 00000000000..98cefe8d9f6 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_6_2/RedfishManager_V1_6_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_6_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_6_2_Dxe + FILE_GUID = 805eca84-9bc7-4994-a462-5ba068ed5537 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_6_2EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_6_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_6_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_6_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_6_3/Manager_V1_6_3_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_6_3/Manager_V1_6_3_Dxe.c new file mode 100644 index 00000000000..fe95f1ce3f3 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_6_3/Manager_V1_6_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_6_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_6_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "6", + "3" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_6_3 *ManagerV1_6_3; + EFI_REDFISH_MANAGER_V1_6_3_CS *ManagerV1_6_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_6_3_To_CS (ResoruceRaw, &ManagerV1_6_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_6_3 = (EFI_REDFISH_MANAGER_V1_6_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_6_3)); + if (ManagerV1_6_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_6_3; + ManagerV1_6_3->Manager = ManagerV1_6_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_6_3_JSON (*((EFI_REDFISH_MANAGER_V1_6_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_6_3 *ManagerV1_6_3; + + ManagerV1_6_3 = (EFI_REDFISH_MANAGER_V1_6_3 *)InterpProp; + DestroyManager_V1_6_3_CS (ManagerV1_6_3->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_6_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_6_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_6_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_6_3/RedfishManager_V1_6_3_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_6_3/RedfishManager_V1_6_3_Dxe.inf new file mode 100644 index 00000000000..b880242bbc7 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_6_3/RedfishManager_V1_6_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_6_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_6_3_Dxe + FILE_GUID = e27d029e-1a4b-4bef-ab28-ecc46ed914f8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_6_3EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_6_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_6_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_6_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_6_4/Manager_V1_6_4_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_6_4/Manager_V1_6_4_Dxe.c new file mode 100644 index 00000000000..6fcf3a0cd51 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_6_4/Manager_V1_6_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_6_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_6_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "6", + "4" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_6_4 *ManagerV1_6_4; + EFI_REDFISH_MANAGER_V1_6_4_CS *ManagerV1_6_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_6_4_To_CS (ResoruceRaw, &ManagerV1_6_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_6_4 = (EFI_REDFISH_MANAGER_V1_6_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_6_4)); + if (ManagerV1_6_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_6_4; + ManagerV1_6_4->Manager = ManagerV1_6_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_6_4_JSON (*((EFI_REDFISH_MANAGER_V1_6_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_6_4 *ManagerV1_6_4; + + ManagerV1_6_4 = (EFI_REDFISH_MANAGER_V1_6_4 *)InterpProp; + DestroyManager_V1_6_4_CS (ManagerV1_6_4->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_6_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_6_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_6_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_6_4/RedfishManager_V1_6_4_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_6_4/RedfishManager_V1_6_4_Dxe.inf new file mode 100644 index 00000000000..98ef5db768e --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_6_4/RedfishManager_V1_6_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_6_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_6_4_Dxe + FILE_GUID = c10f0b37-eb5a-4f08-b8da-983d0395a024 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_6_4EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_6_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_6_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_6_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_7_0/Manager_V1_7_0_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_7_0/Manager_V1_7_0_Dxe.c new file mode 100644 index 00000000000..1362a70eb77 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_7_0/Manager_V1_7_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_7_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "7", + "0" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_7_0 *ManagerV1_7_0; + EFI_REDFISH_MANAGER_V1_7_0_CS *ManagerV1_7_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_7_0_To_CS (ResoruceRaw, &ManagerV1_7_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_7_0 = (EFI_REDFISH_MANAGER_V1_7_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_7_0)); + if (ManagerV1_7_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_7_0; + ManagerV1_7_0->Manager = ManagerV1_7_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_7_0_JSON (*((EFI_REDFISH_MANAGER_V1_7_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_7_0 *ManagerV1_7_0; + + ManagerV1_7_0 = (EFI_REDFISH_MANAGER_V1_7_0 *)InterpProp; + DestroyManager_V1_7_0_CS (ManagerV1_7_0->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_7_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_7_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_7_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_7_0/RedfishManager_V1_7_0_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_7_0/RedfishManager_V1_7_0_Dxe.inf new file mode 100644 index 00000000000..68d938c1cbd --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_7_0/RedfishManager_V1_7_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_7_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_7_0_Dxe + FILE_GUID = 13702aec-a8d3-4edc-a11e-83905a73e76e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_7_0EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_7_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_7_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_7_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_7_1/Manager_V1_7_1_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_7_1/Manager_V1_7_1_Dxe.c new file mode 100644 index 00000000000..d9bdd541ddf --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_7_1/Manager_V1_7_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_7_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_7_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "7", + "1" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_7_1 *ManagerV1_7_1; + EFI_REDFISH_MANAGER_V1_7_1_CS *ManagerV1_7_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_7_1_To_CS (ResoruceRaw, &ManagerV1_7_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_7_1 = (EFI_REDFISH_MANAGER_V1_7_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_7_1)); + if (ManagerV1_7_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_7_1; + ManagerV1_7_1->Manager = ManagerV1_7_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_7_1_JSON (*((EFI_REDFISH_MANAGER_V1_7_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_7_1 *ManagerV1_7_1; + + ManagerV1_7_1 = (EFI_REDFISH_MANAGER_V1_7_1 *)InterpProp; + DestroyManager_V1_7_1_CS (ManagerV1_7_1->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_7_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_7_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_7_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_7_1/RedfishManager_V1_7_1_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_7_1/RedfishManager_V1_7_1_Dxe.inf new file mode 100644 index 00000000000..0ce58184006 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_7_1/RedfishManager_V1_7_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_7_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_7_1_Dxe + FILE_GUID = 7639a6f9-083f-4870-9c2e-46bb2a0918f1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_7_1EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_7_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_7_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_7_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_7_2/Manager_V1_7_2_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_7_2/Manager_V1_7_2_Dxe.c new file mode 100644 index 00000000000..84f8e293d7e --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_7_2/Manager_V1_7_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_7_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_7_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "7", + "2" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_7_2 *ManagerV1_7_2; + EFI_REDFISH_MANAGER_V1_7_2_CS *ManagerV1_7_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_7_2_To_CS (ResoruceRaw, &ManagerV1_7_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_7_2 = (EFI_REDFISH_MANAGER_V1_7_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_7_2)); + if (ManagerV1_7_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_7_2; + ManagerV1_7_2->Manager = ManagerV1_7_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_7_2_JSON (*((EFI_REDFISH_MANAGER_V1_7_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_7_2 *ManagerV1_7_2; + + ManagerV1_7_2 = (EFI_REDFISH_MANAGER_V1_7_2 *)InterpProp; + DestroyManager_V1_7_2_CS (ManagerV1_7_2->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_7_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_7_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_7_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_7_2/RedfishManager_V1_7_2_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_7_2/RedfishManager_V1_7_2_Dxe.inf new file mode 100644 index 00000000000..e2f94ee5e58 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_7_2/RedfishManager_V1_7_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_7_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_7_2_Dxe + FILE_GUID = 6dc1be6e-eeb0-4f9f-bec3-f890f9b89eea + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_7_2EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_7_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_7_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_7_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_7_3/Manager_V1_7_3_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_7_3/Manager_V1_7_3_Dxe.c new file mode 100644 index 00000000000..00f6e07a9da --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_7_3/Manager_V1_7_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_7_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_7_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "7", + "3" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_7_3 *ManagerV1_7_3; + EFI_REDFISH_MANAGER_V1_7_3_CS *ManagerV1_7_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_7_3_To_CS (ResoruceRaw, &ManagerV1_7_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_7_3 = (EFI_REDFISH_MANAGER_V1_7_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_7_3)); + if (ManagerV1_7_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_7_3; + ManagerV1_7_3->Manager = ManagerV1_7_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_7_3_JSON (*((EFI_REDFISH_MANAGER_V1_7_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_7_3 *ManagerV1_7_3; + + ManagerV1_7_3 = (EFI_REDFISH_MANAGER_V1_7_3 *)InterpProp; + DestroyManager_V1_7_3_CS (ManagerV1_7_3->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_7_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_7_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_7_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_7_3/RedfishManager_V1_7_3_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_7_3/RedfishManager_V1_7_3_Dxe.inf new file mode 100644 index 00000000000..f36921eaa8b --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_7_3/RedfishManager_V1_7_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_7_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_7_3_Dxe + FILE_GUID = e0c0914d-28fd-4682-bc50-919c27e4bcbf + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_7_3EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_7_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_7_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_7_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_7_4/Manager_V1_7_4_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_7_4/Manager_V1_7_4_Dxe.c new file mode 100644 index 00000000000..b009afad649 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_7_4/Manager_V1_7_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_7_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_7_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "7", + "4" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_7_4 *ManagerV1_7_4; + EFI_REDFISH_MANAGER_V1_7_4_CS *ManagerV1_7_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_7_4_To_CS (ResoruceRaw, &ManagerV1_7_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_7_4 = (EFI_REDFISH_MANAGER_V1_7_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_7_4)); + if (ManagerV1_7_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_7_4; + ManagerV1_7_4->Manager = ManagerV1_7_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_7_4_JSON (*((EFI_REDFISH_MANAGER_V1_7_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_7_4 *ManagerV1_7_4; + + ManagerV1_7_4 = (EFI_REDFISH_MANAGER_V1_7_4 *)InterpProp; + DestroyManager_V1_7_4_CS (ManagerV1_7_4->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_7_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_7_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_7_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_7_4/RedfishManager_V1_7_4_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_7_4/RedfishManager_V1_7_4_Dxe.inf new file mode 100644 index 00000000000..5474c6f61c7 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_7_4/RedfishManager_V1_7_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_7_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_7_4_Dxe + FILE_GUID = bbe46aa0-b30e-423b-8c3b-420aa6039566 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_7_4EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_7_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_7_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_7_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_8_0/Manager_V1_8_0_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_8_0/Manager_V1_8_0_Dxe.c new file mode 100644 index 00000000000..f5628360386 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_8_0/Manager_V1_8_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_8_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_8_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "8", + "0" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_8_0 *ManagerV1_8_0; + EFI_REDFISH_MANAGER_V1_8_0_CS *ManagerV1_8_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_8_0_To_CS (ResoruceRaw, &ManagerV1_8_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_8_0 = (EFI_REDFISH_MANAGER_V1_8_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_8_0)); + if (ManagerV1_8_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_8_0; + ManagerV1_8_0->Manager = ManagerV1_8_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_8_0_JSON (*((EFI_REDFISH_MANAGER_V1_8_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_8_0 *ManagerV1_8_0; + + ManagerV1_8_0 = (EFI_REDFISH_MANAGER_V1_8_0 *)InterpProp; + DestroyManager_V1_8_0_CS (ManagerV1_8_0->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_8_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_8_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_8_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_8_0/RedfishManager_V1_8_0_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_8_0/RedfishManager_V1_8_0_Dxe.inf new file mode 100644 index 00000000000..62d4d1630ba --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_8_0/RedfishManager_V1_8_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_8_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_8_0_Dxe + FILE_GUID = cbffbaba-9db5-48dc-a83f-0f764020f57b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_8_0EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_8_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_8_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_8_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_8_1/Manager_V1_8_1_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_8_1/Manager_V1_8_1_Dxe.c new file mode 100644 index 00000000000..e6aa5b76002 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_8_1/Manager_V1_8_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_8_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_8_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "8", + "1" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_8_1 *ManagerV1_8_1; + EFI_REDFISH_MANAGER_V1_8_1_CS *ManagerV1_8_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_8_1_To_CS (ResoruceRaw, &ManagerV1_8_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_8_1 = (EFI_REDFISH_MANAGER_V1_8_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_8_1)); + if (ManagerV1_8_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_8_1; + ManagerV1_8_1->Manager = ManagerV1_8_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_8_1_JSON (*((EFI_REDFISH_MANAGER_V1_8_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_8_1 *ManagerV1_8_1; + + ManagerV1_8_1 = (EFI_REDFISH_MANAGER_V1_8_1 *)InterpProp; + DestroyManager_V1_8_1_CS (ManagerV1_8_1->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_8_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_8_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_8_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_8_1/RedfishManager_V1_8_1_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_8_1/RedfishManager_V1_8_1_Dxe.inf new file mode 100644 index 00000000000..c1c3b4fad88 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_8_1/RedfishManager_V1_8_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_8_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_8_1_Dxe + FILE_GUID = 7dde2a7f-b689-4df7-a09d-cd64fcdb96a7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_8_1EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_8_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_8_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_8_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_8_2/Manager_V1_8_2_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_8_2/Manager_V1_8_2_Dxe.c new file mode 100644 index 00000000000..d1e2af70070 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_8_2/Manager_V1_8_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_8_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_8_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "8", + "2" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_8_2 *ManagerV1_8_2; + EFI_REDFISH_MANAGER_V1_8_2_CS *ManagerV1_8_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_8_2_To_CS (ResoruceRaw, &ManagerV1_8_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_8_2 = (EFI_REDFISH_MANAGER_V1_8_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_8_2)); + if (ManagerV1_8_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_8_2; + ManagerV1_8_2->Manager = ManagerV1_8_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_8_2_JSON (*((EFI_REDFISH_MANAGER_V1_8_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_8_2 *ManagerV1_8_2; + + ManagerV1_8_2 = (EFI_REDFISH_MANAGER_V1_8_2 *)InterpProp; + DestroyManager_V1_8_2_CS (ManagerV1_8_2->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_8_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_8_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_8_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_8_2/RedfishManager_V1_8_2_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_8_2/RedfishManager_V1_8_2_Dxe.inf new file mode 100644 index 00000000000..a1cb7547645 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_8_2/RedfishManager_V1_8_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_8_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_8_2_Dxe + FILE_GUID = 849ef854-d309-4b05-819e-39c19d2c8259 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_8_2EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_8_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_8_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_8_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_8_3/Manager_V1_8_3_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_8_3/Manager_V1_8_3_Dxe.c new file mode 100644 index 00000000000..5d2d06f7b58 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_8_3/Manager_V1_8_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_8_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_8_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "8", + "3" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_8_3 *ManagerV1_8_3; + EFI_REDFISH_MANAGER_V1_8_3_CS *ManagerV1_8_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_8_3_To_CS (ResoruceRaw, &ManagerV1_8_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_8_3 = (EFI_REDFISH_MANAGER_V1_8_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_8_3)); + if (ManagerV1_8_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_8_3; + ManagerV1_8_3->Manager = ManagerV1_8_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_8_3_JSON (*((EFI_REDFISH_MANAGER_V1_8_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_8_3 *ManagerV1_8_3; + + ManagerV1_8_3 = (EFI_REDFISH_MANAGER_V1_8_3 *)InterpProp; + DestroyManager_V1_8_3_CS (ManagerV1_8_3->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_8_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_8_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_8_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_8_3/RedfishManager_V1_8_3_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_8_3/RedfishManager_V1_8_3_Dxe.inf new file mode 100644 index 00000000000..86ba01c4306 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_8_3/RedfishManager_V1_8_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_8_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_8_3_Dxe + FILE_GUID = 67125780-ef97-4cee-9486-c367bd8b325b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_8_3EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_8_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_8_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_8_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_9_0/Manager_V1_9_0_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_9_0/Manager_V1_9_0_Dxe.c new file mode 100644 index 00000000000..ebb3140d61b --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_9_0/Manager_V1_9_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_9_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_9_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "9", + "0" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_9_0 *ManagerV1_9_0; + EFI_REDFISH_MANAGER_V1_9_0_CS *ManagerV1_9_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_9_0_To_CS (ResoruceRaw, &ManagerV1_9_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_9_0 = (EFI_REDFISH_MANAGER_V1_9_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_9_0)); + if (ManagerV1_9_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_9_0; + ManagerV1_9_0->Manager = ManagerV1_9_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_9_0_JSON (*((EFI_REDFISH_MANAGER_V1_9_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_9_0 *ManagerV1_9_0; + + ManagerV1_9_0 = (EFI_REDFISH_MANAGER_V1_9_0 *)InterpProp; + DestroyManager_V1_9_0_CS (ManagerV1_9_0->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_9_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_9_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_9_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_9_0/RedfishManager_V1_9_0_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_9_0/RedfishManager_V1_9_0_Dxe.inf new file mode 100644 index 00000000000..115fd2a255f --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_9_0/RedfishManager_V1_9_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_9_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_9_0_Dxe + FILE_GUID = e9914a34-0721-4bff-8fdc-befcfe9e872a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_9_0EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_9_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_9_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_9_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_9_1/Manager_V1_9_1_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_9_1/Manager_V1_9_1_Dxe.c new file mode 100644 index 00000000000..3289c8bfb00 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_9_1/Manager_V1_9_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_9_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_9_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "9", + "1" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_9_1 *ManagerV1_9_1; + EFI_REDFISH_MANAGER_V1_9_1_CS *ManagerV1_9_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_9_1_To_CS (ResoruceRaw, &ManagerV1_9_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_9_1 = (EFI_REDFISH_MANAGER_V1_9_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_9_1)); + if (ManagerV1_9_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_9_1; + ManagerV1_9_1->Manager = ManagerV1_9_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_9_1_JSON (*((EFI_REDFISH_MANAGER_V1_9_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_9_1 *ManagerV1_9_1; + + ManagerV1_9_1 = (EFI_REDFISH_MANAGER_V1_9_1 *)InterpProp; + DestroyManager_V1_9_1_CS (ManagerV1_9_1->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_9_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_9_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_9_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_9_1/RedfishManager_V1_9_1_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_9_1/RedfishManager_V1_9_1_Dxe.inf new file mode 100644 index 00000000000..8436e36cfd6 --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_9_1/RedfishManager_V1_9_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_9_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_9_1_Dxe + FILE_GUID = c0a1d52a-3f6d-4d91-9545-a40427e4f116 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_9_1EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_9_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_9_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_9_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Manager/v1_9_2/Manager_V1_9_2_Dxe.c b/RedfishClientPkg/Converter/Manager/v1_9_2/Manager_V1_9_2_Dxe.c new file mode 100644 index 00000000000..b3a1696bf6f --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_9_2/Manager_V1_9_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Manager.v1_9_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Manager"; +BOOLEAN IsRevisonController = TRUE; + +// Support Manager V1_9_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Manager", + "1", + "9", + "2" + }, + "Manager" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_9_2 *ManagerV1_9_2; + EFI_REDFISH_MANAGER_V1_9_2_CS *ManagerV1_9_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Manager") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Manager_V1_9_2_To_CS (ResoruceRaw, &ManagerV1_9_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerV1_9_2 = (EFI_REDFISH_MANAGER_V1_9_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGER_V1_9_2)); + if (ManagerV1_9_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerV1_9_2; + ManagerV1_9_2->Manager = ManagerV1_9_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Manager"), "Manager"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Manager")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Manager"), "Manager"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Manager_V1_9_2_JSON (*((EFI_REDFISH_MANAGER_V1_9_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGER_V1_9_2 *ManagerV1_9_2; + + ManagerV1_9_2 = (EFI_REDFISH_MANAGER_V1_9_2 *)InterpProp; + DestroyManager_V1_9_2_CS (ManagerV1_9_2->Manager); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManager_V1_9_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_9_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerToStructWrapper, + ManagerToJson, + ManagerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManager_V1_9_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Manager/v1_9_2/RedfishManager_V1_9_2_Dxe.inf b/RedfishClientPkg/Converter/Manager/v1_9_2/RedfishManager_V1_9_2_Dxe.inf new file mode 100644 index 00000000000..ffef3b0350e --- /dev/null +++ b/RedfishClientPkg/Converter/Manager/v1_9_2/RedfishManager_V1_9_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Manager.v1_9_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManager_V1_9_2_Dxe + FILE_GUID = 6a9496c8-fb00-41dd-a41a-b27c848f6aa8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManager_V1_9_2EntryPoint + UNLOAD_IMAGE = RedfishManager_V1_9_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Manager_V1_9_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerV1_9_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_0_0/ManagerAccount_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_0_0/ManagerAccount_V1_0_0_Dxe.c new file mode 100644 index 00000000000..fae7d01117e --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_0_0/ManagerAccount_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "0", + "0" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_0_0 *ManagerAccountV1_0_0; + EFI_REDFISH_MANAGERACCOUNT_V1_0_0_CS *ManagerAccountV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_0_0_To_CS (ResoruceRaw, &ManagerAccountV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_0_0 = (EFI_REDFISH_MANAGERACCOUNT_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_0_0)); + if (ManagerAccountV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_0_0; + ManagerAccountV1_0_0->ManagerAccount = ManagerAccountV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_0_0_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_0_0 *ManagerAccountV1_0_0; + + ManagerAccountV1_0_0 = (EFI_REDFISH_MANAGERACCOUNT_V1_0_0 *)InterpProp; + DestroyManagerAccount_V1_0_0_CS (ManagerAccountV1_0_0->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_0_0/RedfishManagerAccount_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_0_0/RedfishManagerAccount_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..869d22ddc32 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_0_0/RedfishManagerAccount_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_0_0_Dxe + FILE_GUID = 9d105de8-d131-4103-aaed-af1d3a78e77a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_0_10/ManagerAccount_V1_0_10_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_0_10/ManagerAccount_V1_0_10_Dxe.c new file mode 100644 index 00000000000..0891d85b693 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_0_10/ManagerAccount_V1_0_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_0_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "0", + "10" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_0_10 *ManagerAccountV1_0_10; + EFI_REDFISH_MANAGERACCOUNT_V1_0_10_CS *ManagerAccountV1_0_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_0_10_To_CS (ResoruceRaw, &ManagerAccountV1_0_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_0_10 = (EFI_REDFISH_MANAGERACCOUNT_V1_0_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_0_10)); + if (ManagerAccountV1_0_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_0_10; + ManagerAccountV1_0_10->ManagerAccount = ManagerAccountV1_0_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_0_10_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_0_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_0_10 *ManagerAccountV1_0_10; + + ManagerAccountV1_0_10 = (EFI_REDFISH_MANAGERACCOUNT_V1_0_10 *)InterpProp; + DestroyManagerAccount_V1_0_10_CS (ManagerAccountV1_0_10->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_0_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_0_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_0_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_0_10/RedfishManagerAccount_V1_0_10_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_0_10/RedfishManagerAccount_V1_0_10_Dxe.inf new file mode 100644 index 00000000000..38850e23652 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_0_10/RedfishManagerAccount_V1_0_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_0_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_0_10_Dxe + FILE_GUID = dca0ac71-d834-4eab-bce5-a7fab77c0405 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_0_10EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_0_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_0_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_0_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_0_11/ManagerAccount_V1_0_11_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_0_11/ManagerAccount_V1_0_11_Dxe.c new file mode 100644 index 00000000000..01ec2adcc10 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_0_11/ManagerAccount_V1_0_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_0_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "0", + "11" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_0_11 *ManagerAccountV1_0_11; + EFI_REDFISH_MANAGERACCOUNT_V1_0_11_CS *ManagerAccountV1_0_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_0_11_To_CS (ResoruceRaw, &ManagerAccountV1_0_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_0_11 = (EFI_REDFISH_MANAGERACCOUNT_V1_0_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_0_11)); + if (ManagerAccountV1_0_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_0_11; + ManagerAccountV1_0_11->ManagerAccount = ManagerAccountV1_0_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_0_11_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_0_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_0_11 *ManagerAccountV1_0_11; + + ManagerAccountV1_0_11 = (EFI_REDFISH_MANAGERACCOUNT_V1_0_11 *)InterpProp; + DestroyManagerAccount_V1_0_11_CS (ManagerAccountV1_0_11->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_0_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_0_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_0_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_0_11/RedfishManagerAccount_V1_0_11_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_0_11/RedfishManagerAccount_V1_0_11_Dxe.inf new file mode 100644 index 00000000000..7d010991aec --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_0_11/RedfishManagerAccount_V1_0_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_0_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_0_11_Dxe + FILE_GUID = adbb7be5-1ad7-40a8-a558-747c03e3b7b4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_0_11EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_0_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_0_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_0_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_0_2/ManagerAccount_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_0_2/ManagerAccount_V1_0_2_Dxe.c new file mode 100644 index 00000000000..31ec2721009 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_0_2/ManagerAccount_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "0", + "2" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_0_2 *ManagerAccountV1_0_2; + EFI_REDFISH_MANAGERACCOUNT_V1_0_2_CS *ManagerAccountV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_0_2_To_CS (ResoruceRaw, &ManagerAccountV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_0_2 = (EFI_REDFISH_MANAGERACCOUNT_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_0_2)); + if (ManagerAccountV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_0_2; + ManagerAccountV1_0_2->ManagerAccount = ManagerAccountV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_0_2_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_0_2 *ManagerAccountV1_0_2; + + ManagerAccountV1_0_2 = (EFI_REDFISH_MANAGERACCOUNT_V1_0_2 *)InterpProp; + DestroyManagerAccount_V1_0_2_CS (ManagerAccountV1_0_2->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_0_2/RedfishManagerAccount_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_0_2/RedfishManagerAccount_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..c9eb698920f --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_0_2/RedfishManagerAccount_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_0_2_Dxe + FILE_GUID = 0651b9fd-28ad-4f40-bee2-2520acb5e0e8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_0_3/ManagerAccount_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_0_3/ManagerAccount_V1_0_3_Dxe.c new file mode 100644 index 00000000000..cf3ebf5188d --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_0_3/ManagerAccount_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "0", + "3" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_0_3 *ManagerAccountV1_0_3; + EFI_REDFISH_MANAGERACCOUNT_V1_0_3_CS *ManagerAccountV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_0_3_To_CS (ResoruceRaw, &ManagerAccountV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_0_3 = (EFI_REDFISH_MANAGERACCOUNT_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_0_3)); + if (ManagerAccountV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_0_3; + ManagerAccountV1_0_3->ManagerAccount = ManagerAccountV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_0_3_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_0_3 *ManagerAccountV1_0_3; + + ManagerAccountV1_0_3 = (EFI_REDFISH_MANAGERACCOUNT_V1_0_3 *)InterpProp; + DestroyManagerAccount_V1_0_3_CS (ManagerAccountV1_0_3->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_0_3/RedfishManagerAccount_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_0_3/RedfishManagerAccount_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..2f1bcdb7571 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_0_3/RedfishManagerAccount_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_0_3_Dxe + FILE_GUID = eae83bba-0c14-4a48-8133-229c451c973b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_0_4/ManagerAccount_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_0_4/ManagerAccount_V1_0_4_Dxe.c new file mode 100644 index 00000000000..924a160bb94 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_0_4/ManagerAccount_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "0", + "4" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_0_4 *ManagerAccountV1_0_4; + EFI_REDFISH_MANAGERACCOUNT_V1_0_4_CS *ManagerAccountV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_0_4_To_CS (ResoruceRaw, &ManagerAccountV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_0_4 = (EFI_REDFISH_MANAGERACCOUNT_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_0_4)); + if (ManagerAccountV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_0_4; + ManagerAccountV1_0_4->ManagerAccount = ManagerAccountV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_0_4_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_0_4 *ManagerAccountV1_0_4; + + ManagerAccountV1_0_4 = (EFI_REDFISH_MANAGERACCOUNT_V1_0_4 *)InterpProp; + DestroyManagerAccount_V1_0_4_CS (ManagerAccountV1_0_4->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_0_4/RedfishManagerAccount_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_0_4/RedfishManagerAccount_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..fe667a6b6a2 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_0_4/RedfishManagerAccount_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_0_4_Dxe + FILE_GUID = a9715e73-960d-45f7-be4c-d0787ff548ae + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_0_5/ManagerAccount_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_0_5/ManagerAccount_V1_0_5_Dxe.c new file mode 100644 index 00000000000..2db1985b88f --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_0_5/ManagerAccount_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "0", + "5" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_0_5 *ManagerAccountV1_0_5; + EFI_REDFISH_MANAGERACCOUNT_V1_0_5_CS *ManagerAccountV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_0_5_To_CS (ResoruceRaw, &ManagerAccountV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_0_5 = (EFI_REDFISH_MANAGERACCOUNT_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_0_5)); + if (ManagerAccountV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_0_5; + ManagerAccountV1_0_5->ManagerAccount = ManagerAccountV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_0_5_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_0_5 *ManagerAccountV1_0_5; + + ManagerAccountV1_0_5 = (EFI_REDFISH_MANAGERACCOUNT_V1_0_5 *)InterpProp; + DestroyManagerAccount_V1_0_5_CS (ManagerAccountV1_0_5->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_0_5/RedfishManagerAccount_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_0_5/RedfishManagerAccount_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..bc97ae62719 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_0_5/RedfishManagerAccount_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_0_5_Dxe + FILE_GUID = ca419b0b-0fb5-4500-b6c1-19adc38fc35c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_0_6/ManagerAccount_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_0_6/ManagerAccount_V1_0_6_Dxe.c new file mode 100644 index 00000000000..5c87570dae7 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_0_6/ManagerAccount_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "0", + "6" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_0_6 *ManagerAccountV1_0_6; + EFI_REDFISH_MANAGERACCOUNT_V1_0_6_CS *ManagerAccountV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_0_6_To_CS (ResoruceRaw, &ManagerAccountV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_0_6 = (EFI_REDFISH_MANAGERACCOUNT_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_0_6)); + if (ManagerAccountV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_0_6; + ManagerAccountV1_0_6->ManagerAccount = ManagerAccountV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_0_6_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_0_6 *ManagerAccountV1_0_6; + + ManagerAccountV1_0_6 = (EFI_REDFISH_MANAGERACCOUNT_V1_0_6 *)InterpProp; + DestroyManagerAccount_V1_0_6_CS (ManagerAccountV1_0_6->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_0_6/RedfishManagerAccount_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_0_6/RedfishManagerAccount_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..20371e8339e --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_0_6/RedfishManagerAccount_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_0_6_Dxe + FILE_GUID = 122df71b-645e-4f06-89f3-cf0e11465a90 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_0_7/ManagerAccount_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_0_7/ManagerAccount_V1_0_7_Dxe.c new file mode 100644 index 00000000000..d3adbbbe68b --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_0_7/ManagerAccount_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "0", + "7" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_0_7 *ManagerAccountV1_0_7; + EFI_REDFISH_MANAGERACCOUNT_V1_0_7_CS *ManagerAccountV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_0_7_To_CS (ResoruceRaw, &ManagerAccountV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_0_7 = (EFI_REDFISH_MANAGERACCOUNT_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_0_7)); + if (ManagerAccountV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_0_7; + ManagerAccountV1_0_7->ManagerAccount = ManagerAccountV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_0_7_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_0_7 *ManagerAccountV1_0_7; + + ManagerAccountV1_0_7 = (EFI_REDFISH_MANAGERACCOUNT_V1_0_7 *)InterpProp; + DestroyManagerAccount_V1_0_7_CS (ManagerAccountV1_0_7->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_0_7/RedfishManagerAccount_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_0_7/RedfishManagerAccount_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..b0b6195ad28 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_0_7/RedfishManagerAccount_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_0_7_Dxe + FILE_GUID = e262211b-ea45-4724-9a88-5d4b93cd9f27 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_0_8/ManagerAccount_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_0_8/ManagerAccount_V1_0_8_Dxe.c new file mode 100644 index 00000000000..81fcb86e85f --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_0_8/ManagerAccount_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "0", + "8" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_0_8 *ManagerAccountV1_0_8; + EFI_REDFISH_MANAGERACCOUNT_V1_0_8_CS *ManagerAccountV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_0_8_To_CS (ResoruceRaw, &ManagerAccountV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_0_8 = (EFI_REDFISH_MANAGERACCOUNT_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_0_8)); + if (ManagerAccountV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_0_8; + ManagerAccountV1_0_8->ManagerAccount = ManagerAccountV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_0_8_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_0_8 *ManagerAccountV1_0_8; + + ManagerAccountV1_0_8 = (EFI_REDFISH_MANAGERACCOUNT_V1_0_8 *)InterpProp; + DestroyManagerAccount_V1_0_8_CS (ManagerAccountV1_0_8->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_0_8/RedfishManagerAccount_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_0_8/RedfishManagerAccount_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..03f6bc42418 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_0_8/RedfishManagerAccount_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_0_8_Dxe + FILE_GUID = bd053d62-0ef3-41bf-a45b-303a1437a7d1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_0_9/ManagerAccount_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_0_9/ManagerAccount_V1_0_9_Dxe.c new file mode 100644 index 00000000000..fdf556cd116 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_0_9/ManagerAccount_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "0", + "9" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_0_9 *ManagerAccountV1_0_9; + EFI_REDFISH_MANAGERACCOUNT_V1_0_9_CS *ManagerAccountV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_0_9_To_CS (ResoruceRaw, &ManagerAccountV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_0_9 = (EFI_REDFISH_MANAGERACCOUNT_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_0_9)); + if (ManagerAccountV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_0_9; + ManagerAccountV1_0_9->ManagerAccount = ManagerAccountV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_0_9_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_0_9 *ManagerAccountV1_0_9; + + ManagerAccountV1_0_9 = (EFI_REDFISH_MANAGERACCOUNT_V1_0_9 *)InterpProp; + DestroyManagerAccount_V1_0_9_CS (ManagerAccountV1_0_9->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_0_9/RedfishManagerAccount_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_0_9/RedfishManagerAccount_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..68862ccbea5 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_0_9/RedfishManagerAccount_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_0_9_Dxe + FILE_GUID = cb8bef4c-be20-4f77-ba13-3251664da547 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_1_0/ManagerAccount_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_1_0/ManagerAccount_V1_1_0_Dxe.c new file mode 100644 index 00000000000..ccf4bfdd5d1 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_1_0/ManagerAccount_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "1", + "0" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_1_0 *ManagerAccountV1_1_0; + EFI_REDFISH_MANAGERACCOUNT_V1_1_0_CS *ManagerAccountV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_1_0_To_CS (ResoruceRaw, &ManagerAccountV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_1_0 = (EFI_REDFISH_MANAGERACCOUNT_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_1_0)); + if (ManagerAccountV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_1_0; + ManagerAccountV1_1_0->ManagerAccount = ManagerAccountV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_1_0_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_1_0 *ManagerAccountV1_1_0; + + ManagerAccountV1_1_0 = (EFI_REDFISH_MANAGERACCOUNT_V1_1_0 *)InterpProp; + DestroyManagerAccount_V1_1_0_CS (ManagerAccountV1_1_0->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_1_0/RedfishManagerAccount_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_1_0/RedfishManagerAccount_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..ef5380cba99 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_1_0/RedfishManagerAccount_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_1_0_Dxe + FILE_GUID = bdd7d20e-f7df-4bf9-92ee-56ae772d705b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_1_1/ManagerAccount_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_1_1/ManagerAccount_V1_1_1_Dxe.c new file mode 100644 index 00000000000..8446a6c7c93 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_1_1/ManagerAccount_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "1", + "1" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_1_1 *ManagerAccountV1_1_1; + EFI_REDFISH_MANAGERACCOUNT_V1_1_1_CS *ManagerAccountV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_1_1_To_CS (ResoruceRaw, &ManagerAccountV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_1_1 = (EFI_REDFISH_MANAGERACCOUNT_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_1_1)); + if (ManagerAccountV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_1_1; + ManagerAccountV1_1_1->ManagerAccount = ManagerAccountV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_1_1_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_1_1 *ManagerAccountV1_1_1; + + ManagerAccountV1_1_1 = (EFI_REDFISH_MANAGERACCOUNT_V1_1_1 *)InterpProp; + DestroyManagerAccount_V1_1_1_CS (ManagerAccountV1_1_1->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_1_1/RedfishManagerAccount_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_1_1/RedfishManagerAccount_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..bfa96afdc27 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_1_1/RedfishManagerAccount_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_1_1_Dxe + FILE_GUID = 1e3e9cb1-f9cc-4d36-95f4-ad62e51ca71b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_1_2/ManagerAccount_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_1_2/ManagerAccount_V1_1_2_Dxe.c new file mode 100644 index 00000000000..997c86a8c24 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_1_2/ManagerAccount_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "1", + "2" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_1_2 *ManagerAccountV1_1_2; + EFI_REDFISH_MANAGERACCOUNT_V1_1_2_CS *ManagerAccountV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_1_2_To_CS (ResoruceRaw, &ManagerAccountV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_1_2 = (EFI_REDFISH_MANAGERACCOUNT_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_1_2)); + if (ManagerAccountV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_1_2; + ManagerAccountV1_1_2->ManagerAccount = ManagerAccountV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_1_2_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_1_2 *ManagerAccountV1_1_2; + + ManagerAccountV1_1_2 = (EFI_REDFISH_MANAGERACCOUNT_V1_1_2 *)InterpProp; + DestroyManagerAccount_V1_1_2_CS (ManagerAccountV1_1_2->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_1_2/RedfishManagerAccount_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_1_2/RedfishManagerAccount_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..d6d75e2d9f9 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_1_2/RedfishManagerAccount_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_1_2_Dxe + FILE_GUID = 70e7945c-8228-458e-94c6-1f001abfae4a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_1_3/ManagerAccount_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_1_3/ManagerAccount_V1_1_3_Dxe.c new file mode 100644 index 00000000000..f682c3b5708 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_1_3/ManagerAccount_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "1", + "3" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_1_3 *ManagerAccountV1_1_3; + EFI_REDFISH_MANAGERACCOUNT_V1_1_3_CS *ManagerAccountV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_1_3_To_CS (ResoruceRaw, &ManagerAccountV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_1_3 = (EFI_REDFISH_MANAGERACCOUNT_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_1_3)); + if (ManagerAccountV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_1_3; + ManagerAccountV1_1_3->ManagerAccount = ManagerAccountV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_1_3_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_1_3 *ManagerAccountV1_1_3; + + ManagerAccountV1_1_3 = (EFI_REDFISH_MANAGERACCOUNT_V1_1_3 *)InterpProp; + DestroyManagerAccount_V1_1_3_CS (ManagerAccountV1_1_3->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_1_3/RedfishManagerAccount_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_1_3/RedfishManagerAccount_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..09cb36aa34a --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_1_3/RedfishManagerAccount_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_1_3_Dxe + FILE_GUID = e7c5f663-9788-4d9a-9c04-d7fc7397c8c2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_1_4/ManagerAccount_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_1_4/ManagerAccount_V1_1_4_Dxe.c new file mode 100644 index 00000000000..7bf432b9ba7 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_1_4/ManagerAccount_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "1", + "4" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_1_4 *ManagerAccountV1_1_4; + EFI_REDFISH_MANAGERACCOUNT_V1_1_4_CS *ManagerAccountV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_1_4_To_CS (ResoruceRaw, &ManagerAccountV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_1_4 = (EFI_REDFISH_MANAGERACCOUNT_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_1_4)); + if (ManagerAccountV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_1_4; + ManagerAccountV1_1_4->ManagerAccount = ManagerAccountV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_1_4_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_1_4 *ManagerAccountV1_1_4; + + ManagerAccountV1_1_4 = (EFI_REDFISH_MANAGERACCOUNT_V1_1_4 *)InterpProp; + DestroyManagerAccount_V1_1_4_CS (ManagerAccountV1_1_4->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_1_4/RedfishManagerAccount_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_1_4/RedfishManagerAccount_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..9f32bdaa7a1 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_1_4/RedfishManagerAccount_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_1_4_Dxe + FILE_GUID = ebb80639-ed2b-4c09-b0ba-a69f481206e7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_1_5/ManagerAccount_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_1_5/ManagerAccount_V1_1_5_Dxe.c new file mode 100644 index 00000000000..02a93447b88 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_1_5/ManagerAccount_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "1", + "5" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_1_5 *ManagerAccountV1_1_5; + EFI_REDFISH_MANAGERACCOUNT_V1_1_5_CS *ManagerAccountV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_1_5_To_CS (ResoruceRaw, &ManagerAccountV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_1_5 = (EFI_REDFISH_MANAGERACCOUNT_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_1_5)); + if (ManagerAccountV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_1_5; + ManagerAccountV1_1_5->ManagerAccount = ManagerAccountV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_1_5_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_1_5 *ManagerAccountV1_1_5; + + ManagerAccountV1_1_5 = (EFI_REDFISH_MANAGERACCOUNT_V1_1_5 *)InterpProp; + DestroyManagerAccount_V1_1_5_CS (ManagerAccountV1_1_5->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_1_5/RedfishManagerAccount_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_1_5/RedfishManagerAccount_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..f5f357b0f84 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_1_5/RedfishManagerAccount_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_1_5_Dxe + FILE_GUID = 08eaa74b-d635-4930-b78c-5dbb523e4995 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_1_6/ManagerAccount_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_1_6/ManagerAccount_V1_1_6_Dxe.c new file mode 100644 index 00000000000..d6ab2414d7a --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_1_6/ManagerAccount_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "1", + "6" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_1_6 *ManagerAccountV1_1_6; + EFI_REDFISH_MANAGERACCOUNT_V1_1_6_CS *ManagerAccountV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_1_6_To_CS (ResoruceRaw, &ManagerAccountV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_1_6 = (EFI_REDFISH_MANAGERACCOUNT_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_1_6)); + if (ManagerAccountV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_1_6; + ManagerAccountV1_1_6->ManagerAccount = ManagerAccountV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_1_6_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_1_6 *ManagerAccountV1_1_6; + + ManagerAccountV1_1_6 = (EFI_REDFISH_MANAGERACCOUNT_V1_1_6 *)InterpProp; + DestroyManagerAccount_V1_1_6_CS (ManagerAccountV1_1_6->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_1_6/RedfishManagerAccount_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_1_6/RedfishManagerAccount_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..855d44d0d66 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_1_6/RedfishManagerAccount_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_1_6_Dxe + FILE_GUID = cbb37650-f08a-4f04-ba33-9a692d4bf976 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_1_7/ManagerAccount_V1_1_7_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_1_7/ManagerAccount_V1_1_7_Dxe.c new file mode 100644 index 00000000000..3771073872f --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_1_7/ManagerAccount_V1_1_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_1_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "1", + "7" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_1_7 *ManagerAccountV1_1_7; + EFI_REDFISH_MANAGERACCOUNT_V1_1_7_CS *ManagerAccountV1_1_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_1_7_To_CS (ResoruceRaw, &ManagerAccountV1_1_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_1_7 = (EFI_REDFISH_MANAGERACCOUNT_V1_1_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_1_7)); + if (ManagerAccountV1_1_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_1_7; + ManagerAccountV1_1_7->ManagerAccount = ManagerAccountV1_1_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_1_7_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_1_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_1_7 *ManagerAccountV1_1_7; + + ManagerAccountV1_1_7 = (EFI_REDFISH_MANAGERACCOUNT_V1_1_7 *)InterpProp; + DestroyManagerAccount_V1_1_7_CS (ManagerAccountV1_1_7->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_1_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_1_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_1_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_1_7/RedfishManagerAccount_V1_1_7_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_1_7/RedfishManagerAccount_V1_1_7_Dxe.inf new file mode 100644 index 00000000000..2936c057a78 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_1_7/RedfishManagerAccount_V1_1_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_1_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_1_7_Dxe + FILE_GUID = 0ea9d2b2-9848-465d-976c-9ee002fec2f5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_1_7EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_1_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_1_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_1_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_2_0/ManagerAccount_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_2_0/ManagerAccount_V1_2_0_Dxe.c new file mode 100644 index 00000000000..84c8bf174e9 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_2_0/ManagerAccount_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "2", + "0" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_2_0 *ManagerAccountV1_2_0; + EFI_REDFISH_MANAGERACCOUNT_V1_2_0_CS *ManagerAccountV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_2_0_To_CS (ResoruceRaw, &ManagerAccountV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_2_0 = (EFI_REDFISH_MANAGERACCOUNT_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_2_0)); + if (ManagerAccountV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_2_0; + ManagerAccountV1_2_0->ManagerAccount = ManagerAccountV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_2_0_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_2_0 *ManagerAccountV1_2_0; + + ManagerAccountV1_2_0 = (EFI_REDFISH_MANAGERACCOUNT_V1_2_0 *)InterpProp; + DestroyManagerAccount_V1_2_0_CS (ManagerAccountV1_2_0->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_2_0/RedfishManagerAccount_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_2_0/RedfishManagerAccount_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..c28eddfc91e --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_2_0/RedfishManagerAccount_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_2_0_Dxe + FILE_GUID = 1e8c0363-8826-4e95-b914-c84082621746 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_2_1/ManagerAccount_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_2_1/ManagerAccount_V1_2_1_Dxe.c new file mode 100644 index 00000000000..7e50b0052f9 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_2_1/ManagerAccount_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "2", + "1" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_2_1 *ManagerAccountV1_2_1; + EFI_REDFISH_MANAGERACCOUNT_V1_2_1_CS *ManagerAccountV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_2_1_To_CS (ResoruceRaw, &ManagerAccountV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_2_1 = (EFI_REDFISH_MANAGERACCOUNT_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_2_1)); + if (ManagerAccountV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_2_1; + ManagerAccountV1_2_1->ManagerAccount = ManagerAccountV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_2_1_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_2_1 *ManagerAccountV1_2_1; + + ManagerAccountV1_2_1 = (EFI_REDFISH_MANAGERACCOUNT_V1_2_1 *)InterpProp; + DestroyManagerAccount_V1_2_1_CS (ManagerAccountV1_2_1->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_2_1/RedfishManagerAccount_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_2_1/RedfishManagerAccount_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..45ad0c8c272 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_2_1/RedfishManagerAccount_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_2_1_Dxe + FILE_GUID = b5161aaf-9aa1-43d7-9d49-13269b2b0fa7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_2_2/ManagerAccount_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_2_2/ManagerAccount_V1_2_2_Dxe.c new file mode 100644 index 00000000000..b9d62dd87da --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_2_2/ManagerAccount_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "2", + "2" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_2_2 *ManagerAccountV1_2_2; + EFI_REDFISH_MANAGERACCOUNT_V1_2_2_CS *ManagerAccountV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_2_2_To_CS (ResoruceRaw, &ManagerAccountV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_2_2 = (EFI_REDFISH_MANAGERACCOUNT_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_2_2)); + if (ManagerAccountV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_2_2; + ManagerAccountV1_2_2->ManagerAccount = ManagerAccountV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_2_2_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_2_2 *ManagerAccountV1_2_2; + + ManagerAccountV1_2_2 = (EFI_REDFISH_MANAGERACCOUNT_V1_2_2 *)InterpProp; + DestroyManagerAccount_V1_2_2_CS (ManagerAccountV1_2_2->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_2_2/RedfishManagerAccount_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_2_2/RedfishManagerAccount_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..9c9374e65a0 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_2_2/RedfishManagerAccount_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_2_2_Dxe + FILE_GUID = f76cc0db-d4c2-412a-ac9f-d4dd3c10b533 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_2_3/ManagerAccount_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_2_3/ManagerAccount_V1_2_3_Dxe.c new file mode 100644 index 00000000000..76fb860c3ca --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_2_3/ManagerAccount_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "2", + "3" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_2_3 *ManagerAccountV1_2_3; + EFI_REDFISH_MANAGERACCOUNT_V1_2_3_CS *ManagerAccountV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_2_3_To_CS (ResoruceRaw, &ManagerAccountV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_2_3 = (EFI_REDFISH_MANAGERACCOUNT_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_2_3)); + if (ManagerAccountV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_2_3; + ManagerAccountV1_2_3->ManagerAccount = ManagerAccountV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_2_3_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_2_3 *ManagerAccountV1_2_3; + + ManagerAccountV1_2_3 = (EFI_REDFISH_MANAGERACCOUNT_V1_2_3 *)InterpProp; + DestroyManagerAccount_V1_2_3_CS (ManagerAccountV1_2_3->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_2_3/RedfishManagerAccount_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_2_3/RedfishManagerAccount_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..c0aa2ebb73e --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_2_3/RedfishManagerAccount_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_2_3_Dxe + FILE_GUID = 116bc1b5-a242-4e49-9c93-4504414fda43 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_2_4/ManagerAccount_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_2_4/ManagerAccount_V1_2_4_Dxe.c new file mode 100644 index 00000000000..ea41bc27f6e --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_2_4/ManagerAccount_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "2", + "4" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_2_4 *ManagerAccountV1_2_4; + EFI_REDFISH_MANAGERACCOUNT_V1_2_4_CS *ManagerAccountV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_2_4_To_CS (ResoruceRaw, &ManagerAccountV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_2_4 = (EFI_REDFISH_MANAGERACCOUNT_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_2_4)); + if (ManagerAccountV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_2_4; + ManagerAccountV1_2_4->ManagerAccount = ManagerAccountV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_2_4_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_2_4 *ManagerAccountV1_2_4; + + ManagerAccountV1_2_4 = (EFI_REDFISH_MANAGERACCOUNT_V1_2_4 *)InterpProp; + DestroyManagerAccount_V1_2_4_CS (ManagerAccountV1_2_4->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_2_4/RedfishManagerAccount_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_2_4/RedfishManagerAccount_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..49a2fdf2173 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_2_4/RedfishManagerAccount_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_2_4_Dxe + FILE_GUID = f7be877c-366f-46d5-936f-98bd55b95824 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_3_0/ManagerAccount_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_3_0/ManagerAccount_V1_3_0_Dxe.c new file mode 100644 index 00000000000..9255f059354 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_3_0/ManagerAccount_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "3", + "0" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_3_0 *ManagerAccountV1_3_0; + EFI_REDFISH_MANAGERACCOUNT_V1_3_0_CS *ManagerAccountV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_3_0_To_CS (ResoruceRaw, &ManagerAccountV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_3_0 = (EFI_REDFISH_MANAGERACCOUNT_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_3_0)); + if (ManagerAccountV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_3_0; + ManagerAccountV1_3_0->ManagerAccount = ManagerAccountV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_3_0_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_3_0 *ManagerAccountV1_3_0; + + ManagerAccountV1_3_0 = (EFI_REDFISH_MANAGERACCOUNT_V1_3_0 *)InterpProp; + DestroyManagerAccount_V1_3_0_CS (ManagerAccountV1_3_0->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_3_0/RedfishManagerAccount_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_3_0/RedfishManagerAccount_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..fa03c29ad7d --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_3_0/RedfishManagerAccount_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_3_0_Dxe + FILE_GUID = 8824e369-e278-4c95-a96d-3a228751b97f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_3_1/ManagerAccount_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_3_1/ManagerAccount_V1_3_1_Dxe.c new file mode 100644 index 00000000000..e58023b5947 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_3_1/ManagerAccount_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "3", + "1" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_3_1 *ManagerAccountV1_3_1; + EFI_REDFISH_MANAGERACCOUNT_V1_3_1_CS *ManagerAccountV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_3_1_To_CS (ResoruceRaw, &ManagerAccountV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_3_1 = (EFI_REDFISH_MANAGERACCOUNT_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_3_1)); + if (ManagerAccountV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_3_1; + ManagerAccountV1_3_1->ManagerAccount = ManagerAccountV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_3_1_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_3_1 *ManagerAccountV1_3_1; + + ManagerAccountV1_3_1 = (EFI_REDFISH_MANAGERACCOUNT_V1_3_1 *)InterpProp; + DestroyManagerAccount_V1_3_1_CS (ManagerAccountV1_3_1->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_3_1/RedfishManagerAccount_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_3_1/RedfishManagerAccount_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..d1a87cd32c1 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_3_1/RedfishManagerAccount_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_3_1_Dxe + FILE_GUID = 387797ce-f48f-4be4-9914-c097d3d1220e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_3_2/ManagerAccount_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_3_2/ManagerAccount_V1_3_2_Dxe.c new file mode 100644 index 00000000000..b87cfe7408a --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_3_2/ManagerAccount_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "3", + "2" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_3_2 *ManagerAccountV1_3_2; + EFI_REDFISH_MANAGERACCOUNT_V1_3_2_CS *ManagerAccountV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_3_2_To_CS (ResoruceRaw, &ManagerAccountV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_3_2 = (EFI_REDFISH_MANAGERACCOUNT_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_3_2)); + if (ManagerAccountV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_3_2; + ManagerAccountV1_3_2->ManagerAccount = ManagerAccountV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_3_2_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_3_2 *ManagerAccountV1_3_2; + + ManagerAccountV1_3_2 = (EFI_REDFISH_MANAGERACCOUNT_V1_3_2 *)InterpProp; + DestroyManagerAccount_V1_3_2_CS (ManagerAccountV1_3_2->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_3_2/RedfishManagerAccount_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_3_2/RedfishManagerAccount_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..05548987842 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_3_2/RedfishManagerAccount_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_3_2_Dxe + FILE_GUID = 34b4f168-a45d-433c-bbe0-068a1b7e81ec + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_3_3/ManagerAccount_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_3_3/ManagerAccount_V1_3_3_Dxe.c new file mode 100644 index 00000000000..6fd40f0b865 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_3_3/ManagerAccount_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "3", + "3" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_3_3 *ManagerAccountV1_3_3; + EFI_REDFISH_MANAGERACCOUNT_V1_3_3_CS *ManagerAccountV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_3_3_To_CS (ResoruceRaw, &ManagerAccountV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_3_3 = (EFI_REDFISH_MANAGERACCOUNT_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_3_3)); + if (ManagerAccountV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_3_3; + ManagerAccountV1_3_3->ManagerAccount = ManagerAccountV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_3_3_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_3_3 *ManagerAccountV1_3_3; + + ManagerAccountV1_3_3 = (EFI_REDFISH_MANAGERACCOUNT_V1_3_3 *)InterpProp; + DestroyManagerAccount_V1_3_3_CS (ManagerAccountV1_3_3->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_3_3/RedfishManagerAccount_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_3_3/RedfishManagerAccount_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..7159fd5928b --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_3_3/RedfishManagerAccount_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_3_3_Dxe + FILE_GUID = aecd979e-7f07-4676-90f3-0a83bcb5367b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_4_0/ManagerAccount_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_4_0/ManagerAccount_V1_4_0_Dxe.c new file mode 100644 index 00000000000..e8a19cc45d6 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_4_0/ManagerAccount_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "4", + "0" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_4_0 *ManagerAccountV1_4_0; + EFI_REDFISH_MANAGERACCOUNT_V1_4_0_CS *ManagerAccountV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_4_0_To_CS (ResoruceRaw, &ManagerAccountV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_4_0 = (EFI_REDFISH_MANAGERACCOUNT_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_4_0)); + if (ManagerAccountV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_4_0; + ManagerAccountV1_4_0->ManagerAccount = ManagerAccountV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_4_0_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_4_0 *ManagerAccountV1_4_0; + + ManagerAccountV1_4_0 = (EFI_REDFISH_MANAGERACCOUNT_V1_4_0 *)InterpProp; + DestroyManagerAccount_V1_4_0_CS (ManagerAccountV1_4_0->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_4_0/RedfishManagerAccount_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_4_0/RedfishManagerAccount_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..03356ffd7ad --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_4_0/RedfishManagerAccount_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_4_0_Dxe + FILE_GUID = b8696856-1597-47f1-bd72-f6cb493277f9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_4_1/ManagerAccount_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_4_1/ManagerAccount_V1_4_1_Dxe.c new file mode 100644 index 00000000000..e61af1c13b7 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_4_1/ManagerAccount_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "4", + "1" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_4_1 *ManagerAccountV1_4_1; + EFI_REDFISH_MANAGERACCOUNT_V1_4_1_CS *ManagerAccountV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_4_1_To_CS (ResoruceRaw, &ManagerAccountV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_4_1 = (EFI_REDFISH_MANAGERACCOUNT_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_4_1)); + if (ManagerAccountV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_4_1; + ManagerAccountV1_4_1->ManagerAccount = ManagerAccountV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_4_1_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_4_1 *ManagerAccountV1_4_1; + + ManagerAccountV1_4_1 = (EFI_REDFISH_MANAGERACCOUNT_V1_4_1 *)InterpProp; + DestroyManagerAccount_V1_4_1_CS (ManagerAccountV1_4_1->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_4_1/RedfishManagerAccount_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_4_1/RedfishManagerAccount_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..d25368d562a --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_4_1/RedfishManagerAccount_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_4_1_Dxe + FILE_GUID = 908cd78a-a068-4487-86d7-c624ab8bba3f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_4_2/ManagerAccount_V1_4_2_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_4_2/ManagerAccount_V1_4_2_Dxe.c new file mode 100644 index 00000000000..3b2f60d45fc --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_4_2/ManagerAccount_V1_4_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_4_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "4", + "2" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_4_2 *ManagerAccountV1_4_2; + EFI_REDFISH_MANAGERACCOUNT_V1_4_2_CS *ManagerAccountV1_4_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_4_2_To_CS (ResoruceRaw, &ManagerAccountV1_4_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_4_2 = (EFI_REDFISH_MANAGERACCOUNT_V1_4_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_4_2)); + if (ManagerAccountV1_4_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_4_2; + ManagerAccountV1_4_2->ManagerAccount = ManagerAccountV1_4_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_4_2_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_4_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_4_2 *ManagerAccountV1_4_2; + + ManagerAccountV1_4_2 = (EFI_REDFISH_MANAGERACCOUNT_V1_4_2 *)InterpProp; + DestroyManagerAccount_V1_4_2_CS (ManagerAccountV1_4_2->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_4_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_4_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_4_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_4_2/RedfishManagerAccount_V1_4_2_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_4_2/RedfishManagerAccount_V1_4_2_Dxe.inf new file mode 100644 index 00000000000..766504d4f98 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_4_2/RedfishManagerAccount_V1_4_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_4_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_4_2_Dxe + FILE_GUID = 2be91a93-15b7-4e0a-8f8f-c54f60ab2d9f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_4_2EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_4_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_4_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_4_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_4_3/ManagerAccount_V1_4_3_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_4_3/ManagerAccount_V1_4_3_Dxe.c new file mode 100644 index 00000000000..34e8f0e1950 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_4_3/ManagerAccount_V1_4_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_4_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "4", + "3" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_4_3 *ManagerAccountV1_4_3; + EFI_REDFISH_MANAGERACCOUNT_V1_4_3_CS *ManagerAccountV1_4_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_4_3_To_CS (ResoruceRaw, &ManagerAccountV1_4_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_4_3 = (EFI_REDFISH_MANAGERACCOUNT_V1_4_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_4_3)); + if (ManagerAccountV1_4_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_4_3; + ManagerAccountV1_4_3->ManagerAccount = ManagerAccountV1_4_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_4_3_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_4_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_4_3 *ManagerAccountV1_4_3; + + ManagerAccountV1_4_3 = (EFI_REDFISH_MANAGERACCOUNT_V1_4_3 *)InterpProp; + DestroyManagerAccount_V1_4_3_CS (ManagerAccountV1_4_3->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_4_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_4_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_4_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_4_3/RedfishManagerAccount_V1_4_3_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_4_3/RedfishManagerAccount_V1_4_3_Dxe.inf new file mode 100644 index 00000000000..c2d2a9c74a7 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_4_3/RedfishManagerAccount_V1_4_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_4_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_4_3_Dxe + FILE_GUID = ba001730-7a22-42ae-ad63-3d771f5bd54a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_4_3EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_4_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_4_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_4_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_4_4/ManagerAccount_V1_4_4_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_4_4/ManagerAccount_V1_4_4_Dxe.c new file mode 100644 index 00000000000..f5607c2fae3 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_4_4/ManagerAccount_V1_4_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_4_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "4", + "4" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_4_4 *ManagerAccountV1_4_4; + EFI_REDFISH_MANAGERACCOUNT_V1_4_4_CS *ManagerAccountV1_4_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_4_4_To_CS (ResoruceRaw, &ManagerAccountV1_4_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_4_4 = (EFI_REDFISH_MANAGERACCOUNT_V1_4_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_4_4)); + if (ManagerAccountV1_4_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_4_4; + ManagerAccountV1_4_4->ManagerAccount = ManagerAccountV1_4_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_4_4_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_4_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_4_4 *ManagerAccountV1_4_4; + + ManagerAccountV1_4_4 = (EFI_REDFISH_MANAGERACCOUNT_V1_4_4 *)InterpProp; + DestroyManagerAccount_V1_4_4_CS (ManagerAccountV1_4_4->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_4_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_4_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_4_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_4_4/RedfishManagerAccount_V1_4_4_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_4_4/RedfishManagerAccount_V1_4_4_Dxe.inf new file mode 100644 index 00000000000..753beb88892 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_4_4/RedfishManagerAccount_V1_4_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_4_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_4_4_Dxe + FILE_GUID = 250d246a-64a9-41db-868c-d45df07563ca + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_4_4EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_4_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_4_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_4_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_5_0/ManagerAccount_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_5_0/ManagerAccount_V1_5_0_Dxe.c new file mode 100644 index 00000000000..1d946d08e92 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_5_0/ManagerAccount_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "5", + "0" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_5_0 *ManagerAccountV1_5_0; + EFI_REDFISH_MANAGERACCOUNT_V1_5_0_CS *ManagerAccountV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_5_0_To_CS (ResoruceRaw, &ManagerAccountV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_5_0 = (EFI_REDFISH_MANAGERACCOUNT_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_5_0)); + if (ManagerAccountV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_5_0; + ManagerAccountV1_5_0->ManagerAccount = ManagerAccountV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_5_0_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_5_0 *ManagerAccountV1_5_0; + + ManagerAccountV1_5_0 = (EFI_REDFISH_MANAGERACCOUNT_V1_5_0 *)InterpProp; + DestroyManagerAccount_V1_5_0_CS (ManagerAccountV1_5_0->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_5_0/RedfishManagerAccount_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_5_0/RedfishManagerAccount_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..9be230dc387 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_5_0/RedfishManagerAccount_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_5_0_Dxe + FILE_GUID = 1fd2e40e-e370-4d68-85a0-1d7f96f99559 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_5_1/ManagerAccount_V1_5_1_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_5_1/ManagerAccount_V1_5_1_Dxe.c new file mode 100644 index 00000000000..d016177b5a6 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_5_1/ManagerAccount_V1_5_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_5_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "5", + "1" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_5_1 *ManagerAccountV1_5_1; + EFI_REDFISH_MANAGERACCOUNT_V1_5_1_CS *ManagerAccountV1_5_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_5_1_To_CS (ResoruceRaw, &ManagerAccountV1_5_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_5_1 = (EFI_REDFISH_MANAGERACCOUNT_V1_5_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_5_1)); + if (ManagerAccountV1_5_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_5_1; + ManagerAccountV1_5_1->ManagerAccount = ManagerAccountV1_5_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_5_1_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_5_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_5_1 *ManagerAccountV1_5_1; + + ManagerAccountV1_5_1 = (EFI_REDFISH_MANAGERACCOUNT_V1_5_1 *)InterpProp; + DestroyManagerAccount_V1_5_1_CS (ManagerAccountV1_5_1->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_5_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_5_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_5_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_5_1/RedfishManagerAccount_V1_5_1_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_5_1/RedfishManagerAccount_V1_5_1_Dxe.inf new file mode 100644 index 00000000000..2e4f78e7629 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_5_1/RedfishManagerAccount_V1_5_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_5_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_5_1_Dxe + FILE_GUID = 830a73d4-df08-482d-a014-26a87d9010c6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_5_1EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_5_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_5_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_5_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_5_2/ManagerAccount_V1_5_2_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_5_2/ManagerAccount_V1_5_2_Dxe.c new file mode 100644 index 00000000000..32482e7e1bf --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_5_2/ManagerAccount_V1_5_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_5_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "5", + "2" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_5_2 *ManagerAccountV1_5_2; + EFI_REDFISH_MANAGERACCOUNT_V1_5_2_CS *ManagerAccountV1_5_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_5_2_To_CS (ResoruceRaw, &ManagerAccountV1_5_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_5_2 = (EFI_REDFISH_MANAGERACCOUNT_V1_5_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_5_2)); + if (ManagerAccountV1_5_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_5_2; + ManagerAccountV1_5_2->ManagerAccount = ManagerAccountV1_5_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_5_2_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_5_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_5_2 *ManagerAccountV1_5_2; + + ManagerAccountV1_5_2 = (EFI_REDFISH_MANAGERACCOUNT_V1_5_2 *)InterpProp; + DestroyManagerAccount_V1_5_2_CS (ManagerAccountV1_5_2->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_5_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_5_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_5_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_5_2/RedfishManagerAccount_V1_5_2_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_5_2/RedfishManagerAccount_V1_5_2_Dxe.inf new file mode 100644 index 00000000000..93b3959a1d5 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_5_2/RedfishManagerAccount_V1_5_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_5_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_5_2_Dxe + FILE_GUID = 0ee8a5bc-ac21-45d5-b9ba-e5a03cab2907 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_5_2EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_5_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_5_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_5_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_5_3/ManagerAccount_V1_5_3_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_5_3/ManagerAccount_V1_5_3_Dxe.c new file mode 100644 index 00000000000..f59e31eea92 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_5_3/ManagerAccount_V1_5_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_5_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "5", + "3" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_5_3 *ManagerAccountV1_5_3; + EFI_REDFISH_MANAGERACCOUNT_V1_5_3_CS *ManagerAccountV1_5_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_5_3_To_CS (ResoruceRaw, &ManagerAccountV1_5_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_5_3 = (EFI_REDFISH_MANAGERACCOUNT_V1_5_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_5_3)); + if (ManagerAccountV1_5_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_5_3; + ManagerAccountV1_5_3->ManagerAccount = ManagerAccountV1_5_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_5_3_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_5_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_5_3 *ManagerAccountV1_5_3; + + ManagerAccountV1_5_3 = (EFI_REDFISH_MANAGERACCOUNT_V1_5_3 *)InterpProp; + DestroyManagerAccount_V1_5_3_CS (ManagerAccountV1_5_3->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_5_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_5_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_5_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_5_3/RedfishManagerAccount_V1_5_3_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_5_3/RedfishManagerAccount_V1_5_3_Dxe.inf new file mode 100644 index 00000000000..9b232612eff --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_5_3/RedfishManagerAccount_V1_5_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_5_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_5_3_Dxe + FILE_GUID = 14bc512a-7272-4c96-ba09-7896e53800a6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_5_3EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_5_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_5_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_5_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_6_0/ManagerAccount_V1_6_0_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_6_0/ManagerAccount_V1_6_0_Dxe.c new file mode 100644 index 00000000000..7ea105872e3 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_6_0/ManagerAccount_V1_6_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_6_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "6", + "0" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_6_0 *ManagerAccountV1_6_0; + EFI_REDFISH_MANAGERACCOUNT_V1_6_0_CS *ManagerAccountV1_6_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_6_0_To_CS (ResoruceRaw, &ManagerAccountV1_6_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_6_0 = (EFI_REDFISH_MANAGERACCOUNT_V1_6_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_6_0)); + if (ManagerAccountV1_6_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_6_0; + ManagerAccountV1_6_0->ManagerAccount = ManagerAccountV1_6_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_6_0_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_6_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_6_0 *ManagerAccountV1_6_0; + + ManagerAccountV1_6_0 = (EFI_REDFISH_MANAGERACCOUNT_V1_6_0 *)InterpProp; + DestroyManagerAccount_V1_6_0_CS (ManagerAccountV1_6_0->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_6_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_6_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_6_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_6_0/RedfishManagerAccount_V1_6_0_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_6_0/RedfishManagerAccount_V1_6_0_Dxe.inf new file mode 100644 index 00000000000..e920115bc15 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_6_0/RedfishManagerAccount_V1_6_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_6_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_6_0_Dxe + FILE_GUID = c5480daa-e263-450e-bc81-cfbaba729aeb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_6_0EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_6_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_6_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_6_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_6_1/ManagerAccount_V1_6_1_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_6_1/ManagerAccount_V1_6_1_Dxe.c new file mode 100644 index 00000000000..51707c3bc88 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_6_1/ManagerAccount_V1_6_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_6_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "6", + "1" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_6_1 *ManagerAccountV1_6_1; + EFI_REDFISH_MANAGERACCOUNT_V1_6_1_CS *ManagerAccountV1_6_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_6_1_To_CS (ResoruceRaw, &ManagerAccountV1_6_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_6_1 = (EFI_REDFISH_MANAGERACCOUNT_V1_6_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_6_1)); + if (ManagerAccountV1_6_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_6_1; + ManagerAccountV1_6_1->ManagerAccount = ManagerAccountV1_6_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_6_1_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_6_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_6_1 *ManagerAccountV1_6_1; + + ManagerAccountV1_6_1 = (EFI_REDFISH_MANAGERACCOUNT_V1_6_1 *)InterpProp; + DestroyManagerAccount_V1_6_1_CS (ManagerAccountV1_6_1->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_6_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_6_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_6_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_6_1/RedfishManagerAccount_V1_6_1_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_6_1/RedfishManagerAccount_V1_6_1_Dxe.inf new file mode 100644 index 00000000000..ff7ccd8de9d --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_6_1/RedfishManagerAccount_V1_6_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_6_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_6_1_Dxe + FILE_GUID = 5fa6057c-d687-4bc9-a8a0-f443b6ff151a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_6_1EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_6_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_6_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_6_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_6_2/ManagerAccount_V1_6_2_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_6_2/ManagerAccount_V1_6_2_Dxe.c new file mode 100644 index 00000000000..14c6f650300 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_6_2/ManagerAccount_V1_6_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_6_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "6", + "2" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_6_2 *ManagerAccountV1_6_2; + EFI_REDFISH_MANAGERACCOUNT_V1_6_2_CS *ManagerAccountV1_6_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_6_2_To_CS (ResoruceRaw, &ManagerAccountV1_6_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_6_2 = (EFI_REDFISH_MANAGERACCOUNT_V1_6_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_6_2)); + if (ManagerAccountV1_6_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_6_2; + ManagerAccountV1_6_2->ManagerAccount = ManagerAccountV1_6_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_6_2_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_6_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_6_2 *ManagerAccountV1_6_2; + + ManagerAccountV1_6_2 = (EFI_REDFISH_MANAGERACCOUNT_V1_6_2 *)InterpProp; + DestroyManagerAccount_V1_6_2_CS (ManagerAccountV1_6_2->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_6_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_6_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_6_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_6_2/RedfishManagerAccount_V1_6_2_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_6_2/RedfishManagerAccount_V1_6_2_Dxe.inf new file mode 100644 index 00000000000..190ab8ec31b --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_6_2/RedfishManagerAccount_V1_6_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_6_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_6_2_Dxe + FILE_GUID = e8bda0d6-2040-4e20-8e7f-11868f1931d8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_6_2EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_6_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_6_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_6_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_7_0/ManagerAccount_V1_7_0_Dxe.c b/RedfishClientPkg/Converter/ManagerAccount/v1_7_0/ManagerAccount_V1_7_0_Dxe.c new file mode 100644 index 00000000000..0ad51f7e423 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_7_0/ManagerAccount_V1_7_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccount.v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccount"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerAccount V1_7_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccount", + "1", + "7", + "0" + }, + "ManagerAccount" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_7_0 *ManagerAccountV1_7_0; + EFI_REDFISH_MANAGERACCOUNT_V1_7_0_CS *ManagerAccountV1_7_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccount") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccount_V1_7_0_To_CS (ResoruceRaw, &ManagerAccountV1_7_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountV1_7_0 = (EFI_REDFISH_MANAGERACCOUNT_V1_7_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNT_V1_7_0)); + if (ManagerAccountV1_7_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountV1_7_0; + ManagerAccountV1_7_0->ManagerAccount = ManagerAccountV1_7_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccount")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccount"), "ManagerAccount"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccount_V1_7_0_JSON (*((EFI_REDFISH_MANAGERACCOUNT_V1_7_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNT_V1_7_0 *ManagerAccountV1_7_0; + + ManagerAccountV1_7_0 = (EFI_REDFISH_MANAGERACCOUNT_V1_7_0 *)InterpProp; + DestroyManagerAccount_V1_7_0_CS (ManagerAccountV1_7_0->ManagerAccount); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccount_V1_7_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_7_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountToStructWrapper, + ManagerAccountToJson, + ManagerAccountDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccount_V1_7_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccount/v1_7_0/RedfishManagerAccount_V1_7_0_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccount/v1_7_0/RedfishManagerAccount_V1_7_0_Dxe.inf new file mode 100644 index 00000000000..a61de7c4a14 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccount/v1_7_0/RedfishManagerAccount_V1_7_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccount.v1_7_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccount_V1_7_0_Dxe + FILE_GUID = 32badcdc-688b-49be-a18a-fd51dd6e52c3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccount_V1_7_0EntryPoint + UNLOAD_IMAGE = RedfishManagerAccount_V1_7_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccount_V1_7_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountV1_7_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerAccountCollection/ManagerAccountCollection_Dxe.c b/RedfishClientPkg/Converter/ManagerAccountCollection/ManagerAccountCollection_Dxe.c new file mode 100644 index 00000000000..1b307dfa824 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccountCollection/ManagerAccountCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerAccountCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerAccountCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support ManagerAccountCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerAccountCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "ManagerAccountCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNTCOLLECTION *ManagerAccountCollection; + EFI_REDFISH_MANAGERACCOUNTCOLLECTION_CS *ManagerAccountCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerAccountCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerAccountCollection_To_CS (ResoruceRaw, &ManagerAccountCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerAccountCollection = (EFI_REDFISH_MANAGERACCOUNTCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERACCOUNTCOLLECTION)); + if (ManagerAccountCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerAccountCollection; + ManagerAccountCollection->ManagerAccountCollection = ManagerAccountCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccountCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerAccountCollection"), "ManagerAccountCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerAccountCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerAccountCollection"), "ManagerAccountCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerAccountCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerAccountCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerAccountCollection_JSON (*((EFI_REDFISH_MANAGERACCOUNTCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerAccountCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERACCOUNTCOLLECTION *ManagerAccountCollection; + + ManagerAccountCollection = (EFI_REDFISH_MANAGERACCOUNTCOLLECTION *)InterpProp; + DestroyManagerAccountCollection_CS (ManagerAccountCollection->ManagerAccountCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerAccountCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerAccountCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerAccountCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccountCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerAccountCollectionToStructWrapper, + ManagerAccountCollectionToJson, + ManagerAccountCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerAccountCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerAccountCollection/RedfishManagerAccountCollection_Dxe.inf b/RedfishClientPkg/Converter/ManagerAccountCollection/RedfishManagerAccountCollection_Dxe.inf new file mode 100644 index 00000000000..db1a3fb0956 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerAccountCollection/RedfishManagerAccountCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerAccountCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerAccountCollection_Dxe + FILE_GUID = 046a3393-8f5f-4350-9bc7-9d46e22f42f2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerAccountCollectionEntryPoint + UNLOAD_IMAGE = RedfishManagerAccountCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerAccountCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerAccountCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerCollection/ManagerCollection_Dxe.c b/RedfishClientPkg/Converter/ManagerCollection/ManagerCollection_Dxe.c new file mode 100644 index 00000000000..d59a61a9559 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerCollection/ManagerCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support ManagerCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "ManagerCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERCOLLECTION *ManagerCollection; + EFI_REDFISH_MANAGERCOLLECTION_CS *ManagerCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerCollection_To_CS (ResoruceRaw, &ManagerCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerCollection = (EFI_REDFISH_MANAGERCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERCOLLECTION)); + if (ManagerCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerCollection; + ManagerCollection->ManagerCollection = ManagerCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerCollection"), "ManagerCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerCollection"), "ManagerCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerCollection_JSON (*((EFI_REDFISH_MANAGERCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERCOLLECTION *ManagerCollection; + + ManagerCollection = (EFI_REDFISH_MANAGERCOLLECTION *)InterpProp; + DestroyManagerCollection_CS (ManagerCollection->ManagerCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerCollectionToStructWrapper, + ManagerCollectionToJson, + ManagerCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerCollection/RedfishManagerCollection_Dxe.inf b/RedfishClientPkg/Converter/ManagerCollection/RedfishManagerCollection_Dxe.inf new file mode 100644 index 00000000000..d06f402cd4d --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerCollection/RedfishManagerCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerCollection_Dxe + FILE_GUID = 22525ce1-a930-4121-a3d7-bfc9558a3b69 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerCollectionEntryPoint + UNLOAD_IMAGE = RedfishManagerCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_0/ManagerNetworkProtocol_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_0/ManagerNetworkProtocol_V1_0_0_Dxe.c new file mode 100644 index 00000000000..3b769db0e4e --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_0/ManagerNetworkProtocol_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "0", + "0" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_0 *ManagerNetworkProtocolV1_0_0; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_0_CS *ManagerNetworkProtocolV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_0_0_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_0_0 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_0)); + if (ManagerNetworkProtocolV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_0_0; + ManagerNetworkProtocolV1_0_0->ManagerNetworkProtocol = ManagerNetworkProtocolV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_0_0_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_0 *ManagerNetworkProtocolV1_0_0; + + ManagerNetworkProtocolV1_0_0 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_0 *)InterpProp; + DestroyManagerNetworkProtocol_V1_0_0_CS (ManagerNetworkProtocolV1_0_0->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_0/RedfishManagerNetworkProtocol_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_0/RedfishManagerNetworkProtocol_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..456cbba838f --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_0/RedfishManagerNetworkProtocol_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_0_0_Dxe + FILE_GUID = ff5a1486-d28b-4194-9cc3-caba74686e07 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_2/ManagerNetworkProtocol_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_2/ManagerNetworkProtocol_V1_0_2_Dxe.c new file mode 100644 index 00000000000..63d5931d53a --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_2/ManagerNetworkProtocol_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "0", + "2" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_2 *ManagerNetworkProtocolV1_0_2; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_2_CS *ManagerNetworkProtocolV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_0_2_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_0_2 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_2)); + if (ManagerNetworkProtocolV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_0_2; + ManagerNetworkProtocolV1_0_2->ManagerNetworkProtocol = ManagerNetworkProtocolV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_0_2_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_2 *ManagerNetworkProtocolV1_0_2; + + ManagerNetworkProtocolV1_0_2 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_2 *)InterpProp; + DestroyManagerNetworkProtocol_V1_0_2_CS (ManagerNetworkProtocolV1_0_2->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_2/RedfishManagerNetworkProtocol_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_2/RedfishManagerNetworkProtocol_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..f0e0af348c9 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_2/RedfishManagerNetworkProtocol_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_0_2_Dxe + FILE_GUID = 78182140-1a53-4b0a-b7e8-fd48ed4eca88 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_3/ManagerNetworkProtocol_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_3/ManagerNetworkProtocol_V1_0_3_Dxe.c new file mode 100644 index 00000000000..8ed8793ed40 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_3/ManagerNetworkProtocol_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "0", + "3" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_3 *ManagerNetworkProtocolV1_0_3; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_3_CS *ManagerNetworkProtocolV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_0_3_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_0_3 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_3)); + if (ManagerNetworkProtocolV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_0_3; + ManagerNetworkProtocolV1_0_3->ManagerNetworkProtocol = ManagerNetworkProtocolV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_0_3_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_3 *ManagerNetworkProtocolV1_0_3; + + ManagerNetworkProtocolV1_0_3 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_3 *)InterpProp; + DestroyManagerNetworkProtocol_V1_0_3_CS (ManagerNetworkProtocolV1_0_3->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_3/RedfishManagerNetworkProtocol_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_3/RedfishManagerNetworkProtocol_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..0eeec3ab70d --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_3/RedfishManagerNetworkProtocol_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_0_3_Dxe + FILE_GUID = 41dc82b0-18df-48b1-8929-801b06fe5a14 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_4/ManagerNetworkProtocol_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_4/ManagerNetworkProtocol_V1_0_4_Dxe.c new file mode 100644 index 00000000000..c49add5bfb7 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_4/ManagerNetworkProtocol_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "0", + "4" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_4 *ManagerNetworkProtocolV1_0_4; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_4_CS *ManagerNetworkProtocolV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_0_4_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_0_4 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_4)); + if (ManagerNetworkProtocolV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_0_4; + ManagerNetworkProtocolV1_0_4->ManagerNetworkProtocol = ManagerNetworkProtocolV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_0_4_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_4 *ManagerNetworkProtocolV1_0_4; + + ManagerNetworkProtocolV1_0_4 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_4 *)InterpProp; + DestroyManagerNetworkProtocol_V1_0_4_CS (ManagerNetworkProtocolV1_0_4->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_4/RedfishManagerNetworkProtocol_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_4/RedfishManagerNetworkProtocol_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..24bf2140e94 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_4/RedfishManagerNetworkProtocol_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_0_4_Dxe + FILE_GUID = 906f3e14-9bb5-4ab4-bb56-5bbde8884b1b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_5/ManagerNetworkProtocol_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_5/ManagerNetworkProtocol_V1_0_5_Dxe.c new file mode 100644 index 00000000000..fb28b2ad751 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_5/ManagerNetworkProtocol_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "0", + "5" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_5 *ManagerNetworkProtocolV1_0_5; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_5_CS *ManagerNetworkProtocolV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_0_5_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_0_5 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_5)); + if (ManagerNetworkProtocolV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_0_5; + ManagerNetworkProtocolV1_0_5->ManagerNetworkProtocol = ManagerNetworkProtocolV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_0_5_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_5 *ManagerNetworkProtocolV1_0_5; + + ManagerNetworkProtocolV1_0_5 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_5 *)InterpProp; + DestroyManagerNetworkProtocol_V1_0_5_CS (ManagerNetworkProtocolV1_0_5->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_5/RedfishManagerNetworkProtocol_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_5/RedfishManagerNetworkProtocol_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..a2ce18d24ae --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_5/RedfishManagerNetworkProtocol_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_0_5_Dxe + FILE_GUID = da131822-05ad-4066-b62b-f913f24e4b13 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_6/ManagerNetworkProtocol_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_6/ManagerNetworkProtocol_V1_0_6_Dxe.c new file mode 100644 index 00000000000..2e3fde8f030 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_6/ManagerNetworkProtocol_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "0", + "6" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_6 *ManagerNetworkProtocolV1_0_6; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_6_CS *ManagerNetworkProtocolV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_0_6_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_0_6 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_6)); + if (ManagerNetworkProtocolV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_0_6; + ManagerNetworkProtocolV1_0_6->ManagerNetworkProtocol = ManagerNetworkProtocolV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_0_6_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_6 *ManagerNetworkProtocolV1_0_6; + + ManagerNetworkProtocolV1_0_6 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_6 *)InterpProp; + DestroyManagerNetworkProtocol_V1_0_6_CS (ManagerNetworkProtocolV1_0_6->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_6/RedfishManagerNetworkProtocol_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_6/RedfishManagerNetworkProtocol_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..0893890cf95 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_6/RedfishManagerNetworkProtocol_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_0_6_Dxe + FILE_GUID = 79db054a-489d-4cb6-bad5-2bffcfbc37df + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_7/ManagerNetworkProtocol_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_7/ManagerNetworkProtocol_V1_0_7_Dxe.c new file mode 100644 index 00000000000..f3180156e79 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_7/ManagerNetworkProtocol_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "0", + "7" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_7 *ManagerNetworkProtocolV1_0_7; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_7_CS *ManagerNetworkProtocolV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_0_7_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_0_7 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_7)); + if (ManagerNetworkProtocolV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_0_7; + ManagerNetworkProtocolV1_0_7->ManagerNetworkProtocol = ManagerNetworkProtocolV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_0_7_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_7 *ManagerNetworkProtocolV1_0_7; + + ManagerNetworkProtocolV1_0_7 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_7 *)InterpProp; + DestroyManagerNetworkProtocol_V1_0_7_CS (ManagerNetworkProtocolV1_0_7->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_7/RedfishManagerNetworkProtocol_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_7/RedfishManagerNetworkProtocol_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..92714a333e4 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_7/RedfishManagerNetworkProtocol_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_0_7_Dxe + FILE_GUID = f3b817eb-028a-48d2-9ac3-968018d064ef + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_8/ManagerNetworkProtocol_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_8/ManagerNetworkProtocol_V1_0_8_Dxe.c new file mode 100644 index 00000000000..67ab2df7d73 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_8/ManagerNetworkProtocol_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "0", + "8" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_8 *ManagerNetworkProtocolV1_0_8; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_8_CS *ManagerNetworkProtocolV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_0_8_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_0_8 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_8)); + if (ManagerNetworkProtocolV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_0_8; + ManagerNetworkProtocolV1_0_8->ManagerNetworkProtocol = ManagerNetworkProtocolV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_0_8_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_8 *ManagerNetworkProtocolV1_0_8; + + ManagerNetworkProtocolV1_0_8 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_8 *)InterpProp; + DestroyManagerNetworkProtocol_V1_0_8_CS (ManagerNetworkProtocolV1_0_8->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_8/RedfishManagerNetworkProtocol_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_8/RedfishManagerNetworkProtocol_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..aef69e7e514 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_8/RedfishManagerNetworkProtocol_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_0_8_Dxe + FILE_GUID = 51f4f8d7-28f1-46de-8e69-64409d3020fa + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_9/ManagerNetworkProtocol_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_9/ManagerNetworkProtocol_V1_0_9_Dxe.c new file mode 100644 index 00000000000..cea1653ca40 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_9/ManagerNetworkProtocol_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "0", + "9" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_9 *ManagerNetworkProtocolV1_0_9; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_9_CS *ManagerNetworkProtocolV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_0_9_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_0_9 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_9)); + if (ManagerNetworkProtocolV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_0_9; + ManagerNetworkProtocolV1_0_9->ManagerNetworkProtocol = ManagerNetworkProtocolV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_0_9_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_9 *ManagerNetworkProtocolV1_0_9; + + ManagerNetworkProtocolV1_0_9 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_9 *)InterpProp; + DestroyManagerNetworkProtocol_V1_0_9_CS (ManagerNetworkProtocolV1_0_9->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_9/RedfishManagerNetworkProtocol_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_9/RedfishManagerNetworkProtocol_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..03246b69cfc --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_0_9/RedfishManagerNetworkProtocol_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_0_9_Dxe + FILE_GUID = 1e7aea6a-d347-4905-af7e-4a96a8948558 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_0/ManagerNetworkProtocol_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_0/ManagerNetworkProtocol_V1_1_0_Dxe.c new file mode 100644 index 00000000000..da455044d1f --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_0/ManagerNetworkProtocol_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "1", + "0" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_0 *ManagerNetworkProtocolV1_1_0; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_0_CS *ManagerNetworkProtocolV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_1_0_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_1_0 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_0)); + if (ManagerNetworkProtocolV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_1_0; + ManagerNetworkProtocolV1_1_0->ManagerNetworkProtocol = ManagerNetworkProtocolV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_1_0_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_0 *ManagerNetworkProtocolV1_1_0; + + ManagerNetworkProtocolV1_1_0 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_0 *)InterpProp; + DestroyManagerNetworkProtocol_V1_1_0_CS (ManagerNetworkProtocolV1_1_0->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_0/RedfishManagerNetworkProtocol_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_0/RedfishManagerNetworkProtocol_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..922a0fed38b --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_0/RedfishManagerNetworkProtocol_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_1_0_Dxe + FILE_GUID = d927ff69-c559-4e29-a3b9-d0b6b121f182 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_1/ManagerNetworkProtocol_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_1/ManagerNetworkProtocol_V1_1_1_Dxe.c new file mode 100644 index 00000000000..f0bb5d18e80 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_1/ManagerNetworkProtocol_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "1", + "1" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_1 *ManagerNetworkProtocolV1_1_1; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_1_CS *ManagerNetworkProtocolV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_1_1_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_1_1 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_1)); + if (ManagerNetworkProtocolV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_1_1; + ManagerNetworkProtocolV1_1_1->ManagerNetworkProtocol = ManagerNetworkProtocolV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_1_1_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_1 *ManagerNetworkProtocolV1_1_1; + + ManagerNetworkProtocolV1_1_1 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_1 *)InterpProp; + DestroyManagerNetworkProtocol_V1_1_1_CS (ManagerNetworkProtocolV1_1_1->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_1/RedfishManagerNetworkProtocol_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_1/RedfishManagerNetworkProtocol_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..9ac615e7a6e --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_1/RedfishManagerNetworkProtocol_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_1_1_Dxe + FILE_GUID = 49de0db9-41be-4e34-9afa-f233dcaeedd1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_2/ManagerNetworkProtocol_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_2/ManagerNetworkProtocol_V1_1_2_Dxe.c new file mode 100644 index 00000000000..5e3c257c2fc --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_2/ManagerNetworkProtocol_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "1", + "2" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_2 *ManagerNetworkProtocolV1_1_2; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_2_CS *ManagerNetworkProtocolV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_1_2_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_1_2 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_2)); + if (ManagerNetworkProtocolV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_1_2; + ManagerNetworkProtocolV1_1_2->ManagerNetworkProtocol = ManagerNetworkProtocolV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_1_2_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_2 *ManagerNetworkProtocolV1_1_2; + + ManagerNetworkProtocolV1_1_2 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_2 *)InterpProp; + DestroyManagerNetworkProtocol_V1_1_2_CS (ManagerNetworkProtocolV1_1_2->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_2/RedfishManagerNetworkProtocol_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_2/RedfishManagerNetworkProtocol_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..5c97072a0a5 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_2/RedfishManagerNetworkProtocol_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_1_2_Dxe + FILE_GUID = 584888c5-9def-484e-a676-aa8224ff6d15 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_3/ManagerNetworkProtocol_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_3/ManagerNetworkProtocol_V1_1_3_Dxe.c new file mode 100644 index 00000000000..a1867ecad51 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_3/ManagerNetworkProtocol_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "1", + "3" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_3 *ManagerNetworkProtocolV1_1_3; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_3_CS *ManagerNetworkProtocolV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_1_3_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_1_3 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_3)); + if (ManagerNetworkProtocolV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_1_3; + ManagerNetworkProtocolV1_1_3->ManagerNetworkProtocol = ManagerNetworkProtocolV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_1_3_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_3 *ManagerNetworkProtocolV1_1_3; + + ManagerNetworkProtocolV1_1_3 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_3 *)InterpProp; + DestroyManagerNetworkProtocol_V1_1_3_CS (ManagerNetworkProtocolV1_1_3->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_3/RedfishManagerNetworkProtocol_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_3/RedfishManagerNetworkProtocol_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..305acd79d64 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_3/RedfishManagerNetworkProtocol_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_1_3_Dxe + FILE_GUID = b3e6698c-a043-4ceb-95ca-952fa605251d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_4/ManagerNetworkProtocol_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_4/ManagerNetworkProtocol_V1_1_4_Dxe.c new file mode 100644 index 00000000000..dd12ab21a93 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_4/ManagerNetworkProtocol_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "1", + "4" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_4 *ManagerNetworkProtocolV1_1_4; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_4_CS *ManagerNetworkProtocolV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_1_4_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_1_4 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_4)); + if (ManagerNetworkProtocolV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_1_4; + ManagerNetworkProtocolV1_1_4->ManagerNetworkProtocol = ManagerNetworkProtocolV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_1_4_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_4 *ManagerNetworkProtocolV1_1_4; + + ManagerNetworkProtocolV1_1_4 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_4 *)InterpProp; + DestroyManagerNetworkProtocol_V1_1_4_CS (ManagerNetworkProtocolV1_1_4->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_4/RedfishManagerNetworkProtocol_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_4/RedfishManagerNetworkProtocol_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..656b75c59b9 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_4/RedfishManagerNetworkProtocol_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_1_4_Dxe + FILE_GUID = 3e787f7f-6b6c-4d2c-91bb-69144b1ccf33 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_5/ManagerNetworkProtocol_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_5/ManagerNetworkProtocol_V1_1_5_Dxe.c new file mode 100644 index 00000000000..0a73abb3f5d --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_5/ManagerNetworkProtocol_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "1", + "5" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_5 *ManagerNetworkProtocolV1_1_5; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_5_CS *ManagerNetworkProtocolV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_1_5_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_1_5 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_5)); + if (ManagerNetworkProtocolV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_1_5; + ManagerNetworkProtocolV1_1_5->ManagerNetworkProtocol = ManagerNetworkProtocolV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_1_5_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_5 *ManagerNetworkProtocolV1_1_5; + + ManagerNetworkProtocolV1_1_5 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_5 *)InterpProp; + DestroyManagerNetworkProtocol_V1_1_5_CS (ManagerNetworkProtocolV1_1_5->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_5/RedfishManagerNetworkProtocol_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_5/RedfishManagerNetworkProtocol_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..339729a5021 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_5/RedfishManagerNetworkProtocol_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_1_5_Dxe + FILE_GUID = e3787747-2562-4268-8687-9ce62253bec9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_6/ManagerNetworkProtocol_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_6/ManagerNetworkProtocol_V1_1_6_Dxe.c new file mode 100644 index 00000000000..9b820aea45f --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_6/ManagerNetworkProtocol_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "1", + "6" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_6 *ManagerNetworkProtocolV1_1_6; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_6_CS *ManagerNetworkProtocolV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_1_6_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_1_6 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_6)); + if (ManagerNetworkProtocolV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_1_6; + ManagerNetworkProtocolV1_1_6->ManagerNetworkProtocol = ManagerNetworkProtocolV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_1_6_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_6 *ManagerNetworkProtocolV1_1_6; + + ManagerNetworkProtocolV1_1_6 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_6 *)InterpProp; + DestroyManagerNetworkProtocol_V1_1_6_CS (ManagerNetworkProtocolV1_1_6->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_6/RedfishManagerNetworkProtocol_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_6/RedfishManagerNetworkProtocol_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..bc12246b538 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_1_6/RedfishManagerNetworkProtocol_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_1_6_Dxe + FILE_GUID = befc0257-f032-4a2d-a97e-9f5d1ac780fd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_0/ManagerNetworkProtocol_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_0/ManagerNetworkProtocol_V1_2_0_Dxe.c new file mode 100644 index 00000000000..6bd7bce6dd8 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_0/ManagerNetworkProtocol_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "2", + "0" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_0 *ManagerNetworkProtocolV1_2_0; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_0_CS *ManagerNetworkProtocolV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_2_0_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_2_0 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_0)); + if (ManagerNetworkProtocolV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_2_0; + ManagerNetworkProtocolV1_2_0->ManagerNetworkProtocol = ManagerNetworkProtocolV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_2_0_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_0 *ManagerNetworkProtocolV1_2_0; + + ManagerNetworkProtocolV1_2_0 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_0 *)InterpProp; + DestroyManagerNetworkProtocol_V1_2_0_CS (ManagerNetworkProtocolV1_2_0->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_0/RedfishManagerNetworkProtocol_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_0/RedfishManagerNetworkProtocol_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..3a00854c711 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_0/RedfishManagerNetworkProtocol_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_2_0_Dxe + FILE_GUID = faa0ba76-9956-4b88-80a6-4ba3c8e51215 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_1/ManagerNetworkProtocol_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_1/ManagerNetworkProtocol_V1_2_1_Dxe.c new file mode 100644 index 00000000000..7cc9274fdd4 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_1/ManagerNetworkProtocol_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "2", + "1" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_1 *ManagerNetworkProtocolV1_2_1; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_1_CS *ManagerNetworkProtocolV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_2_1_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_2_1 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_1)); + if (ManagerNetworkProtocolV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_2_1; + ManagerNetworkProtocolV1_2_1->ManagerNetworkProtocol = ManagerNetworkProtocolV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_2_1_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_1 *ManagerNetworkProtocolV1_2_1; + + ManagerNetworkProtocolV1_2_1 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_1 *)InterpProp; + DestroyManagerNetworkProtocol_V1_2_1_CS (ManagerNetworkProtocolV1_2_1->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_1/RedfishManagerNetworkProtocol_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_1/RedfishManagerNetworkProtocol_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..89168cf2be9 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_1/RedfishManagerNetworkProtocol_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_2_1_Dxe + FILE_GUID = aa8dd9dc-7d95-4367-8c88-3159cde04af5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_2/ManagerNetworkProtocol_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_2/ManagerNetworkProtocol_V1_2_2_Dxe.c new file mode 100644 index 00000000000..57ec4c4aea6 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_2/ManagerNetworkProtocol_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "2", + "2" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_2 *ManagerNetworkProtocolV1_2_2; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_2_CS *ManagerNetworkProtocolV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_2_2_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_2_2 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_2)); + if (ManagerNetworkProtocolV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_2_2; + ManagerNetworkProtocolV1_2_2->ManagerNetworkProtocol = ManagerNetworkProtocolV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_2_2_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_2 *ManagerNetworkProtocolV1_2_2; + + ManagerNetworkProtocolV1_2_2 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_2 *)InterpProp; + DestroyManagerNetworkProtocol_V1_2_2_CS (ManagerNetworkProtocolV1_2_2->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_2/RedfishManagerNetworkProtocol_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_2/RedfishManagerNetworkProtocol_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..2c985736417 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_2/RedfishManagerNetworkProtocol_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_2_2_Dxe + FILE_GUID = b48ef553-00d9-4443-ae2e-7b1a67b793f9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_3/ManagerNetworkProtocol_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_3/ManagerNetworkProtocol_V1_2_3_Dxe.c new file mode 100644 index 00000000000..a1e4ccc14b4 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_3/ManagerNetworkProtocol_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "2", + "3" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_3 *ManagerNetworkProtocolV1_2_3; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_3_CS *ManagerNetworkProtocolV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_2_3_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_2_3 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_3)); + if (ManagerNetworkProtocolV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_2_3; + ManagerNetworkProtocolV1_2_3->ManagerNetworkProtocol = ManagerNetworkProtocolV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_2_3_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_3 *ManagerNetworkProtocolV1_2_3; + + ManagerNetworkProtocolV1_2_3 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_3 *)InterpProp; + DestroyManagerNetworkProtocol_V1_2_3_CS (ManagerNetworkProtocolV1_2_3->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_3/RedfishManagerNetworkProtocol_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_3/RedfishManagerNetworkProtocol_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..f03771e32ba --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_3/RedfishManagerNetworkProtocol_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_2_3_Dxe + FILE_GUID = 96fdf139-7a09-4827-b2ad-791c9197b39b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_4/ManagerNetworkProtocol_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_4/ManagerNetworkProtocol_V1_2_4_Dxe.c new file mode 100644 index 00000000000..83ba199542c --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_4/ManagerNetworkProtocol_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "2", + "4" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_4 *ManagerNetworkProtocolV1_2_4; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_4_CS *ManagerNetworkProtocolV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_2_4_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_2_4 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_4)); + if (ManagerNetworkProtocolV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_2_4; + ManagerNetworkProtocolV1_2_4->ManagerNetworkProtocol = ManagerNetworkProtocolV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_2_4_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_4 *ManagerNetworkProtocolV1_2_4; + + ManagerNetworkProtocolV1_2_4 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_4 *)InterpProp; + DestroyManagerNetworkProtocol_V1_2_4_CS (ManagerNetworkProtocolV1_2_4->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_4/RedfishManagerNetworkProtocol_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_4/RedfishManagerNetworkProtocol_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..f15292fcacf --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_4/RedfishManagerNetworkProtocol_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_2_4_Dxe + FILE_GUID = 913472db-8864-4433-b4e8-17ad6801407e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_5/ManagerNetworkProtocol_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_5/ManagerNetworkProtocol_V1_2_5_Dxe.c new file mode 100644 index 00000000000..6e36e23418a --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_5/ManagerNetworkProtocol_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "2", + "5" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_5 *ManagerNetworkProtocolV1_2_5; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_5_CS *ManagerNetworkProtocolV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_2_5_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_2_5 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_5)); + if (ManagerNetworkProtocolV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_2_5; + ManagerNetworkProtocolV1_2_5->ManagerNetworkProtocol = ManagerNetworkProtocolV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_2_5_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_5 *ManagerNetworkProtocolV1_2_5; + + ManagerNetworkProtocolV1_2_5 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_5 *)InterpProp; + DestroyManagerNetworkProtocol_V1_2_5_CS (ManagerNetworkProtocolV1_2_5->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_5/RedfishManagerNetworkProtocol_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_5/RedfishManagerNetworkProtocol_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..24c8cac2b1b --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_2_5/RedfishManagerNetworkProtocol_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_2_5_Dxe + FILE_GUID = bfdce465-5b7b-4e1d-8684-d1502e50059d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_0/ManagerNetworkProtocol_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_0/ManagerNetworkProtocol_V1_3_0_Dxe.c new file mode 100644 index 00000000000..89c894add14 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_0/ManagerNetworkProtocol_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "3", + "0" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_0 *ManagerNetworkProtocolV1_3_0; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_0_CS *ManagerNetworkProtocolV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_3_0_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_3_0 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_0)); + if (ManagerNetworkProtocolV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_3_0; + ManagerNetworkProtocolV1_3_0->ManagerNetworkProtocol = ManagerNetworkProtocolV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_3_0_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_0 *ManagerNetworkProtocolV1_3_0; + + ManagerNetworkProtocolV1_3_0 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_0 *)InterpProp; + DestroyManagerNetworkProtocol_V1_3_0_CS (ManagerNetworkProtocolV1_3_0->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_0/RedfishManagerNetworkProtocol_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_0/RedfishManagerNetworkProtocol_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..14ae09fb8eb --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_0/RedfishManagerNetworkProtocol_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_3_0_Dxe + FILE_GUID = 1e1d4500-7702-4788-acff-d1f1d60ff37f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_1/ManagerNetworkProtocol_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_1/ManagerNetworkProtocol_V1_3_1_Dxe.c new file mode 100644 index 00000000000..e70c5c241b7 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_1/ManagerNetworkProtocol_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "3", + "1" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_1 *ManagerNetworkProtocolV1_3_1; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_1_CS *ManagerNetworkProtocolV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_3_1_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_3_1 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_1)); + if (ManagerNetworkProtocolV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_3_1; + ManagerNetworkProtocolV1_3_1->ManagerNetworkProtocol = ManagerNetworkProtocolV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_3_1_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_1 *ManagerNetworkProtocolV1_3_1; + + ManagerNetworkProtocolV1_3_1 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_1 *)InterpProp; + DestroyManagerNetworkProtocol_V1_3_1_CS (ManagerNetworkProtocolV1_3_1->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_1/RedfishManagerNetworkProtocol_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_1/RedfishManagerNetworkProtocol_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..e81962fbb80 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_1/RedfishManagerNetworkProtocol_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_3_1_Dxe + FILE_GUID = 79cdd458-adf4-4184-b44e-a4d30bad8baf + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_2/ManagerNetworkProtocol_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_2/ManagerNetworkProtocol_V1_3_2_Dxe.c new file mode 100644 index 00000000000..f89baecb56f --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_2/ManagerNetworkProtocol_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "3", + "2" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_2 *ManagerNetworkProtocolV1_3_2; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_2_CS *ManagerNetworkProtocolV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_3_2_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_3_2 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_2)); + if (ManagerNetworkProtocolV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_3_2; + ManagerNetworkProtocolV1_3_2->ManagerNetworkProtocol = ManagerNetworkProtocolV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_3_2_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_2 *ManagerNetworkProtocolV1_3_2; + + ManagerNetworkProtocolV1_3_2 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_2 *)InterpProp; + DestroyManagerNetworkProtocol_V1_3_2_CS (ManagerNetworkProtocolV1_3_2->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_2/RedfishManagerNetworkProtocol_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_2/RedfishManagerNetworkProtocol_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..078a9f30927 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_2/RedfishManagerNetworkProtocol_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_3_2_Dxe + FILE_GUID = 1a9d2bbb-229f-4a94-ad07-be647acc943c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_3/ManagerNetworkProtocol_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_3/ManagerNetworkProtocol_V1_3_3_Dxe.c new file mode 100644 index 00000000000..b234642dd56 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_3/ManagerNetworkProtocol_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "3", + "3" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_3 *ManagerNetworkProtocolV1_3_3; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_3_CS *ManagerNetworkProtocolV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_3_3_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_3_3 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_3)); + if (ManagerNetworkProtocolV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_3_3; + ManagerNetworkProtocolV1_3_3->ManagerNetworkProtocol = ManagerNetworkProtocolV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_3_3_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_3 *ManagerNetworkProtocolV1_3_3; + + ManagerNetworkProtocolV1_3_3 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_3 *)InterpProp; + DestroyManagerNetworkProtocol_V1_3_3_CS (ManagerNetworkProtocolV1_3_3->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_3/RedfishManagerNetworkProtocol_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_3/RedfishManagerNetworkProtocol_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..230032f9913 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_3/RedfishManagerNetworkProtocol_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_3_3_Dxe + FILE_GUID = 331422fa-b6ce-425e-945a-b41d273ec5a0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_4/ManagerNetworkProtocol_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_4/ManagerNetworkProtocol_V1_3_4_Dxe.c new file mode 100644 index 00000000000..7eae98714ad --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_4/ManagerNetworkProtocol_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "3", + "4" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_4 *ManagerNetworkProtocolV1_3_4; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_4_CS *ManagerNetworkProtocolV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_3_4_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_3_4 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_4)); + if (ManagerNetworkProtocolV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_3_4; + ManagerNetworkProtocolV1_3_4->ManagerNetworkProtocol = ManagerNetworkProtocolV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_3_4_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_4 *ManagerNetworkProtocolV1_3_4; + + ManagerNetworkProtocolV1_3_4 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_4 *)InterpProp; + DestroyManagerNetworkProtocol_V1_3_4_CS (ManagerNetworkProtocolV1_3_4->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_4/RedfishManagerNetworkProtocol_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_4/RedfishManagerNetworkProtocol_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..a9a2e6c7182 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_3_4/RedfishManagerNetworkProtocol_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_3_4_Dxe + FILE_GUID = 12db49d0-56e3-4ecf-82a4-89e228233491 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_0/ManagerNetworkProtocol_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_0/ManagerNetworkProtocol_V1_4_0_Dxe.c new file mode 100644 index 00000000000..623a8a9e31d --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_0/ManagerNetworkProtocol_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "4", + "0" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_0 *ManagerNetworkProtocolV1_4_0; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_0_CS *ManagerNetworkProtocolV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_4_0_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_4_0 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_0)); + if (ManagerNetworkProtocolV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_4_0; + ManagerNetworkProtocolV1_4_0->ManagerNetworkProtocol = ManagerNetworkProtocolV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_4_0_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_0 *ManagerNetworkProtocolV1_4_0; + + ManagerNetworkProtocolV1_4_0 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_0 *)InterpProp; + DestroyManagerNetworkProtocol_V1_4_0_CS (ManagerNetworkProtocolV1_4_0->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_0/RedfishManagerNetworkProtocol_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_0/RedfishManagerNetworkProtocol_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..77392a9f55c --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_0/RedfishManagerNetworkProtocol_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_4_0_Dxe + FILE_GUID = 61112819-3c0f-4170-8df1-0c5e12f3f314 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_1/ManagerNetworkProtocol_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_1/ManagerNetworkProtocol_V1_4_1_Dxe.c new file mode 100644 index 00000000000..1bf5fd4ae41 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_1/ManagerNetworkProtocol_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "4", + "1" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_1 *ManagerNetworkProtocolV1_4_1; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_1_CS *ManagerNetworkProtocolV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_4_1_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_4_1 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_1)); + if (ManagerNetworkProtocolV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_4_1; + ManagerNetworkProtocolV1_4_1->ManagerNetworkProtocol = ManagerNetworkProtocolV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_4_1_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_1 *ManagerNetworkProtocolV1_4_1; + + ManagerNetworkProtocolV1_4_1 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_1 *)InterpProp; + DestroyManagerNetworkProtocol_V1_4_1_CS (ManagerNetworkProtocolV1_4_1->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_1/RedfishManagerNetworkProtocol_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_1/RedfishManagerNetworkProtocol_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..70ad32dcb9e --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_1/RedfishManagerNetworkProtocol_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_4_1_Dxe + FILE_GUID = 6289c536-44ef-482f-b696-feb6ed63c5a4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_2/ManagerNetworkProtocol_V1_4_2_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_2/ManagerNetworkProtocol_V1_4_2_Dxe.c new file mode 100644 index 00000000000..b3a68c2369e --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_2/ManagerNetworkProtocol_V1_4_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_4_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "4", + "2" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_2 *ManagerNetworkProtocolV1_4_2; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_2_CS *ManagerNetworkProtocolV1_4_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_4_2_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_4_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_4_2 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_2)); + if (ManagerNetworkProtocolV1_4_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_4_2; + ManagerNetworkProtocolV1_4_2->ManagerNetworkProtocol = ManagerNetworkProtocolV1_4_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_4_2_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_2 *ManagerNetworkProtocolV1_4_2; + + ManagerNetworkProtocolV1_4_2 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_2 *)InterpProp; + DestroyManagerNetworkProtocol_V1_4_2_CS (ManagerNetworkProtocolV1_4_2->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_4_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_4_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_4_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_2/RedfishManagerNetworkProtocol_V1_4_2_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_2/RedfishManagerNetworkProtocol_V1_4_2_Dxe.inf new file mode 100644 index 00000000000..e2c693c6374 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_2/RedfishManagerNetworkProtocol_V1_4_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_4_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_4_2_Dxe + FILE_GUID = ef6b67dc-2cf3-4ee5-9ad9-7ecfd127b6f2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_4_2EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_4_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_4_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_4_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_3/ManagerNetworkProtocol_V1_4_3_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_3/ManagerNetworkProtocol_V1_4_3_Dxe.c new file mode 100644 index 00000000000..e0d7065b330 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_3/ManagerNetworkProtocol_V1_4_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_4_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "4", + "3" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_3 *ManagerNetworkProtocolV1_4_3; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_3_CS *ManagerNetworkProtocolV1_4_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_4_3_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_4_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_4_3 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_3)); + if (ManagerNetworkProtocolV1_4_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_4_3; + ManagerNetworkProtocolV1_4_3->ManagerNetworkProtocol = ManagerNetworkProtocolV1_4_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_4_3_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_3 *ManagerNetworkProtocolV1_4_3; + + ManagerNetworkProtocolV1_4_3 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_3 *)InterpProp; + DestroyManagerNetworkProtocol_V1_4_3_CS (ManagerNetworkProtocolV1_4_3->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_4_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_4_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_4_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_3/RedfishManagerNetworkProtocol_V1_4_3_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_3/RedfishManagerNetworkProtocol_V1_4_3_Dxe.inf new file mode 100644 index 00000000000..446074ff810 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_3/RedfishManagerNetworkProtocol_V1_4_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_4_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_4_3_Dxe + FILE_GUID = de358210-4e4d-4b42-997d-25a94993e29d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_4_3EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_4_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_4_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_4_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_4/ManagerNetworkProtocol_V1_4_4_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_4/ManagerNetworkProtocol_V1_4_4_Dxe.c new file mode 100644 index 00000000000..d83e8027739 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_4/ManagerNetworkProtocol_V1_4_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_4_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "4", + "4" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_4 *ManagerNetworkProtocolV1_4_4; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_4_CS *ManagerNetworkProtocolV1_4_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_4_4_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_4_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_4_4 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_4)); + if (ManagerNetworkProtocolV1_4_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_4_4; + ManagerNetworkProtocolV1_4_4->ManagerNetworkProtocol = ManagerNetworkProtocolV1_4_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_4_4_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_4 *ManagerNetworkProtocolV1_4_4; + + ManagerNetworkProtocolV1_4_4 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_4 *)InterpProp; + DestroyManagerNetworkProtocol_V1_4_4_CS (ManagerNetworkProtocolV1_4_4->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_4_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_4_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_4_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_4/RedfishManagerNetworkProtocol_V1_4_4_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_4/RedfishManagerNetworkProtocol_V1_4_4_Dxe.inf new file mode 100644 index 00000000000..5d27d4fedc0 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_4_4/RedfishManagerNetworkProtocol_V1_4_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_4_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_4_4_Dxe + FILE_GUID = e4486b39-35d3-41e4-96fe-a160c114dcec + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_4_4EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_4_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_4_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_4_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_0/ManagerNetworkProtocol_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_0/ManagerNetworkProtocol_V1_5_0_Dxe.c new file mode 100644 index 00000000000..5e5b5842da3 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_0/ManagerNetworkProtocol_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "5", + "0" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_0 *ManagerNetworkProtocolV1_5_0; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_0_CS *ManagerNetworkProtocolV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_5_0_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_5_0 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_0)); + if (ManagerNetworkProtocolV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_5_0; + ManagerNetworkProtocolV1_5_0->ManagerNetworkProtocol = ManagerNetworkProtocolV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_5_0_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_0 *ManagerNetworkProtocolV1_5_0; + + ManagerNetworkProtocolV1_5_0 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_0 *)InterpProp; + DestroyManagerNetworkProtocol_V1_5_0_CS (ManagerNetworkProtocolV1_5_0->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_0/RedfishManagerNetworkProtocol_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_0/RedfishManagerNetworkProtocol_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..351935bdd91 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_0/RedfishManagerNetworkProtocol_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_5_0_Dxe + FILE_GUID = 20771c8b-9d35-48fd-8f4a-59c7ee507401 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_1/ManagerNetworkProtocol_V1_5_1_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_1/ManagerNetworkProtocol_V1_5_1_Dxe.c new file mode 100644 index 00000000000..5f4b2047d74 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_1/ManagerNetworkProtocol_V1_5_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_5_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "5", + "1" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_1 *ManagerNetworkProtocolV1_5_1; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_1_CS *ManagerNetworkProtocolV1_5_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_5_1_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_5_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_5_1 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_1)); + if (ManagerNetworkProtocolV1_5_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_5_1; + ManagerNetworkProtocolV1_5_1->ManagerNetworkProtocol = ManagerNetworkProtocolV1_5_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_5_1_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_1 *ManagerNetworkProtocolV1_5_1; + + ManagerNetworkProtocolV1_5_1 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_1 *)InterpProp; + DestroyManagerNetworkProtocol_V1_5_1_CS (ManagerNetworkProtocolV1_5_1->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_5_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_5_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_5_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_1/RedfishManagerNetworkProtocol_V1_5_1_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_1/RedfishManagerNetworkProtocol_V1_5_1_Dxe.inf new file mode 100644 index 00000000000..10ea1cc3d58 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_1/RedfishManagerNetworkProtocol_V1_5_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_5_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_5_1_Dxe + FILE_GUID = 605099ca-bee5-46de-89c6-84a1a2783253 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_5_1EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_5_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_5_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_5_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_2/ManagerNetworkProtocol_V1_5_2_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_2/ManagerNetworkProtocol_V1_5_2_Dxe.c new file mode 100644 index 00000000000..7050b7cd3d2 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_2/ManagerNetworkProtocol_V1_5_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_5_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "5", + "2" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_2 *ManagerNetworkProtocolV1_5_2; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_2_CS *ManagerNetworkProtocolV1_5_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_5_2_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_5_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_5_2 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_2)); + if (ManagerNetworkProtocolV1_5_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_5_2; + ManagerNetworkProtocolV1_5_2->ManagerNetworkProtocol = ManagerNetworkProtocolV1_5_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_5_2_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_2 *ManagerNetworkProtocolV1_5_2; + + ManagerNetworkProtocolV1_5_2 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_2 *)InterpProp; + DestroyManagerNetworkProtocol_V1_5_2_CS (ManagerNetworkProtocolV1_5_2->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_5_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_5_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_5_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_2/RedfishManagerNetworkProtocol_V1_5_2_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_2/RedfishManagerNetworkProtocol_V1_5_2_Dxe.inf new file mode 100644 index 00000000000..bbab1c58e9d --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_2/RedfishManagerNetworkProtocol_V1_5_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_5_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_5_2_Dxe + FILE_GUID = 1e8a74c1-a181-4a29-89a7-551f02abf1b4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_5_2EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_5_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_5_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_5_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_3/ManagerNetworkProtocol_V1_5_3_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_3/ManagerNetworkProtocol_V1_5_3_Dxe.c new file mode 100644 index 00000000000..7e95bbde017 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_3/ManagerNetworkProtocol_V1_5_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_5_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "5", + "3" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_3 *ManagerNetworkProtocolV1_5_3; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_3_CS *ManagerNetworkProtocolV1_5_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_5_3_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_5_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_5_3 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_3)); + if (ManagerNetworkProtocolV1_5_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_5_3; + ManagerNetworkProtocolV1_5_3->ManagerNetworkProtocol = ManagerNetworkProtocolV1_5_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_5_3_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_3 *ManagerNetworkProtocolV1_5_3; + + ManagerNetworkProtocolV1_5_3 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_3 *)InterpProp; + DestroyManagerNetworkProtocol_V1_5_3_CS (ManagerNetworkProtocolV1_5_3->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_5_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_5_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_5_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_3/RedfishManagerNetworkProtocol_V1_5_3_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_3/RedfishManagerNetworkProtocol_V1_5_3_Dxe.inf new file mode 100644 index 00000000000..6e7c6fa2de7 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_5_3/RedfishManagerNetworkProtocol_V1_5_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_5_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_5_3_Dxe + FILE_GUID = 9386e9dd-0c23-4bfe-8c56-37d92805b2f4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_5_3EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_5_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_5_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_5_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_6_0/ManagerNetworkProtocol_V1_6_0_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_6_0/ManagerNetworkProtocol_V1_6_0_Dxe.c new file mode 100644 index 00000000000..2818fa5a811 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_6_0/ManagerNetworkProtocol_V1_6_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_6_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "6", + "0" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_0 *ManagerNetworkProtocolV1_6_0; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_0_CS *ManagerNetworkProtocolV1_6_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_6_0_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_6_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_6_0 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_0)); + if (ManagerNetworkProtocolV1_6_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_6_0; + ManagerNetworkProtocolV1_6_0->ManagerNetworkProtocol = ManagerNetworkProtocolV1_6_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_6_0_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_0 *ManagerNetworkProtocolV1_6_0; + + ManagerNetworkProtocolV1_6_0 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_0 *)InterpProp; + DestroyManagerNetworkProtocol_V1_6_0_CS (ManagerNetworkProtocolV1_6_0->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_6_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_6_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_6_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_6_0/RedfishManagerNetworkProtocol_V1_6_0_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_6_0/RedfishManagerNetworkProtocol_V1_6_0_Dxe.inf new file mode 100644 index 00000000000..5ad5446163d --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_6_0/RedfishManagerNetworkProtocol_V1_6_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_6_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_6_0_Dxe + FILE_GUID = dcc4e395-574e-4300-94f0-5f96719e1a0c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_6_0EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_6_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_6_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_6_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_6_1/ManagerNetworkProtocol_V1_6_1_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_6_1/ManagerNetworkProtocol_V1_6_1_Dxe.c new file mode 100644 index 00000000000..17a23aa9b53 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_6_1/ManagerNetworkProtocol_V1_6_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_6_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "6", + "1" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_1 *ManagerNetworkProtocolV1_6_1; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_1_CS *ManagerNetworkProtocolV1_6_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_6_1_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_6_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_6_1 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_1)); + if (ManagerNetworkProtocolV1_6_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_6_1; + ManagerNetworkProtocolV1_6_1->ManagerNetworkProtocol = ManagerNetworkProtocolV1_6_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_6_1_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_1 *ManagerNetworkProtocolV1_6_1; + + ManagerNetworkProtocolV1_6_1 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_1 *)InterpProp; + DestroyManagerNetworkProtocol_V1_6_1_CS (ManagerNetworkProtocolV1_6_1->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_6_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_6_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_6_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_6_1/RedfishManagerNetworkProtocol_V1_6_1_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_6_1/RedfishManagerNetworkProtocol_V1_6_1_Dxe.inf new file mode 100644 index 00000000000..56001ad2348 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_6_1/RedfishManagerNetworkProtocol_V1_6_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_6_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_6_1_Dxe + FILE_GUID = 033997a1-afd4-4c95-af2f-349cb420c4e9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_6_1EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_6_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_6_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_6_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_6_2/ManagerNetworkProtocol_V1_6_2_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_6_2/ManagerNetworkProtocol_V1_6_2_Dxe.c new file mode 100644 index 00000000000..49e60dd1fe8 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_6_2/ManagerNetworkProtocol_V1_6_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_6_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "6", + "2" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_2 *ManagerNetworkProtocolV1_6_2; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_2_CS *ManagerNetworkProtocolV1_6_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_6_2_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_6_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_6_2 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_2)); + if (ManagerNetworkProtocolV1_6_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_6_2; + ManagerNetworkProtocolV1_6_2->ManagerNetworkProtocol = ManagerNetworkProtocolV1_6_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_6_2_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_2 *ManagerNetworkProtocolV1_6_2; + + ManagerNetworkProtocolV1_6_2 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_2 *)InterpProp; + DestroyManagerNetworkProtocol_V1_6_2_CS (ManagerNetworkProtocolV1_6_2->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_6_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_6_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_6_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_6_2/RedfishManagerNetworkProtocol_V1_6_2_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_6_2/RedfishManagerNetworkProtocol_V1_6_2_Dxe.inf new file mode 100644 index 00000000000..d3687cec84e --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_6_2/RedfishManagerNetworkProtocol_V1_6_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_6_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_6_2_Dxe + FILE_GUID = 507c7943-1ff5-4009-bd06-bb6df057b561 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_6_2EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_6_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_6_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_6_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_7_0/ManagerNetworkProtocol_V1_7_0_Dxe.c b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_7_0/ManagerNetworkProtocol_V1_7_0_Dxe.c new file mode 100644 index 00000000000..bed17d8e56f --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_7_0/ManagerNetworkProtocol_V1_7_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ManagerNetworkProtocol.v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ManagerNetworkProtocol"; +BOOLEAN IsRevisonController = TRUE; + +// Support ManagerNetworkProtocol V1_7_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ManagerNetworkProtocol", + "1", + "7", + "0" + }, + "ManagerNetworkProtocol" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_7_0 *ManagerNetworkProtocolV1_7_0; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_7_0_CS *ManagerNetworkProtocolV1_7_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ManagerNetworkProtocol") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ManagerNetworkProtocol_V1_7_0_To_CS (ResoruceRaw, &ManagerNetworkProtocolV1_7_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ManagerNetworkProtocolV1_7_0 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_7_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_7_0)); + if (ManagerNetworkProtocolV1_7_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ManagerNetworkProtocolV1_7_0; + ManagerNetworkProtocolV1_7_0->ManagerNetworkProtocol = ManagerNetworkProtocolV1_7_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ManagerNetworkProtocol")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ManagerNetworkProtocol"), "ManagerNetworkProtocol"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ManagerNetworkProtocolToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ManagerNetworkProtocolToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ManagerNetworkProtocol_V1_7_0_JSON (*((EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_7_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ManagerNetworkProtocolToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_7_0 *ManagerNetworkProtocolV1_7_0; + + ManagerNetworkProtocolV1_7_0 = (EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_7_0 *)InterpProp; + DestroyManagerNetworkProtocol_V1_7_0_CS (ManagerNetworkProtocolV1_7_0->ManagerNetworkProtocol); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ManagerNetworkProtocolFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ManagerNetworkProtocolDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyManagerNetworkProtocol_V1_7_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_7_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ManagerNetworkProtocolToStructWrapper, + ManagerNetworkProtocolToJson, + ManagerNetworkProtocolDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishManagerNetworkProtocol_V1_7_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_7_0/RedfishManagerNetworkProtocol_V1_7_0_Dxe.inf b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_7_0/RedfishManagerNetworkProtocol_V1_7_0_Dxe.inf new file mode 100644 index 00000000000..53a53b5e8a7 --- /dev/null +++ b/RedfishClientPkg/Converter/ManagerNetworkProtocol/v1_7_0/RedfishManagerNetworkProtocol_V1_7_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ManagerNetworkProtocol.v1_7_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishManagerNetworkProtocol_V1_7_0_Dxe + FILE_GUID = a9d07ed7-d046-4fcc-968a-2942a2bbd3ea + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishManagerNetworkProtocol_V1_7_0EntryPoint + UNLOAD_IMAGE = RedfishManagerNetworkProtocol_V1_7_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ManagerNetworkProtocol_V1_7_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ManagerNetworkProtocolV1_7_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MediaController/v1_0_0/MediaController_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/MediaController/v1_0_0/MediaController_V1_0_0_Dxe.c new file mode 100644 index 00000000000..530d963dff6 --- /dev/null +++ b/RedfishClientPkg/Converter/MediaController/v1_0_0/MediaController_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MediaController.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MediaController"; +BOOLEAN IsRevisonController = TRUE; + +// Support MediaController V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MediaController", + "1", + "0", + "0" + }, + "MediaController" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MediaControllerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEDIACONTROLLER_V1_0_0 *MediaControllerV1_0_0; + EFI_REDFISH_MEDIACONTROLLER_V1_0_0_CS *MediaControllerV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MediaController") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MediaController_V1_0_0_To_CS (ResoruceRaw, &MediaControllerV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MediaControllerV1_0_0 = (EFI_REDFISH_MEDIACONTROLLER_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEDIACONTROLLER_V1_0_0)); + if (MediaControllerV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MediaControllerV1_0_0; + MediaControllerV1_0_0->MediaController = MediaControllerV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MediaController")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MediaController"), "MediaController"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MediaController")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MediaController"), "MediaController"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MediaControllerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MediaControllerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MediaControllerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MediaControllerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MediaController_V1_0_0_JSON (*((EFI_REDFISH_MEDIACONTROLLER_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MediaControllerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MediaControllerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEDIACONTROLLER_V1_0_0 *MediaControllerV1_0_0; + + MediaControllerV1_0_0 = (EFI_REDFISH_MEDIACONTROLLER_V1_0_0 *)InterpProp; + DestroyMediaController_V1_0_0_CS (MediaControllerV1_0_0->MediaController); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MediaControllerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MediaControllerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMediaController_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMediaController_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MediaControllerToStructWrapper, + MediaControllerToJson, + MediaControllerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMediaController_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MediaController/v1_0_0/RedfishMediaController_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/MediaController/v1_0_0/RedfishMediaController_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..e985034c3f6 --- /dev/null +++ b/RedfishClientPkg/Converter/MediaController/v1_0_0/RedfishMediaController_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MediaController.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMediaController_V1_0_0_Dxe + FILE_GUID = 954a00fd-e133-48f3-b69a-381b258106f2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMediaController_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishMediaController_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MediaController_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MediaControllerV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MediaController/v1_0_1/MediaController_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/MediaController/v1_0_1/MediaController_V1_0_1_Dxe.c new file mode 100644 index 00000000000..4d96c5d2329 --- /dev/null +++ b/RedfishClientPkg/Converter/MediaController/v1_0_1/MediaController_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MediaController.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MediaController"; +BOOLEAN IsRevisonController = TRUE; + +// Support MediaController V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MediaController", + "1", + "0", + "1" + }, + "MediaController" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MediaControllerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEDIACONTROLLER_V1_0_1 *MediaControllerV1_0_1; + EFI_REDFISH_MEDIACONTROLLER_V1_0_1_CS *MediaControllerV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MediaController") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MediaController_V1_0_1_To_CS (ResoruceRaw, &MediaControllerV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MediaControllerV1_0_1 = (EFI_REDFISH_MEDIACONTROLLER_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEDIACONTROLLER_V1_0_1)); + if (MediaControllerV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MediaControllerV1_0_1; + MediaControllerV1_0_1->MediaController = MediaControllerV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MediaController")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MediaController"), "MediaController"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MediaController")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MediaController"), "MediaController"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MediaControllerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MediaControllerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MediaControllerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MediaControllerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MediaController_V1_0_1_JSON (*((EFI_REDFISH_MEDIACONTROLLER_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MediaControllerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MediaControllerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEDIACONTROLLER_V1_0_1 *MediaControllerV1_0_1; + + MediaControllerV1_0_1 = (EFI_REDFISH_MEDIACONTROLLER_V1_0_1 *)InterpProp; + DestroyMediaController_V1_0_1_CS (MediaControllerV1_0_1->MediaController); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MediaControllerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MediaControllerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMediaController_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMediaController_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MediaControllerToStructWrapper, + MediaControllerToJson, + MediaControllerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMediaController_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MediaController/v1_0_1/RedfishMediaController_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/MediaController/v1_0_1/RedfishMediaController_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..ed916c239f1 --- /dev/null +++ b/RedfishClientPkg/Converter/MediaController/v1_0_1/RedfishMediaController_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MediaController.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMediaController_V1_0_1_Dxe + FILE_GUID = 786e9606-ee69-4da7-af07-88db5b59d837 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMediaController_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishMediaController_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MediaController_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MediaControllerV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MediaController/v1_1_0/MediaController_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/MediaController/v1_1_0/MediaController_V1_1_0_Dxe.c new file mode 100644 index 00000000000..a37ffef023c --- /dev/null +++ b/RedfishClientPkg/Converter/MediaController/v1_1_0/MediaController_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MediaController.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MediaController"; +BOOLEAN IsRevisonController = TRUE; + +// Support MediaController V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MediaController", + "1", + "1", + "0" + }, + "MediaController" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MediaControllerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEDIACONTROLLER_V1_1_0 *MediaControllerV1_1_0; + EFI_REDFISH_MEDIACONTROLLER_V1_1_0_CS *MediaControllerV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MediaController") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MediaController_V1_1_0_To_CS (ResoruceRaw, &MediaControllerV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MediaControllerV1_1_0 = (EFI_REDFISH_MEDIACONTROLLER_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEDIACONTROLLER_V1_1_0)); + if (MediaControllerV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MediaControllerV1_1_0; + MediaControllerV1_1_0->MediaController = MediaControllerV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MediaController")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MediaController"), "MediaController"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MediaController")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MediaController"), "MediaController"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MediaControllerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MediaControllerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MediaControllerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MediaControllerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MediaController_V1_1_0_JSON (*((EFI_REDFISH_MEDIACONTROLLER_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MediaControllerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MediaControllerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEDIACONTROLLER_V1_1_0 *MediaControllerV1_1_0; + + MediaControllerV1_1_0 = (EFI_REDFISH_MEDIACONTROLLER_V1_1_0 *)InterpProp; + DestroyMediaController_V1_1_0_CS (MediaControllerV1_1_0->MediaController); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MediaControllerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MediaControllerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMediaController_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMediaController_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MediaControllerToStructWrapper, + MediaControllerToJson, + MediaControllerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMediaController_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MediaController/v1_1_0/RedfishMediaController_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/MediaController/v1_1_0/RedfishMediaController_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..f8f826820ae --- /dev/null +++ b/RedfishClientPkg/Converter/MediaController/v1_1_0/RedfishMediaController_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MediaController.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMediaController_V1_1_0_Dxe + FILE_GUID = 725386a5-e0dd-44d8-8ad8-cb3dcb42ea20 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMediaController_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishMediaController_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MediaController_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MediaControllerV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MediaControllerCollection/MediaControllerCollection_Dxe.c b/RedfishClientPkg/Converter/MediaControllerCollection/MediaControllerCollection_Dxe.c new file mode 100644 index 00000000000..c221eacea9b --- /dev/null +++ b/RedfishClientPkg/Converter/MediaControllerCollection/MediaControllerCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MediaControllerCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MediaControllerCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support MediaControllerCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MediaControllerCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "MediaControllerCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MediaControllerCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEDIACONTROLLERCOLLECTION *MediaControllerCollection; + EFI_REDFISH_MEDIACONTROLLERCOLLECTION_CS *MediaControllerCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MediaControllerCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MediaControllerCollection_To_CS (ResoruceRaw, &MediaControllerCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + MediaControllerCollection = (EFI_REDFISH_MEDIACONTROLLERCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEDIACONTROLLERCOLLECTION)); + if (MediaControllerCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MediaControllerCollection; + MediaControllerCollection->MediaControllerCollection = MediaControllerCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MediaControllerCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MediaControllerCollection"), "MediaControllerCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MediaControllerCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MediaControllerCollection"), "MediaControllerCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MediaControllerCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MediaControllerCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MediaControllerCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MediaControllerCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MediaControllerCollection_JSON (*((EFI_REDFISH_MEDIACONTROLLERCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MediaControllerCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MediaControllerCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEDIACONTROLLERCOLLECTION *MediaControllerCollection; + + MediaControllerCollection = (EFI_REDFISH_MEDIACONTROLLERCOLLECTION *)InterpProp; + DestroyMediaControllerCollection_CS (MediaControllerCollection->MediaControllerCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MediaControllerCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MediaControllerCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMediaControllerCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMediaControllerCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MediaControllerCollectionToStructWrapper, + MediaControllerCollectionToJson, + MediaControllerCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMediaControllerCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MediaControllerCollection/RedfishMediaControllerCollection_Dxe.inf b/RedfishClientPkg/Converter/MediaControllerCollection/RedfishMediaControllerCollection_Dxe.inf new file mode 100644 index 00000000000..db24f67f862 --- /dev/null +++ b/RedfishClientPkg/Converter/MediaControllerCollection/RedfishMediaControllerCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MediaControllerCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMediaControllerCollection_Dxe + FILE_GUID = b52d067b-becf-4177-a659-846966b3877b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMediaControllerCollectionEntryPoint + UNLOAD_IMAGE = RedfishMediaControllerCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MediaControllerCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MediaControllerCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_0_0/Memory_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_0_0/Memory_V1_0_0_Dxe.c new file mode 100644 index 00000000000..db7e03e9119 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_0_0/Memory_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "0", + "0" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_0_0 *MemoryV1_0_0; + EFI_REDFISH_MEMORY_V1_0_0_CS *MemoryV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_0_0_To_CS (ResoruceRaw, &MemoryV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_0_0 = (EFI_REDFISH_MEMORY_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_0_0)); + if (MemoryV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_0_0; + MemoryV1_0_0->Memory = MemoryV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_0_0_JSON (*((EFI_REDFISH_MEMORY_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_0_0 *MemoryV1_0_0; + + MemoryV1_0_0 = (EFI_REDFISH_MEMORY_V1_0_0 *)InterpProp; + DestroyMemory_V1_0_0_CS (MemoryV1_0_0->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_0_0/RedfishMemory_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_0_0/RedfishMemory_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..114e41a7b32 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_0_0/RedfishMemory_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_0_0_Dxe + FILE_GUID = 592a0380-753b-48fc-8fc5-26f13f4c6bf4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_0_1/Memory_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_0_1/Memory_V1_0_1_Dxe.c new file mode 100644 index 00000000000..fba78cbf5b7 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_0_1/Memory_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "0", + "1" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_0_1 *MemoryV1_0_1; + EFI_REDFISH_MEMORY_V1_0_1_CS *MemoryV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_0_1_To_CS (ResoruceRaw, &MemoryV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_0_1 = (EFI_REDFISH_MEMORY_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_0_1)); + if (MemoryV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_0_1; + MemoryV1_0_1->Memory = MemoryV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_0_1_JSON (*((EFI_REDFISH_MEMORY_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_0_1 *MemoryV1_0_1; + + MemoryV1_0_1 = (EFI_REDFISH_MEMORY_V1_0_1 *)InterpProp; + DestroyMemory_V1_0_1_CS (MemoryV1_0_1->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_0_1/RedfishMemory_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_0_1/RedfishMemory_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..01e6854705a --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_0_1/RedfishMemory_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_0_1_Dxe + FILE_GUID = 0e631a1a-89dc-4d8b-8364-a31d8467c12a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_0_10/Memory_V1_0_10_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_0_10/Memory_V1_0_10_Dxe.c new file mode 100644 index 00000000000..926a9891147 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_0_10/Memory_V1_0_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_0_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "0", + "10" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_0_10 *MemoryV1_0_10; + EFI_REDFISH_MEMORY_V1_0_10_CS *MemoryV1_0_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_0_10_To_CS (ResoruceRaw, &MemoryV1_0_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_0_10 = (EFI_REDFISH_MEMORY_V1_0_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_0_10)); + if (MemoryV1_0_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_0_10; + MemoryV1_0_10->Memory = MemoryV1_0_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_0_10_JSON (*((EFI_REDFISH_MEMORY_V1_0_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_0_10 *MemoryV1_0_10; + + MemoryV1_0_10 = (EFI_REDFISH_MEMORY_V1_0_10 *)InterpProp; + DestroyMemory_V1_0_10_CS (MemoryV1_0_10->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_0_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_0_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_0_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_0_10/RedfishMemory_V1_0_10_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_0_10/RedfishMemory_V1_0_10_Dxe.inf new file mode 100644 index 00000000000..502f9613e88 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_0_10/RedfishMemory_V1_0_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_0_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_0_10_Dxe + FILE_GUID = a90667c9-80f2-4035-92c5-34933e8bcf04 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_0_10EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_0_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_0_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_0_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_0_11/Memory_V1_0_11_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_0_11/Memory_V1_0_11_Dxe.c new file mode 100644 index 00000000000..19f4554da77 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_0_11/Memory_V1_0_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_0_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "0", + "11" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_0_11 *MemoryV1_0_11; + EFI_REDFISH_MEMORY_V1_0_11_CS *MemoryV1_0_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_0_11_To_CS (ResoruceRaw, &MemoryV1_0_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_0_11 = (EFI_REDFISH_MEMORY_V1_0_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_0_11)); + if (MemoryV1_0_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_0_11; + MemoryV1_0_11->Memory = MemoryV1_0_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_0_11_JSON (*((EFI_REDFISH_MEMORY_V1_0_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_0_11 *MemoryV1_0_11; + + MemoryV1_0_11 = (EFI_REDFISH_MEMORY_V1_0_11 *)InterpProp; + DestroyMemory_V1_0_11_CS (MemoryV1_0_11->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_0_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_0_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_0_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_0_11/RedfishMemory_V1_0_11_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_0_11/RedfishMemory_V1_0_11_Dxe.inf new file mode 100644 index 00000000000..776a9c481e8 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_0_11/RedfishMemory_V1_0_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_0_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_0_11_Dxe + FILE_GUID = 81adb1a1-82d3-47cc-99c5-093db9c48b1e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_0_11EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_0_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_0_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_0_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_0_2/Memory_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_0_2/Memory_V1_0_2_Dxe.c new file mode 100644 index 00000000000..1a654757139 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_0_2/Memory_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "0", + "2" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_0_2 *MemoryV1_0_2; + EFI_REDFISH_MEMORY_V1_0_2_CS *MemoryV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_0_2_To_CS (ResoruceRaw, &MemoryV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_0_2 = (EFI_REDFISH_MEMORY_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_0_2)); + if (MemoryV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_0_2; + MemoryV1_0_2->Memory = MemoryV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_0_2_JSON (*((EFI_REDFISH_MEMORY_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_0_2 *MemoryV1_0_2; + + MemoryV1_0_2 = (EFI_REDFISH_MEMORY_V1_0_2 *)InterpProp; + DestroyMemory_V1_0_2_CS (MemoryV1_0_2->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_0_2/RedfishMemory_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_0_2/RedfishMemory_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..3b1da4c0b87 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_0_2/RedfishMemory_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_0_2_Dxe + FILE_GUID = f7f0c215-54d2-475e-bdec-f812d5a8493b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_0_3/Memory_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_0_3/Memory_V1_0_3_Dxe.c new file mode 100644 index 00000000000..d89041fd5aa --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_0_3/Memory_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "0", + "3" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_0_3 *MemoryV1_0_3; + EFI_REDFISH_MEMORY_V1_0_3_CS *MemoryV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_0_3_To_CS (ResoruceRaw, &MemoryV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_0_3 = (EFI_REDFISH_MEMORY_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_0_3)); + if (MemoryV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_0_3; + MemoryV1_0_3->Memory = MemoryV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_0_3_JSON (*((EFI_REDFISH_MEMORY_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_0_3 *MemoryV1_0_3; + + MemoryV1_0_3 = (EFI_REDFISH_MEMORY_V1_0_3 *)InterpProp; + DestroyMemory_V1_0_3_CS (MemoryV1_0_3->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_0_3/RedfishMemory_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_0_3/RedfishMemory_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..a88d9dafb1f --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_0_3/RedfishMemory_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_0_3_Dxe + FILE_GUID = e503f873-0aad-4926-842f-e5ade69dccdf + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_0_4/Memory_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_0_4/Memory_V1_0_4_Dxe.c new file mode 100644 index 00000000000..09b8515cfa1 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_0_4/Memory_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "0", + "4" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_0_4 *MemoryV1_0_4; + EFI_REDFISH_MEMORY_V1_0_4_CS *MemoryV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_0_4_To_CS (ResoruceRaw, &MemoryV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_0_4 = (EFI_REDFISH_MEMORY_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_0_4)); + if (MemoryV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_0_4; + MemoryV1_0_4->Memory = MemoryV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_0_4_JSON (*((EFI_REDFISH_MEMORY_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_0_4 *MemoryV1_0_4; + + MemoryV1_0_4 = (EFI_REDFISH_MEMORY_V1_0_4 *)InterpProp; + DestroyMemory_V1_0_4_CS (MemoryV1_0_4->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_0_4/RedfishMemory_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_0_4/RedfishMemory_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..b00059321f9 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_0_4/RedfishMemory_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_0_4_Dxe + FILE_GUID = 61f8bcf5-2362-40ae-b1c2-6d2b2fa42814 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_0_5/Memory_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_0_5/Memory_V1_0_5_Dxe.c new file mode 100644 index 00000000000..e291809ee24 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_0_5/Memory_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "0", + "5" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_0_5 *MemoryV1_0_5; + EFI_REDFISH_MEMORY_V1_0_5_CS *MemoryV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_0_5_To_CS (ResoruceRaw, &MemoryV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_0_5 = (EFI_REDFISH_MEMORY_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_0_5)); + if (MemoryV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_0_5; + MemoryV1_0_5->Memory = MemoryV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_0_5_JSON (*((EFI_REDFISH_MEMORY_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_0_5 *MemoryV1_0_5; + + MemoryV1_0_5 = (EFI_REDFISH_MEMORY_V1_0_5 *)InterpProp; + DestroyMemory_V1_0_5_CS (MemoryV1_0_5->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_0_5/RedfishMemory_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_0_5/RedfishMemory_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..033e98c35af --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_0_5/RedfishMemory_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_0_5_Dxe + FILE_GUID = 02235537-17c9-464f-9f11-381ab7e69062 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_0_6/Memory_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_0_6/Memory_V1_0_6_Dxe.c new file mode 100644 index 00000000000..c55d442eb47 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_0_6/Memory_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "0", + "6" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_0_6 *MemoryV1_0_6; + EFI_REDFISH_MEMORY_V1_0_6_CS *MemoryV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_0_6_To_CS (ResoruceRaw, &MemoryV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_0_6 = (EFI_REDFISH_MEMORY_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_0_6)); + if (MemoryV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_0_6; + MemoryV1_0_6->Memory = MemoryV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_0_6_JSON (*((EFI_REDFISH_MEMORY_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_0_6 *MemoryV1_0_6; + + MemoryV1_0_6 = (EFI_REDFISH_MEMORY_V1_0_6 *)InterpProp; + DestroyMemory_V1_0_6_CS (MemoryV1_0_6->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_0_6/RedfishMemory_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_0_6/RedfishMemory_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..1a4d8a4a7a5 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_0_6/RedfishMemory_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_0_6_Dxe + FILE_GUID = 2e4e118f-ce2c-4d80-83b5-8b6b7d578406 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_0_7/Memory_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_0_7/Memory_V1_0_7_Dxe.c new file mode 100644 index 00000000000..5c7c8a63de5 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_0_7/Memory_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "0", + "7" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_0_7 *MemoryV1_0_7; + EFI_REDFISH_MEMORY_V1_0_7_CS *MemoryV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_0_7_To_CS (ResoruceRaw, &MemoryV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_0_7 = (EFI_REDFISH_MEMORY_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_0_7)); + if (MemoryV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_0_7; + MemoryV1_0_7->Memory = MemoryV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_0_7_JSON (*((EFI_REDFISH_MEMORY_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_0_7 *MemoryV1_0_7; + + MemoryV1_0_7 = (EFI_REDFISH_MEMORY_V1_0_7 *)InterpProp; + DestroyMemory_V1_0_7_CS (MemoryV1_0_7->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_0_7/RedfishMemory_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_0_7/RedfishMemory_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..34d6534f4a4 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_0_7/RedfishMemory_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_0_7_Dxe + FILE_GUID = 8ad5be7d-562b-481d-a483-cdcd3a4b983e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_0_8/Memory_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_0_8/Memory_V1_0_8_Dxe.c new file mode 100644 index 00000000000..5e9fd4b3454 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_0_8/Memory_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "0", + "8" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_0_8 *MemoryV1_0_8; + EFI_REDFISH_MEMORY_V1_0_8_CS *MemoryV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_0_8_To_CS (ResoruceRaw, &MemoryV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_0_8 = (EFI_REDFISH_MEMORY_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_0_8)); + if (MemoryV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_0_8; + MemoryV1_0_8->Memory = MemoryV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_0_8_JSON (*((EFI_REDFISH_MEMORY_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_0_8 *MemoryV1_0_8; + + MemoryV1_0_8 = (EFI_REDFISH_MEMORY_V1_0_8 *)InterpProp; + DestroyMemory_V1_0_8_CS (MemoryV1_0_8->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_0_8/RedfishMemory_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_0_8/RedfishMemory_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..7fa64ab0ee4 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_0_8/RedfishMemory_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_0_8_Dxe + FILE_GUID = 30096d3b-1713-4f32-af58-9ee6aeeb183d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_0_9/Memory_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_0_9/Memory_V1_0_9_Dxe.c new file mode 100644 index 00000000000..6018b7a6df3 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_0_9/Memory_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "0", + "9" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_0_9 *MemoryV1_0_9; + EFI_REDFISH_MEMORY_V1_0_9_CS *MemoryV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_0_9_To_CS (ResoruceRaw, &MemoryV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_0_9 = (EFI_REDFISH_MEMORY_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_0_9)); + if (MemoryV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_0_9; + MemoryV1_0_9->Memory = MemoryV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_0_9_JSON (*((EFI_REDFISH_MEMORY_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_0_9 *MemoryV1_0_9; + + MemoryV1_0_9 = (EFI_REDFISH_MEMORY_V1_0_9 *)InterpProp; + DestroyMemory_V1_0_9_CS (MemoryV1_0_9->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_0_9/RedfishMemory_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_0_9/RedfishMemory_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..89c15e99099 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_0_9/RedfishMemory_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_0_9_Dxe + FILE_GUID = f6d21b87-4780-4101-9884-e66bb14c36c2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_10_0/Memory_V1_10_0_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_10_0/Memory_V1_10_0_Dxe.c new file mode 100644 index 00000000000..ae9b08a80b8 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_10_0/Memory_V1_10_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_10_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_10_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "10", + "0" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_10_0 *MemoryV1_10_0; + EFI_REDFISH_MEMORY_V1_10_0_CS *MemoryV1_10_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_10_0_To_CS (ResoruceRaw, &MemoryV1_10_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_10_0 = (EFI_REDFISH_MEMORY_V1_10_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_10_0)); + if (MemoryV1_10_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_10_0; + MemoryV1_10_0->Memory = MemoryV1_10_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "10"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_10_0_JSON (*((EFI_REDFISH_MEMORY_V1_10_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_10_0 *MemoryV1_10_0; + + MemoryV1_10_0 = (EFI_REDFISH_MEMORY_V1_10_0 *)InterpProp; + DestroyMemory_V1_10_0_CS (MemoryV1_10_0->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_10_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_10_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_10_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_10_0/RedfishMemory_V1_10_0_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_10_0/RedfishMemory_V1_10_0_Dxe.inf new file mode 100644 index 00000000000..30ab1593d8a --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_10_0/RedfishMemory_V1_10_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_10_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_10_0_Dxe + FILE_GUID = 8f123f39-ca68-4edd-97d8-b8824167298b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_10_0EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_10_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_10_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_10_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_10_1/Memory_V1_10_1_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_10_1/Memory_V1_10_1_Dxe.c new file mode 100644 index 00000000000..dec4de7cf6f --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_10_1/Memory_V1_10_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_10_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_10_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "10", + "1" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_10_1 *MemoryV1_10_1; + EFI_REDFISH_MEMORY_V1_10_1_CS *MemoryV1_10_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_10_1_To_CS (ResoruceRaw, &MemoryV1_10_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_10_1 = (EFI_REDFISH_MEMORY_V1_10_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_10_1)); + if (MemoryV1_10_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_10_1; + MemoryV1_10_1->Memory = MemoryV1_10_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "10"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_10_1_JSON (*((EFI_REDFISH_MEMORY_V1_10_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_10_1 *MemoryV1_10_1; + + MemoryV1_10_1 = (EFI_REDFISH_MEMORY_V1_10_1 *)InterpProp; + DestroyMemory_V1_10_1_CS (MemoryV1_10_1->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_10_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_10_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_10_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_10_1/RedfishMemory_V1_10_1_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_10_1/RedfishMemory_V1_10_1_Dxe.inf new file mode 100644 index 00000000000..bb0c321ff7f --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_10_1/RedfishMemory_V1_10_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_10_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_10_1_Dxe + FILE_GUID = 4d4d9f29-d6f1-4506-9c56-f8f9cbca3cb1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_10_1EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_10_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_10_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_10_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_11_0/Memory_V1_11_0_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_11_0/Memory_V1_11_0_Dxe.c new file mode 100644 index 00000000000..af8771a62a2 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_11_0/Memory_V1_11_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_11_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_11_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "11", + "0" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_11_0 *MemoryV1_11_0; + EFI_REDFISH_MEMORY_V1_11_0_CS *MemoryV1_11_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_11_0_To_CS (ResoruceRaw, &MemoryV1_11_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_11_0 = (EFI_REDFISH_MEMORY_V1_11_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_11_0)); + if (MemoryV1_11_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_11_0; + MemoryV1_11_0->Memory = MemoryV1_11_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "11"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_11_0_JSON (*((EFI_REDFISH_MEMORY_V1_11_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_11_0 *MemoryV1_11_0; + + MemoryV1_11_0 = (EFI_REDFISH_MEMORY_V1_11_0 *)InterpProp; + DestroyMemory_V1_11_0_CS (MemoryV1_11_0->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_11_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_11_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_11_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_11_0/RedfishMemory_V1_11_0_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_11_0/RedfishMemory_V1_11_0_Dxe.inf new file mode 100644 index 00000000000..8472f17457a --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_11_0/RedfishMemory_V1_11_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_11_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_11_0_Dxe + FILE_GUID = 067a4898-eb21-493d-9344-c57d2185e186 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_11_0EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_11_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_11_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_11_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_1_0/Memory_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_1_0/Memory_V1_1_0_Dxe.c new file mode 100644 index 00000000000..c80ca6882bf --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_1_0/Memory_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "1", + "0" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_1_0 *MemoryV1_1_0; + EFI_REDFISH_MEMORY_V1_1_0_CS *MemoryV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_1_0_To_CS (ResoruceRaw, &MemoryV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_1_0 = (EFI_REDFISH_MEMORY_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_1_0)); + if (MemoryV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_1_0; + MemoryV1_1_0->Memory = MemoryV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_1_0_JSON (*((EFI_REDFISH_MEMORY_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_1_0 *MemoryV1_1_0; + + MemoryV1_1_0 = (EFI_REDFISH_MEMORY_V1_1_0 *)InterpProp; + DestroyMemory_V1_1_0_CS (MemoryV1_1_0->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_1_0/RedfishMemory_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_1_0/RedfishMemory_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..148c85a5079 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_1_0/RedfishMemory_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_1_0_Dxe + FILE_GUID = 8d922704-9e36-4e0d-ae57-198c060019cb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_1_1/Memory_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_1_1/Memory_V1_1_1_Dxe.c new file mode 100644 index 00000000000..fa54b449097 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_1_1/Memory_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "1", + "1" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_1_1 *MemoryV1_1_1; + EFI_REDFISH_MEMORY_V1_1_1_CS *MemoryV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_1_1_To_CS (ResoruceRaw, &MemoryV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_1_1 = (EFI_REDFISH_MEMORY_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_1_1)); + if (MemoryV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_1_1; + MemoryV1_1_1->Memory = MemoryV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_1_1_JSON (*((EFI_REDFISH_MEMORY_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_1_1 *MemoryV1_1_1; + + MemoryV1_1_1 = (EFI_REDFISH_MEMORY_V1_1_1 *)InterpProp; + DestroyMemory_V1_1_1_CS (MemoryV1_1_1->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_1_1/RedfishMemory_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_1_1/RedfishMemory_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..40dd0a58bae --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_1_1/RedfishMemory_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_1_1_Dxe + FILE_GUID = b518472e-3ed1-4d7c-989e-8f633c419b41 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_1_10/Memory_V1_1_10_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_1_10/Memory_V1_1_10_Dxe.c new file mode 100644 index 00000000000..c0a4a72e00d --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_1_10/Memory_V1_1_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_1_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_1_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "1", + "10" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_1_10 *MemoryV1_1_10; + EFI_REDFISH_MEMORY_V1_1_10_CS *MemoryV1_1_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_1_10_To_CS (ResoruceRaw, &MemoryV1_1_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_1_10 = (EFI_REDFISH_MEMORY_V1_1_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_1_10)); + if (MemoryV1_1_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_1_10; + MemoryV1_1_10->Memory = MemoryV1_1_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_1_10_JSON (*((EFI_REDFISH_MEMORY_V1_1_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_1_10 *MemoryV1_1_10; + + MemoryV1_1_10 = (EFI_REDFISH_MEMORY_V1_1_10 *)InterpProp; + DestroyMemory_V1_1_10_CS (MemoryV1_1_10->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_1_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_1_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_1_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_1_10/RedfishMemory_V1_1_10_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_1_10/RedfishMemory_V1_1_10_Dxe.inf new file mode 100644 index 00000000000..2d1ed74b4de --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_1_10/RedfishMemory_V1_1_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_1_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_1_10_Dxe + FILE_GUID = 07e16b89-b17c-4c09-951c-ff5a11442162 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_1_10EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_1_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_1_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_1_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_1_2/Memory_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_1_2/Memory_V1_1_2_Dxe.c new file mode 100644 index 00000000000..11f0a641343 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_1_2/Memory_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "1", + "2" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_1_2 *MemoryV1_1_2; + EFI_REDFISH_MEMORY_V1_1_2_CS *MemoryV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_1_2_To_CS (ResoruceRaw, &MemoryV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_1_2 = (EFI_REDFISH_MEMORY_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_1_2)); + if (MemoryV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_1_2; + MemoryV1_1_2->Memory = MemoryV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_1_2_JSON (*((EFI_REDFISH_MEMORY_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_1_2 *MemoryV1_1_2; + + MemoryV1_1_2 = (EFI_REDFISH_MEMORY_V1_1_2 *)InterpProp; + DestroyMemory_V1_1_2_CS (MemoryV1_1_2->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_1_2/RedfishMemory_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_1_2/RedfishMemory_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..50dea91d25f --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_1_2/RedfishMemory_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_1_2_Dxe + FILE_GUID = 4529e9bc-8932-41a8-a9cf-ae91677e979c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_1_3/Memory_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_1_3/Memory_V1_1_3_Dxe.c new file mode 100644 index 00000000000..18d4b97edeb --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_1_3/Memory_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "1", + "3" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_1_3 *MemoryV1_1_3; + EFI_REDFISH_MEMORY_V1_1_3_CS *MemoryV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_1_3_To_CS (ResoruceRaw, &MemoryV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_1_3 = (EFI_REDFISH_MEMORY_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_1_3)); + if (MemoryV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_1_3; + MemoryV1_1_3->Memory = MemoryV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_1_3_JSON (*((EFI_REDFISH_MEMORY_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_1_3 *MemoryV1_1_3; + + MemoryV1_1_3 = (EFI_REDFISH_MEMORY_V1_1_3 *)InterpProp; + DestroyMemory_V1_1_3_CS (MemoryV1_1_3->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_1_3/RedfishMemory_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_1_3/RedfishMemory_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..54f5183fab7 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_1_3/RedfishMemory_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_1_3_Dxe + FILE_GUID = 0b0b28a3-2aab-4f43-8b3a-279b45a0f3fb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_1_4/Memory_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_1_4/Memory_V1_1_4_Dxe.c new file mode 100644 index 00000000000..76b58017542 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_1_4/Memory_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "1", + "4" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_1_4 *MemoryV1_1_4; + EFI_REDFISH_MEMORY_V1_1_4_CS *MemoryV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_1_4_To_CS (ResoruceRaw, &MemoryV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_1_4 = (EFI_REDFISH_MEMORY_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_1_4)); + if (MemoryV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_1_4; + MemoryV1_1_4->Memory = MemoryV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_1_4_JSON (*((EFI_REDFISH_MEMORY_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_1_4 *MemoryV1_1_4; + + MemoryV1_1_4 = (EFI_REDFISH_MEMORY_V1_1_4 *)InterpProp; + DestroyMemory_V1_1_4_CS (MemoryV1_1_4->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_1_4/RedfishMemory_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_1_4/RedfishMemory_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..6b2c05922a3 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_1_4/RedfishMemory_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_1_4_Dxe + FILE_GUID = c9de94e6-1120-4459-a8f4-e9ac10696c6a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_1_5/Memory_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_1_5/Memory_V1_1_5_Dxe.c new file mode 100644 index 00000000000..728b8d7fc35 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_1_5/Memory_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "1", + "5" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_1_5 *MemoryV1_1_5; + EFI_REDFISH_MEMORY_V1_1_5_CS *MemoryV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_1_5_To_CS (ResoruceRaw, &MemoryV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_1_5 = (EFI_REDFISH_MEMORY_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_1_5)); + if (MemoryV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_1_5; + MemoryV1_1_5->Memory = MemoryV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_1_5_JSON (*((EFI_REDFISH_MEMORY_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_1_5 *MemoryV1_1_5; + + MemoryV1_1_5 = (EFI_REDFISH_MEMORY_V1_1_5 *)InterpProp; + DestroyMemory_V1_1_5_CS (MemoryV1_1_5->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_1_5/RedfishMemory_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_1_5/RedfishMemory_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..b1acd5cd8a2 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_1_5/RedfishMemory_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_1_5_Dxe + FILE_GUID = f05903f4-0bb7-4bc5-9017-1e5a9de04bfb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_1_6/Memory_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_1_6/Memory_V1_1_6_Dxe.c new file mode 100644 index 00000000000..6256391ce92 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_1_6/Memory_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "1", + "6" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_1_6 *MemoryV1_1_6; + EFI_REDFISH_MEMORY_V1_1_6_CS *MemoryV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_1_6_To_CS (ResoruceRaw, &MemoryV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_1_6 = (EFI_REDFISH_MEMORY_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_1_6)); + if (MemoryV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_1_6; + MemoryV1_1_6->Memory = MemoryV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_1_6_JSON (*((EFI_REDFISH_MEMORY_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_1_6 *MemoryV1_1_6; + + MemoryV1_1_6 = (EFI_REDFISH_MEMORY_V1_1_6 *)InterpProp; + DestroyMemory_V1_1_6_CS (MemoryV1_1_6->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_1_6/RedfishMemory_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_1_6/RedfishMemory_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..168ddc41243 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_1_6/RedfishMemory_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_1_6_Dxe + FILE_GUID = 526eab0f-8bbc-439b-a805-21cfe38153e2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_1_7/Memory_V1_1_7_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_1_7/Memory_V1_1_7_Dxe.c new file mode 100644 index 00000000000..152867533c9 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_1_7/Memory_V1_1_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_1_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "1", + "7" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_1_7 *MemoryV1_1_7; + EFI_REDFISH_MEMORY_V1_1_7_CS *MemoryV1_1_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_1_7_To_CS (ResoruceRaw, &MemoryV1_1_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_1_7 = (EFI_REDFISH_MEMORY_V1_1_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_1_7)); + if (MemoryV1_1_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_1_7; + MemoryV1_1_7->Memory = MemoryV1_1_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_1_7_JSON (*((EFI_REDFISH_MEMORY_V1_1_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_1_7 *MemoryV1_1_7; + + MemoryV1_1_7 = (EFI_REDFISH_MEMORY_V1_1_7 *)InterpProp; + DestroyMemory_V1_1_7_CS (MemoryV1_1_7->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_1_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_1_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_1_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_1_7/RedfishMemory_V1_1_7_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_1_7/RedfishMemory_V1_1_7_Dxe.inf new file mode 100644 index 00000000000..7ac042a4fd6 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_1_7/RedfishMemory_V1_1_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_1_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_1_7_Dxe + FILE_GUID = d31e6d50-b465-41e4-a8c1-8a67cf5610c9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_1_7EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_1_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_1_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_1_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_1_8/Memory_V1_1_8_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_1_8/Memory_V1_1_8_Dxe.c new file mode 100644 index 00000000000..36781ded011 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_1_8/Memory_V1_1_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_1_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "1", + "8" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_1_8 *MemoryV1_1_8; + EFI_REDFISH_MEMORY_V1_1_8_CS *MemoryV1_1_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_1_8_To_CS (ResoruceRaw, &MemoryV1_1_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_1_8 = (EFI_REDFISH_MEMORY_V1_1_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_1_8)); + if (MemoryV1_1_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_1_8; + MemoryV1_1_8->Memory = MemoryV1_1_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_1_8_JSON (*((EFI_REDFISH_MEMORY_V1_1_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_1_8 *MemoryV1_1_8; + + MemoryV1_1_8 = (EFI_REDFISH_MEMORY_V1_1_8 *)InterpProp; + DestroyMemory_V1_1_8_CS (MemoryV1_1_8->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_1_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_1_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_1_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_1_8/RedfishMemory_V1_1_8_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_1_8/RedfishMemory_V1_1_8_Dxe.inf new file mode 100644 index 00000000000..a3b8f9e1b74 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_1_8/RedfishMemory_V1_1_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_1_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_1_8_Dxe + FILE_GUID = fb212de8-99b1-4425-bbe6-8357c64c6656 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_1_8EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_1_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_1_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_1_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_1_9/Memory_V1_1_9_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_1_9/Memory_V1_1_9_Dxe.c new file mode 100644 index 00000000000..46843e19f1e --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_1_9/Memory_V1_1_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_1_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "1", + "9" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_1_9 *MemoryV1_1_9; + EFI_REDFISH_MEMORY_V1_1_9_CS *MemoryV1_1_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_1_9_To_CS (ResoruceRaw, &MemoryV1_1_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_1_9 = (EFI_REDFISH_MEMORY_V1_1_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_1_9)); + if (MemoryV1_1_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_1_9; + MemoryV1_1_9->Memory = MemoryV1_1_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_1_9_JSON (*((EFI_REDFISH_MEMORY_V1_1_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_1_9 *MemoryV1_1_9; + + MemoryV1_1_9 = (EFI_REDFISH_MEMORY_V1_1_9 *)InterpProp; + DestroyMemory_V1_1_9_CS (MemoryV1_1_9->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_1_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_1_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_1_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_1_9/RedfishMemory_V1_1_9_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_1_9/RedfishMemory_V1_1_9_Dxe.inf new file mode 100644 index 00000000000..d8c581fc973 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_1_9/RedfishMemory_V1_1_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_1_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_1_9_Dxe + FILE_GUID = 58e608bb-80fe-4c3f-882d-5df44daaa836 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_1_9EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_1_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_1_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_1_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_2_0/Memory_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_2_0/Memory_V1_2_0_Dxe.c new file mode 100644 index 00000000000..f4dfa640e5e --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_2_0/Memory_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "2", + "0" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_2_0 *MemoryV1_2_0; + EFI_REDFISH_MEMORY_V1_2_0_CS *MemoryV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_2_0_To_CS (ResoruceRaw, &MemoryV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_2_0 = (EFI_REDFISH_MEMORY_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_2_0)); + if (MemoryV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_2_0; + MemoryV1_2_0->Memory = MemoryV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_2_0_JSON (*((EFI_REDFISH_MEMORY_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_2_0 *MemoryV1_2_0; + + MemoryV1_2_0 = (EFI_REDFISH_MEMORY_V1_2_0 *)InterpProp; + DestroyMemory_V1_2_0_CS (MemoryV1_2_0->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_2_0/RedfishMemory_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_2_0/RedfishMemory_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..387bafcff14 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_2_0/RedfishMemory_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_2_0_Dxe + FILE_GUID = b6ae5a26-704e-4490-b2a3-5e37819984e9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_2_1/Memory_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_2_1/Memory_V1_2_1_Dxe.c new file mode 100644 index 00000000000..a0e823c091c --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_2_1/Memory_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "2", + "1" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_2_1 *MemoryV1_2_1; + EFI_REDFISH_MEMORY_V1_2_1_CS *MemoryV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_2_1_To_CS (ResoruceRaw, &MemoryV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_2_1 = (EFI_REDFISH_MEMORY_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_2_1)); + if (MemoryV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_2_1; + MemoryV1_2_1->Memory = MemoryV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_2_1_JSON (*((EFI_REDFISH_MEMORY_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_2_1 *MemoryV1_2_1; + + MemoryV1_2_1 = (EFI_REDFISH_MEMORY_V1_2_1 *)InterpProp; + DestroyMemory_V1_2_1_CS (MemoryV1_2_1->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_2_1/RedfishMemory_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_2_1/RedfishMemory_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..a0e5dffac22 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_2_1/RedfishMemory_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_2_1_Dxe + FILE_GUID = 90f652d5-dc6d-40e1-b4c2-beecee25c099 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_2_2/Memory_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_2_2/Memory_V1_2_2_Dxe.c new file mode 100644 index 00000000000..afda6199c6d --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_2_2/Memory_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "2", + "2" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_2_2 *MemoryV1_2_2; + EFI_REDFISH_MEMORY_V1_2_2_CS *MemoryV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_2_2_To_CS (ResoruceRaw, &MemoryV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_2_2 = (EFI_REDFISH_MEMORY_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_2_2)); + if (MemoryV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_2_2; + MemoryV1_2_2->Memory = MemoryV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_2_2_JSON (*((EFI_REDFISH_MEMORY_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_2_2 *MemoryV1_2_2; + + MemoryV1_2_2 = (EFI_REDFISH_MEMORY_V1_2_2 *)InterpProp; + DestroyMemory_V1_2_2_CS (MemoryV1_2_2->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_2_2/RedfishMemory_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_2_2/RedfishMemory_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..4d4cbe67700 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_2_2/RedfishMemory_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_2_2_Dxe + FILE_GUID = ccfc450b-5280-4be5-913a-5a88b8915659 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_2_3/Memory_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_2_3/Memory_V1_2_3_Dxe.c new file mode 100644 index 00000000000..a7536e2459c --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_2_3/Memory_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "2", + "3" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_2_3 *MemoryV1_2_3; + EFI_REDFISH_MEMORY_V1_2_3_CS *MemoryV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_2_3_To_CS (ResoruceRaw, &MemoryV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_2_3 = (EFI_REDFISH_MEMORY_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_2_3)); + if (MemoryV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_2_3; + MemoryV1_2_3->Memory = MemoryV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_2_3_JSON (*((EFI_REDFISH_MEMORY_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_2_3 *MemoryV1_2_3; + + MemoryV1_2_3 = (EFI_REDFISH_MEMORY_V1_2_3 *)InterpProp; + DestroyMemory_V1_2_3_CS (MemoryV1_2_3->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_2_3/RedfishMemory_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_2_3/RedfishMemory_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..9fcd074f28c --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_2_3/RedfishMemory_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_2_3_Dxe + FILE_GUID = f804b972-2e10-4982-93f3-8278cbfdd33a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_2_4/Memory_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_2_4/Memory_V1_2_4_Dxe.c new file mode 100644 index 00000000000..71b3a11337d --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_2_4/Memory_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "2", + "4" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_2_4 *MemoryV1_2_4; + EFI_REDFISH_MEMORY_V1_2_4_CS *MemoryV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_2_4_To_CS (ResoruceRaw, &MemoryV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_2_4 = (EFI_REDFISH_MEMORY_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_2_4)); + if (MemoryV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_2_4; + MemoryV1_2_4->Memory = MemoryV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_2_4_JSON (*((EFI_REDFISH_MEMORY_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_2_4 *MemoryV1_2_4; + + MemoryV1_2_4 = (EFI_REDFISH_MEMORY_V1_2_4 *)InterpProp; + DestroyMemory_V1_2_4_CS (MemoryV1_2_4->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_2_4/RedfishMemory_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_2_4/RedfishMemory_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..5da3dda4e29 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_2_4/RedfishMemory_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_2_4_Dxe + FILE_GUID = e1b1969c-09e1-476e-8094-39c8b6b859c2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_2_5/Memory_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_2_5/Memory_V1_2_5_Dxe.c new file mode 100644 index 00000000000..d2ee4f988d0 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_2_5/Memory_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "2", + "5" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_2_5 *MemoryV1_2_5; + EFI_REDFISH_MEMORY_V1_2_5_CS *MemoryV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_2_5_To_CS (ResoruceRaw, &MemoryV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_2_5 = (EFI_REDFISH_MEMORY_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_2_5)); + if (MemoryV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_2_5; + MemoryV1_2_5->Memory = MemoryV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_2_5_JSON (*((EFI_REDFISH_MEMORY_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_2_5 *MemoryV1_2_5; + + MemoryV1_2_5 = (EFI_REDFISH_MEMORY_V1_2_5 *)InterpProp; + DestroyMemory_V1_2_5_CS (MemoryV1_2_5->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_2_5/RedfishMemory_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_2_5/RedfishMemory_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..6ce15c893bb --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_2_5/RedfishMemory_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_2_5_Dxe + FILE_GUID = 9adb3576-ba8a-43a1-b0f8-8cf8cb7c3964 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_2_6/Memory_V1_2_6_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_2_6/Memory_V1_2_6_Dxe.c new file mode 100644 index 00000000000..63be13fb3f7 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_2_6/Memory_V1_2_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_2_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "2", + "6" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_2_6 *MemoryV1_2_6; + EFI_REDFISH_MEMORY_V1_2_6_CS *MemoryV1_2_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_2_6_To_CS (ResoruceRaw, &MemoryV1_2_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_2_6 = (EFI_REDFISH_MEMORY_V1_2_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_2_6)); + if (MemoryV1_2_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_2_6; + MemoryV1_2_6->Memory = MemoryV1_2_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_2_6_JSON (*((EFI_REDFISH_MEMORY_V1_2_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_2_6 *MemoryV1_2_6; + + MemoryV1_2_6 = (EFI_REDFISH_MEMORY_V1_2_6 *)InterpProp; + DestroyMemory_V1_2_6_CS (MemoryV1_2_6->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_2_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_2_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_2_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_2_6/RedfishMemory_V1_2_6_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_2_6/RedfishMemory_V1_2_6_Dxe.inf new file mode 100644 index 00000000000..938728fd757 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_2_6/RedfishMemory_V1_2_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_2_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_2_6_Dxe + FILE_GUID = a32554b1-ac66-4703-9a66-10b6479d6945 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_2_6EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_2_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_2_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_2_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_2_7/Memory_V1_2_7_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_2_7/Memory_V1_2_7_Dxe.c new file mode 100644 index 00000000000..e6006ecd345 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_2_7/Memory_V1_2_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_2_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "2", + "7" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_2_7 *MemoryV1_2_7; + EFI_REDFISH_MEMORY_V1_2_7_CS *MemoryV1_2_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_2_7_To_CS (ResoruceRaw, &MemoryV1_2_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_2_7 = (EFI_REDFISH_MEMORY_V1_2_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_2_7)); + if (MemoryV1_2_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_2_7; + MemoryV1_2_7->Memory = MemoryV1_2_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_2_7_JSON (*((EFI_REDFISH_MEMORY_V1_2_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_2_7 *MemoryV1_2_7; + + MemoryV1_2_7 = (EFI_REDFISH_MEMORY_V1_2_7 *)InterpProp; + DestroyMemory_V1_2_7_CS (MemoryV1_2_7->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_2_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_2_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_2_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_2_7/RedfishMemory_V1_2_7_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_2_7/RedfishMemory_V1_2_7_Dxe.inf new file mode 100644 index 00000000000..ff3d590352e --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_2_7/RedfishMemory_V1_2_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_2_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_2_7_Dxe + FILE_GUID = 112e147c-e8c6-4e38-acb1-33956ed496ae + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_2_7EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_2_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_2_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_2_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_2_8/Memory_V1_2_8_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_2_8/Memory_V1_2_8_Dxe.c new file mode 100644 index 00000000000..ca34aea3609 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_2_8/Memory_V1_2_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_2_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "2", + "8" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_2_8 *MemoryV1_2_8; + EFI_REDFISH_MEMORY_V1_2_8_CS *MemoryV1_2_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_2_8_To_CS (ResoruceRaw, &MemoryV1_2_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_2_8 = (EFI_REDFISH_MEMORY_V1_2_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_2_8)); + if (MemoryV1_2_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_2_8; + MemoryV1_2_8->Memory = MemoryV1_2_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_2_8_JSON (*((EFI_REDFISH_MEMORY_V1_2_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_2_8 *MemoryV1_2_8; + + MemoryV1_2_8 = (EFI_REDFISH_MEMORY_V1_2_8 *)InterpProp; + DestroyMemory_V1_2_8_CS (MemoryV1_2_8->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_2_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_2_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_2_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_2_8/RedfishMemory_V1_2_8_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_2_8/RedfishMemory_V1_2_8_Dxe.inf new file mode 100644 index 00000000000..48b47e458af --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_2_8/RedfishMemory_V1_2_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_2_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_2_8_Dxe + FILE_GUID = 3fa4df90-a366-46e5-acd5-f8030a91f852 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_2_8EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_2_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_2_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_2_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_2_9/Memory_V1_2_9_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_2_9/Memory_V1_2_9_Dxe.c new file mode 100644 index 00000000000..fc48b699f61 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_2_9/Memory_V1_2_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_2_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_2_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "2", + "9" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_2_9 *MemoryV1_2_9; + EFI_REDFISH_MEMORY_V1_2_9_CS *MemoryV1_2_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_2_9_To_CS (ResoruceRaw, &MemoryV1_2_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_2_9 = (EFI_REDFISH_MEMORY_V1_2_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_2_9)); + if (MemoryV1_2_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_2_9; + MemoryV1_2_9->Memory = MemoryV1_2_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_2_9_JSON (*((EFI_REDFISH_MEMORY_V1_2_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_2_9 *MemoryV1_2_9; + + MemoryV1_2_9 = (EFI_REDFISH_MEMORY_V1_2_9 *)InterpProp; + DestroyMemory_V1_2_9_CS (MemoryV1_2_9->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_2_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_2_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_2_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_2_9/RedfishMemory_V1_2_9_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_2_9/RedfishMemory_V1_2_9_Dxe.inf new file mode 100644 index 00000000000..934d94b19ff --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_2_9/RedfishMemory_V1_2_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_2_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_2_9_Dxe + FILE_GUID = 3292c741-6fc2-49b0-b35f-519dd9a6d560 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_2_9EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_2_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_2_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_2_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_3_0/Memory_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_3_0/Memory_V1_3_0_Dxe.c new file mode 100644 index 00000000000..e4f66095509 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_3_0/Memory_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "3", + "0" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_3_0 *MemoryV1_3_0; + EFI_REDFISH_MEMORY_V1_3_0_CS *MemoryV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_3_0_To_CS (ResoruceRaw, &MemoryV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_3_0 = (EFI_REDFISH_MEMORY_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_3_0)); + if (MemoryV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_3_0; + MemoryV1_3_0->Memory = MemoryV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_3_0_JSON (*((EFI_REDFISH_MEMORY_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_3_0 *MemoryV1_3_0; + + MemoryV1_3_0 = (EFI_REDFISH_MEMORY_V1_3_0 *)InterpProp; + DestroyMemory_V1_3_0_CS (MemoryV1_3_0->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_3_0/RedfishMemory_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_3_0/RedfishMemory_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..14d7bc32db1 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_3_0/RedfishMemory_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_3_0_Dxe + FILE_GUID = b8a43a9f-b0fb-4a40-87bd-1b736fdce350 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_3_1/Memory_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_3_1/Memory_V1_3_1_Dxe.c new file mode 100644 index 00000000000..0394fb4b7d5 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_3_1/Memory_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "3", + "1" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_3_1 *MemoryV1_3_1; + EFI_REDFISH_MEMORY_V1_3_1_CS *MemoryV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_3_1_To_CS (ResoruceRaw, &MemoryV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_3_1 = (EFI_REDFISH_MEMORY_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_3_1)); + if (MemoryV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_3_1; + MemoryV1_3_1->Memory = MemoryV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_3_1_JSON (*((EFI_REDFISH_MEMORY_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_3_1 *MemoryV1_3_1; + + MemoryV1_3_1 = (EFI_REDFISH_MEMORY_V1_3_1 *)InterpProp; + DestroyMemory_V1_3_1_CS (MemoryV1_3_1->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_3_1/RedfishMemory_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_3_1/RedfishMemory_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..aa25a012b67 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_3_1/RedfishMemory_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_3_1_Dxe + FILE_GUID = 87fbfaf4-948c-48cc-9c99-9cd56dab1b67 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_3_2/Memory_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_3_2/Memory_V1_3_2_Dxe.c new file mode 100644 index 00000000000..c17627ca679 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_3_2/Memory_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "3", + "2" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_3_2 *MemoryV1_3_2; + EFI_REDFISH_MEMORY_V1_3_2_CS *MemoryV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_3_2_To_CS (ResoruceRaw, &MemoryV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_3_2 = (EFI_REDFISH_MEMORY_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_3_2)); + if (MemoryV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_3_2; + MemoryV1_3_2->Memory = MemoryV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_3_2_JSON (*((EFI_REDFISH_MEMORY_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_3_2 *MemoryV1_3_2; + + MemoryV1_3_2 = (EFI_REDFISH_MEMORY_V1_3_2 *)InterpProp; + DestroyMemory_V1_3_2_CS (MemoryV1_3_2->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_3_2/RedfishMemory_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_3_2/RedfishMemory_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..25d882f3cf7 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_3_2/RedfishMemory_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_3_2_Dxe + FILE_GUID = acf620a5-5f7d-414d-a954-257d860e2ec2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_3_3/Memory_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_3_3/Memory_V1_3_3_Dxe.c new file mode 100644 index 00000000000..3d44ab50537 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_3_3/Memory_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "3", + "3" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_3_3 *MemoryV1_3_3; + EFI_REDFISH_MEMORY_V1_3_3_CS *MemoryV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_3_3_To_CS (ResoruceRaw, &MemoryV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_3_3 = (EFI_REDFISH_MEMORY_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_3_3)); + if (MemoryV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_3_3; + MemoryV1_3_3->Memory = MemoryV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_3_3_JSON (*((EFI_REDFISH_MEMORY_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_3_3 *MemoryV1_3_3; + + MemoryV1_3_3 = (EFI_REDFISH_MEMORY_V1_3_3 *)InterpProp; + DestroyMemory_V1_3_3_CS (MemoryV1_3_3->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_3_3/RedfishMemory_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_3_3/RedfishMemory_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..f3b53a7c1fe --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_3_3/RedfishMemory_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_3_3_Dxe + FILE_GUID = e365bcc6-69f6-4316-b8fe-b20e622e3b90 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_3_4/Memory_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_3_4/Memory_V1_3_4_Dxe.c new file mode 100644 index 00000000000..80df3ce8a62 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_3_4/Memory_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "3", + "4" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_3_4 *MemoryV1_3_4; + EFI_REDFISH_MEMORY_V1_3_4_CS *MemoryV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_3_4_To_CS (ResoruceRaw, &MemoryV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_3_4 = (EFI_REDFISH_MEMORY_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_3_4)); + if (MemoryV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_3_4; + MemoryV1_3_4->Memory = MemoryV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_3_4_JSON (*((EFI_REDFISH_MEMORY_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_3_4 *MemoryV1_3_4; + + MemoryV1_3_4 = (EFI_REDFISH_MEMORY_V1_3_4 *)InterpProp; + DestroyMemory_V1_3_4_CS (MemoryV1_3_4->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_3_4/RedfishMemory_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_3_4/RedfishMemory_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..88c1968d100 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_3_4/RedfishMemory_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_3_4_Dxe + FILE_GUID = dfad08c4-eefa-412a-979d-0b98c3cc634f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_3_5/Memory_V1_3_5_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_3_5/Memory_V1_3_5_Dxe.c new file mode 100644 index 00000000000..56903077a19 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_3_5/Memory_V1_3_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_3_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "3", + "5" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_3_5 *MemoryV1_3_5; + EFI_REDFISH_MEMORY_V1_3_5_CS *MemoryV1_3_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_3_5_To_CS (ResoruceRaw, &MemoryV1_3_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_3_5 = (EFI_REDFISH_MEMORY_V1_3_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_3_5)); + if (MemoryV1_3_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_3_5; + MemoryV1_3_5->Memory = MemoryV1_3_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_3_5_JSON (*((EFI_REDFISH_MEMORY_V1_3_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_3_5 *MemoryV1_3_5; + + MemoryV1_3_5 = (EFI_REDFISH_MEMORY_V1_3_5 *)InterpProp; + DestroyMemory_V1_3_5_CS (MemoryV1_3_5->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_3_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_3_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_3_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_3_5/RedfishMemory_V1_3_5_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_3_5/RedfishMemory_V1_3_5_Dxe.inf new file mode 100644 index 00000000000..9227fce4d9c --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_3_5/RedfishMemory_V1_3_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_3_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_3_5_Dxe + FILE_GUID = 17446fdf-be44-4cd1-9af4-12a3bc88e024 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_3_5EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_3_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_3_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_3_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_3_6/Memory_V1_3_6_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_3_6/Memory_V1_3_6_Dxe.c new file mode 100644 index 00000000000..caeb1611173 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_3_6/Memory_V1_3_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_3_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "3", + "6" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_3_6 *MemoryV1_3_6; + EFI_REDFISH_MEMORY_V1_3_6_CS *MemoryV1_3_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_3_6_To_CS (ResoruceRaw, &MemoryV1_3_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_3_6 = (EFI_REDFISH_MEMORY_V1_3_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_3_6)); + if (MemoryV1_3_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_3_6; + MemoryV1_3_6->Memory = MemoryV1_3_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_3_6_JSON (*((EFI_REDFISH_MEMORY_V1_3_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_3_6 *MemoryV1_3_6; + + MemoryV1_3_6 = (EFI_REDFISH_MEMORY_V1_3_6 *)InterpProp; + DestroyMemory_V1_3_6_CS (MemoryV1_3_6->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_3_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_3_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_3_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_3_6/RedfishMemory_V1_3_6_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_3_6/RedfishMemory_V1_3_6_Dxe.inf new file mode 100644 index 00000000000..ba94c9865da --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_3_6/RedfishMemory_V1_3_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_3_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_3_6_Dxe + FILE_GUID = 2f456edc-b08d-4f25-a758-7329fa5205ef + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_3_6EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_3_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_3_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_3_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_3_7/Memory_V1_3_7_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_3_7/Memory_V1_3_7_Dxe.c new file mode 100644 index 00000000000..e6ec7bc9dee --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_3_7/Memory_V1_3_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_3_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_3_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "3", + "7" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_3_7 *MemoryV1_3_7; + EFI_REDFISH_MEMORY_V1_3_7_CS *MemoryV1_3_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_3_7_To_CS (ResoruceRaw, &MemoryV1_3_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_3_7 = (EFI_REDFISH_MEMORY_V1_3_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_3_7)); + if (MemoryV1_3_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_3_7; + MemoryV1_3_7->Memory = MemoryV1_3_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_3_7_JSON (*((EFI_REDFISH_MEMORY_V1_3_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_3_7 *MemoryV1_3_7; + + MemoryV1_3_7 = (EFI_REDFISH_MEMORY_V1_3_7 *)InterpProp; + DestroyMemory_V1_3_7_CS (MemoryV1_3_7->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_3_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_3_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_3_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_3_7/RedfishMemory_V1_3_7_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_3_7/RedfishMemory_V1_3_7_Dxe.inf new file mode 100644 index 00000000000..6b8999a4449 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_3_7/RedfishMemory_V1_3_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_3_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_3_7_Dxe + FILE_GUID = ffb99812-c219-4e0e-9c44-aa5d15665f44 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_3_7EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_3_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_3_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_3_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_3_8/Memory_V1_3_8_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_3_8/Memory_V1_3_8_Dxe.c new file mode 100644 index 00000000000..9aeb5456711 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_3_8/Memory_V1_3_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_3_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_3_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "3", + "8" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_3_8 *MemoryV1_3_8; + EFI_REDFISH_MEMORY_V1_3_8_CS *MemoryV1_3_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_3_8_To_CS (ResoruceRaw, &MemoryV1_3_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_3_8 = (EFI_REDFISH_MEMORY_V1_3_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_3_8)); + if (MemoryV1_3_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_3_8; + MemoryV1_3_8->Memory = MemoryV1_3_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_3_8_JSON (*((EFI_REDFISH_MEMORY_V1_3_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_3_8 *MemoryV1_3_8; + + MemoryV1_3_8 = (EFI_REDFISH_MEMORY_V1_3_8 *)InterpProp; + DestroyMemory_V1_3_8_CS (MemoryV1_3_8->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_3_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_3_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_3_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_3_8/RedfishMemory_V1_3_8_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_3_8/RedfishMemory_V1_3_8_Dxe.inf new file mode 100644 index 00000000000..e27961b2c5e --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_3_8/RedfishMemory_V1_3_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_3_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_3_8_Dxe + FILE_GUID = 2bcad8a8-f0b6-4c34-b73a-4d1eba96de61 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_3_8EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_3_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_3_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_3_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_3_9/Memory_V1_3_9_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_3_9/Memory_V1_3_9_Dxe.c new file mode 100644 index 00000000000..5b740350256 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_3_9/Memory_V1_3_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_3_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_3_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "3", + "9" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_3_9 *MemoryV1_3_9; + EFI_REDFISH_MEMORY_V1_3_9_CS *MemoryV1_3_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_3_9_To_CS (ResoruceRaw, &MemoryV1_3_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_3_9 = (EFI_REDFISH_MEMORY_V1_3_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_3_9)); + if (MemoryV1_3_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_3_9; + MemoryV1_3_9->Memory = MemoryV1_3_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_3_9_JSON (*((EFI_REDFISH_MEMORY_V1_3_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_3_9 *MemoryV1_3_9; + + MemoryV1_3_9 = (EFI_REDFISH_MEMORY_V1_3_9 *)InterpProp; + DestroyMemory_V1_3_9_CS (MemoryV1_3_9->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_3_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_3_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_3_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_3_9/RedfishMemory_V1_3_9_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_3_9/RedfishMemory_V1_3_9_Dxe.inf new file mode 100644 index 00000000000..7840ea26b0b --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_3_9/RedfishMemory_V1_3_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_3_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_3_9_Dxe + FILE_GUID = 849d842a-c461-4306-9551-11b87e897179 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_3_9EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_3_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_3_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_3_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_4_0/Memory_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_4_0/Memory_V1_4_0_Dxe.c new file mode 100644 index 00000000000..3b5d26a76ab --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_4_0/Memory_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "4", + "0" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_4_0 *MemoryV1_4_0; + EFI_REDFISH_MEMORY_V1_4_0_CS *MemoryV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_4_0_To_CS (ResoruceRaw, &MemoryV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_4_0 = (EFI_REDFISH_MEMORY_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_4_0)); + if (MemoryV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_4_0; + MemoryV1_4_0->Memory = MemoryV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_4_0_JSON (*((EFI_REDFISH_MEMORY_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_4_0 *MemoryV1_4_0; + + MemoryV1_4_0 = (EFI_REDFISH_MEMORY_V1_4_0 *)InterpProp; + DestroyMemory_V1_4_0_CS (MemoryV1_4_0->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_4_0/RedfishMemory_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_4_0/RedfishMemory_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..b20227d12b3 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_4_0/RedfishMemory_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_4_0_Dxe + FILE_GUID = cd23c6a1-9313-42a2-8a84-4ebbd40a87f1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_4_1/Memory_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_4_1/Memory_V1_4_1_Dxe.c new file mode 100644 index 00000000000..62da0b45a25 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_4_1/Memory_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "4", + "1" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_4_1 *MemoryV1_4_1; + EFI_REDFISH_MEMORY_V1_4_1_CS *MemoryV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_4_1_To_CS (ResoruceRaw, &MemoryV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_4_1 = (EFI_REDFISH_MEMORY_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_4_1)); + if (MemoryV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_4_1; + MemoryV1_4_1->Memory = MemoryV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_4_1_JSON (*((EFI_REDFISH_MEMORY_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_4_1 *MemoryV1_4_1; + + MemoryV1_4_1 = (EFI_REDFISH_MEMORY_V1_4_1 *)InterpProp; + DestroyMemory_V1_4_1_CS (MemoryV1_4_1->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_4_1/RedfishMemory_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_4_1/RedfishMemory_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..12087af9985 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_4_1/RedfishMemory_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_4_1_Dxe + FILE_GUID = 8d4ed54f-05d9-45cd-ba8a-20aa05a26eb6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_4_2/Memory_V1_4_2_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_4_2/Memory_V1_4_2_Dxe.c new file mode 100644 index 00000000000..99b58b2f13b --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_4_2/Memory_V1_4_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_4_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "4", + "2" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_4_2 *MemoryV1_4_2; + EFI_REDFISH_MEMORY_V1_4_2_CS *MemoryV1_4_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_4_2_To_CS (ResoruceRaw, &MemoryV1_4_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_4_2 = (EFI_REDFISH_MEMORY_V1_4_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_4_2)); + if (MemoryV1_4_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_4_2; + MemoryV1_4_2->Memory = MemoryV1_4_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_4_2_JSON (*((EFI_REDFISH_MEMORY_V1_4_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_4_2 *MemoryV1_4_2; + + MemoryV1_4_2 = (EFI_REDFISH_MEMORY_V1_4_2 *)InterpProp; + DestroyMemory_V1_4_2_CS (MemoryV1_4_2->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_4_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_4_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_4_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_4_2/RedfishMemory_V1_4_2_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_4_2/RedfishMemory_V1_4_2_Dxe.inf new file mode 100644 index 00000000000..0f31e6ec9e6 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_4_2/RedfishMemory_V1_4_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_4_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_4_2_Dxe + FILE_GUID = 1337a7c6-21ab-48ff-9fc6-07ae97154486 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_4_2EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_4_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_4_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_4_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_4_3/Memory_V1_4_3_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_4_3/Memory_V1_4_3_Dxe.c new file mode 100644 index 00000000000..4bcd38b1977 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_4_3/Memory_V1_4_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_4_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "4", + "3" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_4_3 *MemoryV1_4_3; + EFI_REDFISH_MEMORY_V1_4_3_CS *MemoryV1_4_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_4_3_To_CS (ResoruceRaw, &MemoryV1_4_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_4_3 = (EFI_REDFISH_MEMORY_V1_4_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_4_3)); + if (MemoryV1_4_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_4_3; + MemoryV1_4_3->Memory = MemoryV1_4_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_4_3_JSON (*((EFI_REDFISH_MEMORY_V1_4_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_4_3 *MemoryV1_4_3; + + MemoryV1_4_3 = (EFI_REDFISH_MEMORY_V1_4_3 *)InterpProp; + DestroyMemory_V1_4_3_CS (MemoryV1_4_3->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_4_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_4_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_4_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_4_3/RedfishMemory_V1_4_3_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_4_3/RedfishMemory_V1_4_3_Dxe.inf new file mode 100644 index 00000000000..ca71ca63868 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_4_3/RedfishMemory_V1_4_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_4_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_4_3_Dxe + FILE_GUID = d24ed613-f0f0-4147-a7cc-9842773fac86 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_4_3EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_4_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_4_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_4_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_4_4/Memory_V1_4_4_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_4_4/Memory_V1_4_4_Dxe.c new file mode 100644 index 00000000000..35985ff37d4 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_4_4/Memory_V1_4_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_4_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "4", + "4" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_4_4 *MemoryV1_4_4; + EFI_REDFISH_MEMORY_V1_4_4_CS *MemoryV1_4_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_4_4_To_CS (ResoruceRaw, &MemoryV1_4_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_4_4 = (EFI_REDFISH_MEMORY_V1_4_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_4_4)); + if (MemoryV1_4_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_4_4; + MemoryV1_4_4->Memory = MemoryV1_4_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_4_4_JSON (*((EFI_REDFISH_MEMORY_V1_4_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_4_4 *MemoryV1_4_4; + + MemoryV1_4_4 = (EFI_REDFISH_MEMORY_V1_4_4 *)InterpProp; + DestroyMemory_V1_4_4_CS (MemoryV1_4_4->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_4_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_4_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_4_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_4_4/RedfishMemory_V1_4_4_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_4_4/RedfishMemory_V1_4_4_Dxe.inf new file mode 100644 index 00000000000..47cf936cd73 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_4_4/RedfishMemory_V1_4_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_4_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_4_4_Dxe + FILE_GUID = aa7135d3-59d5-4366-8639-dc78448cde5f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_4_4EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_4_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_4_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_4_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_4_5/Memory_V1_4_5_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_4_5/Memory_V1_4_5_Dxe.c new file mode 100644 index 00000000000..a9c4e63ae37 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_4_5/Memory_V1_4_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_4_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "4", + "5" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_4_5 *MemoryV1_4_5; + EFI_REDFISH_MEMORY_V1_4_5_CS *MemoryV1_4_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_4_5_To_CS (ResoruceRaw, &MemoryV1_4_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_4_5 = (EFI_REDFISH_MEMORY_V1_4_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_4_5)); + if (MemoryV1_4_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_4_5; + MemoryV1_4_5->Memory = MemoryV1_4_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_4_5_JSON (*((EFI_REDFISH_MEMORY_V1_4_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_4_5 *MemoryV1_4_5; + + MemoryV1_4_5 = (EFI_REDFISH_MEMORY_V1_4_5 *)InterpProp; + DestroyMemory_V1_4_5_CS (MemoryV1_4_5->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_4_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_4_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_4_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_4_5/RedfishMemory_V1_4_5_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_4_5/RedfishMemory_V1_4_5_Dxe.inf new file mode 100644 index 00000000000..e031263a972 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_4_5/RedfishMemory_V1_4_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_4_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_4_5_Dxe + FILE_GUID = e7e5e354-aa8b-4b10-a344-056b8f19fa4d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_4_5EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_4_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_4_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_4_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_4_6/Memory_V1_4_6_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_4_6/Memory_V1_4_6_Dxe.c new file mode 100644 index 00000000000..2b29df62877 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_4_6/Memory_V1_4_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_4_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_4_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "4", + "6" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_4_6 *MemoryV1_4_6; + EFI_REDFISH_MEMORY_V1_4_6_CS *MemoryV1_4_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_4_6_To_CS (ResoruceRaw, &MemoryV1_4_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_4_6 = (EFI_REDFISH_MEMORY_V1_4_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_4_6)); + if (MemoryV1_4_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_4_6; + MemoryV1_4_6->Memory = MemoryV1_4_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_4_6_JSON (*((EFI_REDFISH_MEMORY_V1_4_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_4_6 *MemoryV1_4_6; + + MemoryV1_4_6 = (EFI_REDFISH_MEMORY_V1_4_6 *)InterpProp; + DestroyMemory_V1_4_6_CS (MemoryV1_4_6->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_4_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_4_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_4_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_4_6/RedfishMemory_V1_4_6_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_4_6/RedfishMemory_V1_4_6_Dxe.inf new file mode 100644 index 00000000000..c5381944f9d --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_4_6/RedfishMemory_V1_4_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_4_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_4_6_Dxe + FILE_GUID = cb5aef93-e068-42b9-88d0-01b7ff2c95f4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_4_6EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_4_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_4_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_4_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_4_7/Memory_V1_4_7_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_4_7/Memory_V1_4_7_Dxe.c new file mode 100644 index 00000000000..cc716097d52 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_4_7/Memory_V1_4_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_4_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_4_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "4", + "7" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_4_7 *MemoryV1_4_7; + EFI_REDFISH_MEMORY_V1_4_7_CS *MemoryV1_4_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_4_7_To_CS (ResoruceRaw, &MemoryV1_4_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_4_7 = (EFI_REDFISH_MEMORY_V1_4_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_4_7)); + if (MemoryV1_4_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_4_7; + MemoryV1_4_7->Memory = MemoryV1_4_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_4_7_JSON (*((EFI_REDFISH_MEMORY_V1_4_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_4_7 *MemoryV1_4_7; + + MemoryV1_4_7 = (EFI_REDFISH_MEMORY_V1_4_7 *)InterpProp; + DestroyMemory_V1_4_7_CS (MemoryV1_4_7->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_4_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_4_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_4_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_4_7/RedfishMemory_V1_4_7_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_4_7/RedfishMemory_V1_4_7_Dxe.inf new file mode 100644 index 00000000000..8e4363d3c4e --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_4_7/RedfishMemory_V1_4_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_4_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_4_7_Dxe + FILE_GUID = c6e3c5f4-79d7-4188-90a9-4cc45dce07d6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_4_7EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_4_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_4_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_4_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_4_8/Memory_V1_4_8_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_4_8/Memory_V1_4_8_Dxe.c new file mode 100644 index 00000000000..7f57e658f6d --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_4_8/Memory_V1_4_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_4_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_4_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "4", + "8" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_4_8 *MemoryV1_4_8; + EFI_REDFISH_MEMORY_V1_4_8_CS *MemoryV1_4_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_4_8_To_CS (ResoruceRaw, &MemoryV1_4_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_4_8 = (EFI_REDFISH_MEMORY_V1_4_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_4_8)); + if (MemoryV1_4_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_4_8; + MemoryV1_4_8->Memory = MemoryV1_4_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_4_8_JSON (*((EFI_REDFISH_MEMORY_V1_4_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_4_8 *MemoryV1_4_8; + + MemoryV1_4_8 = (EFI_REDFISH_MEMORY_V1_4_8 *)InterpProp; + DestroyMemory_V1_4_8_CS (MemoryV1_4_8->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_4_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_4_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_4_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_4_8/RedfishMemory_V1_4_8_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_4_8/RedfishMemory_V1_4_8_Dxe.inf new file mode 100644 index 00000000000..6bdbbdd49bd --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_4_8/RedfishMemory_V1_4_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_4_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_4_8_Dxe + FILE_GUID = c363f494-b100-4ea4-b82c-17fd3db35598 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_4_8EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_4_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_4_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_4_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_4_9/Memory_V1_4_9_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_4_9/Memory_V1_4_9_Dxe.c new file mode 100644 index 00000000000..f99a4e8bd0f --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_4_9/Memory_V1_4_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_4_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_4_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "4", + "9" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_4_9 *MemoryV1_4_9; + EFI_REDFISH_MEMORY_V1_4_9_CS *MemoryV1_4_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_4_9_To_CS (ResoruceRaw, &MemoryV1_4_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_4_9 = (EFI_REDFISH_MEMORY_V1_4_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_4_9)); + if (MemoryV1_4_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_4_9; + MemoryV1_4_9->Memory = MemoryV1_4_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_4_9_JSON (*((EFI_REDFISH_MEMORY_V1_4_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_4_9 *MemoryV1_4_9; + + MemoryV1_4_9 = (EFI_REDFISH_MEMORY_V1_4_9 *)InterpProp; + DestroyMemory_V1_4_9_CS (MemoryV1_4_9->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_4_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_4_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_4_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_4_9/RedfishMemory_V1_4_9_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_4_9/RedfishMemory_V1_4_9_Dxe.inf new file mode 100644 index 00000000000..a4016e805e0 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_4_9/RedfishMemory_V1_4_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_4_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_4_9_Dxe + FILE_GUID = abb4ab6d-0460-49e3-9e30-d3934804dd88 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_4_9EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_4_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_4_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_4_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_5_0/Memory_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_5_0/Memory_V1_5_0_Dxe.c new file mode 100644 index 00000000000..93f95466b92 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_5_0/Memory_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "5", + "0" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_5_0 *MemoryV1_5_0; + EFI_REDFISH_MEMORY_V1_5_0_CS *MemoryV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_5_0_To_CS (ResoruceRaw, &MemoryV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_5_0 = (EFI_REDFISH_MEMORY_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_5_0)); + if (MemoryV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_5_0; + MemoryV1_5_0->Memory = MemoryV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_5_0_JSON (*((EFI_REDFISH_MEMORY_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_5_0 *MemoryV1_5_0; + + MemoryV1_5_0 = (EFI_REDFISH_MEMORY_V1_5_0 *)InterpProp; + DestroyMemory_V1_5_0_CS (MemoryV1_5_0->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_5_0/RedfishMemory_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_5_0/RedfishMemory_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..54895ff153c --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_5_0/RedfishMemory_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_5_0_Dxe + FILE_GUID = 18690d70-741a-4c7a-b94a-98378306ea38 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_5_1/Memory_V1_5_1_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_5_1/Memory_V1_5_1_Dxe.c new file mode 100644 index 00000000000..054145e0d89 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_5_1/Memory_V1_5_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_5_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "5", + "1" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_5_1 *MemoryV1_5_1; + EFI_REDFISH_MEMORY_V1_5_1_CS *MemoryV1_5_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_5_1_To_CS (ResoruceRaw, &MemoryV1_5_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_5_1 = (EFI_REDFISH_MEMORY_V1_5_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_5_1)); + if (MemoryV1_5_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_5_1; + MemoryV1_5_1->Memory = MemoryV1_5_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_5_1_JSON (*((EFI_REDFISH_MEMORY_V1_5_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_5_1 *MemoryV1_5_1; + + MemoryV1_5_1 = (EFI_REDFISH_MEMORY_V1_5_1 *)InterpProp; + DestroyMemory_V1_5_1_CS (MemoryV1_5_1->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_5_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_5_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_5_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_5_1/RedfishMemory_V1_5_1_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_5_1/RedfishMemory_V1_5_1_Dxe.inf new file mode 100644 index 00000000000..21e5ee186b0 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_5_1/RedfishMemory_V1_5_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_5_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_5_1_Dxe + FILE_GUID = f97f0f68-d4d8-40e7-b22d-3be964789f7e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_5_1EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_5_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_5_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_5_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_5_2/Memory_V1_5_2_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_5_2/Memory_V1_5_2_Dxe.c new file mode 100644 index 00000000000..f9ed967aa61 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_5_2/Memory_V1_5_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_5_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "5", + "2" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_5_2 *MemoryV1_5_2; + EFI_REDFISH_MEMORY_V1_5_2_CS *MemoryV1_5_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_5_2_To_CS (ResoruceRaw, &MemoryV1_5_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_5_2 = (EFI_REDFISH_MEMORY_V1_5_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_5_2)); + if (MemoryV1_5_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_5_2; + MemoryV1_5_2->Memory = MemoryV1_5_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_5_2_JSON (*((EFI_REDFISH_MEMORY_V1_5_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_5_2 *MemoryV1_5_2; + + MemoryV1_5_2 = (EFI_REDFISH_MEMORY_V1_5_2 *)InterpProp; + DestroyMemory_V1_5_2_CS (MemoryV1_5_2->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_5_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_5_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_5_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_5_2/RedfishMemory_V1_5_2_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_5_2/RedfishMemory_V1_5_2_Dxe.inf new file mode 100644 index 00000000000..690f6f8c5a1 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_5_2/RedfishMemory_V1_5_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_5_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_5_2_Dxe + FILE_GUID = 69b58c47-56cc-4319-af69-ce6ddfc3f363 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_5_2EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_5_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_5_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_5_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_5_3/Memory_V1_5_3_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_5_3/Memory_V1_5_3_Dxe.c new file mode 100644 index 00000000000..cb50e089698 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_5_3/Memory_V1_5_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_5_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "5", + "3" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_5_3 *MemoryV1_5_3; + EFI_REDFISH_MEMORY_V1_5_3_CS *MemoryV1_5_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_5_3_To_CS (ResoruceRaw, &MemoryV1_5_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_5_3 = (EFI_REDFISH_MEMORY_V1_5_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_5_3)); + if (MemoryV1_5_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_5_3; + MemoryV1_5_3->Memory = MemoryV1_5_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_5_3_JSON (*((EFI_REDFISH_MEMORY_V1_5_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_5_3 *MemoryV1_5_3; + + MemoryV1_5_3 = (EFI_REDFISH_MEMORY_V1_5_3 *)InterpProp; + DestroyMemory_V1_5_3_CS (MemoryV1_5_3->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_5_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_5_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_5_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_5_3/RedfishMemory_V1_5_3_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_5_3/RedfishMemory_V1_5_3_Dxe.inf new file mode 100644 index 00000000000..6087c11129b --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_5_3/RedfishMemory_V1_5_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_5_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_5_3_Dxe + FILE_GUID = 07621ced-76aa-4b81-97a1-23eecdcf07ae + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_5_3EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_5_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_5_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_5_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_5_4/Memory_V1_5_4_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_5_4/Memory_V1_5_4_Dxe.c new file mode 100644 index 00000000000..098298a7e1f --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_5_4/Memory_V1_5_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_5_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "5", + "4" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_5_4 *MemoryV1_5_4; + EFI_REDFISH_MEMORY_V1_5_4_CS *MemoryV1_5_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_5_4_To_CS (ResoruceRaw, &MemoryV1_5_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_5_4 = (EFI_REDFISH_MEMORY_V1_5_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_5_4)); + if (MemoryV1_5_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_5_4; + MemoryV1_5_4->Memory = MemoryV1_5_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_5_4_JSON (*((EFI_REDFISH_MEMORY_V1_5_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_5_4 *MemoryV1_5_4; + + MemoryV1_5_4 = (EFI_REDFISH_MEMORY_V1_5_4 *)InterpProp; + DestroyMemory_V1_5_4_CS (MemoryV1_5_4->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_5_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_5_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_5_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_5_4/RedfishMemory_V1_5_4_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_5_4/RedfishMemory_V1_5_4_Dxe.inf new file mode 100644 index 00000000000..7aae53cb1c0 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_5_4/RedfishMemory_V1_5_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_5_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_5_4_Dxe + FILE_GUID = 91fa1ca7-2c88-4d85-af27-823b193f8e07 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_5_4EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_5_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_5_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_5_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_5_5/Memory_V1_5_5_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_5_5/Memory_V1_5_5_Dxe.c new file mode 100644 index 00000000000..aa61985ed3b --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_5_5/Memory_V1_5_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_5_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_5_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "5", + "5" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_5_5 *MemoryV1_5_5; + EFI_REDFISH_MEMORY_V1_5_5_CS *MemoryV1_5_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_5_5_To_CS (ResoruceRaw, &MemoryV1_5_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_5_5 = (EFI_REDFISH_MEMORY_V1_5_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_5_5)); + if (MemoryV1_5_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_5_5; + MemoryV1_5_5->Memory = MemoryV1_5_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_5_5_JSON (*((EFI_REDFISH_MEMORY_V1_5_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_5_5 *MemoryV1_5_5; + + MemoryV1_5_5 = (EFI_REDFISH_MEMORY_V1_5_5 *)InterpProp; + DestroyMemory_V1_5_5_CS (MemoryV1_5_5->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_5_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_5_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_5_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_5_5/RedfishMemory_V1_5_5_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_5_5/RedfishMemory_V1_5_5_Dxe.inf new file mode 100644 index 00000000000..ab04ff53028 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_5_5/RedfishMemory_V1_5_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_5_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_5_5_Dxe + FILE_GUID = 27760106-caf7-4fb8-bb6d-4e52c931f908 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_5_5EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_5_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_5_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_5_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_5_6/Memory_V1_5_6_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_5_6/Memory_V1_5_6_Dxe.c new file mode 100644 index 00000000000..3dbbef1a1aa --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_5_6/Memory_V1_5_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_5_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_5_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "5", + "6" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_5_6 *MemoryV1_5_6; + EFI_REDFISH_MEMORY_V1_5_6_CS *MemoryV1_5_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_5_6_To_CS (ResoruceRaw, &MemoryV1_5_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_5_6 = (EFI_REDFISH_MEMORY_V1_5_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_5_6)); + if (MemoryV1_5_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_5_6; + MemoryV1_5_6->Memory = MemoryV1_5_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_5_6_JSON (*((EFI_REDFISH_MEMORY_V1_5_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_5_6 *MemoryV1_5_6; + + MemoryV1_5_6 = (EFI_REDFISH_MEMORY_V1_5_6 *)InterpProp; + DestroyMemory_V1_5_6_CS (MemoryV1_5_6->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_5_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_5_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_5_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_5_6/RedfishMemory_V1_5_6_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_5_6/RedfishMemory_V1_5_6_Dxe.inf new file mode 100644 index 00000000000..fea9089337d --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_5_6/RedfishMemory_V1_5_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_5_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_5_6_Dxe + FILE_GUID = c5c1c3dc-3752-4604-b598-511f5109917a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_5_6EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_5_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_5_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_5_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_5_7/Memory_V1_5_7_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_5_7/Memory_V1_5_7_Dxe.c new file mode 100644 index 00000000000..83d8e551bd6 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_5_7/Memory_V1_5_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_5_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_5_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "5", + "7" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_5_7 *MemoryV1_5_7; + EFI_REDFISH_MEMORY_V1_5_7_CS *MemoryV1_5_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_5_7_To_CS (ResoruceRaw, &MemoryV1_5_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_5_7 = (EFI_REDFISH_MEMORY_V1_5_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_5_7)); + if (MemoryV1_5_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_5_7; + MemoryV1_5_7->Memory = MemoryV1_5_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_5_7_JSON (*((EFI_REDFISH_MEMORY_V1_5_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_5_7 *MemoryV1_5_7; + + MemoryV1_5_7 = (EFI_REDFISH_MEMORY_V1_5_7 *)InterpProp; + DestroyMemory_V1_5_7_CS (MemoryV1_5_7->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_5_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_5_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_5_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_5_7/RedfishMemory_V1_5_7_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_5_7/RedfishMemory_V1_5_7_Dxe.inf new file mode 100644 index 00000000000..c0605fa61a4 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_5_7/RedfishMemory_V1_5_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_5_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_5_7_Dxe + FILE_GUID = 7a5d922a-b442-403d-b801-d653e258761b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_5_7EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_5_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_5_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_5_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_5_8/Memory_V1_5_8_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_5_8/Memory_V1_5_8_Dxe.c new file mode 100644 index 00000000000..d43b4c06c9e --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_5_8/Memory_V1_5_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_5_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_5_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "5", + "8" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_5_8 *MemoryV1_5_8; + EFI_REDFISH_MEMORY_V1_5_8_CS *MemoryV1_5_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_5_8_To_CS (ResoruceRaw, &MemoryV1_5_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_5_8 = (EFI_REDFISH_MEMORY_V1_5_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_5_8)); + if (MemoryV1_5_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_5_8; + MemoryV1_5_8->Memory = MemoryV1_5_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_5_8_JSON (*((EFI_REDFISH_MEMORY_V1_5_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_5_8 *MemoryV1_5_8; + + MemoryV1_5_8 = (EFI_REDFISH_MEMORY_V1_5_8 *)InterpProp; + DestroyMemory_V1_5_8_CS (MemoryV1_5_8->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_5_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_5_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_5_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_5_8/RedfishMemory_V1_5_8_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_5_8/RedfishMemory_V1_5_8_Dxe.inf new file mode 100644 index 00000000000..1ba2d2f6fce --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_5_8/RedfishMemory_V1_5_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_5_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_5_8_Dxe + FILE_GUID = 78862281-7165-4ce1-a3a8-cd7a059648ba + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_5_8EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_5_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_5_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_5_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_6_0/Memory_V1_6_0_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_6_0/Memory_V1_6_0_Dxe.c new file mode 100644 index 00000000000..56bbeab5568 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_6_0/Memory_V1_6_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_6_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "6", + "0" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_6_0 *MemoryV1_6_0; + EFI_REDFISH_MEMORY_V1_6_0_CS *MemoryV1_6_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_6_0_To_CS (ResoruceRaw, &MemoryV1_6_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_6_0 = (EFI_REDFISH_MEMORY_V1_6_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_6_0)); + if (MemoryV1_6_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_6_0; + MemoryV1_6_0->Memory = MemoryV1_6_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_6_0_JSON (*((EFI_REDFISH_MEMORY_V1_6_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_6_0 *MemoryV1_6_0; + + MemoryV1_6_0 = (EFI_REDFISH_MEMORY_V1_6_0 *)InterpProp; + DestroyMemory_V1_6_0_CS (MemoryV1_6_0->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_6_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_6_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_6_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_6_0/RedfishMemory_V1_6_0_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_6_0/RedfishMemory_V1_6_0_Dxe.inf new file mode 100644 index 00000000000..69d024cc782 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_6_0/RedfishMemory_V1_6_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_6_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_6_0_Dxe + FILE_GUID = 148789d4-39b1-4e2f-8993-6b46e30db30d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_6_0EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_6_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_6_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_6_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_6_1/Memory_V1_6_1_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_6_1/Memory_V1_6_1_Dxe.c new file mode 100644 index 00000000000..dd02ee87aa1 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_6_1/Memory_V1_6_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_6_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "6", + "1" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_6_1 *MemoryV1_6_1; + EFI_REDFISH_MEMORY_V1_6_1_CS *MemoryV1_6_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_6_1_To_CS (ResoruceRaw, &MemoryV1_6_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_6_1 = (EFI_REDFISH_MEMORY_V1_6_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_6_1)); + if (MemoryV1_6_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_6_1; + MemoryV1_6_1->Memory = MemoryV1_6_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_6_1_JSON (*((EFI_REDFISH_MEMORY_V1_6_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_6_1 *MemoryV1_6_1; + + MemoryV1_6_1 = (EFI_REDFISH_MEMORY_V1_6_1 *)InterpProp; + DestroyMemory_V1_6_1_CS (MemoryV1_6_1->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_6_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_6_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_6_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_6_1/RedfishMemory_V1_6_1_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_6_1/RedfishMemory_V1_6_1_Dxe.inf new file mode 100644 index 00000000000..3cb7ef1d5d7 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_6_1/RedfishMemory_V1_6_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_6_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_6_1_Dxe + FILE_GUID = f04d5d40-5f61-45fb-805b-4832deb1d443 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_6_1EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_6_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_6_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_6_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_6_2/Memory_V1_6_2_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_6_2/Memory_V1_6_2_Dxe.c new file mode 100644 index 00000000000..cc1e707b4ec --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_6_2/Memory_V1_6_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_6_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "6", + "2" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_6_2 *MemoryV1_6_2; + EFI_REDFISH_MEMORY_V1_6_2_CS *MemoryV1_6_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_6_2_To_CS (ResoruceRaw, &MemoryV1_6_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_6_2 = (EFI_REDFISH_MEMORY_V1_6_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_6_2)); + if (MemoryV1_6_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_6_2; + MemoryV1_6_2->Memory = MemoryV1_6_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_6_2_JSON (*((EFI_REDFISH_MEMORY_V1_6_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_6_2 *MemoryV1_6_2; + + MemoryV1_6_2 = (EFI_REDFISH_MEMORY_V1_6_2 *)InterpProp; + DestroyMemory_V1_6_2_CS (MemoryV1_6_2->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_6_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_6_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_6_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_6_2/RedfishMemory_V1_6_2_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_6_2/RedfishMemory_V1_6_2_Dxe.inf new file mode 100644 index 00000000000..c45aa9dd082 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_6_2/RedfishMemory_V1_6_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_6_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_6_2_Dxe + FILE_GUID = a553a886-7947-4c64-9811-09793be70d42 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_6_2EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_6_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_6_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_6_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_6_3/Memory_V1_6_3_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_6_3/Memory_V1_6_3_Dxe.c new file mode 100644 index 00000000000..91d3c4131a3 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_6_3/Memory_V1_6_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_6_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_6_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "6", + "3" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_6_3 *MemoryV1_6_3; + EFI_REDFISH_MEMORY_V1_6_3_CS *MemoryV1_6_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_6_3_To_CS (ResoruceRaw, &MemoryV1_6_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_6_3 = (EFI_REDFISH_MEMORY_V1_6_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_6_3)); + if (MemoryV1_6_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_6_3; + MemoryV1_6_3->Memory = MemoryV1_6_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_6_3_JSON (*((EFI_REDFISH_MEMORY_V1_6_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_6_3 *MemoryV1_6_3; + + MemoryV1_6_3 = (EFI_REDFISH_MEMORY_V1_6_3 *)InterpProp; + DestroyMemory_V1_6_3_CS (MemoryV1_6_3->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_6_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_6_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_6_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_6_3/RedfishMemory_V1_6_3_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_6_3/RedfishMemory_V1_6_3_Dxe.inf new file mode 100644 index 00000000000..4113ebc6874 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_6_3/RedfishMemory_V1_6_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_6_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_6_3_Dxe + FILE_GUID = bb8a4be0-832b-4c6d-926e-3c9dadb7cc9a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_6_3EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_6_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_6_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_6_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_6_4/Memory_V1_6_4_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_6_4/Memory_V1_6_4_Dxe.c new file mode 100644 index 00000000000..5ad5fea63ed --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_6_4/Memory_V1_6_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_6_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_6_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "6", + "4" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_6_4 *MemoryV1_6_4; + EFI_REDFISH_MEMORY_V1_6_4_CS *MemoryV1_6_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_6_4_To_CS (ResoruceRaw, &MemoryV1_6_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_6_4 = (EFI_REDFISH_MEMORY_V1_6_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_6_4)); + if (MemoryV1_6_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_6_4; + MemoryV1_6_4->Memory = MemoryV1_6_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_6_4_JSON (*((EFI_REDFISH_MEMORY_V1_6_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_6_4 *MemoryV1_6_4; + + MemoryV1_6_4 = (EFI_REDFISH_MEMORY_V1_6_4 *)InterpProp; + DestroyMemory_V1_6_4_CS (MemoryV1_6_4->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_6_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_6_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_6_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_6_4/RedfishMemory_V1_6_4_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_6_4/RedfishMemory_V1_6_4_Dxe.inf new file mode 100644 index 00000000000..b51c3098788 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_6_4/RedfishMemory_V1_6_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_6_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_6_4_Dxe + FILE_GUID = 0bd4f04b-4b77-4b5b-b60c-3e0614667d2f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_6_4EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_6_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_6_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_6_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_6_5/Memory_V1_6_5_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_6_5/Memory_V1_6_5_Dxe.c new file mode 100644 index 00000000000..60ded7f072d --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_6_5/Memory_V1_6_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_6_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_6_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "6", + "5" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_6_5 *MemoryV1_6_5; + EFI_REDFISH_MEMORY_V1_6_5_CS *MemoryV1_6_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_6_5_To_CS (ResoruceRaw, &MemoryV1_6_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_6_5 = (EFI_REDFISH_MEMORY_V1_6_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_6_5)); + if (MemoryV1_6_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_6_5; + MemoryV1_6_5->Memory = MemoryV1_6_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_6_5_JSON (*((EFI_REDFISH_MEMORY_V1_6_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_6_5 *MemoryV1_6_5; + + MemoryV1_6_5 = (EFI_REDFISH_MEMORY_V1_6_5 *)InterpProp; + DestroyMemory_V1_6_5_CS (MemoryV1_6_5->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_6_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_6_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_6_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_6_5/RedfishMemory_V1_6_5_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_6_5/RedfishMemory_V1_6_5_Dxe.inf new file mode 100644 index 00000000000..a05d535bad7 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_6_5/RedfishMemory_V1_6_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_6_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_6_5_Dxe + FILE_GUID = e4666364-520a-4d44-a7ed-52558f03d01d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_6_5EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_6_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_6_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_6_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_6_6/Memory_V1_6_6_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_6_6/Memory_V1_6_6_Dxe.c new file mode 100644 index 00000000000..8ff6da7baeb --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_6_6/Memory_V1_6_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_6_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_6_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "6", + "6" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_6_6 *MemoryV1_6_6; + EFI_REDFISH_MEMORY_V1_6_6_CS *MemoryV1_6_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_6_6_To_CS (ResoruceRaw, &MemoryV1_6_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_6_6 = (EFI_REDFISH_MEMORY_V1_6_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_6_6)); + if (MemoryV1_6_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_6_6; + MemoryV1_6_6->Memory = MemoryV1_6_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_6_6_JSON (*((EFI_REDFISH_MEMORY_V1_6_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_6_6 *MemoryV1_6_6; + + MemoryV1_6_6 = (EFI_REDFISH_MEMORY_V1_6_6 *)InterpProp; + DestroyMemory_V1_6_6_CS (MemoryV1_6_6->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_6_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_6_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_6_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_6_6/RedfishMemory_V1_6_6_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_6_6/RedfishMemory_V1_6_6_Dxe.inf new file mode 100644 index 00000000000..6cd00936802 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_6_6/RedfishMemory_V1_6_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_6_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_6_6_Dxe + FILE_GUID = e26b5987-40fd-4663-9055-bba4155871be + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_6_6EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_6_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_6_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_6_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_6_7/Memory_V1_6_7_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_6_7/Memory_V1_6_7_Dxe.c new file mode 100644 index 00000000000..de54be8d6f2 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_6_7/Memory_V1_6_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_6_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_6_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "6", + "7" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_6_7 *MemoryV1_6_7; + EFI_REDFISH_MEMORY_V1_6_7_CS *MemoryV1_6_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_6_7_To_CS (ResoruceRaw, &MemoryV1_6_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_6_7 = (EFI_REDFISH_MEMORY_V1_6_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_6_7)); + if (MemoryV1_6_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_6_7; + MemoryV1_6_7->Memory = MemoryV1_6_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_6_7_JSON (*((EFI_REDFISH_MEMORY_V1_6_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_6_7 *MemoryV1_6_7; + + MemoryV1_6_7 = (EFI_REDFISH_MEMORY_V1_6_7 *)InterpProp; + DestroyMemory_V1_6_7_CS (MemoryV1_6_7->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_6_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_6_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_6_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_6_7/RedfishMemory_V1_6_7_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_6_7/RedfishMemory_V1_6_7_Dxe.inf new file mode 100644 index 00000000000..2407acc997b --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_6_7/RedfishMemory_V1_6_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_6_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_6_7_Dxe + FILE_GUID = 6af5ccd8-f259-47ff-a84e-3b745c8eca1a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_6_7EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_6_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_6_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_6_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_7_0/Memory_V1_7_0_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_7_0/Memory_V1_7_0_Dxe.c new file mode 100644 index 00000000000..22483511e8e --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_7_0/Memory_V1_7_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_7_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "7", + "0" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_7_0 *MemoryV1_7_0; + EFI_REDFISH_MEMORY_V1_7_0_CS *MemoryV1_7_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_7_0_To_CS (ResoruceRaw, &MemoryV1_7_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_7_0 = (EFI_REDFISH_MEMORY_V1_7_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_7_0)); + if (MemoryV1_7_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_7_0; + MemoryV1_7_0->Memory = MemoryV1_7_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_7_0_JSON (*((EFI_REDFISH_MEMORY_V1_7_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_7_0 *MemoryV1_7_0; + + MemoryV1_7_0 = (EFI_REDFISH_MEMORY_V1_7_0 *)InterpProp; + DestroyMemory_V1_7_0_CS (MemoryV1_7_0->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_7_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_7_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_7_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_7_0/RedfishMemory_V1_7_0_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_7_0/RedfishMemory_V1_7_0_Dxe.inf new file mode 100644 index 00000000000..97a0244c7a8 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_7_0/RedfishMemory_V1_7_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_7_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_7_0_Dxe + FILE_GUID = 60471906-3d97-4209-b1e9-65de0d9f48b5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_7_0EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_7_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_7_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_7_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_7_1/Memory_V1_7_1_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_7_1/Memory_V1_7_1_Dxe.c new file mode 100644 index 00000000000..d52ad46cdb7 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_7_1/Memory_V1_7_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_7_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_7_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "7", + "1" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_7_1 *MemoryV1_7_1; + EFI_REDFISH_MEMORY_V1_7_1_CS *MemoryV1_7_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_7_1_To_CS (ResoruceRaw, &MemoryV1_7_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_7_1 = (EFI_REDFISH_MEMORY_V1_7_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_7_1)); + if (MemoryV1_7_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_7_1; + MemoryV1_7_1->Memory = MemoryV1_7_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_7_1_JSON (*((EFI_REDFISH_MEMORY_V1_7_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_7_1 *MemoryV1_7_1; + + MemoryV1_7_1 = (EFI_REDFISH_MEMORY_V1_7_1 *)InterpProp; + DestroyMemory_V1_7_1_CS (MemoryV1_7_1->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_7_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_7_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_7_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_7_1/RedfishMemory_V1_7_1_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_7_1/RedfishMemory_V1_7_1_Dxe.inf new file mode 100644 index 00000000000..9a973cf6ae3 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_7_1/RedfishMemory_V1_7_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_7_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_7_1_Dxe + FILE_GUID = 02d298a4-fce2-40cb-a929-f46e6cc29ba5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_7_1EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_7_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_7_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_7_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_7_2/Memory_V1_7_2_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_7_2/Memory_V1_7_2_Dxe.c new file mode 100644 index 00000000000..4163de053f2 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_7_2/Memory_V1_7_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_7_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_7_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "7", + "2" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_7_2 *MemoryV1_7_2; + EFI_REDFISH_MEMORY_V1_7_2_CS *MemoryV1_7_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_7_2_To_CS (ResoruceRaw, &MemoryV1_7_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_7_2 = (EFI_REDFISH_MEMORY_V1_7_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_7_2)); + if (MemoryV1_7_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_7_2; + MemoryV1_7_2->Memory = MemoryV1_7_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_7_2_JSON (*((EFI_REDFISH_MEMORY_V1_7_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_7_2 *MemoryV1_7_2; + + MemoryV1_7_2 = (EFI_REDFISH_MEMORY_V1_7_2 *)InterpProp; + DestroyMemory_V1_7_2_CS (MemoryV1_7_2->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_7_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_7_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_7_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_7_2/RedfishMemory_V1_7_2_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_7_2/RedfishMemory_V1_7_2_Dxe.inf new file mode 100644 index 00000000000..88ce24bf8fd --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_7_2/RedfishMemory_V1_7_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_7_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_7_2_Dxe + FILE_GUID = 3b70065e-90f4-4ab3-a95a-ed228b482708 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_7_2EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_7_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_7_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_7_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_7_3/Memory_V1_7_3_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_7_3/Memory_V1_7_3_Dxe.c new file mode 100644 index 00000000000..3204236db9b --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_7_3/Memory_V1_7_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_7_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_7_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "7", + "3" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_7_3 *MemoryV1_7_3; + EFI_REDFISH_MEMORY_V1_7_3_CS *MemoryV1_7_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_7_3_To_CS (ResoruceRaw, &MemoryV1_7_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_7_3 = (EFI_REDFISH_MEMORY_V1_7_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_7_3)); + if (MemoryV1_7_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_7_3; + MemoryV1_7_3->Memory = MemoryV1_7_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_7_3_JSON (*((EFI_REDFISH_MEMORY_V1_7_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_7_3 *MemoryV1_7_3; + + MemoryV1_7_3 = (EFI_REDFISH_MEMORY_V1_7_3 *)InterpProp; + DestroyMemory_V1_7_3_CS (MemoryV1_7_3->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_7_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_7_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_7_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_7_3/RedfishMemory_V1_7_3_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_7_3/RedfishMemory_V1_7_3_Dxe.inf new file mode 100644 index 00000000000..bf94a29e1f5 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_7_3/RedfishMemory_V1_7_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_7_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_7_3_Dxe + FILE_GUID = 7be5af17-7304-4cc3-9a22-03411e8b0b30 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_7_3EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_7_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_7_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_7_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_7_4/Memory_V1_7_4_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_7_4/Memory_V1_7_4_Dxe.c new file mode 100644 index 00000000000..5c078b8aafe --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_7_4/Memory_V1_7_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_7_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_7_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "7", + "4" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_7_4 *MemoryV1_7_4; + EFI_REDFISH_MEMORY_V1_7_4_CS *MemoryV1_7_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_7_4_To_CS (ResoruceRaw, &MemoryV1_7_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_7_4 = (EFI_REDFISH_MEMORY_V1_7_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_7_4)); + if (MemoryV1_7_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_7_4; + MemoryV1_7_4->Memory = MemoryV1_7_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_7_4_JSON (*((EFI_REDFISH_MEMORY_V1_7_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_7_4 *MemoryV1_7_4; + + MemoryV1_7_4 = (EFI_REDFISH_MEMORY_V1_7_4 *)InterpProp; + DestroyMemory_V1_7_4_CS (MemoryV1_7_4->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_7_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_7_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_7_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_7_4/RedfishMemory_V1_7_4_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_7_4/RedfishMemory_V1_7_4_Dxe.inf new file mode 100644 index 00000000000..f3dff77aa42 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_7_4/RedfishMemory_V1_7_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_7_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_7_4_Dxe + FILE_GUID = 1b598b15-f895-41e2-b3f9-286f1f5768e1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_7_4EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_7_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_7_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_7_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_7_5/Memory_V1_7_5_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_7_5/Memory_V1_7_5_Dxe.c new file mode 100644 index 00000000000..b95c12c6adf --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_7_5/Memory_V1_7_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_7_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_7_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "7", + "5" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_7_5 *MemoryV1_7_5; + EFI_REDFISH_MEMORY_V1_7_5_CS *MemoryV1_7_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_7_5_To_CS (ResoruceRaw, &MemoryV1_7_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_7_5 = (EFI_REDFISH_MEMORY_V1_7_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_7_5)); + if (MemoryV1_7_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_7_5; + MemoryV1_7_5->Memory = MemoryV1_7_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_7_5_JSON (*((EFI_REDFISH_MEMORY_V1_7_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_7_5 *MemoryV1_7_5; + + MemoryV1_7_5 = (EFI_REDFISH_MEMORY_V1_7_5 *)InterpProp; + DestroyMemory_V1_7_5_CS (MemoryV1_7_5->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_7_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_7_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_7_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_7_5/RedfishMemory_V1_7_5_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_7_5/RedfishMemory_V1_7_5_Dxe.inf new file mode 100644 index 00000000000..6d83d22e2e8 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_7_5/RedfishMemory_V1_7_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_7_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_7_5_Dxe + FILE_GUID = d11c861e-6cd5-4dd6-b2a7-9f401534f017 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_7_5EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_7_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_7_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_7_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_7_6/Memory_V1_7_6_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_7_6/Memory_V1_7_6_Dxe.c new file mode 100644 index 00000000000..032c7b29514 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_7_6/Memory_V1_7_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_7_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_7_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "7", + "6" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_7_6 *MemoryV1_7_6; + EFI_REDFISH_MEMORY_V1_7_6_CS *MemoryV1_7_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_7_6_To_CS (ResoruceRaw, &MemoryV1_7_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_7_6 = (EFI_REDFISH_MEMORY_V1_7_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_7_6)); + if (MemoryV1_7_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_7_6; + MemoryV1_7_6->Memory = MemoryV1_7_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_7_6_JSON (*((EFI_REDFISH_MEMORY_V1_7_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_7_6 *MemoryV1_7_6; + + MemoryV1_7_6 = (EFI_REDFISH_MEMORY_V1_7_6 *)InterpProp; + DestroyMemory_V1_7_6_CS (MemoryV1_7_6->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_7_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_7_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_7_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_7_6/RedfishMemory_V1_7_6_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_7_6/RedfishMemory_V1_7_6_Dxe.inf new file mode 100644 index 00000000000..a2851b3b656 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_7_6/RedfishMemory_V1_7_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_7_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_7_6_Dxe + FILE_GUID = 30c509b5-4f70-456a-8492-02d7d0e8bde9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_7_6EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_7_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_7_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_7_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_8_0/Memory_V1_8_0_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_8_0/Memory_V1_8_0_Dxe.c new file mode 100644 index 00000000000..2883cdeb567 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_8_0/Memory_V1_8_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_8_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_8_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "8", + "0" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_8_0 *MemoryV1_8_0; + EFI_REDFISH_MEMORY_V1_8_0_CS *MemoryV1_8_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_8_0_To_CS (ResoruceRaw, &MemoryV1_8_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_8_0 = (EFI_REDFISH_MEMORY_V1_8_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_8_0)); + if (MemoryV1_8_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_8_0; + MemoryV1_8_0->Memory = MemoryV1_8_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_8_0_JSON (*((EFI_REDFISH_MEMORY_V1_8_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_8_0 *MemoryV1_8_0; + + MemoryV1_8_0 = (EFI_REDFISH_MEMORY_V1_8_0 *)InterpProp; + DestroyMemory_V1_8_0_CS (MemoryV1_8_0->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_8_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_8_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_8_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_8_0/RedfishMemory_V1_8_0_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_8_0/RedfishMemory_V1_8_0_Dxe.inf new file mode 100644 index 00000000000..73f140e6fd3 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_8_0/RedfishMemory_V1_8_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_8_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_8_0_Dxe + FILE_GUID = 42947c93-2a8a-46c4-8a59-8e3ad0f58c53 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_8_0EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_8_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_8_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_8_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_8_1/Memory_V1_8_1_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_8_1/Memory_V1_8_1_Dxe.c new file mode 100644 index 00000000000..08b0f955427 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_8_1/Memory_V1_8_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_8_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_8_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "8", + "1" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_8_1 *MemoryV1_8_1; + EFI_REDFISH_MEMORY_V1_8_1_CS *MemoryV1_8_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_8_1_To_CS (ResoruceRaw, &MemoryV1_8_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_8_1 = (EFI_REDFISH_MEMORY_V1_8_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_8_1)); + if (MemoryV1_8_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_8_1; + MemoryV1_8_1->Memory = MemoryV1_8_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_8_1_JSON (*((EFI_REDFISH_MEMORY_V1_8_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_8_1 *MemoryV1_8_1; + + MemoryV1_8_1 = (EFI_REDFISH_MEMORY_V1_8_1 *)InterpProp; + DestroyMemory_V1_8_1_CS (MemoryV1_8_1->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_8_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_8_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_8_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_8_1/RedfishMemory_V1_8_1_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_8_1/RedfishMemory_V1_8_1_Dxe.inf new file mode 100644 index 00000000000..081f5c38259 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_8_1/RedfishMemory_V1_8_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_8_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_8_1_Dxe + FILE_GUID = 95e0d5fa-5c87-457a-811a-e368895a7188 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_8_1EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_8_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_8_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_8_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_8_2/Memory_V1_8_2_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_8_2/Memory_V1_8_2_Dxe.c new file mode 100644 index 00000000000..5dea2a60ca7 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_8_2/Memory_V1_8_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_8_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_8_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "8", + "2" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_8_2 *MemoryV1_8_2; + EFI_REDFISH_MEMORY_V1_8_2_CS *MemoryV1_8_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_8_2_To_CS (ResoruceRaw, &MemoryV1_8_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_8_2 = (EFI_REDFISH_MEMORY_V1_8_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_8_2)); + if (MemoryV1_8_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_8_2; + MemoryV1_8_2->Memory = MemoryV1_8_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_8_2_JSON (*((EFI_REDFISH_MEMORY_V1_8_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_8_2 *MemoryV1_8_2; + + MemoryV1_8_2 = (EFI_REDFISH_MEMORY_V1_8_2 *)InterpProp; + DestroyMemory_V1_8_2_CS (MemoryV1_8_2->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_8_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_8_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_8_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_8_2/RedfishMemory_V1_8_2_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_8_2/RedfishMemory_V1_8_2_Dxe.inf new file mode 100644 index 00000000000..7501ac4d18a --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_8_2/RedfishMemory_V1_8_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_8_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_8_2_Dxe + FILE_GUID = 20c84925-5673-43bf-a31e-f4fc70df6733 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_8_2EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_8_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_8_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_8_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_8_3/Memory_V1_8_3_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_8_3/Memory_V1_8_3_Dxe.c new file mode 100644 index 00000000000..5ab248d3dab --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_8_3/Memory_V1_8_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_8_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_8_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "8", + "3" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_8_3 *MemoryV1_8_3; + EFI_REDFISH_MEMORY_V1_8_3_CS *MemoryV1_8_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_8_3_To_CS (ResoruceRaw, &MemoryV1_8_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_8_3 = (EFI_REDFISH_MEMORY_V1_8_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_8_3)); + if (MemoryV1_8_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_8_3; + MemoryV1_8_3->Memory = MemoryV1_8_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_8_3_JSON (*((EFI_REDFISH_MEMORY_V1_8_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_8_3 *MemoryV1_8_3; + + MemoryV1_8_3 = (EFI_REDFISH_MEMORY_V1_8_3 *)InterpProp; + DestroyMemory_V1_8_3_CS (MemoryV1_8_3->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_8_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_8_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_8_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_8_3/RedfishMemory_V1_8_3_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_8_3/RedfishMemory_V1_8_3_Dxe.inf new file mode 100644 index 00000000000..d1c70797a09 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_8_3/RedfishMemory_V1_8_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_8_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_8_3_Dxe + FILE_GUID = 262dec5f-81ff-4f70-a837-82199a9999b0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_8_3EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_8_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_8_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_8_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_8_4/Memory_V1_8_4_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_8_4/Memory_V1_8_4_Dxe.c new file mode 100644 index 00000000000..31cc4b61675 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_8_4/Memory_V1_8_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_8_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_8_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "8", + "4" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_8_4 *MemoryV1_8_4; + EFI_REDFISH_MEMORY_V1_8_4_CS *MemoryV1_8_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_8_4_To_CS (ResoruceRaw, &MemoryV1_8_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_8_4 = (EFI_REDFISH_MEMORY_V1_8_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_8_4)); + if (MemoryV1_8_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_8_4; + MemoryV1_8_4->Memory = MemoryV1_8_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_8_4_JSON (*((EFI_REDFISH_MEMORY_V1_8_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_8_4 *MemoryV1_8_4; + + MemoryV1_8_4 = (EFI_REDFISH_MEMORY_V1_8_4 *)InterpProp; + DestroyMemory_V1_8_4_CS (MemoryV1_8_4->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_8_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_8_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_8_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_8_4/RedfishMemory_V1_8_4_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_8_4/RedfishMemory_V1_8_4_Dxe.inf new file mode 100644 index 00000000000..b15e5251701 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_8_4/RedfishMemory_V1_8_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_8_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_8_4_Dxe + FILE_GUID = 0104b70f-7875-4e98-997f-eb76c2cbce25 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_8_4EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_8_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_8_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_8_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_9_0/Memory_V1_9_0_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_9_0/Memory_V1_9_0_Dxe.c new file mode 100644 index 00000000000..60d9a8b9101 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_9_0/Memory_V1_9_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_9_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_9_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "9", + "0" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_9_0 *MemoryV1_9_0; + EFI_REDFISH_MEMORY_V1_9_0_CS *MemoryV1_9_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_9_0_To_CS (ResoruceRaw, &MemoryV1_9_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_9_0 = (EFI_REDFISH_MEMORY_V1_9_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_9_0)); + if (MemoryV1_9_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_9_0; + MemoryV1_9_0->Memory = MemoryV1_9_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_9_0_JSON (*((EFI_REDFISH_MEMORY_V1_9_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_9_0 *MemoryV1_9_0; + + MemoryV1_9_0 = (EFI_REDFISH_MEMORY_V1_9_0 *)InterpProp; + DestroyMemory_V1_9_0_CS (MemoryV1_9_0->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_9_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_9_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_9_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_9_0/RedfishMemory_V1_9_0_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_9_0/RedfishMemory_V1_9_0_Dxe.inf new file mode 100644 index 00000000000..36a22885d28 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_9_0/RedfishMemory_V1_9_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_9_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_9_0_Dxe + FILE_GUID = bcf71208-812d-4526-91c7-c2cd273e5214 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_9_0EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_9_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_9_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_9_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_9_1/Memory_V1_9_1_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_9_1/Memory_V1_9_1_Dxe.c new file mode 100644 index 00000000000..1fb3dde0b61 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_9_1/Memory_V1_9_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_9_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_9_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "9", + "1" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_9_1 *MemoryV1_9_1; + EFI_REDFISH_MEMORY_V1_9_1_CS *MemoryV1_9_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_9_1_To_CS (ResoruceRaw, &MemoryV1_9_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_9_1 = (EFI_REDFISH_MEMORY_V1_9_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_9_1)); + if (MemoryV1_9_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_9_1; + MemoryV1_9_1->Memory = MemoryV1_9_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_9_1_JSON (*((EFI_REDFISH_MEMORY_V1_9_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_9_1 *MemoryV1_9_1; + + MemoryV1_9_1 = (EFI_REDFISH_MEMORY_V1_9_1 *)InterpProp; + DestroyMemory_V1_9_1_CS (MemoryV1_9_1->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_9_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_9_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_9_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_9_1/RedfishMemory_V1_9_1_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_9_1/RedfishMemory_V1_9_1_Dxe.inf new file mode 100644 index 00000000000..9298ebc7111 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_9_1/RedfishMemory_V1_9_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_9_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_9_1_Dxe + FILE_GUID = 3b83eb8d-74f1-416c-852c-a25114398507 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_9_1EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_9_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_9_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_9_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_9_2/Memory_V1_9_2_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_9_2/Memory_V1_9_2_Dxe.c new file mode 100644 index 00000000000..4a9bf55c3c6 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_9_2/Memory_V1_9_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_9_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_9_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "9", + "2" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_9_2 *MemoryV1_9_2; + EFI_REDFISH_MEMORY_V1_9_2_CS *MemoryV1_9_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_9_2_To_CS (ResoruceRaw, &MemoryV1_9_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_9_2 = (EFI_REDFISH_MEMORY_V1_9_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_9_2)); + if (MemoryV1_9_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_9_2; + MemoryV1_9_2->Memory = MemoryV1_9_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_9_2_JSON (*((EFI_REDFISH_MEMORY_V1_9_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_9_2 *MemoryV1_9_2; + + MemoryV1_9_2 = (EFI_REDFISH_MEMORY_V1_9_2 *)InterpProp; + DestroyMemory_V1_9_2_CS (MemoryV1_9_2->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_9_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_9_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_9_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_9_2/RedfishMemory_V1_9_2_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_9_2/RedfishMemory_V1_9_2_Dxe.inf new file mode 100644 index 00000000000..5db9c8786f8 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_9_2/RedfishMemory_V1_9_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_9_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_9_2_Dxe + FILE_GUID = e32bdb35-86a9-4bf0-8d28-27bd4e9a9821 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_9_2EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_9_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_9_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_9_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_9_3/Memory_V1_9_3_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_9_3/Memory_V1_9_3_Dxe.c new file mode 100644 index 00000000000..dc1fcfa9944 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_9_3/Memory_V1_9_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_9_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_9_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "9", + "3" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_9_3 *MemoryV1_9_3; + EFI_REDFISH_MEMORY_V1_9_3_CS *MemoryV1_9_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_9_3_To_CS (ResoruceRaw, &MemoryV1_9_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_9_3 = (EFI_REDFISH_MEMORY_V1_9_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_9_3)); + if (MemoryV1_9_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_9_3; + MemoryV1_9_3->Memory = MemoryV1_9_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_9_3_JSON (*((EFI_REDFISH_MEMORY_V1_9_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_9_3 *MemoryV1_9_3; + + MemoryV1_9_3 = (EFI_REDFISH_MEMORY_V1_9_3 *)InterpProp; + DestroyMemory_V1_9_3_CS (MemoryV1_9_3->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_9_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_9_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_9_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_9_3/RedfishMemory_V1_9_3_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_9_3/RedfishMemory_V1_9_3_Dxe.inf new file mode 100644 index 00000000000..d4bbad5668d --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_9_3/RedfishMemory_V1_9_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_9_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_9_3_Dxe + FILE_GUID = fef8efc9-4d46-4e2e-b66f-2bcea5ccf01d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_9_3EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_9_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_9_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_9_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Memory/v1_9_4/Memory_V1_9_4_Dxe.c b/RedfishClientPkg/Converter/Memory/v1_9_4/Memory_V1_9_4_Dxe.c new file mode 100644 index 00000000000..e30f0e26248 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_9_4/Memory_V1_9_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Memory.v1_9_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Memory"; +BOOLEAN IsRevisonController = TRUE; + +// Support Memory V1_9_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Memory", + "1", + "9", + "4" + }, + "Memory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_9_4 *MemoryV1_9_4; + EFI_REDFISH_MEMORY_V1_9_4_CS *MemoryV1_9_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Memory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Memory_V1_9_4_To_CS (ResoruceRaw, &MemoryV1_9_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryV1_9_4 = (EFI_REDFISH_MEMORY_V1_9_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORY_V1_9_4)); + if (MemoryV1_9_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryV1_9_4; + MemoryV1_9_4->Memory = MemoryV1_9_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Memory"), "Memory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Memory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Memory"), "Memory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Memory_V1_9_4_JSON (*((EFI_REDFISH_MEMORY_V1_9_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORY_V1_9_4 *MemoryV1_9_4; + + MemoryV1_9_4 = (EFI_REDFISH_MEMORY_V1_9_4 *)InterpProp; + DestroyMemory_V1_9_4_CS (MemoryV1_9_4->Memory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemory_V1_9_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_9_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryToStructWrapper, + MemoryToJson, + MemoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemory_V1_9_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Memory/v1_9_4/RedfishMemory_V1_9_4_Dxe.inf b/RedfishClientPkg/Converter/Memory/v1_9_4/RedfishMemory_V1_9_4_Dxe.inf new file mode 100644 index 00000000000..5a593d15613 --- /dev/null +++ b/RedfishClientPkg/Converter/Memory/v1_9_4/RedfishMemory_V1_9_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Memory.v1_9_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemory_V1_9_4_Dxe + FILE_GUID = 979056d4-19dc-4a80-b0b2-febe00647842 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemory_V1_9_4EntryPoint + UNLOAD_IMAGE = RedfishMemory_V1_9_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Memory_V1_9_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryV1_9_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_0_0/MemoryChunks_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_0_0/MemoryChunks_V1_0_0_Dxe.c new file mode 100644 index 00000000000..d82de98d4a0 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_0_0/MemoryChunks_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "0", + "0" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_0_0 *MemoryChunksV1_0_0; + EFI_REDFISH_MEMORYCHUNKS_V1_0_0_CS *MemoryChunksV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_0_0_To_CS (ResoruceRaw, &MemoryChunksV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_0_0 = (EFI_REDFISH_MEMORYCHUNKS_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_0_0)); + if (MemoryChunksV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_0_0; + MemoryChunksV1_0_0->MemoryChunks = MemoryChunksV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_0_0_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_0_0 *MemoryChunksV1_0_0; + + MemoryChunksV1_0_0 = (EFI_REDFISH_MEMORYCHUNKS_V1_0_0 *)InterpProp; + DestroyMemoryChunks_V1_0_0_CS (MemoryChunksV1_0_0->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_0_0/RedfishMemoryChunks_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_0_0/RedfishMemoryChunks_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..de7ecae26c4 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_0_0/RedfishMemoryChunks_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_0_0_Dxe + FILE_GUID = 015d8096-ab06-47d5-b259-0a1fb96a3177 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_0_1/MemoryChunks_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_0_1/MemoryChunks_V1_0_1_Dxe.c new file mode 100644 index 00000000000..33b3007a837 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_0_1/MemoryChunks_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "0", + "1" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_0_1 *MemoryChunksV1_0_1; + EFI_REDFISH_MEMORYCHUNKS_V1_0_1_CS *MemoryChunksV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_0_1_To_CS (ResoruceRaw, &MemoryChunksV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_0_1 = (EFI_REDFISH_MEMORYCHUNKS_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_0_1)); + if (MemoryChunksV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_0_1; + MemoryChunksV1_0_1->MemoryChunks = MemoryChunksV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_0_1_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_0_1 *MemoryChunksV1_0_1; + + MemoryChunksV1_0_1 = (EFI_REDFISH_MEMORYCHUNKS_V1_0_1 *)InterpProp; + DestroyMemoryChunks_V1_0_1_CS (MemoryChunksV1_0_1->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_0_1/RedfishMemoryChunks_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_0_1/RedfishMemoryChunks_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..4cac204b334 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_0_1/RedfishMemoryChunks_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_0_1_Dxe + FILE_GUID = 87c13be3-0344-440f-bed3-b5f1dda97f89 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_0_2/MemoryChunks_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_0_2/MemoryChunks_V1_0_2_Dxe.c new file mode 100644 index 00000000000..275aba25605 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_0_2/MemoryChunks_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "0", + "2" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_0_2 *MemoryChunksV1_0_2; + EFI_REDFISH_MEMORYCHUNKS_V1_0_2_CS *MemoryChunksV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_0_2_To_CS (ResoruceRaw, &MemoryChunksV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_0_2 = (EFI_REDFISH_MEMORYCHUNKS_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_0_2)); + if (MemoryChunksV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_0_2; + MemoryChunksV1_0_2->MemoryChunks = MemoryChunksV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_0_2_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_0_2 *MemoryChunksV1_0_2; + + MemoryChunksV1_0_2 = (EFI_REDFISH_MEMORYCHUNKS_V1_0_2 *)InterpProp; + DestroyMemoryChunks_V1_0_2_CS (MemoryChunksV1_0_2->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_0_2/RedfishMemoryChunks_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_0_2/RedfishMemoryChunks_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..d3d2b28018a --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_0_2/RedfishMemoryChunks_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_0_2_Dxe + FILE_GUID = d4b44bc6-b773-4df4-a297-c975fc25b728 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_0_3/MemoryChunks_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_0_3/MemoryChunks_V1_0_3_Dxe.c new file mode 100644 index 00000000000..63ece4df10f --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_0_3/MemoryChunks_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "0", + "3" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_0_3 *MemoryChunksV1_0_3; + EFI_REDFISH_MEMORYCHUNKS_V1_0_3_CS *MemoryChunksV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_0_3_To_CS (ResoruceRaw, &MemoryChunksV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_0_3 = (EFI_REDFISH_MEMORYCHUNKS_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_0_3)); + if (MemoryChunksV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_0_3; + MemoryChunksV1_0_3->MemoryChunks = MemoryChunksV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_0_3_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_0_3 *MemoryChunksV1_0_3; + + MemoryChunksV1_0_3 = (EFI_REDFISH_MEMORYCHUNKS_V1_0_3 *)InterpProp; + DestroyMemoryChunks_V1_0_3_CS (MemoryChunksV1_0_3->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_0_3/RedfishMemoryChunks_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_0_3/RedfishMemoryChunks_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..b83ee6e9de7 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_0_3/RedfishMemoryChunks_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_0_3_Dxe + FILE_GUID = fd73293c-f365-4fd8-af73-894cd4dae212 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_0_4/MemoryChunks_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_0_4/MemoryChunks_V1_0_4_Dxe.c new file mode 100644 index 00000000000..175c1022b43 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_0_4/MemoryChunks_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "0", + "4" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_0_4 *MemoryChunksV1_0_4; + EFI_REDFISH_MEMORYCHUNKS_V1_0_4_CS *MemoryChunksV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_0_4_To_CS (ResoruceRaw, &MemoryChunksV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_0_4 = (EFI_REDFISH_MEMORYCHUNKS_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_0_4)); + if (MemoryChunksV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_0_4; + MemoryChunksV1_0_4->MemoryChunks = MemoryChunksV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_0_4_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_0_4 *MemoryChunksV1_0_4; + + MemoryChunksV1_0_4 = (EFI_REDFISH_MEMORYCHUNKS_V1_0_4 *)InterpProp; + DestroyMemoryChunks_V1_0_4_CS (MemoryChunksV1_0_4->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_0_4/RedfishMemoryChunks_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_0_4/RedfishMemoryChunks_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..9a10d184905 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_0_4/RedfishMemoryChunks_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_0_4_Dxe + FILE_GUID = 8971253d-c040-4f99-b3b1-25cd1ced19fb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_0_5/MemoryChunks_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_0_5/MemoryChunks_V1_0_5_Dxe.c new file mode 100644 index 00000000000..1a46d06f4e9 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_0_5/MemoryChunks_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "0", + "5" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_0_5 *MemoryChunksV1_0_5; + EFI_REDFISH_MEMORYCHUNKS_V1_0_5_CS *MemoryChunksV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_0_5_To_CS (ResoruceRaw, &MemoryChunksV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_0_5 = (EFI_REDFISH_MEMORYCHUNKS_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_0_5)); + if (MemoryChunksV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_0_5; + MemoryChunksV1_0_5->MemoryChunks = MemoryChunksV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_0_5_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_0_5 *MemoryChunksV1_0_5; + + MemoryChunksV1_0_5 = (EFI_REDFISH_MEMORYCHUNKS_V1_0_5 *)InterpProp; + DestroyMemoryChunks_V1_0_5_CS (MemoryChunksV1_0_5->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_0_5/RedfishMemoryChunks_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_0_5/RedfishMemoryChunks_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..7ba38597309 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_0_5/RedfishMemoryChunks_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_0_5_Dxe + FILE_GUID = 617f6900-4ea3-4192-b12a-7b0c06b88257 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_0_6/MemoryChunks_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_0_6/MemoryChunks_V1_0_6_Dxe.c new file mode 100644 index 00000000000..3847b87acde --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_0_6/MemoryChunks_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "0", + "6" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_0_6 *MemoryChunksV1_0_6; + EFI_REDFISH_MEMORYCHUNKS_V1_0_6_CS *MemoryChunksV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_0_6_To_CS (ResoruceRaw, &MemoryChunksV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_0_6 = (EFI_REDFISH_MEMORYCHUNKS_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_0_6)); + if (MemoryChunksV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_0_6; + MemoryChunksV1_0_6->MemoryChunks = MemoryChunksV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_0_6_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_0_6 *MemoryChunksV1_0_6; + + MemoryChunksV1_0_6 = (EFI_REDFISH_MEMORYCHUNKS_V1_0_6 *)InterpProp; + DestroyMemoryChunks_V1_0_6_CS (MemoryChunksV1_0_6->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_0_6/RedfishMemoryChunks_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_0_6/RedfishMemoryChunks_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..f6bc5a75680 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_0_6/RedfishMemoryChunks_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_0_6_Dxe + FILE_GUID = 5508d2ab-64ee-42f9-9d25-4dfcd3b01bae + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_0_7/MemoryChunks_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_0_7/MemoryChunks_V1_0_7_Dxe.c new file mode 100644 index 00000000000..f48124784d3 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_0_7/MemoryChunks_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "0", + "7" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_0_7 *MemoryChunksV1_0_7; + EFI_REDFISH_MEMORYCHUNKS_V1_0_7_CS *MemoryChunksV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_0_7_To_CS (ResoruceRaw, &MemoryChunksV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_0_7 = (EFI_REDFISH_MEMORYCHUNKS_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_0_7)); + if (MemoryChunksV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_0_7; + MemoryChunksV1_0_7->MemoryChunks = MemoryChunksV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_0_7_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_0_7 *MemoryChunksV1_0_7; + + MemoryChunksV1_0_7 = (EFI_REDFISH_MEMORYCHUNKS_V1_0_7 *)InterpProp; + DestroyMemoryChunks_V1_0_7_CS (MemoryChunksV1_0_7->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_0_7/RedfishMemoryChunks_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_0_7/RedfishMemoryChunks_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..4492e54f37a --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_0_7/RedfishMemoryChunks_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_0_7_Dxe + FILE_GUID = 98898346-bfa4-4be2-9411-c7c19d066bd3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_1_0/MemoryChunks_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_1_0/MemoryChunks_V1_1_0_Dxe.c new file mode 100644 index 00000000000..800ddc7a8ca --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_1_0/MemoryChunks_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "1", + "0" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_1_0 *MemoryChunksV1_1_0; + EFI_REDFISH_MEMORYCHUNKS_V1_1_0_CS *MemoryChunksV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_1_0_To_CS (ResoruceRaw, &MemoryChunksV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_1_0 = (EFI_REDFISH_MEMORYCHUNKS_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_1_0)); + if (MemoryChunksV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_1_0; + MemoryChunksV1_1_0->MemoryChunks = MemoryChunksV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_1_0_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_1_0 *MemoryChunksV1_1_0; + + MemoryChunksV1_1_0 = (EFI_REDFISH_MEMORYCHUNKS_V1_1_0 *)InterpProp; + DestroyMemoryChunks_V1_1_0_CS (MemoryChunksV1_1_0->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_1_0/RedfishMemoryChunks_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_1_0/RedfishMemoryChunks_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..b72dd5d5fed --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_1_0/RedfishMemoryChunks_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_1_0_Dxe + FILE_GUID = 78a53cb1-2b7b-4d29-b419-644e6589f5a9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_1_1/MemoryChunks_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_1_1/MemoryChunks_V1_1_1_Dxe.c new file mode 100644 index 00000000000..c20f3da3fe8 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_1_1/MemoryChunks_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "1", + "1" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_1_1 *MemoryChunksV1_1_1; + EFI_REDFISH_MEMORYCHUNKS_V1_1_1_CS *MemoryChunksV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_1_1_To_CS (ResoruceRaw, &MemoryChunksV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_1_1 = (EFI_REDFISH_MEMORYCHUNKS_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_1_1)); + if (MemoryChunksV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_1_1; + MemoryChunksV1_1_1->MemoryChunks = MemoryChunksV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_1_1_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_1_1 *MemoryChunksV1_1_1; + + MemoryChunksV1_1_1 = (EFI_REDFISH_MEMORYCHUNKS_V1_1_1 *)InterpProp; + DestroyMemoryChunks_V1_1_1_CS (MemoryChunksV1_1_1->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_1_1/RedfishMemoryChunks_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_1_1/RedfishMemoryChunks_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..bc3785add78 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_1_1/RedfishMemoryChunks_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_1_1_Dxe + FILE_GUID = c1582385-490f-4f2d-8493-cdaaa19dd482 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_1_2/MemoryChunks_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_1_2/MemoryChunks_V1_1_2_Dxe.c new file mode 100644 index 00000000000..1d828df63fb --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_1_2/MemoryChunks_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "1", + "2" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_1_2 *MemoryChunksV1_1_2; + EFI_REDFISH_MEMORYCHUNKS_V1_1_2_CS *MemoryChunksV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_1_2_To_CS (ResoruceRaw, &MemoryChunksV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_1_2 = (EFI_REDFISH_MEMORYCHUNKS_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_1_2)); + if (MemoryChunksV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_1_2; + MemoryChunksV1_1_2->MemoryChunks = MemoryChunksV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_1_2_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_1_2 *MemoryChunksV1_1_2; + + MemoryChunksV1_1_2 = (EFI_REDFISH_MEMORYCHUNKS_V1_1_2 *)InterpProp; + DestroyMemoryChunks_V1_1_2_CS (MemoryChunksV1_1_2->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_1_2/RedfishMemoryChunks_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_1_2/RedfishMemoryChunks_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..04e53e63688 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_1_2/RedfishMemoryChunks_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_1_2_Dxe + FILE_GUID = 734d80cc-f594-4ca1-9f0c-ca1b9e024b60 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_1_3/MemoryChunks_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_1_3/MemoryChunks_V1_1_3_Dxe.c new file mode 100644 index 00000000000..fb8b273721e --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_1_3/MemoryChunks_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "1", + "3" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_1_3 *MemoryChunksV1_1_3; + EFI_REDFISH_MEMORYCHUNKS_V1_1_3_CS *MemoryChunksV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_1_3_To_CS (ResoruceRaw, &MemoryChunksV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_1_3 = (EFI_REDFISH_MEMORYCHUNKS_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_1_3)); + if (MemoryChunksV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_1_3; + MemoryChunksV1_1_3->MemoryChunks = MemoryChunksV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_1_3_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_1_3 *MemoryChunksV1_1_3; + + MemoryChunksV1_1_3 = (EFI_REDFISH_MEMORYCHUNKS_V1_1_3 *)InterpProp; + DestroyMemoryChunks_V1_1_3_CS (MemoryChunksV1_1_3->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_1_3/RedfishMemoryChunks_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_1_3/RedfishMemoryChunks_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..9add25c2a4f --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_1_3/RedfishMemoryChunks_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_1_3_Dxe + FILE_GUID = 9f38199e-de99-4c86-9590-bd50d5df7051 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_1_4/MemoryChunks_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_1_4/MemoryChunks_V1_1_4_Dxe.c new file mode 100644 index 00000000000..a486be6fd65 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_1_4/MemoryChunks_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "1", + "4" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_1_4 *MemoryChunksV1_1_4; + EFI_REDFISH_MEMORYCHUNKS_V1_1_4_CS *MemoryChunksV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_1_4_To_CS (ResoruceRaw, &MemoryChunksV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_1_4 = (EFI_REDFISH_MEMORYCHUNKS_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_1_4)); + if (MemoryChunksV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_1_4; + MemoryChunksV1_1_4->MemoryChunks = MemoryChunksV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_1_4_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_1_4 *MemoryChunksV1_1_4; + + MemoryChunksV1_1_4 = (EFI_REDFISH_MEMORYCHUNKS_V1_1_4 *)InterpProp; + DestroyMemoryChunks_V1_1_4_CS (MemoryChunksV1_1_4->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_1_4/RedfishMemoryChunks_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_1_4/RedfishMemoryChunks_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..a0a409d1a0c --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_1_4/RedfishMemoryChunks_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_1_4_Dxe + FILE_GUID = b307a4bc-64c4-49a5-8a60-66ee54e20fc0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_1_5/MemoryChunks_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_1_5/MemoryChunks_V1_1_5_Dxe.c new file mode 100644 index 00000000000..6a850f5a8f8 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_1_5/MemoryChunks_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "1", + "5" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_1_5 *MemoryChunksV1_1_5; + EFI_REDFISH_MEMORYCHUNKS_V1_1_5_CS *MemoryChunksV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_1_5_To_CS (ResoruceRaw, &MemoryChunksV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_1_5 = (EFI_REDFISH_MEMORYCHUNKS_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_1_5)); + if (MemoryChunksV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_1_5; + MemoryChunksV1_1_5->MemoryChunks = MemoryChunksV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_1_5_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_1_5 *MemoryChunksV1_1_5; + + MemoryChunksV1_1_5 = (EFI_REDFISH_MEMORYCHUNKS_V1_1_5 *)InterpProp; + DestroyMemoryChunks_V1_1_5_CS (MemoryChunksV1_1_5->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_1_5/RedfishMemoryChunks_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_1_5/RedfishMemoryChunks_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..fc56b2edcb6 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_1_5/RedfishMemoryChunks_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_1_5_Dxe + FILE_GUID = 3d904027-857f-442c-8a1a-3fb971c88456 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_2_0/MemoryChunks_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_2_0/MemoryChunks_V1_2_0_Dxe.c new file mode 100644 index 00000000000..618bf33289d --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_2_0/MemoryChunks_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "2", + "0" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_2_0 *MemoryChunksV1_2_0; + EFI_REDFISH_MEMORYCHUNKS_V1_2_0_CS *MemoryChunksV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_2_0_To_CS (ResoruceRaw, &MemoryChunksV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_2_0 = (EFI_REDFISH_MEMORYCHUNKS_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_2_0)); + if (MemoryChunksV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_2_0; + MemoryChunksV1_2_0->MemoryChunks = MemoryChunksV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_2_0_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_2_0 *MemoryChunksV1_2_0; + + MemoryChunksV1_2_0 = (EFI_REDFISH_MEMORYCHUNKS_V1_2_0 *)InterpProp; + DestroyMemoryChunks_V1_2_0_CS (MemoryChunksV1_2_0->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_2_0/RedfishMemoryChunks_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_2_0/RedfishMemoryChunks_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..3f02192d6c8 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_2_0/RedfishMemoryChunks_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_2_0_Dxe + FILE_GUID = 19704e4d-504e-4ff0-8ca6-a5ec14b92b69 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_2_1/MemoryChunks_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_2_1/MemoryChunks_V1_2_1_Dxe.c new file mode 100644 index 00000000000..f18651115f5 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_2_1/MemoryChunks_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "2", + "1" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_2_1 *MemoryChunksV1_2_1; + EFI_REDFISH_MEMORYCHUNKS_V1_2_1_CS *MemoryChunksV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_2_1_To_CS (ResoruceRaw, &MemoryChunksV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_2_1 = (EFI_REDFISH_MEMORYCHUNKS_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_2_1)); + if (MemoryChunksV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_2_1; + MemoryChunksV1_2_1->MemoryChunks = MemoryChunksV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_2_1_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_2_1 *MemoryChunksV1_2_1; + + MemoryChunksV1_2_1 = (EFI_REDFISH_MEMORYCHUNKS_V1_2_1 *)InterpProp; + DestroyMemoryChunks_V1_2_1_CS (MemoryChunksV1_2_1->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_2_1/RedfishMemoryChunks_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_2_1/RedfishMemoryChunks_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..1dcd0e52dab --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_2_1/RedfishMemoryChunks_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_2_1_Dxe + FILE_GUID = 5898659e-c83f-4209-8959-612c2a257d3e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_2_2/MemoryChunks_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_2_2/MemoryChunks_V1_2_2_Dxe.c new file mode 100644 index 00000000000..30576e79584 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_2_2/MemoryChunks_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "2", + "2" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_2_2 *MemoryChunksV1_2_2; + EFI_REDFISH_MEMORYCHUNKS_V1_2_2_CS *MemoryChunksV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_2_2_To_CS (ResoruceRaw, &MemoryChunksV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_2_2 = (EFI_REDFISH_MEMORYCHUNKS_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_2_2)); + if (MemoryChunksV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_2_2; + MemoryChunksV1_2_2->MemoryChunks = MemoryChunksV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_2_2_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_2_2 *MemoryChunksV1_2_2; + + MemoryChunksV1_2_2 = (EFI_REDFISH_MEMORYCHUNKS_V1_2_2 *)InterpProp; + DestroyMemoryChunks_V1_2_2_CS (MemoryChunksV1_2_2->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_2_2/RedfishMemoryChunks_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_2_2/RedfishMemoryChunks_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..a12570aeadb --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_2_2/RedfishMemoryChunks_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_2_2_Dxe + FILE_GUID = 6695955f-ee77-4a10-aefa-aa7708f4192b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_2_3/MemoryChunks_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_2_3/MemoryChunks_V1_2_3_Dxe.c new file mode 100644 index 00000000000..aa9a69ca781 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_2_3/MemoryChunks_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "2", + "3" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_2_3 *MemoryChunksV1_2_3; + EFI_REDFISH_MEMORYCHUNKS_V1_2_3_CS *MemoryChunksV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_2_3_To_CS (ResoruceRaw, &MemoryChunksV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_2_3 = (EFI_REDFISH_MEMORYCHUNKS_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_2_3)); + if (MemoryChunksV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_2_3; + MemoryChunksV1_2_3->MemoryChunks = MemoryChunksV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_2_3_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_2_3 *MemoryChunksV1_2_3; + + MemoryChunksV1_2_3 = (EFI_REDFISH_MEMORYCHUNKS_V1_2_3 *)InterpProp; + DestroyMemoryChunks_V1_2_3_CS (MemoryChunksV1_2_3->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_2_3/RedfishMemoryChunks_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_2_3/RedfishMemoryChunks_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..83cc033e301 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_2_3/RedfishMemoryChunks_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_2_3_Dxe + FILE_GUID = 19269f55-c2ce-41b7-8f35-1f2485e5ee5f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_2_4/MemoryChunks_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_2_4/MemoryChunks_V1_2_4_Dxe.c new file mode 100644 index 00000000000..ba5f333f06d --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_2_4/MemoryChunks_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "2", + "4" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_2_4 *MemoryChunksV1_2_4; + EFI_REDFISH_MEMORYCHUNKS_V1_2_4_CS *MemoryChunksV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_2_4_To_CS (ResoruceRaw, &MemoryChunksV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_2_4 = (EFI_REDFISH_MEMORYCHUNKS_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_2_4)); + if (MemoryChunksV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_2_4; + MemoryChunksV1_2_4->MemoryChunks = MemoryChunksV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_2_4_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_2_4 *MemoryChunksV1_2_4; + + MemoryChunksV1_2_4 = (EFI_REDFISH_MEMORYCHUNKS_V1_2_4 *)InterpProp; + DestroyMemoryChunks_V1_2_4_CS (MemoryChunksV1_2_4->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_2_4/RedfishMemoryChunks_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_2_4/RedfishMemoryChunks_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..ddf5fb896db --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_2_4/RedfishMemoryChunks_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_2_4_Dxe + FILE_GUID = 4d5dd792-eb93-4255-8b59-5280e5accb76 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_2_5/MemoryChunks_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_2_5/MemoryChunks_V1_2_5_Dxe.c new file mode 100644 index 00000000000..9a562bc5656 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_2_5/MemoryChunks_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "2", + "5" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_2_5 *MemoryChunksV1_2_5; + EFI_REDFISH_MEMORYCHUNKS_V1_2_5_CS *MemoryChunksV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_2_5_To_CS (ResoruceRaw, &MemoryChunksV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_2_5 = (EFI_REDFISH_MEMORYCHUNKS_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_2_5)); + if (MemoryChunksV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_2_5; + MemoryChunksV1_2_5->MemoryChunks = MemoryChunksV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_2_5_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_2_5 *MemoryChunksV1_2_5; + + MemoryChunksV1_2_5 = (EFI_REDFISH_MEMORYCHUNKS_V1_2_5 *)InterpProp; + DestroyMemoryChunks_V1_2_5_CS (MemoryChunksV1_2_5->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_2_5/RedfishMemoryChunks_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_2_5/RedfishMemoryChunks_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..6865d4e420a --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_2_5/RedfishMemoryChunks_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_2_5_Dxe + FILE_GUID = 19d1fce6-4e56-469f-bc99-100f93a8b1c8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_2_6/MemoryChunks_V1_2_6_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_2_6/MemoryChunks_V1_2_6_Dxe.c new file mode 100644 index 00000000000..1696f2476c8 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_2_6/MemoryChunks_V1_2_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_2_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "2", + "6" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_2_6 *MemoryChunksV1_2_6; + EFI_REDFISH_MEMORYCHUNKS_V1_2_6_CS *MemoryChunksV1_2_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_2_6_To_CS (ResoruceRaw, &MemoryChunksV1_2_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_2_6 = (EFI_REDFISH_MEMORYCHUNKS_V1_2_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_2_6)); + if (MemoryChunksV1_2_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_2_6; + MemoryChunksV1_2_6->MemoryChunks = MemoryChunksV1_2_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_2_6_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_2_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_2_6 *MemoryChunksV1_2_6; + + MemoryChunksV1_2_6 = (EFI_REDFISH_MEMORYCHUNKS_V1_2_6 *)InterpProp; + DestroyMemoryChunks_V1_2_6_CS (MemoryChunksV1_2_6->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_2_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_2_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_2_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_2_6/RedfishMemoryChunks_V1_2_6_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_2_6/RedfishMemoryChunks_V1_2_6_Dxe.inf new file mode 100644 index 00000000000..c2ce230f8df --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_2_6/RedfishMemoryChunks_V1_2_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_2_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_2_6_Dxe + FILE_GUID = 87287a05-2311-452f-81ab-69ddc0c62735 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_2_6EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_2_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_2_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_2_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_3_0/MemoryChunks_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_3_0/MemoryChunks_V1_3_0_Dxe.c new file mode 100644 index 00000000000..32c6f7aae1d --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_3_0/MemoryChunks_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "3", + "0" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_3_0 *MemoryChunksV1_3_0; + EFI_REDFISH_MEMORYCHUNKS_V1_3_0_CS *MemoryChunksV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_3_0_To_CS (ResoruceRaw, &MemoryChunksV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_3_0 = (EFI_REDFISH_MEMORYCHUNKS_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_3_0)); + if (MemoryChunksV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_3_0; + MemoryChunksV1_3_0->MemoryChunks = MemoryChunksV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_3_0_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_3_0 *MemoryChunksV1_3_0; + + MemoryChunksV1_3_0 = (EFI_REDFISH_MEMORYCHUNKS_V1_3_0 *)InterpProp; + DestroyMemoryChunks_V1_3_0_CS (MemoryChunksV1_3_0->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_3_0/RedfishMemoryChunks_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_3_0/RedfishMemoryChunks_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..3b7050f6eb1 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_3_0/RedfishMemoryChunks_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_3_0_Dxe + FILE_GUID = 8858f4e1-fe24-458f-9e9f-8186a41ade6c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_3_1/MemoryChunks_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_3_1/MemoryChunks_V1_3_1_Dxe.c new file mode 100644 index 00000000000..32212ea49ec --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_3_1/MemoryChunks_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "3", + "1" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_3_1 *MemoryChunksV1_3_1; + EFI_REDFISH_MEMORYCHUNKS_V1_3_1_CS *MemoryChunksV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_3_1_To_CS (ResoruceRaw, &MemoryChunksV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_3_1 = (EFI_REDFISH_MEMORYCHUNKS_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_3_1)); + if (MemoryChunksV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_3_1; + MemoryChunksV1_3_1->MemoryChunks = MemoryChunksV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_3_1_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_3_1 *MemoryChunksV1_3_1; + + MemoryChunksV1_3_1 = (EFI_REDFISH_MEMORYCHUNKS_V1_3_1 *)InterpProp; + DestroyMemoryChunks_V1_3_1_CS (MemoryChunksV1_3_1->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_3_1/RedfishMemoryChunks_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_3_1/RedfishMemoryChunks_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..e326af8744c --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_3_1/RedfishMemoryChunks_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_3_1_Dxe + FILE_GUID = e1585241-6759-476d-b48d-39f0d8e18971 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_3_2/MemoryChunks_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_3_2/MemoryChunks_V1_3_2_Dxe.c new file mode 100644 index 00000000000..50a35466b4e --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_3_2/MemoryChunks_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "3", + "2" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_3_2 *MemoryChunksV1_3_2; + EFI_REDFISH_MEMORYCHUNKS_V1_3_2_CS *MemoryChunksV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_3_2_To_CS (ResoruceRaw, &MemoryChunksV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_3_2 = (EFI_REDFISH_MEMORYCHUNKS_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_3_2)); + if (MemoryChunksV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_3_2; + MemoryChunksV1_3_2->MemoryChunks = MemoryChunksV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_3_2_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_3_2 *MemoryChunksV1_3_2; + + MemoryChunksV1_3_2 = (EFI_REDFISH_MEMORYCHUNKS_V1_3_2 *)InterpProp; + DestroyMemoryChunks_V1_3_2_CS (MemoryChunksV1_3_2->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_3_2/RedfishMemoryChunks_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_3_2/RedfishMemoryChunks_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..bab232dfdb7 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_3_2/RedfishMemoryChunks_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_3_2_Dxe + FILE_GUID = 9efa07db-8fcc-4a36-9c34-28f7832ca675 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_4_0/MemoryChunks_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_4_0/MemoryChunks_V1_4_0_Dxe.c new file mode 100644 index 00000000000..d595fcfe18e --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_4_0/MemoryChunks_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "4", + "0" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_4_0 *MemoryChunksV1_4_0; + EFI_REDFISH_MEMORYCHUNKS_V1_4_0_CS *MemoryChunksV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_4_0_To_CS (ResoruceRaw, &MemoryChunksV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_4_0 = (EFI_REDFISH_MEMORYCHUNKS_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_4_0)); + if (MemoryChunksV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_4_0; + MemoryChunksV1_4_0->MemoryChunks = MemoryChunksV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_4_0_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_4_0 *MemoryChunksV1_4_0; + + MemoryChunksV1_4_0 = (EFI_REDFISH_MEMORYCHUNKS_V1_4_0 *)InterpProp; + DestroyMemoryChunks_V1_4_0_CS (MemoryChunksV1_4_0->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_4_0/RedfishMemoryChunks_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_4_0/RedfishMemoryChunks_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..5f0c44f4941 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_4_0/RedfishMemoryChunks_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_4_0_Dxe + FILE_GUID = 89e2d301-c967-4134-b9bc-ec45104aa751 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_4_1/MemoryChunks_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/MemoryChunks/v1_4_1/MemoryChunks_V1_4_1_Dxe.c new file mode 100644 index 00000000000..4bf629f94da --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_4_1/MemoryChunks_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunks.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunks"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryChunks V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunks", + "1", + "4", + "1" + }, + "MemoryChunks" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_4_1 *MemoryChunksV1_4_1; + EFI_REDFISH_MEMORYCHUNKS_V1_4_1_CS *MemoryChunksV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunks") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunks_V1_4_1_To_CS (ResoruceRaw, &MemoryChunksV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksV1_4_1 = (EFI_REDFISH_MEMORYCHUNKS_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKS_V1_4_1)); + if (MemoryChunksV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksV1_4_1; + MemoryChunksV1_4_1->MemoryChunks = MemoryChunksV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunks")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunks"), "MemoryChunks"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunks_V1_4_1_JSON (*((EFI_REDFISH_MEMORYCHUNKS_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKS_V1_4_1 *MemoryChunksV1_4_1; + + MemoryChunksV1_4_1 = (EFI_REDFISH_MEMORYCHUNKS_V1_4_1 *)InterpProp; + DestroyMemoryChunks_V1_4_1_CS (MemoryChunksV1_4_1->MemoryChunks); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunks_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksToStructWrapper, + MemoryChunksToJson, + MemoryChunksDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunks_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunks/v1_4_1/RedfishMemoryChunks_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunks/v1_4_1/RedfishMemoryChunks_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..4ed86e25f4e --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunks/v1_4_1/RedfishMemoryChunks_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunks.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunks_V1_4_1_Dxe + FILE_GUID = e68c86ec-ba3f-467e-aceb-f87cee6fbea9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunks_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishMemoryChunks_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunks_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryChunksCollection/MemoryChunksCollection_Dxe.c b/RedfishClientPkg/Converter/MemoryChunksCollection/MemoryChunksCollection_Dxe.c new file mode 100644 index 00000000000..fa97f12e010 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunksCollection/MemoryChunksCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryChunksCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryChunksCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support MemoryChunksCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryChunksCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "MemoryChunksCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKSCOLLECTION *MemoryChunksCollection; + EFI_REDFISH_MEMORYCHUNKSCOLLECTION_CS *MemoryChunksCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryChunksCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryChunksCollection_To_CS (ResoruceRaw, &MemoryChunksCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryChunksCollection = (EFI_REDFISH_MEMORYCHUNKSCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCHUNKSCOLLECTION)); + if (MemoryChunksCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryChunksCollection; + MemoryChunksCollection->MemoryChunksCollection = MemoryChunksCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunksCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryChunksCollection"), "MemoryChunksCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryChunksCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryChunksCollection"), "MemoryChunksCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryChunksCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryChunksCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryChunksCollection_JSON (*((EFI_REDFISH_MEMORYCHUNKSCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryChunksCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCHUNKSCOLLECTION *MemoryChunksCollection; + + MemoryChunksCollection = (EFI_REDFISH_MEMORYCHUNKSCOLLECTION *)InterpProp; + DestroyMemoryChunksCollection_CS (MemoryChunksCollection->MemoryChunksCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryChunksCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryChunksCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryChunksCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunksCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryChunksCollectionToStructWrapper, + MemoryChunksCollectionToJson, + MemoryChunksCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryChunksCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryChunksCollection/RedfishMemoryChunksCollection_Dxe.inf b/RedfishClientPkg/Converter/MemoryChunksCollection/RedfishMemoryChunksCollection_Dxe.inf new file mode 100644 index 00000000000..8804fae06f3 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryChunksCollection/RedfishMemoryChunksCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryChunksCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryChunksCollection_Dxe + FILE_GUID = 5f277f39-124d-4d88-87bd-cd2b104b99c4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryChunksCollectionEntryPoint + UNLOAD_IMAGE = RedfishMemoryChunksCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryChunksCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryChunksCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryCollection/MemoryCollection_Dxe.c b/RedfishClientPkg/Converter/MemoryCollection/MemoryCollection_Dxe.c new file mode 100644 index 00000000000..ff19f38ad12 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryCollection/MemoryCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support MemoryCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "MemoryCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYCOLLECTION *MemoryCollection; + EFI_REDFISH_MEMORYCOLLECTION_CS *MemoryCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryCollection_To_CS (ResoruceRaw, &MemoryCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryCollection = (EFI_REDFISH_MEMORYCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYCOLLECTION)); + if (MemoryCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryCollection; + MemoryCollection->MemoryCollection = MemoryCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryCollection"), "MemoryCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryCollection"), "MemoryCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryCollection_JSON (*((EFI_REDFISH_MEMORYCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYCOLLECTION *MemoryCollection; + + MemoryCollection = (EFI_REDFISH_MEMORYCOLLECTION *)InterpProp; + DestroyMemoryCollection_CS (MemoryCollection->MemoryCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryCollectionToStructWrapper, + MemoryCollectionToJson, + MemoryCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryCollection/RedfishMemoryCollection_Dxe.inf b/RedfishClientPkg/Converter/MemoryCollection/RedfishMemoryCollection_Dxe.inf new file mode 100644 index 00000000000..6dfc50ec987 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryCollection/RedfishMemoryCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryCollection_Dxe + FILE_GUID = 88f6de59-7fbb-4559-abc1-fa19bbd6da95 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryCollectionEntryPoint + UNLOAD_IMAGE = RedfishMemoryCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_0_0/MemoryDomain_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/MemoryDomain/v1_0_0/MemoryDomain_V1_0_0_Dxe.c new file mode 100644 index 00000000000..0e169e742e2 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_0_0/MemoryDomain_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryDomain.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryDomain"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryDomain V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryDomain", + "1", + "0", + "0" + }, + "MemoryDomain" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_0_0 *MemoryDomainV1_0_0; + EFI_REDFISH_MEMORYDOMAIN_V1_0_0_CS *MemoryDomainV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryDomain") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryDomain_V1_0_0_To_CS (ResoruceRaw, &MemoryDomainV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryDomainV1_0_0 = (EFI_REDFISH_MEMORYDOMAIN_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYDOMAIN_V1_0_0)); + if (MemoryDomainV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryDomainV1_0_0; + MemoryDomainV1_0_0->MemoryDomain = MemoryDomainV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryDomainToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryDomainToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryDomain_V1_0_0_JSON (*((EFI_REDFISH_MEMORYDOMAIN_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryDomainToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_0_0 *MemoryDomainV1_0_0; + + MemoryDomainV1_0_0 = (EFI_REDFISH_MEMORYDOMAIN_V1_0_0 *)InterpProp; + DestroyMemoryDomain_V1_0_0_CS (MemoryDomainV1_0_0->MemoryDomain); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryDomainFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryDomain_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryDomainToStructWrapper, + MemoryDomainToJson, + MemoryDomainDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_0_0/RedfishMemoryDomain_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/MemoryDomain/v1_0_0/RedfishMemoryDomain_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..8a5ff22dc4a --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_0_0/RedfishMemoryDomain_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryDomain.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryDomain_V1_0_0_Dxe + FILE_GUID = a2dc00ab-cc26-43a0-b79e-79c62fb4465a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryDomain_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishMemoryDomain_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryDomain_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryDomainV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_0_1/MemoryDomain_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/MemoryDomain/v1_0_1/MemoryDomain_V1_0_1_Dxe.c new file mode 100644 index 00000000000..c8c6ce8983f --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_0_1/MemoryDomain_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryDomain.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryDomain"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryDomain V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryDomain", + "1", + "0", + "1" + }, + "MemoryDomain" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_0_1 *MemoryDomainV1_0_1; + EFI_REDFISH_MEMORYDOMAIN_V1_0_1_CS *MemoryDomainV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryDomain") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryDomain_V1_0_1_To_CS (ResoruceRaw, &MemoryDomainV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryDomainV1_0_1 = (EFI_REDFISH_MEMORYDOMAIN_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYDOMAIN_V1_0_1)); + if (MemoryDomainV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryDomainV1_0_1; + MemoryDomainV1_0_1->MemoryDomain = MemoryDomainV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryDomainToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryDomainToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryDomain_V1_0_1_JSON (*((EFI_REDFISH_MEMORYDOMAIN_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryDomainToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_0_1 *MemoryDomainV1_0_1; + + MemoryDomainV1_0_1 = (EFI_REDFISH_MEMORYDOMAIN_V1_0_1 *)InterpProp; + DestroyMemoryDomain_V1_0_1_CS (MemoryDomainV1_0_1->MemoryDomain); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryDomainFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryDomain_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryDomainToStructWrapper, + MemoryDomainToJson, + MemoryDomainDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_0_1/RedfishMemoryDomain_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/MemoryDomain/v1_0_1/RedfishMemoryDomain_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..c322a5582bc --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_0_1/RedfishMemoryDomain_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryDomain.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryDomain_V1_0_1_Dxe + FILE_GUID = ab9da488-6e8d-4a1a-b9c0-3360526010fc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryDomain_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishMemoryDomain_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryDomain_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryDomainV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_0_2/MemoryDomain_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/MemoryDomain/v1_0_2/MemoryDomain_V1_0_2_Dxe.c new file mode 100644 index 00000000000..c07cb08395b --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_0_2/MemoryDomain_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryDomain.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryDomain"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryDomain V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryDomain", + "1", + "0", + "2" + }, + "MemoryDomain" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_0_2 *MemoryDomainV1_0_2; + EFI_REDFISH_MEMORYDOMAIN_V1_0_2_CS *MemoryDomainV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryDomain") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryDomain_V1_0_2_To_CS (ResoruceRaw, &MemoryDomainV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryDomainV1_0_2 = (EFI_REDFISH_MEMORYDOMAIN_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYDOMAIN_V1_0_2)); + if (MemoryDomainV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryDomainV1_0_2; + MemoryDomainV1_0_2->MemoryDomain = MemoryDomainV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryDomainToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryDomainToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryDomain_V1_0_2_JSON (*((EFI_REDFISH_MEMORYDOMAIN_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryDomainToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_0_2 *MemoryDomainV1_0_2; + + MemoryDomainV1_0_2 = (EFI_REDFISH_MEMORYDOMAIN_V1_0_2 *)InterpProp; + DestroyMemoryDomain_V1_0_2_CS (MemoryDomainV1_0_2->MemoryDomain); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryDomainFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryDomain_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryDomainToStructWrapper, + MemoryDomainToJson, + MemoryDomainDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_0_2/RedfishMemoryDomain_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/MemoryDomain/v1_0_2/RedfishMemoryDomain_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..e7acc4ce153 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_0_2/RedfishMemoryDomain_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryDomain.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryDomain_V1_0_2_Dxe + FILE_GUID = de5b5675-98df-4940-aba8-0533bdf342e9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryDomain_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishMemoryDomain_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryDomain_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryDomainV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_0_3/MemoryDomain_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/MemoryDomain/v1_0_3/MemoryDomain_V1_0_3_Dxe.c new file mode 100644 index 00000000000..791edf39bf8 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_0_3/MemoryDomain_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryDomain.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryDomain"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryDomain V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryDomain", + "1", + "0", + "3" + }, + "MemoryDomain" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_0_3 *MemoryDomainV1_0_3; + EFI_REDFISH_MEMORYDOMAIN_V1_0_3_CS *MemoryDomainV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryDomain") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryDomain_V1_0_3_To_CS (ResoruceRaw, &MemoryDomainV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryDomainV1_0_3 = (EFI_REDFISH_MEMORYDOMAIN_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYDOMAIN_V1_0_3)); + if (MemoryDomainV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryDomainV1_0_3; + MemoryDomainV1_0_3->MemoryDomain = MemoryDomainV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryDomainToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryDomainToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryDomain_V1_0_3_JSON (*((EFI_REDFISH_MEMORYDOMAIN_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryDomainToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_0_3 *MemoryDomainV1_0_3; + + MemoryDomainV1_0_3 = (EFI_REDFISH_MEMORYDOMAIN_V1_0_3 *)InterpProp; + DestroyMemoryDomain_V1_0_3_CS (MemoryDomainV1_0_3->MemoryDomain); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryDomainFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryDomain_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryDomainToStructWrapper, + MemoryDomainToJson, + MemoryDomainDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_0_3/RedfishMemoryDomain_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/MemoryDomain/v1_0_3/RedfishMemoryDomain_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..5871c8b7bd2 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_0_3/RedfishMemoryDomain_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryDomain.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryDomain_V1_0_3_Dxe + FILE_GUID = fb228be1-4ac0-4764-a6a8-d22089d8a557 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryDomain_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishMemoryDomain_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryDomain_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryDomainV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_0_4/MemoryDomain_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/MemoryDomain/v1_0_4/MemoryDomain_V1_0_4_Dxe.c new file mode 100644 index 00000000000..5fc98a1f313 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_0_4/MemoryDomain_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryDomain.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryDomain"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryDomain V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryDomain", + "1", + "0", + "4" + }, + "MemoryDomain" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_0_4 *MemoryDomainV1_0_4; + EFI_REDFISH_MEMORYDOMAIN_V1_0_4_CS *MemoryDomainV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryDomain") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryDomain_V1_0_4_To_CS (ResoruceRaw, &MemoryDomainV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryDomainV1_0_4 = (EFI_REDFISH_MEMORYDOMAIN_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYDOMAIN_V1_0_4)); + if (MemoryDomainV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryDomainV1_0_4; + MemoryDomainV1_0_4->MemoryDomain = MemoryDomainV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryDomainToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryDomainToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryDomain_V1_0_4_JSON (*((EFI_REDFISH_MEMORYDOMAIN_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryDomainToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_0_4 *MemoryDomainV1_0_4; + + MemoryDomainV1_0_4 = (EFI_REDFISH_MEMORYDOMAIN_V1_0_4 *)InterpProp; + DestroyMemoryDomain_V1_0_4_CS (MemoryDomainV1_0_4->MemoryDomain); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryDomainFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryDomain_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryDomainToStructWrapper, + MemoryDomainToJson, + MemoryDomainDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_0_4/RedfishMemoryDomain_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/MemoryDomain/v1_0_4/RedfishMemoryDomain_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..7b46bf7340d --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_0_4/RedfishMemoryDomain_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryDomain.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryDomain_V1_0_4_Dxe + FILE_GUID = 97781148-9d7f-4228-bb6c-b87fea03eb7b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryDomain_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishMemoryDomain_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryDomain_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryDomainV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_0_5/MemoryDomain_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/MemoryDomain/v1_0_5/MemoryDomain_V1_0_5_Dxe.c new file mode 100644 index 00000000000..f61b5a75f8d --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_0_5/MemoryDomain_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryDomain.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryDomain"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryDomain V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryDomain", + "1", + "0", + "5" + }, + "MemoryDomain" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_0_5 *MemoryDomainV1_0_5; + EFI_REDFISH_MEMORYDOMAIN_V1_0_5_CS *MemoryDomainV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryDomain") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryDomain_V1_0_5_To_CS (ResoruceRaw, &MemoryDomainV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryDomainV1_0_5 = (EFI_REDFISH_MEMORYDOMAIN_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYDOMAIN_V1_0_5)); + if (MemoryDomainV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryDomainV1_0_5; + MemoryDomainV1_0_5->MemoryDomain = MemoryDomainV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryDomainToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryDomainToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryDomain_V1_0_5_JSON (*((EFI_REDFISH_MEMORYDOMAIN_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryDomainToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_0_5 *MemoryDomainV1_0_5; + + MemoryDomainV1_0_5 = (EFI_REDFISH_MEMORYDOMAIN_V1_0_5 *)InterpProp; + DestroyMemoryDomain_V1_0_5_CS (MemoryDomainV1_0_5->MemoryDomain); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryDomainFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryDomain_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryDomainToStructWrapper, + MemoryDomainToJson, + MemoryDomainDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_0_5/RedfishMemoryDomain_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/MemoryDomain/v1_0_5/RedfishMemoryDomain_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..796328db927 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_0_5/RedfishMemoryDomain_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryDomain.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryDomain_V1_0_5_Dxe + FILE_GUID = 02eb3bf0-6ff5-4aee-824f-b45ebf68ebc9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryDomain_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishMemoryDomain_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryDomain_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryDomainV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_1_0/MemoryDomain_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/MemoryDomain/v1_1_0/MemoryDomain_V1_1_0_Dxe.c new file mode 100644 index 00000000000..e478fdacc05 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_1_0/MemoryDomain_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryDomain.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryDomain"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryDomain V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryDomain", + "1", + "1", + "0" + }, + "MemoryDomain" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_1_0 *MemoryDomainV1_1_0; + EFI_REDFISH_MEMORYDOMAIN_V1_1_0_CS *MemoryDomainV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryDomain") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryDomain_V1_1_0_To_CS (ResoruceRaw, &MemoryDomainV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryDomainV1_1_0 = (EFI_REDFISH_MEMORYDOMAIN_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYDOMAIN_V1_1_0)); + if (MemoryDomainV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryDomainV1_1_0; + MemoryDomainV1_1_0->MemoryDomain = MemoryDomainV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryDomainToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryDomainToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryDomain_V1_1_0_JSON (*((EFI_REDFISH_MEMORYDOMAIN_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryDomainToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_1_0 *MemoryDomainV1_1_0; + + MemoryDomainV1_1_0 = (EFI_REDFISH_MEMORYDOMAIN_V1_1_0 *)InterpProp; + DestroyMemoryDomain_V1_1_0_CS (MemoryDomainV1_1_0->MemoryDomain); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryDomainFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryDomain_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryDomainToStructWrapper, + MemoryDomainToJson, + MemoryDomainDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_1_0/RedfishMemoryDomain_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/MemoryDomain/v1_1_0/RedfishMemoryDomain_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..87ae6d006f9 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_1_0/RedfishMemoryDomain_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryDomain.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryDomain_V1_1_0_Dxe + FILE_GUID = 633a6aa7-8ed5-4947-af49-109a3479ecdb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryDomain_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishMemoryDomain_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryDomain_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryDomainV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_1_1/MemoryDomain_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/MemoryDomain/v1_1_1/MemoryDomain_V1_1_1_Dxe.c new file mode 100644 index 00000000000..4b98102e7ed --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_1_1/MemoryDomain_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryDomain.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryDomain"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryDomain V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryDomain", + "1", + "1", + "1" + }, + "MemoryDomain" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_1_1 *MemoryDomainV1_1_1; + EFI_REDFISH_MEMORYDOMAIN_V1_1_1_CS *MemoryDomainV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryDomain") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryDomain_V1_1_1_To_CS (ResoruceRaw, &MemoryDomainV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryDomainV1_1_1 = (EFI_REDFISH_MEMORYDOMAIN_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYDOMAIN_V1_1_1)); + if (MemoryDomainV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryDomainV1_1_1; + MemoryDomainV1_1_1->MemoryDomain = MemoryDomainV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryDomainToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryDomainToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryDomain_V1_1_1_JSON (*((EFI_REDFISH_MEMORYDOMAIN_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryDomainToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_1_1 *MemoryDomainV1_1_1; + + MemoryDomainV1_1_1 = (EFI_REDFISH_MEMORYDOMAIN_V1_1_1 *)InterpProp; + DestroyMemoryDomain_V1_1_1_CS (MemoryDomainV1_1_1->MemoryDomain); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryDomainFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryDomain_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryDomainToStructWrapper, + MemoryDomainToJson, + MemoryDomainDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_1_1/RedfishMemoryDomain_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/MemoryDomain/v1_1_1/RedfishMemoryDomain_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..1ace551fddd --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_1_1/RedfishMemoryDomain_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryDomain.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryDomain_V1_1_1_Dxe + FILE_GUID = 95898239-693c-4344-bfd1-a47f0666b5bd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryDomain_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishMemoryDomain_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryDomain_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryDomainV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_1_2/MemoryDomain_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/MemoryDomain/v1_1_2/MemoryDomain_V1_1_2_Dxe.c new file mode 100644 index 00000000000..13b4fee7a3b --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_1_2/MemoryDomain_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryDomain.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryDomain"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryDomain V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryDomain", + "1", + "1", + "2" + }, + "MemoryDomain" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_1_2 *MemoryDomainV1_1_2; + EFI_REDFISH_MEMORYDOMAIN_V1_1_2_CS *MemoryDomainV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryDomain") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryDomain_V1_1_2_To_CS (ResoruceRaw, &MemoryDomainV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryDomainV1_1_2 = (EFI_REDFISH_MEMORYDOMAIN_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYDOMAIN_V1_1_2)); + if (MemoryDomainV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryDomainV1_1_2; + MemoryDomainV1_1_2->MemoryDomain = MemoryDomainV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryDomainToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryDomainToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryDomain_V1_1_2_JSON (*((EFI_REDFISH_MEMORYDOMAIN_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryDomainToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_1_2 *MemoryDomainV1_1_2; + + MemoryDomainV1_1_2 = (EFI_REDFISH_MEMORYDOMAIN_V1_1_2 *)InterpProp; + DestroyMemoryDomain_V1_1_2_CS (MemoryDomainV1_1_2->MemoryDomain); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryDomainFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryDomain_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryDomainToStructWrapper, + MemoryDomainToJson, + MemoryDomainDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_1_2/RedfishMemoryDomain_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/MemoryDomain/v1_1_2/RedfishMemoryDomain_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..a4f35814958 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_1_2/RedfishMemoryDomain_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryDomain.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryDomain_V1_1_2_Dxe + FILE_GUID = d24eee16-650f-4d25-afea-52eaa3fb4a4c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryDomain_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishMemoryDomain_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryDomain_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryDomainV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_1_3/MemoryDomain_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/MemoryDomain/v1_1_3/MemoryDomain_V1_1_3_Dxe.c new file mode 100644 index 00000000000..7bcf8a50a7a --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_1_3/MemoryDomain_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryDomain.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryDomain"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryDomain V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryDomain", + "1", + "1", + "3" + }, + "MemoryDomain" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_1_3 *MemoryDomainV1_1_3; + EFI_REDFISH_MEMORYDOMAIN_V1_1_3_CS *MemoryDomainV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryDomain") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryDomain_V1_1_3_To_CS (ResoruceRaw, &MemoryDomainV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryDomainV1_1_3 = (EFI_REDFISH_MEMORYDOMAIN_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYDOMAIN_V1_1_3)); + if (MemoryDomainV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryDomainV1_1_3; + MemoryDomainV1_1_3->MemoryDomain = MemoryDomainV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryDomainToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryDomainToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryDomain_V1_1_3_JSON (*((EFI_REDFISH_MEMORYDOMAIN_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryDomainToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_1_3 *MemoryDomainV1_1_3; + + MemoryDomainV1_1_3 = (EFI_REDFISH_MEMORYDOMAIN_V1_1_3 *)InterpProp; + DestroyMemoryDomain_V1_1_3_CS (MemoryDomainV1_1_3->MemoryDomain); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryDomainFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryDomain_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryDomainToStructWrapper, + MemoryDomainToJson, + MemoryDomainDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_1_3/RedfishMemoryDomain_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/MemoryDomain/v1_1_3/RedfishMemoryDomain_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..9e93e03d9c3 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_1_3/RedfishMemoryDomain_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryDomain.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryDomain_V1_1_3_Dxe + FILE_GUID = 330a772d-3fad-4b6a-bb60-dd1a1cf21cda + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryDomain_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishMemoryDomain_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryDomain_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryDomainV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_1_4/MemoryDomain_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/MemoryDomain/v1_1_4/MemoryDomain_V1_1_4_Dxe.c new file mode 100644 index 00000000000..6dc2700dc31 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_1_4/MemoryDomain_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryDomain.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryDomain"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryDomain V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryDomain", + "1", + "1", + "4" + }, + "MemoryDomain" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_1_4 *MemoryDomainV1_1_4; + EFI_REDFISH_MEMORYDOMAIN_V1_1_4_CS *MemoryDomainV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryDomain") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryDomain_V1_1_4_To_CS (ResoruceRaw, &MemoryDomainV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryDomainV1_1_4 = (EFI_REDFISH_MEMORYDOMAIN_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYDOMAIN_V1_1_4)); + if (MemoryDomainV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryDomainV1_1_4; + MemoryDomainV1_1_4->MemoryDomain = MemoryDomainV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryDomainToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryDomainToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryDomain_V1_1_4_JSON (*((EFI_REDFISH_MEMORYDOMAIN_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryDomainToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_1_4 *MemoryDomainV1_1_4; + + MemoryDomainV1_1_4 = (EFI_REDFISH_MEMORYDOMAIN_V1_1_4 *)InterpProp; + DestroyMemoryDomain_V1_1_4_CS (MemoryDomainV1_1_4->MemoryDomain); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryDomainFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryDomain_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryDomainToStructWrapper, + MemoryDomainToJson, + MemoryDomainDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_1_4/RedfishMemoryDomain_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/MemoryDomain/v1_1_4/RedfishMemoryDomain_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..c04491d9b02 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_1_4/RedfishMemoryDomain_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryDomain.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryDomain_V1_1_4_Dxe + FILE_GUID = ff28c469-01b5-4997-a91a-bfcaf954b10f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryDomain_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishMemoryDomain_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryDomain_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryDomainV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_2_0/MemoryDomain_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/MemoryDomain/v1_2_0/MemoryDomain_V1_2_0_Dxe.c new file mode 100644 index 00000000000..86a8a0c4013 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_2_0/MemoryDomain_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryDomain.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryDomain"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryDomain V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryDomain", + "1", + "2", + "0" + }, + "MemoryDomain" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_2_0 *MemoryDomainV1_2_0; + EFI_REDFISH_MEMORYDOMAIN_V1_2_0_CS *MemoryDomainV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryDomain") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryDomain_V1_2_0_To_CS (ResoruceRaw, &MemoryDomainV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryDomainV1_2_0 = (EFI_REDFISH_MEMORYDOMAIN_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYDOMAIN_V1_2_0)); + if (MemoryDomainV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryDomainV1_2_0; + MemoryDomainV1_2_0->MemoryDomain = MemoryDomainV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryDomainToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryDomainToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryDomain_V1_2_0_JSON (*((EFI_REDFISH_MEMORYDOMAIN_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryDomainToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_2_0 *MemoryDomainV1_2_0; + + MemoryDomainV1_2_0 = (EFI_REDFISH_MEMORYDOMAIN_V1_2_0 *)InterpProp; + DestroyMemoryDomain_V1_2_0_CS (MemoryDomainV1_2_0->MemoryDomain); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryDomainFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryDomain_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryDomainToStructWrapper, + MemoryDomainToJson, + MemoryDomainDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_2_0/RedfishMemoryDomain_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/MemoryDomain/v1_2_0/RedfishMemoryDomain_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..9ffc89d4a2d --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_2_0/RedfishMemoryDomain_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryDomain.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryDomain_V1_2_0_Dxe + FILE_GUID = c7ae03ca-3b76-4718-9412-ad82031fdb30 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryDomain_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishMemoryDomain_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryDomain_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryDomainV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_2_1/MemoryDomain_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/MemoryDomain/v1_2_1/MemoryDomain_V1_2_1_Dxe.c new file mode 100644 index 00000000000..bb3fb65616f --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_2_1/MemoryDomain_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryDomain.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryDomain"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryDomain V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryDomain", + "1", + "2", + "1" + }, + "MemoryDomain" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_2_1 *MemoryDomainV1_2_1; + EFI_REDFISH_MEMORYDOMAIN_V1_2_1_CS *MemoryDomainV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryDomain") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryDomain_V1_2_1_To_CS (ResoruceRaw, &MemoryDomainV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryDomainV1_2_1 = (EFI_REDFISH_MEMORYDOMAIN_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYDOMAIN_V1_2_1)); + if (MemoryDomainV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryDomainV1_2_1; + MemoryDomainV1_2_1->MemoryDomain = MemoryDomainV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryDomainToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryDomainToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryDomain_V1_2_1_JSON (*((EFI_REDFISH_MEMORYDOMAIN_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryDomainToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_2_1 *MemoryDomainV1_2_1; + + MemoryDomainV1_2_1 = (EFI_REDFISH_MEMORYDOMAIN_V1_2_1 *)InterpProp; + DestroyMemoryDomain_V1_2_1_CS (MemoryDomainV1_2_1->MemoryDomain); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryDomainFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryDomain_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryDomainToStructWrapper, + MemoryDomainToJson, + MemoryDomainDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_2_1/RedfishMemoryDomain_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/MemoryDomain/v1_2_1/RedfishMemoryDomain_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..d53ce2124dd --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_2_1/RedfishMemoryDomain_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryDomain.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryDomain_V1_2_1_Dxe + FILE_GUID = 4161c21f-4c9e-43f6-bfee-2089109e3075 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryDomain_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishMemoryDomain_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryDomain_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryDomainV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_2_2/MemoryDomain_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/MemoryDomain/v1_2_2/MemoryDomain_V1_2_2_Dxe.c new file mode 100644 index 00000000000..1eec69c775f --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_2_2/MemoryDomain_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryDomain.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryDomain"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryDomain V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryDomain", + "1", + "2", + "2" + }, + "MemoryDomain" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_2_2 *MemoryDomainV1_2_2; + EFI_REDFISH_MEMORYDOMAIN_V1_2_2_CS *MemoryDomainV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryDomain") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryDomain_V1_2_2_To_CS (ResoruceRaw, &MemoryDomainV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryDomainV1_2_2 = (EFI_REDFISH_MEMORYDOMAIN_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYDOMAIN_V1_2_2)); + if (MemoryDomainV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryDomainV1_2_2; + MemoryDomainV1_2_2->MemoryDomain = MemoryDomainV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryDomainToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryDomainToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryDomain_V1_2_2_JSON (*((EFI_REDFISH_MEMORYDOMAIN_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryDomainToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_2_2 *MemoryDomainV1_2_2; + + MemoryDomainV1_2_2 = (EFI_REDFISH_MEMORYDOMAIN_V1_2_2 *)InterpProp; + DestroyMemoryDomain_V1_2_2_CS (MemoryDomainV1_2_2->MemoryDomain); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryDomainFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryDomain_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryDomainToStructWrapper, + MemoryDomainToJson, + MemoryDomainDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_2_2/RedfishMemoryDomain_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/MemoryDomain/v1_2_2/RedfishMemoryDomain_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..cda7113a7af --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_2_2/RedfishMemoryDomain_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryDomain.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryDomain_V1_2_2_Dxe + FILE_GUID = 87b02fb4-9d92-4067-b5c3-f422c0f9740f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryDomain_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishMemoryDomain_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryDomain_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryDomainV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_2_3/MemoryDomain_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/MemoryDomain/v1_2_3/MemoryDomain_V1_2_3_Dxe.c new file mode 100644 index 00000000000..d38f74b5f2e --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_2_3/MemoryDomain_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryDomain.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryDomain"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryDomain V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryDomain", + "1", + "2", + "3" + }, + "MemoryDomain" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_2_3 *MemoryDomainV1_2_3; + EFI_REDFISH_MEMORYDOMAIN_V1_2_3_CS *MemoryDomainV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryDomain") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryDomain_V1_2_3_To_CS (ResoruceRaw, &MemoryDomainV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryDomainV1_2_3 = (EFI_REDFISH_MEMORYDOMAIN_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYDOMAIN_V1_2_3)); + if (MemoryDomainV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryDomainV1_2_3; + MemoryDomainV1_2_3->MemoryDomain = MemoryDomainV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryDomainToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryDomainToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryDomain_V1_2_3_JSON (*((EFI_REDFISH_MEMORYDOMAIN_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryDomainToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_2_3 *MemoryDomainV1_2_3; + + MemoryDomainV1_2_3 = (EFI_REDFISH_MEMORYDOMAIN_V1_2_3 *)InterpProp; + DestroyMemoryDomain_V1_2_3_CS (MemoryDomainV1_2_3->MemoryDomain); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryDomainFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryDomain_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryDomainToStructWrapper, + MemoryDomainToJson, + MemoryDomainDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_2_3/RedfishMemoryDomain_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/MemoryDomain/v1_2_3/RedfishMemoryDomain_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..5155634f745 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_2_3/RedfishMemoryDomain_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryDomain.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryDomain_V1_2_3_Dxe + FILE_GUID = 5aa6a2b6-51b1-4688-9b9b-0d96e3773a25 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryDomain_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishMemoryDomain_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryDomain_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryDomainV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_3_0/MemoryDomain_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/MemoryDomain/v1_3_0/MemoryDomain_V1_3_0_Dxe.c new file mode 100644 index 00000000000..715f189310d --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_3_0/MemoryDomain_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryDomain.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryDomain"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryDomain V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryDomain", + "1", + "3", + "0" + }, + "MemoryDomain" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_3_0 *MemoryDomainV1_3_0; + EFI_REDFISH_MEMORYDOMAIN_V1_3_0_CS *MemoryDomainV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryDomain") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryDomain_V1_3_0_To_CS (ResoruceRaw, &MemoryDomainV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryDomainV1_3_0 = (EFI_REDFISH_MEMORYDOMAIN_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYDOMAIN_V1_3_0)); + if (MemoryDomainV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryDomainV1_3_0; + MemoryDomainV1_3_0->MemoryDomain = MemoryDomainV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryDomain"), "MemoryDomain"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryDomainToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryDomainToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryDomain_V1_3_0_JSON (*((EFI_REDFISH_MEMORYDOMAIN_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryDomainToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAIN_V1_3_0 *MemoryDomainV1_3_0; + + MemoryDomainV1_3_0 = (EFI_REDFISH_MEMORYDOMAIN_V1_3_0 *)InterpProp; + DestroyMemoryDomain_V1_3_0_CS (MemoryDomainV1_3_0->MemoryDomain); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryDomainFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryDomain_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryDomainToStructWrapper, + MemoryDomainToJson, + MemoryDomainDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomain_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryDomain/v1_3_0/RedfishMemoryDomain_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/MemoryDomain/v1_3_0/RedfishMemoryDomain_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..916cab5423c --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomain/v1_3_0/RedfishMemoryDomain_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryDomain.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryDomain_V1_3_0_Dxe + FILE_GUID = 4b464ec5-bd46-4c9b-9de1-7dad15f7b5ba + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryDomain_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishMemoryDomain_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryDomain_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryDomainV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryDomainCollection/MemoryDomainCollection_Dxe.c b/RedfishClientPkg/Converter/MemoryDomainCollection/MemoryDomainCollection_Dxe.c new file mode 100644 index 00000000000..57ac9a5f185 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomainCollection/MemoryDomainCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryDomainCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryDomainCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support MemoryDomainCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryDomainCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "MemoryDomainCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAINCOLLECTION *MemoryDomainCollection; + EFI_REDFISH_MEMORYDOMAINCOLLECTION_CS *MemoryDomainCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryDomainCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryDomainCollection_To_CS (ResoruceRaw, &MemoryDomainCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryDomainCollection = (EFI_REDFISH_MEMORYDOMAINCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYDOMAINCOLLECTION)); + if (MemoryDomainCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryDomainCollection; + MemoryDomainCollection->MemoryDomainCollection = MemoryDomainCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomainCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryDomainCollection"), "MemoryDomainCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryDomainCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryDomainCollection"), "MemoryDomainCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryDomainCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryDomainCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryDomainCollection_JSON (*((EFI_REDFISH_MEMORYDOMAINCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryDomainCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYDOMAINCOLLECTION *MemoryDomainCollection; + + MemoryDomainCollection = (EFI_REDFISH_MEMORYDOMAINCOLLECTION *)InterpProp; + DestroyMemoryDomainCollection_CS (MemoryDomainCollection->MemoryDomainCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryDomainCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryDomainCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryDomainCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomainCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryDomainCollectionToStructWrapper, + MemoryDomainCollectionToJson, + MemoryDomainCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryDomainCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryDomainCollection/RedfishMemoryDomainCollection_Dxe.inf b/RedfishClientPkg/Converter/MemoryDomainCollection/RedfishMemoryDomainCollection_Dxe.inf new file mode 100644 index 00000000000..99cb4dd9077 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryDomainCollection/RedfishMemoryDomainCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryDomainCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryDomainCollection_Dxe + FILE_GUID = 73f31772-c45f-4e28-ac83-3a1afbab94a6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryDomainCollectionEntryPoint + UNLOAD_IMAGE = RedfishMemoryDomainCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryDomainCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryDomainCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_0_0/MemoryMetrics_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_0/MemoryMetrics_V1_0_0_Dxe.c new file mode 100644 index 00000000000..2d879b042af --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_0/MemoryMetrics_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryMetrics.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryMetrics V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryMetrics", + "1", + "0", + "0" + }, + "MemoryMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_0_0 *MemoryMetricsV1_0_0; + EFI_REDFISH_MEMORYMETRICS_V1_0_0_CS *MemoryMetricsV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryMetrics_V1_0_0_To_CS (ResoruceRaw, &MemoryMetricsV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryMetricsV1_0_0 = (EFI_REDFISH_MEMORYMETRICS_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYMETRICS_V1_0_0)); + if (MemoryMetricsV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryMetricsV1_0_0; + MemoryMetricsV1_0_0->MemoryMetrics = MemoryMetricsV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryMetrics_V1_0_0_JSON (*((EFI_REDFISH_MEMORYMETRICS_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_0_0 *MemoryMetricsV1_0_0; + + MemoryMetricsV1_0_0 = (EFI_REDFISH_MEMORYMETRICS_V1_0_0 *)InterpProp; + DestroyMemoryMetrics_V1_0_0_CS (MemoryMetricsV1_0_0->MemoryMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryMetrics_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryMetricsToStructWrapper, + MemoryMetricsToJson, + MemoryMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_0_0/RedfishMemoryMetrics_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_0/RedfishMemoryMetrics_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..717d58cca9e --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_0/RedfishMemoryMetrics_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryMetrics.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryMetrics_V1_0_0_Dxe + FILE_GUID = 68f01b5d-4f3d-4709-b980-b7e7768a28fb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryMetrics_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishMemoryMetrics_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryMetrics_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryMetricsV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_0_1/MemoryMetrics_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_1/MemoryMetrics_V1_0_1_Dxe.c new file mode 100644 index 00000000000..5ba8f46c5da --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_1/MemoryMetrics_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryMetrics.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryMetrics V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryMetrics", + "1", + "0", + "1" + }, + "MemoryMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_0_1 *MemoryMetricsV1_0_1; + EFI_REDFISH_MEMORYMETRICS_V1_0_1_CS *MemoryMetricsV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryMetrics_V1_0_1_To_CS (ResoruceRaw, &MemoryMetricsV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryMetricsV1_0_1 = (EFI_REDFISH_MEMORYMETRICS_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYMETRICS_V1_0_1)); + if (MemoryMetricsV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryMetricsV1_0_1; + MemoryMetricsV1_0_1->MemoryMetrics = MemoryMetricsV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryMetrics_V1_0_1_JSON (*((EFI_REDFISH_MEMORYMETRICS_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_0_1 *MemoryMetricsV1_0_1; + + MemoryMetricsV1_0_1 = (EFI_REDFISH_MEMORYMETRICS_V1_0_1 *)InterpProp; + DestroyMemoryMetrics_V1_0_1_CS (MemoryMetricsV1_0_1->MemoryMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryMetrics_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryMetricsToStructWrapper, + MemoryMetricsToJson, + MemoryMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_0_1/RedfishMemoryMetrics_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_1/RedfishMemoryMetrics_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..b74d4fcce94 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_1/RedfishMemoryMetrics_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryMetrics.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryMetrics_V1_0_1_Dxe + FILE_GUID = 5419db13-ae5a-4604-95b1-673c4ad8fc1b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryMetrics_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishMemoryMetrics_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryMetrics_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryMetricsV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_0_2/MemoryMetrics_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_2/MemoryMetrics_V1_0_2_Dxe.c new file mode 100644 index 00000000000..8ab29e35272 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_2/MemoryMetrics_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryMetrics.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryMetrics V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryMetrics", + "1", + "0", + "2" + }, + "MemoryMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_0_2 *MemoryMetricsV1_0_2; + EFI_REDFISH_MEMORYMETRICS_V1_0_2_CS *MemoryMetricsV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryMetrics_V1_0_2_To_CS (ResoruceRaw, &MemoryMetricsV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryMetricsV1_0_2 = (EFI_REDFISH_MEMORYMETRICS_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYMETRICS_V1_0_2)); + if (MemoryMetricsV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryMetricsV1_0_2; + MemoryMetricsV1_0_2->MemoryMetrics = MemoryMetricsV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryMetrics_V1_0_2_JSON (*((EFI_REDFISH_MEMORYMETRICS_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_0_2 *MemoryMetricsV1_0_2; + + MemoryMetricsV1_0_2 = (EFI_REDFISH_MEMORYMETRICS_V1_0_2 *)InterpProp; + DestroyMemoryMetrics_V1_0_2_CS (MemoryMetricsV1_0_2->MemoryMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryMetrics_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryMetricsToStructWrapper, + MemoryMetricsToJson, + MemoryMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_0_2/RedfishMemoryMetrics_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_2/RedfishMemoryMetrics_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..e0a9de543c6 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_2/RedfishMemoryMetrics_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryMetrics.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryMetrics_V1_0_2_Dxe + FILE_GUID = 8d72bf22-b004-4d34-9053-2b0ce11b997b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryMetrics_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishMemoryMetrics_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryMetrics_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryMetricsV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_0_3/MemoryMetrics_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_3/MemoryMetrics_V1_0_3_Dxe.c new file mode 100644 index 00000000000..1e119e2d5ae --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_3/MemoryMetrics_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryMetrics.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryMetrics V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryMetrics", + "1", + "0", + "3" + }, + "MemoryMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_0_3 *MemoryMetricsV1_0_3; + EFI_REDFISH_MEMORYMETRICS_V1_0_3_CS *MemoryMetricsV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryMetrics_V1_0_3_To_CS (ResoruceRaw, &MemoryMetricsV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryMetricsV1_0_3 = (EFI_REDFISH_MEMORYMETRICS_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYMETRICS_V1_0_3)); + if (MemoryMetricsV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryMetricsV1_0_3; + MemoryMetricsV1_0_3->MemoryMetrics = MemoryMetricsV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryMetrics_V1_0_3_JSON (*((EFI_REDFISH_MEMORYMETRICS_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_0_3 *MemoryMetricsV1_0_3; + + MemoryMetricsV1_0_3 = (EFI_REDFISH_MEMORYMETRICS_V1_0_3 *)InterpProp; + DestroyMemoryMetrics_V1_0_3_CS (MemoryMetricsV1_0_3->MemoryMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryMetrics_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryMetricsToStructWrapper, + MemoryMetricsToJson, + MemoryMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_0_3/RedfishMemoryMetrics_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_3/RedfishMemoryMetrics_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..d18aeafc208 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_3/RedfishMemoryMetrics_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryMetrics.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryMetrics_V1_0_3_Dxe + FILE_GUID = c5ccd81e-ef83-4901-a646-b63acf8f6381 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryMetrics_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishMemoryMetrics_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryMetrics_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryMetricsV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_0_4/MemoryMetrics_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_4/MemoryMetrics_V1_0_4_Dxe.c new file mode 100644 index 00000000000..a045e005f4b --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_4/MemoryMetrics_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryMetrics.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryMetrics V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryMetrics", + "1", + "0", + "4" + }, + "MemoryMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_0_4 *MemoryMetricsV1_0_4; + EFI_REDFISH_MEMORYMETRICS_V1_0_4_CS *MemoryMetricsV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryMetrics_V1_0_4_To_CS (ResoruceRaw, &MemoryMetricsV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryMetricsV1_0_4 = (EFI_REDFISH_MEMORYMETRICS_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYMETRICS_V1_0_4)); + if (MemoryMetricsV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryMetricsV1_0_4; + MemoryMetricsV1_0_4->MemoryMetrics = MemoryMetricsV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryMetrics_V1_0_4_JSON (*((EFI_REDFISH_MEMORYMETRICS_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_0_4 *MemoryMetricsV1_0_4; + + MemoryMetricsV1_0_4 = (EFI_REDFISH_MEMORYMETRICS_V1_0_4 *)InterpProp; + DestroyMemoryMetrics_V1_0_4_CS (MemoryMetricsV1_0_4->MemoryMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryMetrics_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryMetricsToStructWrapper, + MemoryMetricsToJson, + MemoryMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_0_4/RedfishMemoryMetrics_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_4/RedfishMemoryMetrics_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..0b33263786c --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_4/RedfishMemoryMetrics_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryMetrics.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryMetrics_V1_0_4_Dxe + FILE_GUID = 9dbc7c3c-66a5-4f39-8e82-af986c2509eb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryMetrics_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishMemoryMetrics_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryMetrics_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryMetricsV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_0_5/MemoryMetrics_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_5/MemoryMetrics_V1_0_5_Dxe.c new file mode 100644 index 00000000000..f8e7b68d341 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_5/MemoryMetrics_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryMetrics.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryMetrics V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryMetrics", + "1", + "0", + "5" + }, + "MemoryMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_0_5 *MemoryMetricsV1_0_5; + EFI_REDFISH_MEMORYMETRICS_V1_0_5_CS *MemoryMetricsV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryMetrics_V1_0_5_To_CS (ResoruceRaw, &MemoryMetricsV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryMetricsV1_0_5 = (EFI_REDFISH_MEMORYMETRICS_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYMETRICS_V1_0_5)); + if (MemoryMetricsV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryMetricsV1_0_5; + MemoryMetricsV1_0_5->MemoryMetrics = MemoryMetricsV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryMetrics_V1_0_5_JSON (*((EFI_REDFISH_MEMORYMETRICS_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_0_5 *MemoryMetricsV1_0_5; + + MemoryMetricsV1_0_5 = (EFI_REDFISH_MEMORYMETRICS_V1_0_5 *)InterpProp; + DestroyMemoryMetrics_V1_0_5_CS (MemoryMetricsV1_0_5->MemoryMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryMetrics_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryMetricsToStructWrapper, + MemoryMetricsToJson, + MemoryMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_0_5/RedfishMemoryMetrics_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_5/RedfishMemoryMetrics_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..986651671e4 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_5/RedfishMemoryMetrics_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryMetrics.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryMetrics_V1_0_5_Dxe + FILE_GUID = 9ad42a1d-56dc-415b-b51d-e968aca3b175 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryMetrics_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishMemoryMetrics_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryMetrics_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryMetricsV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_0_6/MemoryMetrics_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_6/MemoryMetrics_V1_0_6_Dxe.c new file mode 100644 index 00000000000..0a2c0c3df9d --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_6/MemoryMetrics_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryMetrics.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryMetrics V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryMetrics", + "1", + "0", + "6" + }, + "MemoryMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_0_6 *MemoryMetricsV1_0_6; + EFI_REDFISH_MEMORYMETRICS_V1_0_6_CS *MemoryMetricsV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryMetrics_V1_0_6_To_CS (ResoruceRaw, &MemoryMetricsV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryMetricsV1_0_6 = (EFI_REDFISH_MEMORYMETRICS_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYMETRICS_V1_0_6)); + if (MemoryMetricsV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryMetricsV1_0_6; + MemoryMetricsV1_0_6->MemoryMetrics = MemoryMetricsV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryMetrics_V1_0_6_JSON (*((EFI_REDFISH_MEMORYMETRICS_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_0_6 *MemoryMetricsV1_0_6; + + MemoryMetricsV1_0_6 = (EFI_REDFISH_MEMORYMETRICS_V1_0_6 *)InterpProp; + DestroyMemoryMetrics_V1_0_6_CS (MemoryMetricsV1_0_6->MemoryMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryMetrics_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryMetricsToStructWrapper, + MemoryMetricsToJson, + MemoryMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_0_6/RedfishMemoryMetrics_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_6/RedfishMemoryMetrics_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..45ccff1dd17 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_6/RedfishMemoryMetrics_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryMetrics.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryMetrics_V1_0_6_Dxe + FILE_GUID = e86057ea-371c-4d09-9cc3-a045843837ea + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryMetrics_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishMemoryMetrics_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryMetrics_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryMetricsV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_0_7/MemoryMetrics_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_7/MemoryMetrics_V1_0_7_Dxe.c new file mode 100644 index 00000000000..8808451fa46 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_7/MemoryMetrics_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryMetrics.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryMetrics V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryMetrics", + "1", + "0", + "7" + }, + "MemoryMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_0_7 *MemoryMetricsV1_0_7; + EFI_REDFISH_MEMORYMETRICS_V1_0_7_CS *MemoryMetricsV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryMetrics_V1_0_7_To_CS (ResoruceRaw, &MemoryMetricsV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryMetricsV1_0_7 = (EFI_REDFISH_MEMORYMETRICS_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYMETRICS_V1_0_7)); + if (MemoryMetricsV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryMetricsV1_0_7; + MemoryMetricsV1_0_7->MemoryMetrics = MemoryMetricsV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryMetrics_V1_0_7_JSON (*((EFI_REDFISH_MEMORYMETRICS_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_0_7 *MemoryMetricsV1_0_7; + + MemoryMetricsV1_0_7 = (EFI_REDFISH_MEMORYMETRICS_V1_0_7 *)InterpProp; + DestroyMemoryMetrics_V1_0_7_CS (MemoryMetricsV1_0_7->MemoryMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryMetrics_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryMetricsToStructWrapper, + MemoryMetricsToJson, + MemoryMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_0_7/RedfishMemoryMetrics_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_7/RedfishMemoryMetrics_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..08d71dbb954 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_7/RedfishMemoryMetrics_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryMetrics.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryMetrics_V1_0_7_Dxe + FILE_GUID = 8d1ac2ad-6775-4153-b4b2-408cd18e031d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryMetrics_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishMemoryMetrics_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryMetrics_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryMetricsV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_0_8/MemoryMetrics_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_8/MemoryMetrics_V1_0_8_Dxe.c new file mode 100644 index 00000000000..03645265c42 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_8/MemoryMetrics_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryMetrics.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryMetrics V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryMetrics", + "1", + "0", + "8" + }, + "MemoryMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_0_8 *MemoryMetricsV1_0_8; + EFI_REDFISH_MEMORYMETRICS_V1_0_8_CS *MemoryMetricsV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryMetrics_V1_0_8_To_CS (ResoruceRaw, &MemoryMetricsV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryMetricsV1_0_8 = (EFI_REDFISH_MEMORYMETRICS_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYMETRICS_V1_0_8)); + if (MemoryMetricsV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryMetricsV1_0_8; + MemoryMetricsV1_0_8->MemoryMetrics = MemoryMetricsV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryMetrics_V1_0_8_JSON (*((EFI_REDFISH_MEMORYMETRICS_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_0_8 *MemoryMetricsV1_0_8; + + MemoryMetricsV1_0_8 = (EFI_REDFISH_MEMORYMETRICS_V1_0_8 *)InterpProp; + DestroyMemoryMetrics_V1_0_8_CS (MemoryMetricsV1_0_8->MemoryMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryMetrics_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryMetricsToStructWrapper, + MemoryMetricsToJson, + MemoryMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_0_8/RedfishMemoryMetrics_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_8/RedfishMemoryMetrics_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..544cab41997 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_0_8/RedfishMemoryMetrics_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryMetrics.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryMetrics_V1_0_8_Dxe + FILE_GUID = 05c43193-e9f0-49c9-b069-60b422d35ccc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryMetrics_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishMemoryMetrics_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryMetrics_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryMetricsV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_1_1/MemoryMetrics_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_1/MemoryMetrics_V1_1_1_Dxe.c new file mode 100644 index 00000000000..b69e243f692 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_1/MemoryMetrics_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryMetrics.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryMetrics V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryMetrics", + "1", + "1", + "1" + }, + "MemoryMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_1_1 *MemoryMetricsV1_1_1; + EFI_REDFISH_MEMORYMETRICS_V1_1_1_CS *MemoryMetricsV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryMetrics_V1_1_1_To_CS (ResoruceRaw, &MemoryMetricsV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryMetricsV1_1_1 = (EFI_REDFISH_MEMORYMETRICS_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYMETRICS_V1_1_1)); + if (MemoryMetricsV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryMetricsV1_1_1; + MemoryMetricsV1_1_1->MemoryMetrics = MemoryMetricsV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryMetrics_V1_1_1_JSON (*((EFI_REDFISH_MEMORYMETRICS_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_1_1 *MemoryMetricsV1_1_1; + + MemoryMetricsV1_1_1 = (EFI_REDFISH_MEMORYMETRICS_V1_1_1 *)InterpProp; + DestroyMemoryMetrics_V1_1_1_CS (MemoryMetricsV1_1_1->MemoryMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryMetrics_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryMetricsToStructWrapper, + MemoryMetricsToJson, + MemoryMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_1_1/RedfishMemoryMetrics_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_1/RedfishMemoryMetrics_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..b70171f682f --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_1/RedfishMemoryMetrics_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryMetrics.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryMetrics_V1_1_1_Dxe + FILE_GUID = b5389b3f-f51e-4629-a07f-70bcb2500c72 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryMetrics_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishMemoryMetrics_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryMetrics_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryMetricsV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_1_2/MemoryMetrics_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_2/MemoryMetrics_V1_1_2_Dxe.c new file mode 100644 index 00000000000..2cb6c8eec10 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_2/MemoryMetrics_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryMetrics.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryMetrics V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryMetrics", + "1", + "1", + "2" + }, + "MemoryMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_1_2 *MemoryMetricsV1_1_2; + EFI_REDFISH_MEMORYMETRICS_V1_1_2_CS *MemoryMetricsV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryMetrics_V1_1_2_To_CS (ResoruceRaw, &MemoryMetricsV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryMetricsV1_1_2 = (EFI_REDFISH_MEMORYMETRICS_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYMETRICS_V1_1_2)); + if (MemoryMetricsV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryMetricsV1_1_2; + MemoryMetricsV1_1_2->MemoryMetrics = MemoryMetricsV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryMetrics_V1_1_2_JSON (*((EFI_REDFISH_MEMORYMETRICS_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_1_2 *MemoryMetricsV1_1_2; + + MemoryMetricsV1_1_2 = (EFI_REDFISH_MEMORYMETRICS_V1_1_2 *)InterpProp; + DestroyMemoryMetrics_V1_1_2_CS (MemoryMetricsV1_1_2->MemoryMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryMetrics_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryMetricsToStructWrapper, + MemoryMetricsToJson, + MemoryMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_1_2/RedfishMemoryMetrics_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_2/RedfishMemoryMetrics_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..fc6fa3136b4 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_2/RedfishMemoryMetrics_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryMetrics.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryMetrics_V1_1_2_Dxe + FILE_GUID = 45787794-f348-4a17-ac2d-1799a3546d94 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryMetrics_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishMemoryMetrics_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryMetrics_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryMetricsV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_1_3/MemoryMetrics_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_3/MemoryMetrics_V1_1_3_Dxe.c new file mode 100644 index 00000000000..44e912e0fa4 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_3/MemoryMetrics_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryMetrics.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryMetrics V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryMetrics", + "1", + "1", + "3" + }, + "MemoryMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_1_3 *MemoryMetricsV1_1_3; + EFI_REDFISH_MEMORYMETRICS_V1_1_3_CS *MemoryMetricsV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryMetrics_V1_1_3_To_CS (ResoruceRaw, &MemoryMetricsV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryMetricsV1_1_3 = (EFI_REDFISH_MEMORYMETRICS_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYMETRICS_V1_1_3)); + if (MemoryMetricsV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryMetricsV1_1_3; + MemoryMetricsV1_1_3->MemoryMetrics = MemoryMetricsV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryMetrics_V1_1_3_JSON (*((EFI_REDFISH_MEMORYMETRICS_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_1_3 *MemoryMetricsV1_1_3; + + MemoryMetricsV1_1_3 = (EFI_REDFISH_MEMORYMETRICS_V1_1_3 *)InterpProp; + DestroyMemoryMetrics_V1_1_3_CS (MemoryMetricsV1_1_3->MemoryMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryMetrics_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryMetricsToStructWrapper, + MemoryMetricsToJson, + MemoryMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_1_3/RedfishMemoryMetrics_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_3/RedfishMemoryMetrics_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..5ce2cc9a27a --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_3/RedfishMemoryMetrics_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryMetrics.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryMetrics_V1_1_3_Dxe + FILE_GUID = 1e34c5b5-f6cf-4b69-a02b-2e482770b123 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryMetrics_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishMemoryMetrics_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryMetrics_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryMetricsV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_1_4/MemoryMetrics_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_4/MemoryMetrics_V1_1_4_Dxe.c new file mode 100644 index 00000000000..6feb354fe17 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_4/MemoryMetrics_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryMetrics.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryMetrics V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryMetrics", + "1", + "1", + "4" + }, + "MemoryMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_1_4 *MemoryMetricsV1_1_4; + EFI_REDFISH_MEMORYMETRICS_V1_1_4_CS *MemoryMetricsV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryMetrics_V1_1_4_To_CS (ResoruceRaw, &MemoryMetricsV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryMetricsV1_1_4 = (EFI_REDFISH_MEMORYMETRICS_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYMETRICS_V1_1_4)); + if (MemoryMetricsV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryMetricsV1_1_4; + MemoryMetricsV1_1_4->MemoryMetrics = MemoryMetricsV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryMetrics_V1_1_4_JSON (*((EFI_REDFISH_MEMORYMETRICS_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_1_4 *MemoryMetricsV1_1_4; + + MemoryMetricsV1_1_4 = (EFI_REDFISH_MEMORYMETRICS_V1_1_4 *)InterpProp; + DestroyMemoryMetrics_V1_1_4_CS (MemoryMetricsV1_1_4->MemoryMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryMetrics_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryMetricsToStructWrapper, + MemoryMetricsToJson, + MemoryMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_1_4/RedfishMemoryMetrics_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_4/RedfishMemoryMetrics_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..bbfc71fd9f7 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_4/RedfishMemoryMetrics_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryMetrics.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryMetrics_V1_1_4_Dxe + FILE_GUID = 815ee72b-2882-4649-a00f-9f5beaddc9c9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryMetrics_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishMemoryMetrics_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryMetrics_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryMetricsV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_1_5/MemoryMetrics_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_5/MemoryMetrics_V1_1_5_Dxe.c new file mode 100644 index 00000000000..42c72289881 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_5/MemoryMetrics_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryMetrics.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryMetrics V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryMetrics", + "1", + "1", + "5" + }, + "MemoryMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_1_5 *MemoryMetricsV1_1_5; + EFI_REDFISH_MEMORYMETRICS_V1_1_5_CS *MemoryMetricsV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryMetrics_V1_1_5_To_CS (ResoruceRaw, &MemoryMetricsV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryMetricsV1_1_5 = (EFI_REDFISH_MEMORYMETRICS_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYMETRICS_V1_1_5)); + if (MemoryMetricsV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryMetricsV1_1_5; + MemoryMetricsV1_1_5->MemoryMetrics = MemoryMetricsV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryMetrics_V1_1_5_JSON (*((EFI_REDFISH_MEMORYMETRICS_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_1_5 *MemoryMetricsV1_1_5; + + MemoryMetricsV1_1_5 = (EFI_REDFISH_MEMORYMETRICS_V1_1_5 *)InterpProp; + DestroyMemoryMetrics_V1_1_5_CS (MemoryMetricsV1_1_5->MemoryMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryMetrics_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryMetricsToStructWrapper, + MemoryMetricsToJson, + MemoryMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_1_5/RedfishMemoryMetrics_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_5/RedfishMemoryMetrics_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..e830a01e15f --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_5/RedfishMemoryMetrics_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryMetrics.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryMetrics_V1_1_5_Dxe + FILE_GUID = f4cb4fb3-86d5-43b0-bceb-6310e478f1df + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryMetrics_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishMemoryMetrics_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryMetrics_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryMetricsV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_1_6/MemoryMetrics_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_6/MemoryMetrics_V1_1_6_Dxe.c new file mode 100644 index 00000000000..b457f79158f --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_6/MemoryMetrics_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryMetrics.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryMetrics V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryMetrics", + "1", + "1", + "6" + }, + "MemoryMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_1_6 *MemoryMetricsV1_1_6; + EFI_REDFISH_MEMORYMETRICS_V1_1_6_CS *MemoryMetricsV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryMetrics_V1_1_6_To_CS (ResoruceRaw, &MemoryMetricsV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryMetricsV1_1_6 = (EFI_REDFISH_MEMORYMETRICS_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYMETRICS_V1_1_6)); + if (MemoryMetricsV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryMetricsV1_1_6; + MemoryMetricsV1_1_6->MemoryMetrics = MemoryMetricsV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryMetrics_V1_1_6_JSON (*((EFI_REDFISH_MEMORYMETRICS_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_1_6 *MemoryMetricsV1_1_6; + + MemoryMetricsV1_1_6 = (EFI_REDFISH_MEMORYMETRICS_V1_1_6 *)InterpProp; + DestroyMemoryMetrics_V1_1_6_CS (MemoryMetricsV1_1_6->MemoryMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryMetrics_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryMetricsToStructWrapper, + MemoryMetricsToJson, + MemoryMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_1_6/RedfishMemoryMetrics_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_6/RedfishMemoryMetrics_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..037ca833afe --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_6/RedfishMemoryMetrics_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryMetrics.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryMetrics_V1_1_6_Dxe + FILE_GUID = 0687897a-6052-4a7b-aef1-d8e5db1e94ed + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryMetrics_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishMemoryMetrics_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryMetrics_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryMetricsV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_1_7/MemoryMetrics_V1_1_7_Dxe.c b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_7/MemoryMetrics_V1_1_7_Dxe.c new file mode 100644 index 00000000000..ae09dcd240e --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_7/MemoryMetrics_V1_1_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryMetrics.v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryMetrics V1_1_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryMetrics", + "1", + "1", + "7" + }, + "MemoryMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_1_7 *MemoryMetricsV1_1_7; + EFI_REDFISH_MEMORYMETRICS_V1_1_7_CS *MemoryMetricsV1_1_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryMetrics_V1_1_7_To_CS (ResoruceRaw, &MemoryMetricsV1_1_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryMetricsV1_1_7 = (EFI_REDFISH_MEMORYMETRICS_V1_1_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYMETRICS_V1_1_7)); + if (MemoryMetricsV1_1_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryMetricsV1_1_7; + MemoryMetricsV1_1_7->MemoryMetrics = MemoryMetricsV1_1_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryMetrics_V1_1_7_JSON (*((EFI_REDFISH_MEMORYMETRICS_V1_1_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_1_7 *MemoryMetricsV1_1_7; + + MemoryMetricsV1_1_7 = (EFI_REDFISH_MEMORYMETRICS_V1_1_7 *)InterpProp; + DestroyMemoryMetrics_V1_1_7_CS (MemoryMetricsV1_1_7->MemoryMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryMetrics_V1_1_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_1_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryMetricsToStructWrapper, + MemoryMetricsToJson, + MemoryMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_1_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_1_7/RedfishMemoryMetrics_V1_1_7_Dxe.inf b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_7/RedfishMemoryMetrics_V1_1_7_Dxe.inf new file mode 100644 index 00000000000..eacd8503d69 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_7/RedfishMemoryMetrics_V1_1_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryMetrics.v1_1_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryMetrics_V1_1_7_Dxe + FILE_GUID = 8187d404-0cbf-4a04-9554-cce28900bfaa + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryMetrics_V1_1_7EntryPoint + UNLOAD_IMAGE = RedfishMemoryMetrics_V1_1_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryMetrics_V1_1_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryMetricsV1_1_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_1_8/MemoryMetrics_V1_1_8_Dxe.c b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_8/MemoryMetrics_V1_1_8_Dxe.c new file mode 100644 index 00000000000..3eb2e3a6cf3 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_8/MemoryMetrics_V1_1_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryMetrics.v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryMetrics V1_1_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryMetrics", + "1", + "1", + "8" + }, + "MemoryMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_1_8 *MemoryMetricsV1_1_8; + EFI_REDFISH_MEMORYMETRICS_V1_1_8_CS *MemoryMetricsV1_1_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryMetrics_V1_1_8_To_CS (ResoruceRaw, &MemoryMetricsV1_1_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryMetricsV1_1_8 = (EFI_REDFISH_MEMORYMETRICS_V1_1_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYMETRICS_V1_1_8)); + if (MemoryMetricsV1_1_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryMetricsV1_1_8; + MemoryMetricsV1_1_8->MemoryMetrics = MemoryMetricsV1_1_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryMetrics_V1_1_8_JSON (*((EFI_REDFISH_MEMORYMETRICS_V1_1_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_1_8 *MemoryMetricsV1_1_8; + + MemoryMetricsV1_1_8 = (EFI_REDFISH_MEMORYMETRICS_V1_1_8 *)InterpProp; + DestroyMemoryMetrics_V1_1_8_CS (MemoryMetricsV1_1_8->MemoryMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryMetrics_V1_1_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_1_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryMetricsToStructWrapper, + MemoryMetricsToJson, + MemoryMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_1_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_1_8/RedfishMemoryMetrics_V1_1_8_Dxe.inf b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_8/RedfishMemoryMetrics_V1_1_8_Dxe.inf new file mode 100644 index 00000000000..fe3f416c6db --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_1_8/RedfishMemoryMetrics_V1_1_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryMetrics.v1_1_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryMetrics_V1_1_8_Dxe + FILE_GUID = fb760a91-fb7c-413f-9c61-194e955cb050 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryMetrics_V1_1_8EntryPoint + UNLOAD_IMAGE = RedfishMemoryMetrics_V1_1_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryMetrics_V1_1_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryMetricsV1_1_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_2_0/MemoryMetrics_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/MemoryMetrics/v1_2_0/MemoryMetrics_V1_2_0_Dxe.c new file mode 100644 index 00000000000..bc2a5349152 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_2_0/MemoryMetrics_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryMetrics.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryMetrics V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryMetrics", + "1", + "2", + "0" + }, + "MemoryMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_2_0 *MemoryMetricsV1_2_0; + EFI_REDFISH_MEMORYMETRICS_V1_2_0_CS *MemoryMetricsV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryMetrics_V1_2_0_To_CS (ResoruceRaw, &MemoryMetricsV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryMetricsV1_2_0 = (EFI_REDFISH_MEMORYMETRICS_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYMETRICS_V1_2_0)); + if (MemoryMetricsV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryMetricsV1_2_0; + MemoryMetricsV1_2_0->MemoryMetrics = MemoryMetricsV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryMetrics_V1_2_0_JSON (*((EFI_REDFISH_MEMORYMETRICS_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_2_0 *MemoryMetricsV1_2_0; + + MemoryMetricsV1_2_0 = (EFI_REDFISH_MEMORYMETRICS_V1_2_0 *)InterpProp; + DestroyMemoryMetrics_V1_2_0_CS (MemoryMetricsV1_2_0->MemoryMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryMetrics_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryMetricsToStructWrapper, + MemoryMetricsToJson, + MemoryMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_2_0/RedfishMemoryMetrics_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/MemoryMetrics/v1_2_0/RedfishMemoryMetrics_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..7cfea4cd9f3 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_2_0/RedfishMemoryMetrics_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryMetrics.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryMetrics_V1_2_0_Dxe + FILE_GUID = 1eca8df2-53ff-4c7d-83cb-7f27c79b9e12 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryMetrics_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishMemoryMetrics_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryMetrics_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryMetricsV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_2_1/MemoryMetrics_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/MemoryMetrics/v1_2_1/MemoryMetrics_V1_2_1_Dxe.c new file mode 100644 index 00000000000..95d28f3aa72 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_2_1/MemoryMetrics_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryMetrics.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryMetrics V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryMetrics", + "1", + "2", + "1" + }, + "MemoryMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_2_1 *MemoryMetricsV1_2_1; + EFI_REDFISH_MEMORYMETRICS_V1_2_1_CS *MemoryMetricsV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryMetrics_V1_2_1_To_CS (ResoruceRaw, &MemoryMetricsV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryMetricsV1_2_1 = (EFI_REDFISH_MEMORYMETRICS_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYMETRICS_V1_2_1)); + if (MemoryMetricsV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryMetricsV1_2_1; + MemoryMetricsV1_2_1->MemoryMetrics = MemoryMetricsV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryMetrics_V1_2_1_JSON (*((EFI_REDFISH_MEMORYMETRICS_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_2_1 *MemoryMetricsV1_2_1; + + MemoryMetricsV1_2_1 = (EFI_REDFISH_MEMORYMETRICS_V1_2_1 *)InterpProp; + DestroyMemoryMetrics_V1_2_1_CS (MemoryMetricsV1_2_1->MemoryMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryMetrics_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryMetricsToStructWrapper, + MemoryMetricsToJson, + MemoryMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_2_1/RedfishMemoryMetrics_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/MemoryMetrics/v1_2_1/RedfishMemoryMetrics_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..6d5e820efb8 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_2_1/RedfishMemoryMetrics_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryMetrics.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryMetrics_V1_2_1_Dxe + FILE_GUID = b2852c8f-ae28-4605-995c-d46159b1c20a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryMetrics_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishMemoryMetrics_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryMetrics_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryMetricsV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_2_2/MemoryMetrics_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/MemoryMetrics/v1_2_2/MemoryMetrics_V1_2_2_Dxe.c new file mode 100644 index 00000000000..1952b5b0038 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_2_2/MemoryMetrics_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryMetrics.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryMetrics V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryMetrics", + "1", + "2", + "2" + }, + "MemoryMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_2_2 *MemoryMetricsV1_2_2; + EFI_REDFISH_MEMORYMETRICS_V1_2_2_CS *MemoryMetricsV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryMetrics_V1_2_2_To_CS (ResoruceRaw, &MemoryMetricsV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryMetricsV1_2_2 = (EFI_REDFISH_MEMORYMETRICS_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYMETRICS_V1_2_2)); + if (MemoryMetricsV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryMetricsV1_2_2; + MemoryMetricsV1_2_2->MemoryMetrics = MemoryMetricsV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryMetrics_V1_2_2_JSON (*((EFI_REDFISH_MEMORYMETRICS_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_2_2 *MemoryMetricsV1_2_2; + + MemoryMetricsV1_2_2 = (EFI_REDFISH_MEMORYMETRICS_V1_2_2 *)InterpProp; + DestroyMemoryMetrics_V1_2_2_CS (MemoryMetricsV1_2_2->MemoryMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryMetrics_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryMetricsToStructWrapper, + MemoryMetricsToJson, + MemoryMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_2_2/RedfishMemoryMetrics_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/MemoryMetrics/v1_2_2/RedfishMemoryMetrics_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..079bacb8f9f --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_2_2/RedfishMemoryMetrics_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryMetrics.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryMetrics_V1_2_2_Dxe + FILE_GUID = 7a9f8514-25d7-48bb-8417-53e2ecf562e2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryMetrics_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishMemoryMetrics_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryMetrics_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryMetricsV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_3_0/MemoryMetrics_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/MemoryMetrics/v1_3_0/MemoryMetrics_V1_3_0_Dxe.c new file mode 100644 index 00000000000..2c0f622cd02 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_3_0/MemoryMetrics_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryMetrics.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryMetrics V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryMetrics", + "1", + "3", + "0" + }, + "MemoryMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_3_0 *MemoryMetricsV1_3_0; + EFI_REDFISH_MEMORYMETRICS_V1_3_0_CS *MemoryMetricsV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryMetrics_V1_3_0_To_CS (ResoruceRaw, &MemoryMetricsV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryMetricsV1_3_0 = (EFI_REDFISH_MEMORYMETRICS_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYMETRICS_V1_3_0)); + if (MemoryMetricsV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryMetricsV1_3_0; + MemoryMetricsV1_3_0->MemoryMetrics = MemoryMetricsV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryMetrics_V1_3_0_JSON (*((EFI_REDFISH_MEMORYMETRICS_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_3_0 *MemoryMetricsV1_3_0; + + MemoryMetricsV1_3_0 = (EFI_REDFISH_MEMORYMETRICS_V1_3_0 *)InterpProp; + DestroyMemoryMetrics_V1_3_0_CS (MemoryMetricsV1_3_0->MemoryMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryMetrics_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryMetricsToStructWrapper, + MemoryMetricsToJson, + MemoryMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_3_0/RedfishMemoryMetrics_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/MemoryMetrics/v1_3_0/RedfishMemoryMetrics_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..9ead3d3333b --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_3_0/RedfishMemoryMetrics_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryMetrics.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryMetrics_V1_3_0_Dxe + FILE_GUID = 0443aea0-de10-4bb4-9a02-e30f7047a44e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryMetrics_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishMemoryMetrics_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryMetrics_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryMetricsV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_3_1/MemoryMetrics_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/MemoryMetrics/v1_3_1/MemoryMetrics_V1_3_1_Dxe.c new file mode 100644 index 00000000000..2b6fb1f67f8 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_3_1/MemoryMetrics_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryMetrics.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryMetrics V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryMetrics", + "1", + "3", + "1" + }, + "MemoryMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_3_1 *MemoryMetricsV1_3_1; + EFI_REDFISH_MEMORYMETRICS_V1_3_1_CS *MemoryMetricsV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryMetrics_V1_3_1_To_CS (ResoruceRaw, &MemoryMetricsV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryMetricsV1_3_1 = (EFI_REDFISH_MEMORYMETRICS_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYMETRICS_V1_3_1)); + if (MemoryMetricsV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryMetricsV1_3_1; + MemoryMetricsV1_3_1->MemoryMetrics = MemoryMetricsV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryMetrics_V1_3_1_JSON (*((EFI_REDFISH_MEMORYMETRICS_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_3_1 *MemoryMetricsV1_3_1; + + MemoryMetricsV1_3_1 = (EFI_REDFISH_MEMORYMETRICS_V1_3_1 *)InterpProp; + DestroyMemoryMetrics_V1_3_1_CS (MemoryMetricsV1_3_1->MemoryMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryMetrics_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryMetricsToStructWrapper, + MemoryMetricsToJson, + MemoryMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_3_1/RedfishMemoryMetrics_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/MemoryMetrics/v1_3_1/RedfishMemoryMetrics_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..1960bf6e109 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_3_1/RedfishMemoryMetrics_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryMetrics.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryMetrics_V1_3_1_Dxe + FILE_GUID = 68161090-ff37-45f9-a2d9-f7aeb08b5922 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryMetrics_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishMemoryMetrics_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryMetrics_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryMetricsV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_4_0/MemoryMetrics_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/MemoryMetrics/v1_4_0/MemoryMetrics_V1_4_0_Dxe.c new file mode 100644 index 00000000000..3690b9ff6c3 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_4_0/MemoryMetrics_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryMetrics.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryMetrics V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryMetrics", + "1", + "4", + "0" + }, + "MemoryMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_4_0 *MemoryMetricsV1_4_0; + EFI_REDFISH_MEMORYMETRICS_V1_4_0_CS *MemoryMetricsV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryMetrics_V1_4_0_To_CS (ResoruceRaw, &MemoryMetricsV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryMetricsV1_4_0 = (EFI_REDFISH_MEMORYMETRICS_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYMETRICS_V1_4_0)); + if (MemoryMetricsV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryMetricsV1_4_0; + MemoryMetricsV1_4_0->MemoryMetrics = MemoryMetricsV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryMetrics_V1_4_0_JSON (*((EFI_REDFISH_MEMORYMETRICS_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_4_0 *MemoryMetricsV1_4_0; + + MemoryMetricsV1_4_0 = (EFI_REDFISH_MEMORYMETRICS_V1_4_0 *)InterpProp; + DestroyMemoryMetrics_V1_4_0_CS (MemoryMetricsV1_4_0->MemoryMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryMetrics_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryMetricsToStructWrapper, + MemoryMetricsToJson, + MemoryMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_4_0/RedfishMemoryMetrics_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/MemoryMetrics/v1_4_0/RedfishMemoryMetrics_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..301d0b45d82 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_4_0/RedfishMemoryMetrics_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryMetrics.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryMetrics_V1_4_0_Dxe + FILE_GUID = 839cc67a-aec2-4ec5-b91b-9d37be2dbf8d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryMetrics_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishMemoryMetrics_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryMetrics_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryMetricsV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_4_1/MemoryMetrics_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/MemoryMetrics/v1_4_1/MemoryMetrics_V1_4_1_Dxe.c new file mode 100644 index 00000000000..3cffa9884c3 --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_4_1/MemoryMetrics_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MemoryMetrics.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MemoryMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support MemoryMetrics V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MemoryMetrics", + "1", + "4", + "1" + }, + "MemoryMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_4_1 *MemoryMetricsV1_4_1; + EFI_REDFISH_MEMORYMETRICS_V1_4_1_CS *MemoryMetricsV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MemoryMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MemoryMetrics_V1_4_1_To_CS (ResoruceRaw, &MemoryMetricsV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MemoryMetricsV1_4_1 = (EFI_REDFISH_MEMORYMETRICS_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MEMORYMETRICS_V1_4_1)); + if (MemoryMetricsV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MemoryMetricsV1_4_1; + MemoryMetricsV1_4_1->MemoryMetrics = MemoryMetricsV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MemoryMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MemoryMetrics"), "MemoryMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MemoryMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MemoryMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MemoryMetrics_V1_4_1_JSON (*((EFI_REDFISH_MEMORYMETRICS_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MemoryMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MEMORYMETRICS_V1_4_1 *MemoryMetricsV1_4_1; + + MemoryMetricsV1_4_1 = (EFI_REDFISH_MEMORYMETRICS_V1_4_1 *)InterpProp; + DestroyMemoryMetrics_V1_4_1_CS (MemoryMetricsV1_4_1->MemoryMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MemoryMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MemoryMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMemoryMetrics_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MemoryMetricsToStructWrapper, + MemoryMetricsToJson, + MemoryMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMemoryMetrics_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MemoryMetrics/v1_4_1/RedfishMemoryMetrics_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/MemoryMetrics/v1_4_1/RedfishMemoryMetrics_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..50edb1a61fc --- /dev/null +++ b/RedfishClientPkg/Converter/MemoryMetrics/v1_4_1/RedfishMemoryMetrics_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MemoryMetrics.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMemoryMetrics_V1_4_1_Dxe + FILE_GUID = df76561d-cc47-45bb-a1ec-c4a89b155ad0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMemoryMetrics_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishMemoryMetrics_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MemoryMetrics_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MemoryMetricsV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_0_0/MessageRegistry_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_0_0/MessageRegistry_V1_0_0_Dxe.c new file mode 100644 index 00000000000..52c8cd78ece --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_0_0/MessageRegistry_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "0", + "0" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_0_0 *MessageRegistryV1_0_0; + EFI_REDFISH_MESSAGEREGISTRY_V1_0_0_CS *MessageRegistryV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_0_0_To_CS (ResoruceRaw, &MessageRegistryV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_0_0 = (EFI_REDFISH_MESSAGEREGISTRY_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_0_0)); + if (MessageRegistryV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_0_0; + MessageRegistryV1_0_0->MessageRegistry = MessageRegistryV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_0_0_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_0_0 *MessageRegistryV1_0_0; + + MessageRegistryV1_0_0 = (EFI_REDFISH_MESSAGEREGISTRY_V1_0_0 *)InterpProp; + DestroyMessageRegistry_V1_0_0_CS (MessageRegistryV1_0_0->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_0_0/RedfishMessageRegistry_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_0_0/RedfishMessageRegistry_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..f8a804adab6 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_0_0/RedfishMessageRegistry_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_0_0_Dxe + FILE_GUID = df0141db-84c9-4f13-8e8f-612aaa2a0bb7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_0_10/MessageRegistry_V1_0_10_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_0_10/MessageRegistry_V1_0_10_Dxe.c new file mode 100644 index 00000000000..5eaf3b1993b --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_0_10/MessageRegistry_V1_0_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_0_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "0", + "10" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_0_10 *MessageRegistryV1_0_10; + EFI_REDFISH_MESSAGEREGISTRY_V1_0_10_CS *MessageRegistryV1_0_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_0_10_To_CS (ResoruceRaw, &MessageRegistryV1_0_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_0_10 = (EFI_REDFISH_MESSAGEREGISTRY_V1_0_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_0_10)); + if (MessageRegistryV1_0_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_0_10; + MessageRegistryV1_0_10->MessageRegistry = MessageRegistryV1_0_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_0_10_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_0_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_0_10 *MessageRegistryV1_0_10; + + MessageRegistryV1_0_10 = (EFI_REDFISH_MESSAGEREGISTRY_V1_0_10 *)InterpProp; + DestroyMessageRegistry_V1_0_10_CS (MessageRegistryV1_0_10->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_0_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_0_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_0_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_0_10/RedfishMessageRegistry_V1_0_10_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_0_10/RedfishMessageRegistry_V1_0_10_Dxe.inf new file mode 100644 index 00000000000..850a5f4f37f --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_0_10/RedfishMessageRegistry_V1_0_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_0_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_0_10_Dxe + FILE_GUID = fa9a3d5a-06de-401f-b07f-d9906d516547 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_0_10EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_0_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_0_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_0_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_0_2/MessageRegistry_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_0_2/MessageRegistry_V1_0_2_Dxe.c new file mode 100644 index 00000000000..fcc1114a716 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_0_2/MessageRegistry_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "0", + "2" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_0_2 *MessageRegistryV1_0_2; + EFI_REDFISH_MESSAGEREGISTRY_V1_0_2_CS *MessageRegistryV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_0_2_To_CS (ResoruceRaw, &MessageRegistryV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_0_2 = (EFI_REDFISH_MESSAGEREGISTRY_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_0_2)); + if (MessageRegistryV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_0_2; + MessageRegistryV1_0_2->MessageRegistry = MessageRegistryV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_0_2_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_0_2 *MessageRegistryV1_0_2; + + MessageRegistryV1_0_2 = (EFI_REDFISH_MESSAGEREGISTRY_V1_0_2 *)InterpProp; + DestroyMessageRegistry_V1_0_2_CS (MessageRegistryV1_0_2->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_0_2/RedfishMessageRegistry_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_0_2/RedfishMessageRegistry_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..52db6c8476c --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_0_2/RedfishMessageRegistry_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_0_2_Dxe + FILE_GUID = c134198e-772e-41ea-9f73-e141b56f2838 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_0_3/MessageRegistry_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_0_3/MessageRegistry_V1_0_3_Dxe.c new file mode 100644 index 00000000000..7cabe0ec69c --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_0_3/MessageRegistry_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "0", + "3" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_0_3 *MessageRegistryV1_0_3; + EFI_REDFISH_MESSAGEREGISTRY_V1_0_3_CS *MessageRegistryV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_0_3_To_CS (ResoruceRaw, &MessageRegistryV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_0_3 = (EFI_REDFISH_MESSAGEREGISTRY_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_0_3)); + if (MessageRegistryV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_0_3; + MessageRegistryV1_0_3->MessageRegistry = MessageRegistryV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_0_3_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_0_3 *MessageRegistryV1_0_3; + + MessageRegistryV1_0_3 = (EFI_REDFISH_MESSAGEREGISTRY_V1_0_3 *)InterpProp; + DestroyMessageRegistry_V1_0_3_CS (MessageRegistryV1_0_3->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_0_3/RedfishMessageRegistry_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_0_3/RedfishMessageRegistry_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..8a6c5930d87 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_0_3/RedfishMessageRegistry_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_0_3_Dxe + FILE_GUID = 9b9f4558-73c1-4187-9b7f-b8a5ece6ea8b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_0_4/MessageRegistry_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_0_4/MessageRegistry_V1_0_4_Dxe.c new file mode 100644 index 00000000000..0d52c70b973 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_0_4/MessageRegistry_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "0", + "4" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_0_4 *MessageRegistryV1_0_4; + EFI_REDFISH_MESSAGEREGISTRY_V1_0_4_CS *MessageRegistryV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_0_4_To_CS (ResoruceRaw, &MessageRegistryV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_0_4 = (EFI_REDFISH_MESSAGEREGISTRY_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_0_4)); + if (MessageRegistryV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_0_4; + MessageRegistryV1_0_4->MessageRegistry = MessageRegistryV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_0_4_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_0_4 *MessageRegistryV1_0_4; + + MessageRegistryV1_0_4 = (EFI_REDFISH_MESSAGEREGISTRY_V1_0_4 *)InterpProp; + DestroyMessageRegistry_V1_0_4_CS (MessageRegistryV1_0_4->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_0_4/RedfishMessageRegistry_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_0_4/RedfishMessageRegistry_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..5c8b99b388a --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_0_4/RedfishMessageRegistry_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_0_4_Dxe + FILE_GUID = cdb26267-9ce2-46df-8058-fb284afc1e1d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_0_5/MessageRegistry_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_0_5/MessageRegistry_V1_0_5_Dxe.c new file mode 100644 index 00000000000..e88cecf87ae --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_0_5/MessageRegistry_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "0", + "5" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_0_5 *MessageRegistryV1_0_5; + EFI_REDFISH_MESSAGEREGISTRY_V1_0_5_CS *MessageRegistryV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_0_5_To_CS (ResoruceRaw, &MessageRegistryV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_0_5 = (EFI_REDFISH_MESSAGEREGISTRY_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_0_5)); + if (MessageRegistryV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_0_5; + MessageRegistryV1_0_5->MessageRegistry = MessageRegistryV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_0_5_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_0_5 *MessageRegistryV1_0_5; + + MessageRegistryV1_0_5 = (EFI_REDFISH_MESSAGEREGISTRY_V1_0_5 *)InterpProp; + DestroyMessageRegistry_V1_0_5_CS (MessageRegistryV1_0_5->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_0_5/RedfishMessageRegistry_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_0_5/RedfishMessageRegistry_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..292cb53e1f5 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_0_5/RedfishMessageRegistry_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_0_5_Dxe + FILE_GUID = 71a54113-6086-4495-9e8b-e7e0e4a18381 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_0_6/MessageRegistry_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_0_6/MessageRegistry_V1_0_6_Dxe.c new file mode 100644 index 00000000000..5d1ebd96051 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_0_6/MessageRegistry_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "0", + "6" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_0_6 *MessageRegistryV1_0_6; + EFI_REDFISH_MESSAGEREGISTRY_V1_0_6_CS *MessageRegistryV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_0_6_To_CS (ResoruceRaw, &MessageRegistryV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_0_6 = (EFI_REDFISH_MESSAGEREGISTRY_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_0_6)); + if (MessageRegistryV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_0_6; + MessageRegistryV1_0_6->MessageRegistry = MessageRegistryV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_0_6_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_0_6 *MessageRegistryV1_0_6; + + MessageRegistryV1_0_6 = (EFI_REDFISH_MESSAGEREGISTRY_V1_0_6 *)InterpProp; + DestroyMessageRegistry_V1_0_6_CS (MessageRegistryV1_0_6->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_0_6/RedfishMessageRegistry_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_0_6/RedfishMessageRegistry_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..592f5e617d6 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_0_6/RedfishMessageRegistry_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_0_6_Dxe + FILE_GUID = 09da2d5d-7998-4bce-9b74-42cfbab53784 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_0_7/MessageRegistry_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_0_7/MessageRegistry_V1_0_7_Dxe.c new file mode 100644 index 00000000000..3ee005360b5 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_0_7/MessageRegistry_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "0", + "7" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_0_7 *MessageRegistryV1_0_7; + EFI_REDFISH_MESSAGEREGISTRY_V1_0_7_CS *MessageRegistryV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_0_7_To_CS (ResoruceRaw, &MessageRegistryV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_0_7 = (EFI_REDFISH_MESSAGEREGISTRY_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_0_7)); + if (MessageRegistryV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_0_7; + MessageRegistryV1_0_7->MessageRegistry = MessageRegistryV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_0_7_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_0_7 *MessageRegistryV1_0_7; + + MessageRegistryV1_0_7 = (EFI_REDFISH_MESSAGEREGISTRY_V1_0_7 *)InterpProp; + DestroyMessageRegistry_V1_0_7_CS (MessageRegistryV1_0_7->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_0_7/RedfishMessageRegistry_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_0_7/RedfishMessageRegistry_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..9c85c834faa --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_0_7/RedfishMessageRegistry_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_0_7_Dxe + FILE_GUID = a5ae0ea5-6faf-4b26-9123-eca109961800 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_0_8/MessageRegistry_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_0_8/MessageRegistry_V1_0_8_Dxe.c new file mode 100644 index 00000000000..39ea0fa17af --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_0_8/MessageRegistry_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "0", + "8" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_0_8 *MessageRegistryV1_0_8; + EFI_REDFISH_MESSAGEREGISTRY_V1_0_8_CS *MessageRegistryV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_0_8_To_CS (ResoruceRaw, &MessageRegistryV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_0_8 = (EFI_REDFISH_MESSAGEREGISTRY_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_0_8)); + if (MessageRegistryV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_0_8; + MessageRegistryV1_0_8->MessageRegistry = MessageRegistryV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_0_8_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_0_8 *MessageRegistryV1_0_8; + + MessageRegistryV1_0_8 = (EFI_REDFISH_MESSAGEREGISTRY_V1_0_8 *)InterpProp; + DestroyMessageRegistry_V1_0_8_CS (MessageRegistryV1_0_8->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_0_8/RedfishMessageRegistry_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_0_8/RedfishMessageRegistry_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..edcfbc8ba25 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_0_8/RedfishMessageRegistry_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_0_8_Dxe + FILE_GUID = f31828d5-990a-458d-9b3e-665b59f887e9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_0_9/MessageRegistry_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_0_9/MessageRegistry_V1_0_9_Dxe.c new file mode 100644 index 00000000000..080d1cac844 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_0_9/MessageRegistry_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "0", + "9" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_0_9 *MessageRegistryV1_0_9; + EFI_REDFISH_MESSAGEREGISTRY_V1_0_9_CS *MessageRegistryV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_0_9_To_CS (ResoruceRaw, &MessageRegistryV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_0_9 = (EFI_REDFISH_MESSAGEREGISTRY_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_0_9)); + if (MessageRegistryV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_0_9; + MessageRegistryV1_0_9->MessageRegistry = MessageRegistryV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_0_9_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_0_9 *MessageRegistryV1_0_9; + + MessageRegistryV1_0_9 = (EFI_REDFISH_MESSAGEREGISTRY_V1_0_9 *)InterpProp; + DestroyMessageRegistry_V1_0_9_CS (MessageRegistryV1_0_9->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_0_9/RedfishMessageRegistry_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_0_9/RedfishMessageRegistry_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..245e5bd6949 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_0_9/RedfishMessageRegistry_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_0_9_Dxe + FILE_GUID = eb74b285-15f0-46a8-a012-d5c759875dac + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_1_0/MessageRegistry_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_1_0/MessageRegistry_V1_1_0_Dxe.c new file mode 100644 index 00000000000..b8ad52c07c1 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_1_0/MessageRegistry_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "1", + "0" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_1_0 *MessageRegistryV1_1_0; + EFI_REDFISH_MESSAGEREGISTRY_V1_1_0_CS *MessageRegistryV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_1_0_To_CS (ResoruceRaw, &MessageRegistryV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_1_0 = (EFI_REDFISH_MESSAGEREGISTRY_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_1_0)); + if (MessageRegistryV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_1_0; + MessageRegistryV1_1_0->MessageRegistry = MessageRegistryV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_1_0_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_1_0 *MessageRegistryV1_1_0; + + MessageRegistryV1_1_0 = (EFI_REDFISH_MESSAGEREGISTRY_V1_1_0 *)InterpProp; + DestroyMessageRegistry_V1_1_0_CS (MessageRegistryV1_1_0->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_1_0/RedfishMessageRegistry_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_1_0/RedfishMessageRegistry_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..49f9606c62c --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_1_0/RedfishMessageRegistry_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_1_0_Dxe + FILE_GUID = cf9646d7-815e-472d-be1d-d2dee9027228 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_1_1/MessageRegistry_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_1_1/MessageRegistry_V1_1_1_Dxe.c new file mode 100644 index 00000000000..5a73bc531dd --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_1_1/MessageRegistry_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "1", + "1" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_1_1 *MessageRegistryV1_1_1; + EFI_REDFISH_MESSAGEREGISTRY_V1_1_1_CS *MessageRegistryV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_1_1_To_CS (ResoruceRaw, &MessageRegistryV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_1_1 = (EFI_REDFISH_MESSAGEREGISTRY_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_1_1)); + if (MessageRegistryV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_1_1; + MessageRegistryV1_1_1->MessageRegistry = MessageRegistryV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_1_1_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_1_1 *MessageRegistryV1_1_1; + + MessageRegistryV1_1_1 = (EFI_REDFISH_MESSAGEREGISTRY_V1_1_1 *)InterpProp; + DestroyMessageRegistry_V1_1_1_CS (MessageRegistryV1_1_1->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_1_1/RedfishMessageRegistry_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_1_1/RedfishMessageRegistry_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..e48236411b6 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_1_1/RedfishMessageRegistry_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_1_1_Dxe + FILE_GUID = 47402d43-94a0-4ded-8cdd-d7783ee9531b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_1_2/MessageRegistry_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_1_2/MessageRegistry_V1_1_2_Dxe.c new file mode 100644 index 00000000000..ad47fcb0426 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_1_2/MessageRegistry_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "1", + "2" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_1_2 *MessageRegistryV1_1_2; + EFI_REDFISH_MESSAGEREGISTRY_V1_1_2_CS *MessageRegistryV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_1_2_To_CS (ResoruceRaw, &MessageRegistryV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_1_2 = (EFI_REDFISH_MESSAGEREGISTRY_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_1_2)); + if (MessageRegistryV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_1_2; + MessageRegistryV1_1_2->MessageRegistry = MessageRegistryV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_1_2_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_1_2 *MessageRegistryV1_1_2; + + MessageRegistryV1_1_2 = (EFI_REDFISH_MESSAGEREGISTRY_V1_1_2 *)InterpProp; + DestroyMessageRegistry_V1_1_2_CS (MessageRegistryV1_1_2->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_1_2/RedfishMessageRegistry_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_1_2/RedfishMessageRegistry_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..9a20d46f4b7 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_1_2/RedfishMessageRegistry_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_1_2_Dxe + FILE_GUID = 61d2a1b4-8d6a-41be-9d2b-2c5452c04be6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_1_3/MessageRegistry_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_1_3/MessageRegistry_V1_1_3_Dxe.c new file mode 100644 index 00000000000..9d23da7f840 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_1_3/MessageRegistry_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "1", + "3" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_1_3 *MessageRegistryV1_1_3; + EFI_REDFISH_MESSAGEREGISTRY_V1_1_3_CS *MessageRegistryV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_1_3_To_CS (ResoruceRaw, &MessageRegistryV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_1_3 = (EFI_REDFISH_MESSAGEREGISTRY_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_1_3)); + if (MessageRegistryV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_1_3; + MessageRegistryV1_1_3->MessageRegistry = MessageRegistryV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_1_3_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_1_3 *MessageRegistryV1_1_3; + + MessageRegistryV1_1_3 = (EFI_REDFISH_MESSAGEREGISTRY_V1_1_3 *)InterpProp; + DestroyMessageRegistry_V1_1_3_CS (MessageRegistryV1_1_3->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_1_3/RedfishMessageRegistry_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_1_3/RedfishMessageRegistry_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..a5334e1f778 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_1_3/RedfishMessageRegistry_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_1_3_Dxe + FILE_GUID = ec8b0df2-d983-45de-9893-09648fee3076 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_1_4/MessageRegistry_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_1_4/MessageRegistry_V1_1_4_Dxe.c new file mode 100644 index 00000000000..927008f604e --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_1_4/MessageRegistry_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "1", + "4" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_1_4 *MessageRegistryV1_1_4; + EFI_REDFISH_MESSAGEREGISTRY_V1_1_4_CS *MessageRegistryV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_1_4_To_CS (ResoruceRaw, &MessageRegistryV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_1_4 = (EFI_REDFISH_MESSAGEREGISTRY_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_1_4)); + if (MessageRegistryV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_1_4; + MessageRegistryV1_1_4->MessageRegistry = MessageRegistryV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_1_4_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_1_4 *MessageRegistryV1_1_4; + + MessageRegistryV1_1_4 = (EFI_REDFISH_MESSAGEREGISTRY_V1_1_4 *)InterpProp; + DestroyMessageRegistry_V1_1_4_CS (MessageRegistryV1_1_4->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_1_4/RedfishMessageRegistry_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_1_4/RedfishMessageRegistry_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..bcb9f756656 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_1_4/RedfishMessageRegistry_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_1_4_Dxe + FILE_GUID = a1015181-396f-4f41-8492-89bcdfb40a7e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_1_5/MessageRegistry_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_1_5/MessageRegistry_V1_1_5_Dxe.c new file mode 100644 index 00000000000..08ffc76e452 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_1_5/MessageRegistry_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "1", + "5" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_1_5 *MessageRegistryV1_1_5; + EFI_REDFISH_MESSAGEREGISTRY_V1_1_5_CS *MessageRegistryV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_1_5_To_CS (ResoruceRaw, &MessageRegistryV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_1_5 = (EFI_REDFISH_MESSAGEREGISTRY_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_1_5)); + if (MessageRegistryV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_1_5; + MessageRegistryV1_1_5->MessageRegistry = MessageRegistryV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_1_5_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_1_5 *MessageRegistryV1_1_5; + + MessageRegistryV1_1_5 = (EFI_REDFISH_MESSAGEREGISTRY_V1_1_5 *)InterpProp; + DestroyMessageRegistry_V1_1_5_CS (MessageRegistryV1_1_5->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_1_5/RedfishMessageRegistry_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_1_5/RedfishMessageRegistry_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..5491b48725b --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_1_5/RedfishMessageRegistry_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_1_5_Dxe + FILE_GUID = f8c59c64-a74c-42a8-be2b-313e0a127162 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_1_6/MessageRegistry_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_1_6/MessageRegistry_V1_1_6_Dxe.c new file mode 100644 index 00000000000..aceadf90681 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_1_6/MessageRegistry_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "1", + "6" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_1_6 *MessageRegistryV1_1_6; + EFI_REDFISH_MESSAGEREGISTRY_V1_1_6_CS *MessageRegistryV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_1_6_To_CS (ResoruceRaw, &MessageRegistryV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_1_6 = (EFI_REDFISH_MESSAGEREGISTRY_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_1_6)); + if (MessageRegistryV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_1_6; + MessageRegistryV1_1_6->MessageRegistry = MessageRegistryV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_1_6_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_1_6 *MessageRegistryV1_1_6; + + MessageRegistryV1_1_6 = (EFI_REDFISH_MESSAGEREGISTRY_V1_1_6 *)InterpProp; + DestroyMessageRegistry_V1_1_6_CS (MessageRegistryV1_1_6->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_1_6/RedfishMessageRegistry_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_1_6/RedfishMessageRegistry_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..980ded40e45 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_1_6/RedfishMessageRegistry_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_1_6_Dxe + FILE_GUID = 2aab2629-0a97-46f2-85d4-9251de566128 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_2_0/MessageRegistry_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_2_0/MessageRegistry_V1_2_0_Dxe.c new file mode 100644 index 00000000000..7eb2a1482c6 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_2_0/MessageRegistry_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "2", + "0" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_2_0 *MessageRegistryV1_2_0; + EFI_REDFISH_MESSAGEREGISTRY_V1_2_0_CS *MessageRegistryV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_2_0_To_CS (ResoruceRaw, &MessageRegistryV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_2_0 = (EFI_REDFISH_MESSAGEREGISTRY_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_2_0)); + if (MessageRegistryV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_2_0; + MessageRegistryV1_2_0->MessageRegistry = MessageRegistryV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_2_0_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_2_0 *MessageRegistryV1_2_0; + + MessageRegistryV1_2_0 = (EFI_REDFISH_MESSAGEREGISTRY_V1_2_0 *)InterpProp; + DestroyMessageRegistry_V1_2_0_CS (MessageRegistryV1_2_0->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_2_0/RedfishMessageRegistry_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_2_0/RedfishMessageRegistry_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..5a271b2e204 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_2_0/RedfishMessageRegistry_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_2_0_Dxe + FILE_GUID = 3034b272-64d2-4f5c-bade-cdd4e2eb391f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_2_1/MessageRegistry_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_2_1/MessageRegistry_V1_2_1_Dxe.c new file mode 100644 index 00000000000..9a899cc2049 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_2_1/MessageRegistry_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "2", + "1" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_2_1 *MessageRegistryV1_2_1; + EFI_REDFISH_MESSAGEREGISTRY_V1_2_1_CS *MessageRegistryV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_2_1_To_CS (ResoruceRaw, &MessageRegistryV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_2_1 = (EFI_REDFISH_MESSAGEREGISTRY_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_2_1)); + if (MessageRegistryV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_2_1; + MessageRegistryV1_2_1->MessageRegistry = MessageRegistryV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_2_1_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_2_1 *MessageRegistryV1_2_1; + + MessageRegistryV1_2_1 = (EFI_REDFISH_MESSAGEREGISTRY_V1_2_1 *)InterpProp; + DestroyMessageRegistry_V1_2_1_CS (MessageRegistryV1_2_1->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_2_1/RedfishMessageRegistry_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_2_1/RedfishMessageRegistry_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..73a0c31a8fc --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_2_1/RedfishMessageRegistry_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_2_1_Dxe + FILE_GUID = 7ed71575-6199-46dd-b1f0-b7a58f1c3027 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_2_2/MessageRegistry_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_2_2/MessageRegistry_V1_2_2_Dxe.c new file mode 100644 index 00000000000..83b08e0c79f --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_2_2/MessageRegistry_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "2", + "2" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_2_2 *MessageRegistryV1_2_2; + EFI_REDFISH_MESSAGEREGISTRY_V1_2_2_CS *MessageRegistryV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_2_2_To_CS (ResoruceRaw, &MessageRegistryV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_2_2 = (EFI_REDFISH_MESSAGEREGISTRY_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_2_2)); + if (MessageRegistryV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_2_2; + MessageRegistryV1_2_2->MessageRegistry = MessageRegistryV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_2_2_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_2_2 *MessageRegistryV1_2_2; + + MessageRegistryV1_2_2 = (EFI_REDFISH_MESSAGEREGISTRY_V1_2_2 *)InterpProp; + DestroyMessageRegistry_V1_2_2_CS (MessageRegistryV1_2_2->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_2_2/RedfishMessageRegistry_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_2_2/RedfishMessageRegistry_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..71079c28bba --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_2_2/RedfishMessageRegistry_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_2_2_Dxe + FILE_GUID = 290197f3-cd4f-4139-93d0-a444184f5f95 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_2_3/MessageRegistry_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_2_3/MessageRegistry_V1_2_3_Dxe.c new file mode 100644 index 00000000000..5f7dd57f7b0 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_2_3/MessageRegistry_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "2", + "3" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_2_3 *MessageRegistryV1_2_3; + EFI_REDFISH_MESSAGEREGISTRY_V1_2_3_CS *MessageRegistryV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_2_3_To_CS (ResoruceRaw, &MessageRegistryV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_2_3 = (EFI_REDFISH_MESSAGEREGISTRY_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_2_3)); + if (MessageRegistryV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_2_3; + MessageRegistryV1_2_3->MessageRegistry = MessageRegistryV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_2_3_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_2_3 *MessageRegistryV1_2_3; + + MessageRegistryV1_2_3 = (EFI_REDFISH_MESSAGEREGISTRY_V1_2_3 *)InterpProp; + DestroyMessageRegistry_V1_2_3_CS (MessageRegistryV1_2_3->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_2_3/RedfishMessageRegistry_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_2_3/RedfishMessageRegistry_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..1a608f84b08 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_2_3/RedfishMessageRegistry_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_2_3_Dxe + FILE_GUID = a8d6aa64-9907-45df-af2c-babb5a6a862d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_2_4/MessageRegistry_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_2_4/MessageRegistry_V1_2_4_Dxe.c new file mode 100644 index 00000000000..a6a90cc20ea --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_2_4/MessageRegistry_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "2", + "4" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_2_4 *MessageRegistryV1_2_4; + EFI_REDFISH_MESSAGEREGISTRY_V1_2_4_CS *MessageRegistryV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_2_4_To_CS (ResoruceRaw, &MessageRegistryV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_2_4 = (EFI_REDFISH_MESSAGEREGISTRY_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_2_4)); + if (MessageRegistryV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_2_4; + MessageRegistryV1_2_4->MessageRegistry = MessageRegistryV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_2_4_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_2_4 *MessageRegistryV1_2_4; + + MessageRegistryV1_2_4 = (EFI_REDFISH_MESSAGEREGISTRY_V1_2_4 *)InterpProp; + DestroyMessageRegistry_V1_2_4_CS (MessageRegistryV1_2_4->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_2_4/RedfishMessageRegistry_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_2_4/RedfishMessageRegistry_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..3913aae99b1 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_2_4/RedfishMessageRegistry_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_2_4_Dxe + FILE_GUID = dd074beb-0303-448d-9cea-b30483029443 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_3_0/MessageRegistry_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_3_0/MessageRegistry_V1_3_0_Dxe.c new file mode 100644 index 00000000000..9b4428077d0 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_3_0/MessageRegistry_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "3", + "0" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_3_0 *MessageRegistryV1_3_0; + EFI_REDFISH_MESSAGEREGISTRY_V1_3_0_CS *MessageRegistryV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_3_0_To_CS (ResoruceRaw, &MessageRegistryV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_3_0 = (EFI_REDFISH_MESSAGEREGISTRY_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_3_0)); + if (MessageRegistryV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_3_0; + MessageRegistryV1_3_0->MessageRegistry = MessageRegistryV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_3_0_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_3_0 *MessageRegistryV1_3_0; + + MessageRegistryV1_3_0 = (EFI_REDFISH_MESSAGEREGISTRY_V1_3_0 *)InterpProp; + DestroyMessageRegistry_V1_3_0_CS (MessageRegistryV1_3_0->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_3_0/RedfishMessageRegistry_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_3_0/RedfishMessageRegistry_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..f55f3c8a15f --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_3_0/RedfishMessageRegistry_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_3_0_Dxe + FILE_GUID = 3e81d4d1-860f-4418-b9db-b34f1df288db + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_3_1/MessageRegistry_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_3_1/MessageRegistry_V1_3_1_Dxe.c new file mode 100644 index 00000000000..63f1aee5e0f --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_3_1/MessageRegistry_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "3", + "1" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_3_1 *MessageRegistryV1_3_1; + EFI_REDFISH_MESSAGEREGISTRY_V1_3_1_CS *MessageRegistryV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_3_1_To_CS (ResoruceRaw, &MessageRegistryV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_3_1 = (EFI_REDFISH_MESSAGEREGISTRY_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_3_1)); + if (MessageRegistryV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_3_1; + MessageRegistryV1_3_1->MessageRegistry = MessageRegistryV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_3_1_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_3_1 *MessageRegistryV1_3_1; + + MessageRegistryV1_3_1 = (EFI_REDFISH_MESSAGEREGISTRY_V1_3_1 *)InterpProp; + DestroyMessageRegistry_V1_3_1_CS (MessageRegistryV1_3_1->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_3_1/RedfishMessageRegistry_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_3_1/RedfishMessageRegistry_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..ecb2b8901cb --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_3_1/RedfishMessageRegistry_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_3_1_Dxe + FILE_GUID = 69f3c1e4-ac2c-4bcf-8c31-84a3d0836b81 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_3_2/MessageRegistry_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_3_2/MessageRegistry_V1_3_2_Dxe.c new file mode 100644 index 00000000000..aa836a7c4c0 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_3_2/MessageRegistry_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "3", + "2" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_3_2 *MessageRegistryV1_3_2; + EFI_REDFISH_MESSAGEREGISTRY_V1_3_2_CS *MessageRegistryV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_3_2_To_CS (ResoruceRaw, &MessageRegistryV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_3_2 = (EFI_REDFISH_MESSAGEREGISTRY_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_3_2)); + if (MessageRegistryV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_3_2; + MessageRegistryV1_3_2->MessageRegistry = MessageRegistryV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_3_2_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_3_2 *MessageRegistryV1_3_2; + + MessageRegistryV1_3_2 = (EFI_REDFISH_MESSAGEREGISTRY_V1_3_2 *)InterpProp; + DestroyMessageRegistry_V1_3_2_CS (MessageRegistryV1_3_2->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_3_2/RedfishMessageRegistry_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_3_2/RedfishMessageRegistry_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..aa3d09ad838 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_3_2/RedfishMessageRegistry_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_3_2_Dxe + FILE_GUID = 18b6dc8f-ede0-46b9-a4b7-07516795116a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_3_3/MessageRegistry_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_3_3/MessageRegistry_V1_3_3_Dxe.c new file mode 100644 index 00000000000..9e2d6885d3d --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_3_3/MessageRegistry_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "3", + "3" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_3_3 *MessageRegistryV1_3_3; + EFI_REDFISH_MESSAGEREGISTRY_V1_3_3_CS *MessageRegistryV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_3_3_To_CS (ResoruceRaw, &MessageRegistryV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_3_3 = (EFI_REDFISH_MESSAGEREGISTRY_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_3_3)); + if (MessageRegistryV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_3_3; + MessageRegistryV1_3_3->MessageRegistry = MessageRegistryV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_3_3_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_3_3 *MessageRegistryV1_3_3; + + MessageRegistryV1_3_3 = (EFI_REDFISH_MESSAGEREGISTRY_V1_3_3 *)InterpProp; + DestroyMessageRegistry_V1_3_3_CS (MessageRegistryV1_3_3->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_3_3/RedfishMessageRegistry_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_3_3/RedfishMessageRegistry_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..64b7e7ed858 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_3_3/RedfishMessageRegistry_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_3_3_Dxe + FILE_GUID = bf90747c-c111-493e-8abe-302bf0ff3de9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_4_0/MessageRegistry_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_4_0/MessageRegistry_V1_4_0_Dxe.c new file mode 100644 index 00000000000..e90a665a015 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_4_0/MessageRegistry_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "4", + "0" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_4_0 *MessageRegistryV1_4_0; + EFI_REDFISH_MESSAGEREGISTRY_V1_4_0_CS *MessageRegistryV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_4_0_To_CS (ResoruceRaw, &MessageRegistryV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_4_0 = (EFI_REDFISH_MESSAGEREGISTRY_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_4_0)); + if (MessageRegistryV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_4_0; + MessageRegistryV1_4_0->MessageRegistry = MessageRegistryV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_4_0_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_4_0 *MessageRegistryV1_4_0; + + MessageRegistryV1_4_0 = (EFI_REDFISH_MESSAGEREGISTRY_V1_4_0 *)InterpProp; + DestroyMessageRegistry_V1_4_0_CS (MessageRegistryV1_4_0->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_4_0/RedfishMessageRegistry_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_4_0/RedfishMessageRegistry_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..2599617f0de --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_4_0/RedfishMessageRegistry_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_4_0_Dxe + FILE_GUID = ad36fc42-bdf6-4506-8051-f0e1abc52879 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_4_1/MessageRegistry_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_4_1/MessageRegistry_V1_4_1_Dxe.c new file mode 100644 index 00000000000..30189600c7c --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_4_1/MessageRegistry_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "4", + "1" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_4_1 *MessageRegistryV1_4_1; + EFI_REDFISH_MESSAGEREGISTRY_V1_4_1_CS *MessageRegistryV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_4_1_To_CS (ResoruceRaw, &MessageRegistryV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_4_1 = (EFI_REDFISH_MESSAGEREGISTRY_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_4_1)); + if (MessageRegistryV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_4_1; + MessageRegistryV1_4_1->MessageRegistry = MessageRegistryV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_4_1_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_4_1 *MessageRegistryV1_4_1; + + MessageRegistryV1_4_1 = (EFI_REDFISH_MESSAGEREGISTRY_V1_4_1 *)InterpProp; + DestroyMessageRegistry_V1_4_1_CS (MessageRegistryV1_4_1->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_4_1/RedfishMessageRegistry_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_4_1/RedfishMessageRegistry_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..3730644721a --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_4_1/RedfishMessageRegistry_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_4_1_Dxe + FILE_GUID = 36af92a8-035f-461f-aef8-7eb592c4c33f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_4_2/MessageRegistry_V1_4_2_Dxe.c b/RedfishClientPkg/Converter/MessageRegistry/v1_4_2/MessageRegistry_V1_4_2_Dxe.c new file mode 100644 index 00000000000..5befaded264 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_4_2/MessageRegistry_V1_4_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistry.v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistry V1_4_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistry", + "1", + "4", + "2" + }, + "MessageRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_4_2 *MessageRegistryV1_4_2; + EFI_REDFISH_MESSAGEREGISTRY_V1_4_2_CS *MessageRegistryV1_4_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistry_V1_4_2_To_CS (ResoruceRaw, &MessageRegistryV1_4_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryV1_4_2 = (EFI_REDFISH_MESSAGEREGISTRY_V1_4_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRY_V1_4_2)); + if (MessageRegistryV1_4_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryV1_4_2; + MessageRegistryV1_4_2->MessageRegistry = MessageRegistryV1_4_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistry"), "MessageRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistry_V1_4_2_JSON (*((EFI_REDFISH_MESSAGEREGISTRY_V1_4_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRY_V1_4_2 *MessageRegistryV1_4_2; + + MessageRegistryV1_4_2 = (EFI_REDFISH_MESSAGEREGISTRY_V1_4_2 *)InterpProp; + DestroyMessageRegistry_V1_4_2_CS (MessageRegistryV1_4_2->MessageRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistry_V1_4_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_4_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryToStructWrapper, + MessageRegistryToJson, + MessageRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistry_V1_4_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistry/v1_4_2/RedfishMessageRegistry_V1_4_2_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistry/v1_4_2/RedfishMessageRegistry_V1_4_2_Dxe.inf new file mode 100644 index 00000000000..7f0a87c40a7 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistry/v1_4_2/RedfishMessageRegistry_V1_4_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistry.v1_4_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistry_V1_4_2_Dxe + FILE_GUID = df46e1d9-0d39-4e77-a87c-4615033cc2c4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistry_V1_4_2EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistry_V1_4_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistry_V1_4_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryV1_4_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistryCollection/MessageRegistryCollection_Dxe.c b/RedfishClientPkg/Converter/MessageRegistryCollection/MessageRegistryCollection_Dxe.c new file mode 100644 index 00000000000..79a3ac3e3c4 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryCollection/MessageRegistryCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistryCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistryCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support MessageRegistryCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistryCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "MessageRegistryCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYCOLLECTION *MessageRegistryCollection; + EFI_REDFISH_MESSAGEREGISTRYCOLLECTION_CS *MessageRegistryCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistryCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistryCollection_To_CS (ResoruceRaw, &MessageRegistryCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryCollection = (EFI_REDFISH_MESSAGEREGISTRYCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRYCOLLECTION)); + if (MessageRegistryCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryCollection; + MessageRegistryCollection->MessageRegistryCollection = MessageRegistryCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistryCollection"), "MessageRegistryCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistryCollection"), "MessageRegistryCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistryCollection_JSON (*((EFI_REDFISH_MESSAGEREGISTRYCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYCOLLECTION *MessageRegistryCollection; + + MessageRegistryCollection = (EFI_REDFISH_MESSAGEREGISTRYCOLLECTION *)InterpProp; + DestroyMessageRegistryCollection_CS (MessageRegistryCollection->MessageRegistryCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistryCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryCollectionToStructWrapper, + MessageRegistryCollectionToJson, + MessageRegistryCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistryCollection/RedfishMessageRegistryCollection_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistryCollection/RedfishMessageRegistryCollection_Dxe.inf new file mode 100644 index 00000000000..8c3b3c776e4 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryCollection/RedfishMessageRegistryCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistryCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistryCollection_Dxe + FILE_GUID = 2b7819e0-eee3-4745-9217-c0c1fb9651e1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistryCollectionEntryPoint + UNLOAD_IMAGE = RedfishMessageRegistryCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistryCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_0/MessageRegistryFile_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_0/MessageRegistryFile_V1_0_0_Dxe.c new file mode 100644 index 00000000000..c320a092c72 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_0/MessageRegistryFile_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistryFile.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistryFile"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistryFile V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistryFile", + "1", + "0", + "0" + }, + "MessageRegistryFile" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_0 *MessageRegistryFileV1_0_0; + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_0_CS *MessageRegistryFileV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistryFile") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistryFile_V1_0_0_To_CS (ResoruceRaw, &MessageRegistryFileV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryFileV1_0_0 = (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_0)); + if (MessageRegistryFileV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryFileV1_0_0; + MessageRegistryFileV1_0_0->MessageRegistryFile = MessageRegistryFileV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistryFile"), "MessageRegistryFile"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistryFile"), "MessageRegistryFile"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryFileToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryFileToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistryFile_V1_0_0_JSON (*((EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryFileToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_0 *MessageRegistryFileV1_0_0; + + MessageRegistryFileV1_0_0 = (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_0 *)InterpProp; + DestroyMessageRegistryFile_V1_0_0_CS (MessageRegistryFileV1_0_0->MessageRegistryFile); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFileFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistryFile_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryFile_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryFileToStructWrapper, + MessageRegistryFileToJson, + MessageRegistryFileDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryFile_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_0/RedfishMessageRegistryFile_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_0/RedfishMessageRegistryFile_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..9548c928c27 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_0/RedfishMessageRegistryFile_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistryFile.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistryFile_V1_0_0_Dxe + FILE_GUID = 1162f326-85c6-441b-92d1-44eea117d73b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistryFile_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistryFile_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistryFile_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryFileV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_2/MessageRegistryFile_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_2/MessageRegistryFile_V1_0_2_Dxe.c new file mode 100644 index 00000000000..7dbdc4ede25 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_2/MessageRegistryFile_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistryFile.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistryFile"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistryFile V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistryFile", + "1", + "0", + "2" + }, + "MessageRegistryFile" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_2 *MessageRegistryFileV1_0_2; + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_2_CS *MessageRegistryFileV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistryFile") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistryFile_V1_0_2_To_CS (ResoruceRaw, &MessageRegistryFileV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryFileV1_0_2 = (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_2)); + if (MessageRegistryFileV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryFileV1_0_2; + MessageRegistryFileV1_0_2->MessageRegistryFile = MessageRegistryFileV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistryFile"), "MessageRegistryFile"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistryFile"), "MessageRegistryFile"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryFileToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryFileToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistryFile_V1_0_2_JSON (*((EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryFileToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_2 *MessageRegistryFileV1_0_2; + + MessageRegistryFileV1_0_2 = (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_2 *)InterpProp; + DestroyMessageRegistryFile_V1_0_2_CS (MessageRegistryFileV1_0_2->MessageRegistryFile); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFileFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistryFile_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryFile_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryFileToStructWrapper, + MessageRegistryFileToJson, + MessageRegistryFileDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryFile_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_2/RedfishMessageRegistryFile_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_2/RedfishMessageRegistryFile_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..8e251de2629 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_2/RedfishMessageRegistryFile_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistryFile.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistryFile_V1_0_2_Dxe + FILE_GUID = 7a0f736f-93d2-4db4-bde3-1f078ed86ee1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistryFile_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistryFile_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistryFile_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryFileV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_3/MessageRegistryFile_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_3/MessageRegistryFile_V1_0_3_Dxe.c new file mode 100644 index 00000000000..15e06c30622 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_3/MessageRegistryFile_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistryFile.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistryFile"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistryFile V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistryFile", + "1", + "0", + "3" + }, + "MessageRegistryFile" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_3 *MessageRegistryFileV1_0_3; + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_3_CS *MessageRegistryFileV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistryFile") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistryFile_V1_0_3_To_CS (ResoruceRaw, &MessageRegistryFileV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryFileV1_0_3 = (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_3)); + if (MessageRegistryFileV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryFileV1_0_3; + MessageRegistryFileV1_0_3->MessageRegistryFile = MessageRegistryFileV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistryFile"), "MessageRegistryFile"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistryFile"), "MessageRegistryFile"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryFileToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryFileToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistryFile_V1_0_3_JSON (*((EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryFileToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_3 *MessageRegistryFileV1_0_3; + + MessageRegistryFileV1_0_3 = (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_3 *)InterpProp; + DestroyMessageRegistryFile_V1_0_3_CS (MessageRegistryFileV1_0_3->MessageRegistryFile); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFileFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistryFile_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryFile_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryFileToStructWrapper, + MessageRegistryFileToJson, + MessageRegistryFileDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryFile_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_3/RedfishMessageRegistryFile_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_3/RedfishMessageRegistryFile_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..c9725d47cfa --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_3/RedfishMessageRegistryFile_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistryFile.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistryFile_V1_0_3_Dxe + FILE_GUID = 848ea06f-8ca5-4a44-a1d4-2039a597db19 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistryFile_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistryFile_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistryFile_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryFileV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_4/MessageRegistryFile_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_4/MessageRegistryFile_V1_0_4_Dxe.c new file mode 100644 index 00000000000..813a0764eb3 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_4/MessageRegistryFile_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistryFile.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistryFile"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistryFile V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistryFile", + "1", + "0", + "4" + }, + "MessageRegistryFile" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_4 *MessageRegistryFileV1_0_4; + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_4_CS *MessageRegistryFileV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistryFile") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistryFile_V1_0_4_To_CS (ResoruceRaw, &MessageRegistryFileV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryFileV1_0_4 = (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_4)); + if (MessageRegistryFileV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryFileV1_0_4; + MessageRegistryFileV1_0_4->MessageRegistryFile = MessageRegistryFileV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistryFile"), "MessageRegistryFile"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistryFile"), "MessageRegistryFile"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryFileToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryFileToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistryFile_V1_0_4_JSON (*((EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryFileToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_4 *MessageRegistryFileV1_0_4; + + MessageRegistryFileV1_0_4 = (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_4 *)InterpProp; + DestroyMessageRegistryFile_V1_0_4_CS (MessageRegistryFileV1_0_4->MessageRegistryFile); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFileFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistryFile_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryFile_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryFileToStructWrapper, + MessageRegistryFileToJson, + MessageRegistryFileDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryFile_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_4/RedfishMessageRegistryFile_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_4/RedfishMessageRegistryFile_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..30f1ba04e59 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_4/RedfishMessageRegistryFile_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistryFile.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistryFile_V1_0_4_Dxe + FILE_GUID = 92a760b7-3143-4137-99ff-83f9bf8e842d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistryFile_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistryFile_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistryFile_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryFileV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_5/MessageRegistryFile_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_5/MessageRegistryFile_V1_0_5_Dxe.c new file mode 100644 index 00000000000..6ef3f0c8d3a --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_5/MessageRegistryFile_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistryFile.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistryFile"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistryFile V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistryFile", + "1", + "0", + "5" + }, + "MessageRegistryFile" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_5 *MessageRegistryFileV1_0_5; + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_5_CS *MessageRegistryFileV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistryFile") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistryFile_V1_0_5_To_CS (ResoruceRaw, &MessageRegistryFileV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryFileV1_0_5 = (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_5)); + if (MessageRegistryFileV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryFileV1_0_5; + MessageRegistryFileV1_0_5->MessageRegistryFile = MessageRegistryFileV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistryFile"), "MessageRegistryFile"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistryFile"), "MessageRegistryFile"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryFileToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryFileToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistryFile_V1_0_5_JSON (*((EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryFileToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_5 *MessageRegistryFileV1_0_5; + + MessageRegistryFileV1_0_5 = (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_5 *)InterpProp; + DestroyMessageRegistryFile_V1_0_5_CS (MessageRegistryFileV1_0_5->MessageRegistryFile); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFileFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistryFile_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryFile_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryFileToStructWrapper, + MessageRegistryFileToJson, + MessageRegistryFileDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryFile_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_5/RedfishMessageRegistryFile_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_5/RedfishMessageRegistryFile_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..5b8f3c9fe68 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_5/RedfishMessageRegistryFile_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistryFile.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistryFile_V1_0_5_Dxe + FILE_GUID = d031d730-580e-47a4-b6f4-1a8362c53cc7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistryFile_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistryFile_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistryFile_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryFileV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_6/MessageRegistryFile_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_6/MessageRegistryFile_V1_0_6_Dxe.c new file mode 100644 index 00000000000..575faa133e6 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_6/MessageRegistryFile_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistryFile.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistryFile"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistryFile V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistryFile", + "1", + "0", + "6" + }, + "MessageRegistryFile" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_6 *MessageRegistryFileV1_0_6; + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_6_CS *MessageRegistryFileV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistryFile") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistryFile_V1_0_6_To_CS (ResoruceRaw, &MessageRegistryFileV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryFileV1_0_6 = (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_6)); + if (MessageRegistryFileV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryFileV1_0_6; + MessageRegistryFileV1_0_6->MessageRegistryFile = MessageRegistryFileV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistryFile"), "MessageRegistryFile"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistryFile"), "MessageRegistryFile"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryFileToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryFileToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistryFile_V1_0_6_JSON (*((EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryFileToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_6 *MessageRegistryFileV1_0_6; + + MessageRegistryFileV1_0_6 = (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_6 *)InterpProp; + DestroyMessageRegistryFile_V1_0_6_CS (MessageRegistryFileV1_0_6->MessageRegistryFile); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFileFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistryFile_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryFile_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryFileToStructWrapper, + MessageRegistryFileToJson, + MessageRegistryFileDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryFile_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_6/RedfishMessageRegistryFile_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_6/RedfishMessageRegistryFile_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..c6e62bb310c --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_6/RedfishMessageRegistryFile_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistryFile.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistryFile_V1_0_6_Dxe + FILE_GUID = b6836fa8-2077-4f95-91c9-f1674f17ccbd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistryFile_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistryFile_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistryFile_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryFileV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_7/MessageRegistryFile_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_7/MessageRegistryFile_V1_0_7_Dxe.c new file mode 100644 index 00000000000..6f871d7e781 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_7/MessageRegistryFile_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistryFile.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistryFile"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistryFile V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistryFile", + "1", + "0", + "7" + }, + "MessageRegistryFile" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_7 *MessageRegistryFileV1_0_7; + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_7_CS *MessageRegistryFileV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistryFile") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistryFile_V1_0_7_To_CS (ResoruceRaw, &MessageRegistryFileV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryFileV1_0_7 = (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_7)); + if (MessageRegistryFileV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryFileV1_0_7; + MessageRegistryFileV1_0_7->MessageRegistryFile = MessageRegistryFileV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistryFile"), "MessageRegistryFile"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistryFile"), "MessageRegistryFile"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryFileToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryFileToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistryFile_V1_0_7_JSON (*((EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryFileToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_7 *MessageRegistryFileV1_0_7; + + MessageRegistryFileV1_0_7 = (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_7 *)InterpProp; + DestroyMessageRegistryFile_V1_0_7_CS (MessageRegistryFileV1_0_7->MessageRegistryFile); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFileFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistryFile_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryFile_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryFileToStructWrapper, + MessageRegistryFileToJson, + MessageRegistryFileDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryFile_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_7/RedfishMessageRegistryFile_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_7/RedfishMessageRegistryFile_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..513c0364574 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryFile/v1_0_7/RedfishMessageRegistryFile_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistryFile.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistryFile_V1_0_7_Dxe + FILE_GUID = 0d29cb4e-3616-44b3-898a-94b7c9a49b42 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistryFile_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistryFile_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistryFile_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryFileV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistryFile/v1_1_0/MessageRegistryFile_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/MessageRegistryFile/v1_1_0/MessageRegistryFile_V1_1_0_Dxe.c new file mode 100644 index 00000000000..f3bc5c49be6 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryFile/v1_1_0/MessageRegistryFile_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistryFile.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistryFile"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistryFile V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistryFile", + "1", + "1", + "0" + }, + "MessageRegistryFile" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_0 *MessageRegistryFileV1_1_0; + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_0_CS *MessageRegistryFileV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistryFile") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistryFile_V1_1_0_To_CS (ResoruceRaw, &MessageRegistryFileV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryFileV1_1_0 = (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_0)); + if (MessageRegistryFileV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryFileV1_1_0; + MessageRegistryFileV1_1_0->MessageRegistryFile = MessageRegistryFileV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistryFile"), "MessageRegistryFile"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistryFile"), "MessageRegistryFile"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryFileToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryFileToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistryFile_V1_1_0_JSON (*((EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryFileToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_0 *MessageRegistryFileV1_1_0; + + MessageRegistryFileV1_1_0 = (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_0 *)InterpProp; + DestroyMessageRegistryFile_V1_1_0_CS (MessageRegistryFileV1_1_0->MessageRegistryFile); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFileFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistryFile_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryFile_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryFileToStructWrapper, + MessageRegistryFileToJson, + MessageRegistryFileDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryFile_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistryFile/v1_1_0/RedfishMessageRegistryFile_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistryFile/v1_1_0/RedfishMessageRegistryFile_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..8732e33ee9e --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryFile/v1_1_0/RedfishMessageRegistryFile_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistryFile.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistryFile_V1_1_0_Dxe + FILE_GUID = c1d76134-c34a-42d5-9a44-421747f246e4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistryFile_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistryFile_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistryFile_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryFileV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistryFile/v1_1_1/MessageRegistryFile_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/MessageRegistryFile/v1_1_1/MessageRegistryFile_V1_1_1_Dxe.c new file mode 100644 index 00000000000..56c70c0ffd4 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryFile/v1_1_1/MessageRegistryFile_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistryFile.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistryFile"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistryFile V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistryFile", + "1", + "1", + "1" + }, + "MessageRegistryFile" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_1 *MessageRegistryFileV1_1_1; + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_1_CS *MessageRegistryFileV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistryFile") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistryFile_V1_1_1_To_CS (ResoruceRaw, &MessageRegistryFileV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryFileV1_1_1 = (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_1)); + if (MessageRegistryFileV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryFileV1_1_1; + MessageRegistryFileV1_1_1->MessageRegistryFile = MessageRegistryFileV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistryFile"), "MessageRegistryFile"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistryFile"), "MessageRegistryFile"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryFileToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryFileToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistryFile_V1_1_1_JSON (*((EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryFileToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_1 *MessageRegistryFileV1_1_1; + + MessageRegistryFileV1_1_1 = (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_1 *)InterpProp; + DestroyMessageRegistryFile_V1_1_1_CS (MessageRegistryFileV1_1_1->MessageRegistryFile); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFileFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistryFile_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryFile_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryFileToStructWrapper, + MessageRegistryFileToJson, + MessageRegistryFileDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryFile_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistryFile/v1_1_1/RedfishMessageRegistryFile_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistryFile/v1_1_1/RedfishMessageRegistryFile_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..b0494990878 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryFile/v1_1_1/RedfishMessageRegistryFile_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistryFile.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistryFile_V1_1_1_Dxe + FILE_GUID = 8c5cae17-9c2b-4b79-b128-e1e715e6ad24 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistryFile_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistryFile_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistryFile_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryFileV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistryFile/v1_1_2/MessageRegistryFile_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/MessageRegistryFile/v1_1_2/MessageRegistryFile_V1_1_2_Dxe.c new file mode 100644 index 00000000000..a07a6c7a4a0 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryFile/v1_1_2/MessageRegistryFile_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistryFile.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistryFile"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistryFile V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistryFile", + "1", + "1", + "2" + }, + "MessageRegistryFile" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_2 *MessageRegistryFileV1_1_2; + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_2_CS *MessageRegistryFileV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistryFile") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistryFile_V1_1_2_To_CS (ResoruceRaw, &MessageRegistryFileV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryFileV1_1_2 = (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_2)); + if (MessageRegistryFileV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryFileV1_1_2; + MessageRegistryFileV1_1_2->MessageRegistryFile = MessageRegistryFileV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistryFile"), "MessageRegistryFile"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistryFile"), "MessageRegistryFile"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryFileToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryFileToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistryFile_V1_1_2_JSON (*((EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryFileToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_2 *MessageRegistryFileV1_1_2; + + MessageRegistryFileV1_1_2 = (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_2 *)InterpProp; + DestroyMessageRegistryFile_V1_1_2_CS (MessageRegistryFileV1_1_2->MessageRegistryFile); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFileFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistryFile_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryFile_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryFileToStructWrapper, + MessageRegistryFileToJson, + MessageRegistryFileDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryFile_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistryFile/v1_1_2/RedfishMessageRegistryFile_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistryFile/v1_1_2/RedfishMessageRegistryFile_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..6c8f7e8c28b --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryFile/v1_1_2/RedfishMessageRegistryFile_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistryFile.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistryFile_V1_1_2_Dxe + FILE_GUID = 3b8ecb5c-f703-4733-b5f1-4f821921757e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistryFile_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistryFile_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistryFile_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryFileV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistryFile/v1_1_3/MessageRegistryFile_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/MessageRegistryFile/v1_1_3/MessageRegistryFile_V1_1_3_Dxe.c new file mode 100644 index 00000000000..ec7773aa064 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryFile/v1_1_3/MessageRegistryFile_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistryFile.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistryFile"; +BOOLEAN IsRevisonController = TRUE; + +// Support MessageRegistryFile V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistryFile", + "1", + "1", + "3" + }, + "MessageRegistryFile" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_3 *MessageRegistryFileV1_1_3; + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_3_CS *MessageRegistryFileV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistryFile") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistryFile_V1_1_3_To_CS (ResoruceRaw, &MessageRegistryFileV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryFileV1_1_3 = (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_3)); + if (MessageRegistryFileV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryFileV1_1_3; + MessageRegistryFileV1_1_3->MessageRegistryFile = MessageRegistryFileV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistryFile"), "MessageRegistryFile"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryFile")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistryFile"), "MessageRegistryFile"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryFileToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryFileToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistryFile_V1_1_3_JSON (*((EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryFileToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_3 *MessageRegistryFileV1_1_3; + + MessageRegistryFileV1_1_3 = (EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_3 *)InterpProp; + DestroyMessageRegistryFile_V1_1_3_CS (MessageRegistryFileV1_1_3->MessageRegistryFile); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFileFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistryFile_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryFile_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryFileToStructWrapper, + MessageRegistryFileToJson, + MessageRegistryFileDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryFile_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistryFile/v1_1_3/RedfishMessageRegistryFile_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistryFile/v1_1_3/RedfishMessageRegistryFile_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..5cb747c009f --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryFile/v1_1_3/RedfishMessageRegistryFile_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistryFile.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistryFile_V1_1_3_Dxe + FILE_GUID = e1f8fd8f-a46c-4641-ac99-a5ea6dbd490c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistryFile_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishMessageRegistryFile_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistryFile_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryFileV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MessageRegistryFileCollection/MessageRegistryFileCollection_Dxe.c b/RedfishClientPkg/Converter/MessageRegistryFileCollection/MessageRegistryFileCollection_Dxe.c new file mode 100644 index 00000000000..4993beaedd7 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryFileCollection/MessageRegistryFileCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MessageRegistryFileCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MessageRegistryFileCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support MessageRegistryFileCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MessageRegistryFileCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "MessageRegistryFileCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYFILECOLLECTION *MessageRegistryFileCollection; + EFI_REDFISH_MESSAGEREGISTRYFILECOLLECTION_CS *MessageRegistryFileCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MessageRegistryFileCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MessageRegistryFileCollection_To_CS (ResoruceRaw, &MessageRegistryFileCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + MessageRegistryFileCollection = (EFI_REDFISH_MESSAGEREGISTRYFILECOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_MESSAGEREGISTRYFILECOLLECTION)); + if (MessageRegistryFileCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MessageRegistryFileCollection; + MessageRegistryFileCollection->MessageRegistryFileCollection = MessageRegistryFileCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryFileCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MessageRegistryFileCollection"), "MessageRegistryFileCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MessageRegistryFileCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MessageRegistryFileCollection"), "MessageRegistryFileCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MessageRegistryFileCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MessageRegistryFileCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MessageRegistryFileCollection_JSON (*((EFI_REDFISH_MESSAGEREGISTRYFILECOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MessageRegistryFileCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_MESSAGEREGISTRYFILECOLLECTION *MessageRegistryFileCollection; + + MessageRegistryFileCollection = (EFI_REDFISH_MESSAGEREGISTRYFILECOLLECTION *)InterpProp; + DestroyMessageRegistryFileCollection_CS (MessageRegistryFileCollection->MessageRegistryFileCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MessageRegistryFileCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MessageRegistryFileCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMessageRegistryFileCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryFileCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MessageRegistryFileCollectionToStructWrapper, + MessageRegistryFileCollectionToJson, + MessageRegistryFileCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMessageRegistryFileCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MessageRegistryFileCollection/RedfishMessageRegistryFileCollection_Dxe.inf b/RedfishClientPkg/Converter/MessageRegistryFileCollection/RedfishMessageRegistryFileCollection_Dxe.inf new file mode 100644 index 00000000000..725f0a3a889 --- /dev/null +++ b/RedfishClientPkg/Converter/MessageRegistryFileCollection/RedfishMessageRegistryFileCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MessageRegistryFileCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMessageRegistryFileCollection_Dxe + FILE_GUID = ba693c66-e4ed-428a-8d27-ab95d1513766 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMessageRegistryFileCollectionEntryPoint + UNLOAD_IMAGE = RedfishMessageRegistryFileCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MessageRegistryFileCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MessageRegistryFileCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricDefinition/v1_0_0/MetricDefinition_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/MetricDefinition/v1_0_0/MetricDefinition_V1_0_0_Dxe.c new file mode 100644 index 00000000000..ebfc52a26c2 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricDefinition/v1_0_0/MetricDefinition_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricDefinition.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricDefinition V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricDefinition", + "1", + "0", + "0" + }, + "MetricDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICDEFINITION_V1_0_0 *MetricDefinitionV1_0_0; + EFI_REDFISH_METRICDEFINITION_V1_0_0_CS *MetricDefinitionV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricDefinition_V1_0_0_To_CS (ResoruceRaw, &MetricDefinitionV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricDefinitionV1_0_0 = (EFI_REDFISH_METRICDEFINITION_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICDEFINITION_V1_0_0)); + if (MetricDefinitionV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricDefinitionV1_0_0; + MetricDefinitionV1_0_0->MetricDefinition = MetricDefinitionV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricDefinition"), "MetricDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricDefinition"), "MetricDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricDefinition_V1_0_0_JSON (*((EFI_REDFISH_METRICDEFINITION_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICDEFINITION_V1_0_0 *MetricDefinitionV1_0_0; + + MetricDefinitionV1_0_0 = (EFI_REDFISH_METRICDEFINITION_V1_0_0 *)InterpProp; + DestroyMetricDefinition_V1_0_0_CS (MetricDefinitionV1_0_0->MetricDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricDefinition_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricDefinition_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricDefinitionToStructWrapper, + MetricDefinitionToJson, + MetricDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricDefinition_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricDefinition/v1_0_0/RedfishMetricDefinition_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/MetricDefinition/v1_0_0/RedfishMetricDefinition_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..6d358158585 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricDefinition/v1_0_0/RedfishMetricDefinition_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricDefinition.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricDefinition_V1_0_0_Dxe + FILE_GUID = ee943bbb-d174-4990-a3c7-3a4e4153b2dd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricDefinition_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishMetricDefinition_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricDefinition_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricDefinitionV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricDefinition/v1_0_1/MetricDefinition_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/MetricDefinition/v1_0_1/MetricDefinition_V1_0_1_Dxe.c new file mode 100644 index 00000000000..ffbd530fecc --- /dev/null +++ b/RedfishClientPkg/Converter/MetricDefinition/v1_0_1/MetricDefinition_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricDefinition.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricDefinition V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricDefinition", + "1", + "0", + "1" + }, + "MetricDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICDEFINITION_V1_0_1 *MetricDefinitionV1_0_1; + EFI_REDFISH_METRICDEFINITION_V1_0_1_CS *MetricDefinitionV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricDefinition_V1_0_1_To_CS (ResoruceRaw, &MetricDefinitionV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricDefinitionV1_0_1 = (EFI_REDFISH_METRICDEFINITION_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICDEFINITION_V1_0_1)); + if (MetricDefinitionV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricDefinitionV1_0_1; + MetricDefinitionV1_0_1->MetricDefinition = MetricDefinitionV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricDefinition"), "MetricDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricDefinition"), "MetricDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricDefinition_V1_0_1_JSON (*((EFI_REDFISH_METRICDEFINITION_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICDEFINITION_V1_0_1 *MetricDefinitionV1_0_1; + + MetricDefinitionV1_0_1 = (EFI_REDFISH_METRICDEFINITION_V1_0_1 *)InterpProp; + DestroyMetricDefinition_V1_0_1_CS (MetricDefinitionV1_0_1->MetricDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricDefinition_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricDefinition_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricDefinitionToStructWrapper, + MetricDefinitionToJson, + MetricDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricDefinition_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricDefinition/v1_0_1/RedfishMetricDefinition_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/MetricDefinition/v1_0_1/RedfishMetricDefinition_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..1ddc8b31096 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricDefinition/v1_0_1/RedfishMetricDefinition_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricDefinition.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricDefinition_V1_0_1_Dxe + FILE_GUID = d739effb-a813-4ec7-93a7-dfe9b3caf20e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricDefinition_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishMetricDefinition_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricDefinition_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricDefinitionV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricDefinition/v1_0_2/MetricDefinition_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/MetricDefinition/v1_0_2/MetricDefinition_V1_0_2_Dxe.c new file mode 100644 index 00000000000..e1b7281f2de --- /dev/null +++ b/RedfishClientPkg/Converter/MetricDefinition/v1_0_2/MetricDefinition_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricDefinition.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricDefinition V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricDefinition", + "1", + "0", + "2" + }, + "MetricDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICDEFINITION_V1_0_2 *MetricDefinitionV1_0_2; + EFI_REDFISH_METRICDEFINITION_V1_0_2_CS *MetricDefinitionV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricDefinition_V1_0_2_To_CS (ResoruceRaw, &MetricDefinitionV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricDefinitionV1_0_2 = (EFI_REDFISH_METRICDEFINITION_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICDEFINITION_V1_0_2)); + if (MetricDefinitionV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricDefinitionV1_0_2; + MetricDefinitionV1_0_2->MetricDefinition = MetricDefinitionV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricDefinition"), "MetricDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricDefinition"), "MetricDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricDefinition_V1_0_2_JSON (*((EFI_REDFISH_METRICDEFINITION_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICDEFINITION_V1_0_2 *MetricDefinitionV1_0_2; + + MetricDefinitionV1_0_2 = (EFI_REDFISH_METRICDEFINITION_V1_0_2 *)InterpProp; + DestroyMetricDefinition_V1_0_2_CS (MetricDefinitionV1_0_2->MetricDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricDefinition_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricDefinition_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricDefinitionToStructWrapper, + MetricDefinitionToJson, + MetricDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricDefinition_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricDefinition/v1_0_2/RedfishMetricDefinition_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/MetricDefinition/v1_0_2/RedfishMetricDefinition_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..d8ee4b477de --- /dev/null +++ b/RedfishClientPkg/Converter/MetricDefinition/v1_0_2/RedfishMetricDefinition_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricDefinition.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricDefinition_V1_0_2_Dxe + FILE_GUID = 81eff538-87e7-48ef-aa02-2b3f90b03e84 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricDefinition_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishMetricDefinition_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricDefinition_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricDefinitionV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricDefinition/v1_0_3/MetricDefinition_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/MetricDefinition/v1_0_3/MetricDefinition_V1_0_3_Dxe.c new file mode 100644 index 00000000000..5a24f52d82c --- /dev/null +++ b/RedfishClientPkg/Converter/MetricDefinition/v1_0_3/MetricDefinition_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricDefinition.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricDefinition V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricDefinition", + "1", + "0", + "3" + }, + "MetricDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICDEFINITION_V1_0_3 *MetricDefinitionV1_0_3; + EFI_REDFISH_METRICDEFINITION_V1_0_3_CS *MetricDefinitionV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricDefinition_V1_0_3_To_CS (ResoruceRaw, &MetricDefinitionV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricDefinitionV1_0_3 = (EFI_REDFISH_METRICDEFINITION_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICDEFINITION_V1_0_3)); + if (MetricDefinitionV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricDefinitionV1_0_3; + MetricDefinitionV1_0_3->MetricDefinition = MetricDefinitionV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricDefinition"), "MetricDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricDefinition"), "MetricDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricDefinition_V1_0_3_JSON (*((EFI_REDFISH_METRICDEFINITION_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICDEFINITION_V1_0_3 *MetricDefinitionV1_0_3; + + MetricDefinitionV1_0_3 = (EFI_REDFISH_METRICDEFINITION_V1_0_3 *)InterpProp; + DestroyMetricDefinition_V1_0_3_CS (MetricDefinitionV1_0_3->MetricDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricDefinition_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricDefinition_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricDefinitionToStructWrapper, + MetricDefinitionToJson, + MetricDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricDefinition_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricDefinition/v1_0_3/RedfishMetricDefinition_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/MetricDefinition/v1_0_3/RedfishMetricDefinition_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..3587f5e86b3 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricDefinition/v1_0_3/RedfishMetricDefinition_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricDefinition.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricDefinition_V1_0_3_Dxe + FILE_GUID = 3e886bd4-7e69-4b76-b729-48232485b0f0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricDefinition_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishMetricDefinition_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricDefinition_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricDefinitionV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricDefinition/v1_0_4/MetricDefinition_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/MetricDefinition/v1_0_4/MetricDefinition_V1_0_4_Dxe.c new file mode 100644 index 00000000000..619aabf1d2f --- /dev/null +++ b/RedfishClientPkg/Converter/MetricDefinition/v1_0_4/MetricDefinition_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricDefinition.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricDefinition V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricDefinition", + "1", + "0", + "4" + }, + "MetricDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICDEFINITION_V1_0_4 *MetricDefinitionV1_0_4; + EFI_REDFISH_METRICDEFINITION_V1_0_4_CS *MetricDefinitionV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricDefinition_V1_0_4_To_CS (ResoruceRaw, &MetricDefinitionV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricDefinitionV1_0_4 = (EFI_REDFISH_METRICDEFINITION_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICDEFINITION_V1_0_4)); + if (MetricDefinitionV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricDefinitionV1_0_4; + MetricDefinitionV1_0_4->MetricDefinition = MetricDefinitionV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricDefinition"), "MetricDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricDefinition"), "MetricDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricDefinition_V1_0_4_JSON (*((EFI_REDFISH_METRICDEFINITION_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICDEFINITION_V1_0_4 *MetricDefinitionV1_0_4; + + MetricDefinitionV1_0_4 = (EFI_REDFISH_METRICDEFINITION_V1_0_4 *)InterpProp; + DestroyMetricDefinition_V1_0_4_CS (MetricDefinitionV1_0_4->MetricDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricDefinition_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricDefinition_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricDefinitionToStructWrapper, + MetricDefinitionToJson, + MetricDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricDefinition_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricDefinition/v1_0_4/RedfishMetricDefinition_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/MetricDefinition/v1_0_4/RedfishMetricDefinition_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..794005efc06 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricDefinition/v1_0_4/RedfishMetricDefinition_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricDefinition.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricDefinition_V1_0_4_Dxe + FILE_GUID = b873e59e-50a9-4779-9184-194f536f0013 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricDefinition_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishMetricDefinition_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricDefinition_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricDefinitionV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricDefinition/v1_0_5/MetricDefinition_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/MetricDefinition/v1_0_5/MetricDefinition_V1_0_5_Dxe.c new file mode 100644 index 00000000000..07f59e39f92 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricDefinition/v1_0_5/MetricDefinition_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricDefinition.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricDefinition V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricDefinition", + "1", + "0", + "5" + }, + "MetricDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICDEFINITION_V1_0_5 *MetricDefinitionV1_0_5; + EFI_REDFISH_METRICDEFINITION_V1_0_5_CS *MetricDefinitionV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricDefinition_V1_0_5_To_CS (ResoruceRaw, &MetricDefinitionV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricDefinitionV1_0_5 = (EFI_REDFISH_METRICDEFINITION_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICDEFINITION_V1_0_5)); + if (MetricDefinitionV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricDefinitionV1_0_5; + MetricDefinitionV1_0_5->MetricDefinition = MetricDefinitionV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricDefinition"), "MetricDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricDefinition"), "MetricDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricDefinition_V1_0_5_JSON (*((EFI_REDFISH_METRICDEFINITION_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICDEFINITION_V1_0_5 *MetricDefinitionV1_0_5; + + MetricDefinitionV1_0_5 = (EFI_REDFISH_METRICDEFINITION_V1_0_5 *)InterpProp; + DestroyMetricDefinition_V1_0_5_CS (MetricDefinitionV1_0_5->MetricDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricDefinition_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricDefinition_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricDefinitionToStructWrapper, + MetricDefinitionToJson, + MetricDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricDefinition_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricDefinition/v1_0_5/RedfishMetricDefinition_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/MetricDefinition/v1_0_5/RedfishMetricDefinition_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..5afd1371be0 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricDefinition/v1_0_5/RedfishMetricDefinition_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricDefinition.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricDefinition_V1_0_5_Dxe + FILE_GUID = 335e4936-2114-42e6-85a5-6617bcbc85f2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricDefinition_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishMetricDefinition_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricDefinition_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricDefinitionV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricDefinition/v1_0_6/MetricDefinition_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/MetricDefinition/v1_0_6/MetricDefinition_V1_0_6_Dxe.c new file mode 100644 index 00000000000..7999c259a1e --- /dev/null +++ b/RedfishClientPkg/Converter/MetricDefinition/v1_0_6/MetricDefinition_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricDefinition.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricDefinition V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricDefinition", + "1", + "0", + "6" + }, + "MetricDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICDEFINITION_V1_0_6 *MetricDefinitionV1_0_6; + EFI_REDFISH_METRICDEFINITION_V1_0_6_CS *MetricDefinitionV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricDefinition_V1_0_6_To_CS (ResoruceRaw, &MetricDefinitionV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricDefinitionV1_0_6 = (EFI_REDFISH_METRICDEFINITION_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICDEFINITION_V1_0_6)); + if (MetricDefinitionV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricDefinitionV1_0_6; + MetricDefinitionV1_0_6->MetricDefinition = MetricDefinitionV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricDefinition"), "MetricDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricDefinition"), "MetricDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricDefinition_V1_0_6_JSON (*((EFI_REDFISH_METRICDEFINITION_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICDEFINITION_V1_0_6 *MetricDefinitionV1_0_6; + + MetricDefinitionV1_0_6 = (EFI_REDFISH_METRICDEFINITION_V1_0_6 *)InterpProp; + DestroyMetricDefinition_V1_0_6_CS (MetricDefinitionV1_0_6->MetricDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricDefinition_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricDefinition_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricDefinitionToStructWrapper, + MetricDefinitionToJson, + MetricDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricDefinition_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricDefinition/v1_0_6/RedfishMetricDefinition_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/MetricDefinition/v1_0_6/RedfishMetricDefinition_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..57f2eb65383 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricDefinition/v1_0_6/RedfishMetricDefinition_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricDefinition.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricDefinition_V1_0_6_Dxe + FILE_GUID = 72589983-aeb4-4ca6-ab3e-9134c8541fd5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricDefinition_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishMetricDefinition_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricDefinition_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricDefinitionV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricDefinition/v1_1_0/MetricDefinition_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/MetricDefinition/v1_1_0/MetricDefinition_V1_1_0_Dxe.c new file mode 100644 index 00000000000..fbafb144246 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricDefinition/v1_1_0/MetricDefinition_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricDefinition.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricDefinition V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricDefinition", + "1", + "1", + "0" + }, + "MetricDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICDEFINITION_V1_1_0 *MetricDefinitionV1_1_0; + EFI_REDFISH_METRICDEFINITION_V1_1_0_CS *MetricDefinitionV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricDefinition_V1_1_0_To_CS (ResoruceRaw, &MetricDefinitionV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricDefinitionV1_1_0 = (EFI_REDFISH_METRICDEFINITION_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICDEFINITION_V1_1_0)); + if (MetricDefinitionV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricDefinitionV1_1_0; + MetricDefinitionV1_1_0->MetricDefinition = MetricDefinitionV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricDefinition"), "MetricDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricDefinition"), "MetricDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricDefinition_V1_1_0_JSON (*((EFI_REDFISH_METRICDEFINITION_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICDEFINITION_V1_1_0 *MetricDefinitionV1_1_0; + + MetricDefinitionV1_1_0 = (EFI_REDFISH_METRICDEFINITION_V1_1_0 *)InterpProp; + DestroyMetricDefinition_V1_1_0_CS (MetricDefinitionV1_1_0->MetricDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricDefinition_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricDefinition_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricDefinitionToStructWrapper, + MetricDefinitionToJson, + MetricDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricDefinition_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricDefinition/v1_1_0/RedfishMetricDefinition_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/MetricDefinition/v1_1_0/RedfishMetricDefinition_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..2f533232148 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricDefinition/v1_1_0/RedfishMetricDefinition_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricDefinition.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricDefinition_V1_1_0_Dxe + FILE_GUID = 5ff77262-c725-4403-86de-9ce182ad2d45 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricDefinition_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishMetricDefinition_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricDefinition_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricDefinitionV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricDefinition/v1_1_1/MetricDefinition_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/MetricDefinition/v1_1_1/MetricDefinition_V1_1_1_Dxe.c new file mode 100644 index 00000000000..00705264e93 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricDefinition/v1_1_1/MetricDefinition_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricDefinition.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricDefinition V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricDefinition", + "1", + "1", + "1" + }, + "MetricDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICDEFINITION_V1_1_1 *MetricDefinitionV1_1_1; + EFI_REDFISH_METRICDEFINITION_V1_1_1_CS *MetricDefinitionV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricDefinition_V1_1_1_To_CS (ResoruceRaw, &MetricDefinitionV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricDefinitionV1_1_1 = (EFI_REDFISH_METRICDEFINITION_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICDEFINITION_V1_1_1)); + if (MetricDefinitionV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricDefinitionV1_1_1; + MetricDefinitionV1_1_1->MetricDefinition = MetricDefinitionV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricDefinition"), "MetricDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricDefinition"), "MetricDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricDefinition_V1_1_1_JSON (*((EFI_REDFISH_METRICDEFINITION_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICDEFINITION_V1_1_1 *MetricDefinitionV1_1_1; + + MetricDefinitionV1_1_1 = (EFI_REDFISH_METRICDEFINITION_V1_1_1 *)InterpProp; + DestroyMetricDefinition_V1_1_1_CS (MetricDefinitionV1_1_1->MetricDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricDefinition_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricDefinition_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricDefinitionToStructWrapper, + MetricDefinitionToJson, + MetricDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricDefinition_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricDefinition/v1_1_1/RedfishMetricDefinition_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/MetricDefinition/v1_1_1/RedfishMetricDefinition_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..71c9c47b83d --- /dev/null +++ b/RedfishClientPkg/Converter/MetricDefinition/v1_1_1/RedfishMetricDefinition_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricDefinition.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricDefinition_V1_1_1_Dxe + FILE_GUID = 94d65e80-1722-44f1-8fdf-865e2d811c8e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricDefinition_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishMetricDefinition_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricDefinition_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricDefinitionV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricDefinitionCollection/MetricDefinitionCollection_Dxe.c b/RedfishClientPkg/Converter/MetricDefinitionCollection/MetricDefinitionCollection_Dxe.c new file mode 100644 index 00000000000..a9a653afb4c --- /dev/null +++ b/RedfishClientPkg/Converter/MetricDefinitionCollection/MetricDefinitionCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricDefinitionCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricDefinitionCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support MetricDefinitionCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricDefinitionCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "MetricDefinitionCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICDEFINITIONCOLLECTION *MetricDefinitionCollection; + EFI_REDFISH_METRICDEFINITIONCOLLECTION_CS *MetricDefinitionCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricDefinitionCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricDefinitionCollection_To_CS (ResoruceRaw, &MetricDefinitionCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricDefinitionCollection = (EFI_REDFISH_METRICDEFINITIONCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICDEFINITIONCOLLECTION)); + if (MetricDefinitionCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricDefinitionCollection; + MetricDefinitionCollection->MetricDefinitionCollection = MetricDefinitionCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricDefinitionCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricDefinitionCollection"), "MetricDefinitionCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricDefinitionCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricDefinitionCollection"), "MetricDefinitionCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricDefinitionCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricDefinitionCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricDefinitionCollection_JSON (*((EFI_REDFISH_METRICDEFINITIONCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricDefinitionCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICDEFINITIONCOLLECTION *MetricDefinitionCollection; + + MetricDefinitionCollection = (EFI_REDFISH_METRICDEFINITIONCOLLECTION *)InterpProp; + DestroyMetricDefinitionCollection_CS (MetricDefinitionCollection->MetricDefinitionCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricDefinitionCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricDefinitionCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricDefinitionCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricDefinitionCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricDefinitionCollectionToStructWrapper, + MetricDefinitionCollectionToJson, + MetricDefinitionCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricDefinitionCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricDefinitionCollection/RedfishMetricDefinitionCollection_Dxe.inf b/RedfishClientPkg/Converter/MetricDefinitionCollection/RedfishMetricDefinitionCollection_Dxe.inf new file mode 100644 index 00000000000..7e71cab098c --- /dev/null +++ b/RedfishClientPkg/Converter/MetricDefinitionCollection/RedfishMetricDefinitionCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricDefinitionCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricDefinitionCollection_Dxe + FILE_GUID = ba591f70-f02d-45c0-8d55-ee06dd68a65e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricDefinitionCollectionEntryPoint + UNLOAD_IMAGE = RedfishMetricDefinitionCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricDefinitionCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricDefinitionCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReport/v1_0_0/MetricReport_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/MetricReport/v1_0_0/MetricReport_V1_0_0_Dxe.c new file mode 100644 index 00000000000..73084d5b128 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_0_0/MetricReport_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReport.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReport"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReport V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReport", + "1", + "0", + "0" + }, + "MetricReport" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_0_0 *MetricReportV1_0_0; + EFI_REDFISH_METRICREPORT_V1_0_0_CS *MetricReportV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReport") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReport_V1_0_0_To_CS (ResoruceRaw, &MetricReportV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportV1_0_0 = (EFI_REDFISH_METRICREPORT_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORT_V1_0_0)); + if (MetricReportV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportV1_0_0; + MetricReportV1_0_0->MetricReport = MetricReportV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReport"), "MetricReport"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReport"), "MetricReport"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReport_V1_0_0_JSON (*((EFI_REDFISH_METRICREPORT_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_0_0 *MetricReportV1_0_0; + + MetricReportV1_0_0 = (EFI_REDFISH_METRICREPORT_V1_0_0 *)InterpProp; + DestroyMetricReport_V1_0_0_CS (MetricReportV1_0_0->MetricReport); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReport_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportToStructWrapper, + MetricReportToJson, + MetricReportDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReport/v1_0_0/RedfishMetricReport_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/MetricReport/v1_0_0/RedfishMetricReport_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..a55c21c4c5f --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_0_0/RedfishMetricReport_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReport.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReport_V1_0_0_Dxe + FILE_GUID = 55338434-e225-4877-a56d-db819738c6af + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReport_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishMetricReport_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReport_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReport/v1_0_1/MetricReport_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/MetricReport/v1_0_1/MetricReport_V1_0_1_Dxe.c new file mode 100644 index 00000000000..be5ab95ab64 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_0_1/MetricReport_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReport.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReport"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReport V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReport", + "1", + "0", + "1" + }, + "MetricReport" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_0_1 *MetricReportV1_0_1; + EFI_REDFISH_METRICREPORT_V1_0_1_CS *MetricReportV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReport") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReport_V1_0_1_To_CS (ResoruceRaw, &MetricReportV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportV1_0_1 = (EFI_REDFISH_METRICREPORT_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORT_V1_0_1)); + if (MetricReportV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportV1_0_1; + MetricReportV1_0_1->MetricReport = MetricReportV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReport"), "MetricReport"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReport"), "MetricReport"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReport_V1_0_1_JSON (*((EFI_REDFISH_METRICREPORT_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_0_1 *MetricReportV1_0_1; + + MetricReportV1_0_1 = (EFI_REDFISH_METRICREPORT_V1_0_1 *)InterpProp; + DestroyMetricReport_V1_0_1_CS (MetricReportV1_0_1->MetricReport); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReport_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportToStructWrapper, + MetricReportToJson, + MetricReportDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReport/v1_0_1/RedfishMetricReport_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/MetricReport/v1_0_1/RedfishMetricReport_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..52f8de910a1 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_0_1/RedfishMetricReport_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReport.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReport_V1_0_1_Dxe + FILE_GUID = af603daa-dfc4-45f9-8629-f6f77d10666b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReport_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishMetricReport_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReport_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReport/v1_0_2/MetricReport_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/MetricReport/v1_0_2/MetricReport_V1_0_2_Dxe.c new file mode 100644 index 00000000000..519866ec347 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_0_2/MetricReport_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReport.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReport"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReport V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReport", + "1", + "0", + "2" + }, + "MetricReport" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_0_2 *MetricReportV1_0_2; + EFI_REDFISH_METRICREPORT_V1_0_2_CS *MetricReportV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReport") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReport_V1_0_2_To_CS (ResoruceRaw, &MetricReportV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportV1_0_2 = (EFI_REDFISH_METRICREPORT_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORT_V1_0_2)); + if (MetricReportV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportV1_0_2; + MetricReportV1_0_2->MetricReport = MetricReportV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReport"), "MetricReport"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReport"), "MetricReport"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReport_V1_0_2_JSON (*((EFI_REDFISH_METRICREPORT_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_0_2 *MetricReportV1_0_2; + + MetricReportV1_0_2 = (EFI_REDFISH_METRICREPORT_V1_0_2 *)InterpProp; + DestroyMetricReport_V1_0_2_CS (MetricReportV1_0_2->MetricReport); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReport_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportToStructWrapper, + MetricReportToJson, + MetricReportDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReport/v1_0_2/RedfishMetricReport_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/MetricReport/v1_0_2/RedfishMetricReport_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..721d0f68b9b --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_0_2/RedfishMetricReport_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReport.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReport_V1_0_2_Dxe + FILE_GUID = 9cf17254-7d5e-4c8d-9472-43ae5e4a5a54 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReport_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishMetricReport_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReport_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReport/v1_0_3/MetricReport_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/MetricReport/v1_0_3/MetricReport_V1_0_3_Dxe.c new file mode 100644 index 00000000000..4626754a4f4 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_0_3/MetricReport_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReport.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReport"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReport V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReport", + "1", + "0", + "3" + }, + "MetricReport" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_0_3 *MetricReportV1_0_3; + EFI_REDFISH_METRICREPORT_V1_0_3_CS *MetricReportV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReport") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReport_V1_0_3_To_CS (ResoruceRaw, &MetricReportV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportV1_0_3 = (EFI_REDFISH_METRICREPORT_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORT_V1_0_3)); + if (MetricReportV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportV1_0_3; + MetricReportV1_0_3->MetricReport = MetricReportV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReport"), "MetricReport"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReport"), "MetricReport"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReport_V1_0_3_JSON (*((EFI_REDFISH_METRICREPORT_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_0_3 *MetricReportV1_0_3; + + MetricReportV1_0_3 = (EFI_REDFISH_METRICREPORT_V1_0_3 *)InterpProp; + DestroyMetricReport_V1_0_3_CS (MetricReportV1_0_3->MetricReport); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReport_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportToStructWrapper, + MetricReportToJson, + MetricReportDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReport/v1_0_3/RedfishMetricReport_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/MetricReport/v1_0_3/RedfishMetricReport_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..b2eb8657c81 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_0_3/RedfishMetricReport_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReport.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReport_V1_0_3_Dxe + FILE_GUID = 77576557-2237-42cf-bd35-83d05f04f338 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReport_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishMetricReport_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReport_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReport/v1_0_4/MetricReport_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/MetricReport/v1_0_4/MetricReport_V1_0_4_Dxe.c new file mode 100644 index 00000000000..d5a3afa717f --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_0_4/MetricReport_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReport.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReport"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReport V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReport", + "1", + "0", + "4" + }, + "MetricReport" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_0_4 *MetricReportV1_0_4; + EFI_REDFISH_METRICREPORT_V1_0_4_CS *MetricReportV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReport") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReport_V1_0_4_To_CS (ResoruceRaw, &MetricReportV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportV1_0_4 = (EFI_REDFISH_METRICREPORT_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORT_V1_0_4)); + if (MetricReportV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportV1_0_4; + MetricReportV1_0_4->MetricReport = MetricReportV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReport"), "MetricReport"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReport"), "MetricReport"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReport_V1_0_4_JSON (*((EFI_REDFISH_METRICREPORT_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_0_4 *MetricReportV1_0_4; + + MetricReportV1_0_4 = (EFI_REDFISH_METRICREPORT_V1_0_4 *)InterpProp; + DestroyMetricReport_V1_0_4_CS (MetricReportV1_0_4->MetricReport); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReport_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportToStructWrapper, + MetricReportToJson, + MetricReportDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReport/v1_0_4/RedfishMetricReport_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/MetricReport/v1_0_4/RedfishMetricReport_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..8cd14145715 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_0_4/RedfishMetricReport_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReport.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReport_V1_0_4_Dxe + FILE_GUID = 1f3d5829-2572-481a-8fb3-4054b5c7f520 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReport_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishMetricReport_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReport_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReport/v1_0_5/MetricReport_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/MetricReport/v1_0_5/MetricReport_V1_0_5_Dxe.c new file mode 100644 index 00000000000..6efdee85ba7 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_0_5/MetricReport_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReport.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReport"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReport V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReport", + "1", + "0", + "5" + }, + "MetricReport" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_0_5 *MetricReportV1_0_5; + EFI_REDFISH_METRICREPORT_V1_0_5_CS *MetricReportV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReport") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReport_V1_0_5_To_CS (ResoruceRaw, &MetricReportV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportV1_0_5 = (EFI_REDFISH_METRICREPORT_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORT_V1_0_5)); + if (MetricReportV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportV1_0_5; + MetricReportV1_0_5->MetricReport = MetricReportV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReport"), "MetricReport"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReport"), "MetricReport"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReport_V1_0_5_JSON (*((EFI_REDFISH_METRICREPORT_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_0_5 *MetricReportV1_0_5; + + MetricReportV1_0_5 = (EFI_REDFISH_METRICREPORT_V1_0_5 *)InterpProp; + DestroyMetricReport_V1_0_5_CS (MetricReportV1_0_5->MetricReport); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReport_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportToStructWrapper, + MetricReportToJson, + MetricReportDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReport/v1_0_5/RedfishMetricReport_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/MetricReport/v1_0_5/RedfishMetricReport_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..c02e20b291e --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_0_5/RedfishMetricReport_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReport.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReport_V1_0_5_Dxe + FILE_GUID = 7273e1a9-ab34-417d-8e99-e10e55ef6d9f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReport_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishMetricReport_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReport_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReport/v1_0_6/MetricReport_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/MetricReport/v1_0_6/MetricReport_V1_0_6_Dxe.c new file mode 100644 index 00000000000..a494080bf75 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_0_6/MetricReport_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReport.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReport"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReport V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReport", + "1", + "0", + "6" + }, + "MetricReport" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_0_6 *MetricReportV1_0_6; + EFI_REDFISH_METRICREPORT_V1_0_6_CS *MetricReportV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReport") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReport_V1_0_6_To_CS (ResoruceRaw, &MetricReportV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportV1_0_6 = (EFI_REDFISH_METRICREPORT_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORT_V1_0_6)); + if (MetricReportV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportV1_0_6; + MetricReportV1_0_6->MetricReport = MetricReportV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReport"), "MetricReport"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReport"), "MetricReport"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReport_V1_0_6_JSON (*((EFI_REDFISH_METRICREPORT_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_0_6 *MetricReportV1_0_6; + + MetricReportV1_0_6 = (EFI_REDFISH_METRICREPORT_V1_0_6 *)InterpProp; + DestroyMetricReport_V1_0_6_CS (MetricReportV1_0_6->MetricReport); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReport_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportToStructWrapper, + MetricReportToJson, + MetricReportDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReport/v1_0_6/RedfishMetricReport_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/MetricReport/v1_0_6/RedfishMetricReport_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..f9e5b27625a --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_0_6/RedfishMetricReport_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReport.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReport_V1_0_6_Dxe + FILE_GUID = 00de3cd5-543a-45a2-aa0f-66936faaf0a1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReport_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishMetricReport_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReport_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReport/v1_1_0/MetricReport_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/MetricReport/v1_1_0/MetricReport_V1_1_0_Dxe.c new file mode 100644 index 00000000000..cfe4938ded3 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_1_0/MetricReport_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReport.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReport"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReport V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReport", + "1", + "1", + "0" + }, + "MetricReport" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_1_0 *MetricReportV1_1_0; + EFI_REDFISH_METRICREPORT_V1_1_0_CS *MetricReportV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReport") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReport_V1_1_0_To_CS (ResoruceRaw, &MetricReportV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportV1_1_0 = (EFI_REDFISH_METRICREPORT_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORT_V1_1_0)); + if (MetricReportV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportV1_1_0; + MetricReportV1_1_0->MetricReport = MetricReportV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReport"), "MetricReport"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReport"), "MetricReport"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReport_V1_1_0_JSON (*((EFI_REDFISH_METRICREPORT_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_1_0 *MetricReportV1_1_0; + + MetricReportV1_1_0 = (EFI_REDFISH_METRICREPORT_V1_1_0 *)InterpProp; + DestroyMetricReport_V1_1_0_CS (MetricReportV1_1_0->MetricReport); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReport_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportToStructWrapper, + MetricReportToJson, + MetricReportDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReport/v1_1_0/RedfishMetricReport_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/MetricReport/v1_1_0/RedfishMetricReport_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..ff69048b2e7 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_1_0/RedfishMetricReport_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReport.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReport_V1_1_0_Dxe + FILE_GUID = a0385fcd-c243-4136-bef5-a37711105cce + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReport_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishMetricReport_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReport_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReport/v1_1_1/MetricReport_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/MetricReport/v1_1_1/MetricReport_V1_1_1_Dxe.c new file mode 100644 index 00000000000..c3a8abe6935 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_1_1/MetricReport_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReport.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReport"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReport V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReport", + "1", + "1", + "1" + }, + "MetricReport" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_1_1 *MetricReportV1_1_1; + EFI_REDFISH_METRICREPORT_V1_1_1_CS *MetricReportV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReport") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReport_V1_1_1_To_CS (ResoruceRaw, &MetricReportV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportV1_1_1 = (EFI_REDFISH_METRICREPORT_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORT_V1_1_1)); + if (MetricReportV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportV1_1_1; + MetricReportV1_1_1->MetricReport = MetricReportV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReport"), "MetricReport"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReport"), "MetricReport"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReport_V1_1_1_JSON (*((EFI_REDFISH_METRICREPORT_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_1_1 *MetricReportV1_1_1; + + MetricReportV1_1_1 = (EFI_REDFISH_METRICREPORT_V1_1_1 *)InterpProp; + DestroyMetricReport_V1_1_1_CS (MetricReportV1_1_1->MetricReport); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReport_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportToStructWrapper, + MetricReportToJson, + MetricReportDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReport/v1_1_1/RedfishMetricReport_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/MetricReport/v1_1_1/RedfishMetricReport_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..c3ee9c0ae3d --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_1_1/RedfishMetricReport_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReport.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReport_V1_1_1_Dxe + FILE_GUID = 533055a3-a4c7-4e18-8f2d-85eb305234db + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReport_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishMetricReport_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReport_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReport/v1_1_2/MetricReport_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/MetricReport/v1_1_2/MetricReport_V1_1_2_Dxe.c new file mode 100644 index 00000000000..d5757515050 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_1_2/MetricReport_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReport.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReport"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReport V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReport", + "1", + "1", + "2" + }, + "MetricReport" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_1_2 *MetricReportV1_1_2; + EFI_REDFISH_METRICREPORT_V1_1_2_CS *MetricReportV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReport") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReport_V1_1_2_To_CS (ResoruceRaw, &MetricReportV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportV1_1_2 = (EFI_REDFISH_METRICREPORT_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORT_V1_1_2)); + if (MetricReportV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportV1_1_2; + MetricReportV1_1_2->MetricReport = MetricReportV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReport"), "MetricReport"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReport"), "MetricReport"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReport_V1_1_2_JSON (*((EFI_REDFISH_METRICREPORT_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_1_2 *MetricReportV1_1_2; + + MetricReportV1_1_2 = (EFI_REDFISH_METRICREPORT_V1_1_2 *)InterpProp; + DestroyMetricReport_V1_1_2_CS (MetricReportV1_1_2->MetricReport); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReport_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportToStructWrapper, + MetricReportToJson, + MetricReportDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReport/v1_1_2/RedfishMetricReport_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/MetricReport/v1_1_2/RedfishMetricReport_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..a005351edf4 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_1_2/RedfishMetricReport_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReport.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReport_V1_1_2_Dxe + FILE_GUID = 90ee0674-834a-4ad0-961f-69cec68853a4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReport_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishMetricReport_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReport_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReport/v1_1_3/MetricReport_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/MetricReport/v1_1_3/MetricReport_V1_1_3_Dxe.c new file mode 100644 index 00000000000..396f76960ee --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_1_3/MetricReport_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReport.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReport"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReport V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReport", + "1", + "1", + "3" + }, + "MetricReport" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_1_3 *MetricReportV1_1_3; + EFI_REDFISH_METRICREPORT_V1_1_3_CS *MetricReportV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReport") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReport_V1_1_3_To_CS (ResoruceRaw, &MetricReportV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportV1_1_3 = (EFI_REDFISH_METRICREPORT_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORT_V1_1_3)); + if (MetricReportV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportV1_1_3; + MetricReportV1_1_3->MetricReport = MetricReportV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReport"), "MetricReport"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReport"), "MetricReport"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReport_V1_1_3_JSON (*((EFI_REDFISH_METRICREPORT_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_1_3 *MetricReportV1_1_3; + + MetricReportV1_1_3 = (EFI_REDFISH_METRICREPORT_V1_1_3 *)InterpProp; + DestroyMetricReport_V1_1_3_CS (MetricReportV1_1_3->MetricReport); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReport_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportToStructWrapper, + MetricReportToJson, + MetricReportDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReport/v1_1_3/RedfishMetricReport_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/MetricReport/v1_1_3/RedfishMetricReport_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..57a01fd5557 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_1_3/RedfishMetricReport_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReport.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReport_V1_1_3_Dxe + FILE_GUID = 72b3fd98-b64d-4d72-8fc3-3e0c9263f1ed + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReport_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishMetricReport_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReport_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReport/v1_1_4/MetricReport_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/MetricReport/v1_1_4/MetricReport_V1_1_4_Dxe.c new file mode 100644 index 00000000000..0efb2ce26a6 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_1_4/MetricReport_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReport.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReport"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReport V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReport", + "1", + "1", + "4" + }, + "MetricReport" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_1_4 *MetricReportV1_1_4; + EFI_REDFISH_METRICREPORT_V1_1_4_CS *MetricReportV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReport") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReport_V1_1_4_To_CS (ResoruceRaw, &MetricReportV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportV1_1_4 = (EFI_REDFISH_METRICREPORT_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORT_V1_1_4)); + if (MetricReportV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportV1_1_4; + MetricReportV1_1_4->MetricReport = MetricReportV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReport"), "MetricReport"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReport"), "MetricReport"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReport_V1_1_4_JSON (*((EFI_REDFISH_METRICREPORT_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_1_4 *MetricReportV1_1_4; + + MetricReportV1_1_4 = (EFI_REDFISH_METRICREPORT_V1_1_4 *)InterpProp; + DestroyMetricReport_V1_1_4_CS (MetricReportV1_1_4->MetricReport); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReport_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportToStructWrapper, + MetricReportToJson, + MetricReportDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReport/v1_1_4/RedfishMetricReport_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/MetricReport/v1_1_4/RedfishMetricReport_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..427aeaab84b --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_1_4/RedfishMetricReport_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReport.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReport_V1_1_4_Dxe + FILE_GUID = 496e7abb-758e-43bd-97ed-db871edc98da + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReport_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishMetricReport_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReport_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReport/v1_1_5/MetricReport_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/MetricReport/v1_1_5/MetricReport_V1_1_5_Dxe.c new file mode 100644 index 00000000000..027d1e09d67 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_1_5/MetricReport_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReport.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReport"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReport V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReport", + "1", + "1", + "5" + }, + "MetricReport" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_1_5 *MetricReportV1_1_5; + EFI_REDFISH_METRICREPORT_V1_1_5_CS *MetricReportV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReport") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReport_V1_1_5_To_CS (ResoruceRaw, &MetricReportV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportV1_1_5 = (EFI_REDFISH_METRICREPORT_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORT_V1_1_5)); + if (MetricReportV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportV1_1_5; + MetricReportV1_1_5->MetricReport = MetricReportV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReport"), "MetricReport"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReport"), "MetricReport"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReport_V1_1_5_JSON (*((EFI_REDFISH_METRICREPORT_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_1_5 *MetricReportV1_1_5; + + MetricReportV1_1_5 = (EFI_REDFISH_METRICREPORT_V1_1_5 *)InterpProp; + DestroyMetricReport_V1_1_5_CS (MetricReportV1_1_5->MetricReport); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReport_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportToStructWrapper, + MetricReportToJson, + MetricReportDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReport/v1_1_5/RedfishMetricReport_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/MetricReport/v1_1_5/RedfishMetricReport_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..5e5dc3f5be7 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_1_5/RedfishMetricReport_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReport.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReport_V1_1_5_Dxe + FILE_GUID = aa6a197f-772f-4eb2-a8b2-932a7657bb2b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReport_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishMetricReport_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReport_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReport/v1_2_0/MetricReport_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/MetricReport/v1_2_0/MetricReport_V1_2_0_Dxe.c new file mode 100644 index 00000000000..0820eec95dc --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_2_0/MetricReport_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReport.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReport"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReport V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReport", + "1", + "2", + "0" + }, + "MetricReport" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_2_0 *MetricReportV1_2_0; + EFI_REDFISH_METRICREPORT_V1_2_0_CS *MetricReportV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReport") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReport_V1_2_0_To_CS (ResoruceRaw, &MetricReportV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportV1_2_0 = (EFI_REDFISH_METRICREPORT_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORT_V1_2_0)); + if (MetricReportV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportV1_2_0; + MetricReportV1_2_0->MetricReport = MetricReportV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReport"), "MetricReport"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReport"), "MetricReport"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReport_V1_2_0_JSON (*((EFI_REDFISH_METRICREPORT_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_2_0 *MetricReportV1_2_0; + + MetricReportV1_2_0 = (EFI_REDFISH_METRICREPORT_V1_2_0 *)InterpProp; + DestroyMetricReport_V1_2_0_CS (MetricReportV1_2_0->MetricReport); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReport_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportToStructWrapper, + MetricReportToJson, + MetricReportDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReport/v1_2_0/RedfishMetricReport_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/MetricReport/v1_2_0/RedfishMetricReport_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..07e2984b598 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_2_0/RedfishMetricReport_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReport.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReport_V1_2_0_Dxe + FILE_GUID = 38b29096-f642-428e-a30e-f4674c23dda4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReport_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishMetricReport_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReport_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReport/v1_2_1/MetricReport_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/MetricReport/v1_2_1/MetricReport_V1_2_1_Dxe.c new file mode 100644 index 00000000000..79ac506e2bd --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_2_1/MetricReport_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReport.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReport"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReport V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReport", + "1", + "2", + "1" + }, + "MetricReport" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_2_1 *MetricReportV1_2_1; + EFI_REDFISH_METRICREPORT_V1_2_1_CS *MetricReportV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReport") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReport_V1_2_1_To_CS (ResoruceRaw, &MetricReportV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportV1_2_1 = (EFI_REDFISH_METRICREPORT_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORT_V1_2_1)); + if (MetricReportV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportV1_2_1; + MetricReportV1_2_1->MetricReport = MetricReportV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReport"), "MetricReport"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReport"), "MetricReport"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReport_V1_2_1_JSON (*((EFI_REDFISH_METRICREPORT_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_2_1 *MetricReportV1_2_1; + + MetricReportV1_2_1 = (EFI_REDFISH_METRICREPORT_V1_2_1 *)InterpProp; + DestroyMetricReport_V1_2_1_CS (MetricReportV1_2_1->MetricReport); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReport_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportToStructWrapper, + MetricReportToJson, + MetricReportDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReport/v1_2_1/RedfishMetricReport_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/MetricReport/v1_2_1/RedfishMetricReport_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..e423963a93a --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_2_1/RedfishMetricReport_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReport.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReport_V1_2_1_Dxe + FILE_GUID = f9086a29-840f-4a7f-b45c-6f79241d78ea + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReport_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishMetricReport_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReport_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReport/v1_2_2/MetricReport_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/MetricReport/v1_2_2/MetricReport_V1_2_2_Dxe.c new file mode 100644 index 00000000000..dac1de652ab --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_2_2/MetricReport_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReport.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReport"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReport V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReport", + "1", + "2", + "2" + }, + "MetricReport" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_2_2 *MetricReportV1_2_2; + EFI_REDFISH_METRICREPORT_V1_2_2_CS *MetricReportV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReport") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReport_V1_2_2_To_CS (ResoruceRaw, &MetricReportV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportV1_2_2 = (EFI_REDFISH_METRICREPORT_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORT_V1_2_2)); + if (MetricReportV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportV1_2_2; + MetricReportV1_2_2->MetricReport = MetricReportV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReport"), "MetricReport"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReport"), "MetricReport"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReport_V1_2_2_JSON (*((EFI_REDFISH_METRICREPORT_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_2_2 *MetricReportV1_2_2; + + MetricReportV1_2_2 = (EFI_REDFISH_METRICREPORT_V1_2_2 *)InterpProp; + DestroyMetricReport_V1_2_2_CS (MetricReportV1_2_2->MetricReport); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReport_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportToStructWrapper, + MetricReportToJson, + MetricReportDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReport/v1_2_2/RedfishMetricReport_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/MetricReport/v1_2_2/RedfishMetricReport_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..b4d4c6b326f --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_2_2/RedfishMetricReport_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReport.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReport_V1_2_2_Dxe + FILE_GUID = b4e5f71c-1410-4c35-947b-5923312f5cda + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReport_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishMetricReport_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReport_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReport/v1_2_3/MetricReport_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/MetricReport/v1_2_3/MetricReport_V1_2_3_Dxe.c new file mode 100644 index 00000000000..133b7fe0862 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_2_3/MetricReport_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReport.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReport"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReport V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReport", + "1", + "2", + "3" + }, + "MetricReport" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_2_3 *MetricReportV1_2_3; + EFI_REDFISH_METRICREPORT_V1_2_3_CS *MetricReportV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReport") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReport_V1_2_3_To_CS (ResoruceRaw, &MetricReportV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportV1_2_3 = (EFI_REDFISH_METRICREPORT_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORT_V1_2_3)); + if (MetricReportV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportV1_2_3; + MetricReportV1_2_3->MetricReport = MetricReportV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReport"), "MetricReport"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReport"), "MetricReport"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReport_V1_2_3_JSON (*((EFI_REDFISH_METRICREPORT_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_2_3 *MetricReportV1_2_3; + + MetricReportV1_2_3 = (EFI_REDFISH_METRICREPORT_V1_2_3 *)InterpProp; + DestroyMetricReport_V1_2_3_CS (MetricReportV1_2_3->MetricReport); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReport_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportToStructWrapper, + MetricReportToJson, + MetricReportDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReport/v1_2_3/RedfishMetricReport_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/MetricReport/v1_2_3/RedfishMetricReport_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..a8409bd08c3 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_2_3/RedfishMetricReport_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReport.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReport_V1_2_3_Dxe + FILE_GUID = 186302ba-429e-4f7d-8539-9a39a2a3da6d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReport_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishMetricReport_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReport_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReport/v1_3_0/MetricReport_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/MetricReport/v1_3_0/MetricReport_V1_3_0_Dxe.c new file mode 100644 index 00000000000..7743b9f3701 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_3_0/MetricReport_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReport.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReport"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReport V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReport", + "1", + "3", + "0" + }, + "MetricReport" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_3_0 *MetricReportV1_3_0; + EFI_REDFISH_METRICREPORT_V1_3_0_CS *MetricReportV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReport") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReport_V1_3_0_To_CS (ResoruceRaw, &MetricReportV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportV1_3_0 = (EFI_REDFISH_METRICREPORT_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORT_V1_3_0)); + if (MetricReportV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportV1_3_0; + MetricReportV1_3_0->MetricReport = MetricReportV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReport"), "MetricReport"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReport"), "MetricReport"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReport_V1_3_0_JSON (*((EFI_REDFISH_METRICREPORT_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_3_0 *MetricReportV1_3_0; + + MetricReportV1_3_0 = (EFI_REDFISH_METRICREPORT_V1_3_0 *)InterpProp; + DestroyMetricReport_V1_3_0_CS (MetricReportV1_3_0->MetricReport); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReport_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportToStructWrapper, + MetricReportToJson, + MetricReportDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReport/v1_3_0/RedfishMetricReport_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/MetricReport/v1_3_0/RedfishMetricReport_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..62b797ffc06 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_3_0/RedfishMetricReport_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReport.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReport_V1_3_0_Dxe + FILE_GUID = e8f36e2e-f299-4cae-9822-0ec7ad0861aa + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReport_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishMetricReport_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReport_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReport/v1_3_1/MetricReport_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/MetricReport/v1_3_1/MetricReport_V1_3_1_Dxe.c new file mode 100644 index 00000000000..edce0112762 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_3_1/MetricReport_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReport.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReport"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReport V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReport", + "1", + "3", + "1" + }, + "MetricReport" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_3_1 *MetricReportV1_3_1; + EFI_REDFISH_METRICREPORT_V1_3_1_CS *MetricReportV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReport") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReport_V1_3_1_To_CS (ResoruceRaw, &MetricReportV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportV1_3_1 = (EFI_REDFISH_METRICREPORT_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORT_V1_3_1)); + if (MetricReportV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportV1_3_1; + MetricReportV1_3_1->MetricReport = MetricReportV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReport"), "MetricReport"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReport"), "MetricReport"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReport_V1_3_1_JSON (*((EFI_REDFISH_METRICREPORT_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_3_1 *MetricReportV1_3_1; + + MetricReportV1_3_1 = (EFI_REDFISH_METRICREPORT_V1_3_1 *)InterpProp; + DestroyMetricReport_V1_3_1_CS (MetricReportV1_3_1->MetricReport); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReport_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportToStructWrapper, + MetricReportToJson, + MetricReportDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReport/v1_3_1/RedfishMetricReport_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/MetricReport/v1_3_1/RedfishMetricReport_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..37760903ad1 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_3_1/RedfishMetricReport_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReport.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReport_V1_3_1_Dxe + FILE_GUID = 6e997811-5730-4f03-b908-e05ed2338548 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReport_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishMetricReport_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReport_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReport/v1_3_2/MetricReport_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/MetricReport/v1_3_2/MetricReport_V1_3_2_Dxe.c new file mode 100644 index 00000000000..d6e73733391 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_3_2/MetricReport_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReport.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReport"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReport V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReport", + "1", + "3", + "2" + }, + "MetricReport" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_3_2 *MetricReportV1_3_2; + EFI_REDFISH_METRICREPORT_V1_3_2_CS *MetricReportV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReport") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReport_V1_3_2_To_CS (ResoruceRaw, &MetricReportV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportV1_3_2 = (EFI_REDFISH_METRICREPORT_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORT_V1_3_2)); + if (MetricReportV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportV1_3_2; + MetricReportV1_3_2->MetricReport = MetricReportV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReport"), "MetricReport"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReport"), "MetricReport"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReport_V1_3_2_JSON (*((EFI_REDFISH_METRICREPORT_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_3_2 *MetricReportV1_3_2; + + MetricReportV1_3_2 = (EFI_REDFISH_METRICREPORT_V1_3_2 *)InterpProp; + DestroyMetricReport_V1_3_2_CS (MetricReportV1_3_2->MetricReport); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReport_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportToStructWrapper, + MetricReportToJson, + MetricReportDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReport/v1_3_2/RedfishMetricReport_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/MetricReport/v1_3_2/RedfishMetricReport_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..e33a1465d7a --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_3_2/RedfishMetricReport_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReport.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReport_V1_3_2_Dxe + FILE_GUID = c8c56d56-322a-4973-9ea0-6bac65fc76a8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReport_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishMetricReport_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReport_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReport/v1_4_0/MetricReport_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/MetricReport/v1_4_0/MetricReport_V1_4_0_Dxe.c new file mode 100644 index 00000000000..3eb07898fb5 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_4_0/MetricReport_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReport.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReport"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReport V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReport", + "1", + "4", + "0" + }, + "MetricReport" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_4_0 *MetricReportV1_4_0; + EFI_REDFISH_METRICREPORT_V1_4_0_CS *MetricReportV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReport") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReport_V1_4_0_To_CS (ResoruceRaw, &MetricReportV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportV1_4_0 = (EFI_REDFISH_METRICREPORT_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORT_V1_4_0)); + if (MetricReportV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportV1_4_0; + MetricReportV1_4_0->MetricReport = MetricReportV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReport"), "MetricReport"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReport"), "MetricReport"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReport_V1_4_0_JSON (*((EFI_REDFISH_METRICREPORT_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_4_0 *MetricReportV1_4_0; + + MetricReportV1_4_0 = (EFI_REDFISH_METRICREPORT_V1_4_0 *)InterpProp; + DestroyMetricReport_V1_4_0_CS (MetricReportV1_4_0->MetricReport); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReport_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportToStructWrapper, + MetricReportToJson, + MetricReportDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReport/v1_4_0/RedfishMetricReport_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/MetricReport/v1_4_0/RedfishMetricReport_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..46d48153e0d --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_4_0/RedfishMetricReport_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReport.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReport_V1_4_0_Dxe + FILE_GUID = 1f0fade8-2149-417d-af75-afd38d4e8b6b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReport_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishMetricReport_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReport_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReport/v1_4_1/MetricReport_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/MetricReport/v1_4_1/MetricReport_V1_4_1_Dxe.c new file mode 100644 index 00000000000..867f862fbe3 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_4_1/MetricReport_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReport.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReport"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReport V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReport", + "1", + "4", + "1" + }, + "MetricReport" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_4_1 *MetricReportV1_4_1; + EFI_REDFISH_METRICREPORT_V1_4_1_CS *MetricReportV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReport") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReport_V1_4_1_To_CS (ResoruceRaw, &MetricReportV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportV1_4_1 = (EFI_REDFISH_METRICREPORT_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORT_V1_4_1)); + if (MetricReportV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportV1_4_1; + MetricReportV1_4_1->MetricReport = MetricReportV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReport"), "MetricReport"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReport")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReport"), "MetricReport"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReport_V1_4_1_JSON (*((EFI_REDFISH_METRICREPORT_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORT_V1_4_1 *MetricReportV1_4_1; + + MetricReportV1_4_1 = (EFI_REDFISH_METRICREPORT_V1_4_1 *)InterpProp; + DestroyMetricReport_V1_4_1_CS (MetricReportV1_4_1->MetricReport); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReport_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportToStructWrapper, + MetricReportToJson, + MetricReportDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReport_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReport/v1_4_1/RedfishMetricReport_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/MetricReport/v1_4_1/RedfishMetricReport_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..105d49de1f8 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReport/v1_4_1/RedfishMetricReport_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReport.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReport_V1_4_1_Dxe + FILE_GUID = d2fb1478-1742-43c5-9dd6-feddffcf7fef + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReport_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishMetricReport_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReport_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportCollection/MetricReportCollection_Dxe.c b/RedfishClientPkg/Converter/MetricReportCollection/MetricReportCollection_Dxe.c new file mode 100644 index 00000000000..38b3bb9ef64 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportCollection/MetricReportCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support MetricReportCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "MetricReportCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTCOLLECTION *MetricReportCollection; + EFI_REDFISH_METRICREPORTCOLLECTION_CS *MetricReportCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportCollection_To_CS (ResoruceRaw, &MetricReportCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportCollection = (EFI_REDFISH_METRICREPORTCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTCOLLECTION)); + if (MetricReportCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportCollection; + MetricReportCollection->MetricReportCollection = MetricReportCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportCollection"), "MetricReportCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportCollection"), "MetricReportCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportCollection_JSON (*((EFI_REDFISH_METRICREPORTCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTCOLLECTION *MetricReportCollection; + + MetricReportCollection = (EFI_REDFISH_METRICREPORTCOLLECTION *)InterpProp; + DestroyMetricReportCollection_CS (MetricReportCollection->MetricReportCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportCollectionToStructWrapper, + MetricReportCollectionToJson, + MetricReportCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportCollection/RedfishMetricReportCollection_Dxe.inf b/RedfishClientPkg/Converter/MetricReportCollection/RedfishMetricReportCollection_Dxe.inf new file mode 100644 index 00000000000..c5e333b5585 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportCollection/RedfishMetricReportCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportCollection_Dxe + FILE_GUID = 52d94843-2754-4fae-9d21-f68cd1644074 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportCollectionEntryPoint + UNLOAD_IMAGE = RedfishMetricReportCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_0/MetricReportDefinition_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_0/MetricReportDefinition_V1_0_0_Dxe.c new file mode 100644 index 00000000000..1de6403d31b --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_0/MetricReportDefinition_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "0", + "0" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_0 *MetricReportDefinitionV1_0_0; + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_0_CS *MetricReportDefinitionV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_0_0_To_CS (ResoruceRaw, &MetricReportDefinitionV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_0_0 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_0_0)); + if (MetricReportDefinitionV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_0_0; + MetricReportDefinitionV1_0_0->MetricReportDefinition = MetricReportDefinitionV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_0_0_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_0 *MetricReportDefinitionV1_0_0; + + MetricReportDefinitionV1_0_0 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_0_0 *)InterpProp; + DestroyMetricReportDefinition_V1_0_0_CS (MetricReportDefinitionV1_0_0->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_0/RedfishMetricReportDefinition_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_0/RedfishMetricReportDefinition_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..67ee75fe121 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_0/RedfishMetricReportDefinition_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_0_0_Dxe + FILE_GUID = 730d36b1-b98c-4635-8645-caa3a6676c13 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_1/MetricReportDefinition_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_1/MetricReportDefinition_V1_0_1_Dxe.c new file mode 100644 index 00000000000..499fd90d161 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_1/MetricReportDefinition_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "0", + "1" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_1 *MetricReportDefinitionV1_0_1; + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_1_CS *MetricReportDefinitionV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_0_1_To_CS (ResoruceRaw, &MetricReportDefinitionV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_0_1 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_0_1)); + if (MetricReportDefinitionV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_0_1; + MetricReportDefinitionV1_0_1->MetricReportDefinition = MetricReportDefinitionV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_0_1_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_1 *MetricReportDefinitionV1_0_1; + + MetricReportDefinitionV1_0_1 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_0_1 *)InterpProp; + DestroyMetricReportDefinition_V1_0_1_CS (MetricReportDefinitionV1_0_1->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_1/RedfishMetricReportDefinition_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_1/RedfishMetricReportDefinition_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..b60ea568a22 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_1/RedfishMetricReportDefinition_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_0_1_Dxe + FILE_GUID = 2eaa67b1-9a13-4473-9adc-38a3536a32f5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_2/MetricReportDefinition_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_2/MetricReportDefinition_V1_0_2_Dxe.c new file mode 100644 index 00000000000..e25295bb11b --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_2/MetricReportDefinition_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "0", + "2" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_2 *MetricReportDefinitionV1_0_2; + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_2_CS *MetricReportDefinitionV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_0_2_To_CS (ResoruceRaw, &MetricReportDefinitionV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_0_2 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_0_2)); + if (MetricReportDefinitionV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_0_2; + MetricReportDefinitionV1_0_2->MetricReportDefinition = MetricReportDefinitionV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_0_2_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_2 *MetricReportDefinitionV1_0_2; + + MetricReportDefinitionV1_0_2 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_0_2 *)InterpProp; + DestroyMetricReportDefinition_V1_0_2_CS (MetricReportDefinitionV1_0_2->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_2/RedfishMetricReportDefinition_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_2/RedfishMetricReportDefinition_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..e07c97748ae --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_2/RedfishMetricReportDefinition_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_0_2_Dxe + FILE_GUID = ffcd73c8-e66d-4d5a-864d-00f93843f291 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_3/MetricReportDefinition_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_3/MetricReportDefinition_V1_0_3_Dxe.c new file mode 100644 index 00000000000..a3c5dc3db56 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_3/MetricReportDefinition_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "0", + "3" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_3 *MetricReportDefinitionV1_0_3; + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_3_CS *MetricReportDefinitionV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_0_3_To_CS (ResoruceRaw, &MetricReportDefinitionV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_0_3 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_0_3)); + if (MetricReportDefinitionV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_0_3; + MetricReportDefinitionV1_0_3->MetricReportDefinition = MetricReportDefinitionV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_0_3_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_3 *MetricReportDefinitionV1_0_3; + + MetricReportDefinitionV1_0_3 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_0_3 *)InterpProp; + DestroyMetricReportDefinition_V1_0_3_CS (MetricReportDefinitionV1_0_3->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_3/RedfishMetricReportDefinition_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_3/RedfishMetricReportDefinition_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..0ec699a3913 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_3/RedfishMetricReportDefinition_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_0_3_Dxe + FILE_GUID = 7eb52d28-15f8-4730-adea-f89c8f3e8781 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_4/MetricReportDefinition_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_4/MetricReportDefinition_V1_0_4_Dxe.c new file mode 100644 index 00000000000..afeca74a5c7 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_4/MetricReportDefinition_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "0", + "4" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_4 *MetricReportDefinitionV1_0_4; + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_4_CS *MetricReportDefinitionV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_0_4_To_CS (ResoruceRaw, &MetricReportDefinitionV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_0_4 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_0_4)); + if (MetricReportDefinitionV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_0_4; + MetricReportDefinitionV1_0_4->MetricReportDefinition = MetricReportDefinitionV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_0_4_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_4 *MetricReportDefinitionV1_0_4; + + MetricReportDefinitionV1_0_4 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_0_4 *)InterpProp; + DestroyMetricReportDefinition_V1_0_4_CS (MetricReportDefinitionV1_0_4->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_4/RedfishMetricReportDefinition_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_4/RedfishMetricReportDefinition_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..f0292ee43e2 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_4/RedfishMetricReportDefinition_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_0_4_Dxe + FILE_GUID = c8cd389b-0311-42ad-9e54-16a28b70fa76 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_5/MetricReportDefinition_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_5/MetricReportDefinition_V1_0_5_Dxe.c new file mode 100644 index 00000000000..27a36d35b95 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_5/MetricReportDefinition_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "0", + "5" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_5 *MetricReportDefinitionV1_0_5; + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_5_CS *MetricReportDefinitionV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_0_5_To_CS (ResoruceRaw, &MetricReportDefinitionV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_0_5 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_0_5)); + if (MetricReportDefinitionV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_0_5; + MetricReportDefinitionV1_0_5->MetricReportDefinition = MetricReportDefinitionV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_0_5_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_5 *MetricReportDefinitionV1_0_5; + + MetricReportDefinitionV1_0_5 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_0_5 *)InterpProp; + DestroyMetricReportDefinition_V1_0_5_CS (MetricReportDefinitionV1_0_5->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_5/RedfishMetricReportDefinition_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_5/RedfishMetricReportDefinition_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..00dd9923405 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_5/RedfishMetricReportDefinition_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_0_5_Dxe + FILE_GUID = cb2e0263-0ebd-45f7-b48e-5936390142e4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_6/MetricReportDefinition_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_6/MetricReportDefinition_V1_0_6_Dxe.c new file mode 100644 index 00000000000..d5a14c7c1c1 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_6/MetricReportDefinition_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "0", + "6" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_6 *MetricReportDefinitionV1_0_6; + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_6_CS *MetricReportDefinitionV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_0_6_To_CS (ResoruceRaw, &MetricReportDefinitionV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_0_6 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_0_6)); + if (MetricReportDefinitionV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_0_6; + MetricReportDefinitionV1_0_6->MetricReportDefinition = MetricReportDefinitionV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_0_6_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_6 *MetricReportDefinitionV1_0_6; + + MetricReportDefinitionV1_0_6 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_0_6 *)InterpProp; + DestroyMetricReportDefinition_V1_0_6_CS (MetricReportDefinitionV1_0_6->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_6/RedfishMetricReportDefinition_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_6/RedfishMetricReportDefinition_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..2e112698dd8 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_6/RedfishMetricReportDefinition_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_0_6_Dxe + FILE_GUID = 70633bd2-7ae7-4d3f-ae82-e214441e69a6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_7/MetricReportDefinition_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_7/MetricReportDefinition_V1_0_7_Dxe.c new file mode 100644 index 00000000000..bfd3650fbf3 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_7/MetricReportDefinition_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "0", + "7" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_7 *MetricReportDefinitionV1_0_7; + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_7_CS *MetricReportDefinitionV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_0_7_To_CS (ResoruceRaw, &MetricReportDefinitionV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_0_7 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_0_7)); + if (MetricReportDefinitionV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_0_7; + MetricReportDefinitionV1_0_7->MetricReportDefinition = MetricReportDefinitionV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_0_7_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_7 *MetricReportDefinitionV1_0_7; + + MetricReportDefinitionV1_0_7 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_0_7 *)InterpProp; + DestroyMetricReportDefinition_V1_0_7_CS (MetricReportDefinitionV1_0_7->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_7/RedfishMetricReportDefinition_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_7/RedfishMetricReportDefinition_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..f0ab8124a70 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_0_7/RedfishMetricReportDefinition_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_0_7_Dxe + FILE_GUID = 1ed192cd-d9bd-4a92-abcb-035baa561cff + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_0/MetricReportDefinition_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_0/MetricReportDefinition_V1_1_0_Dxe.c new file mode 100644 index 00000000000..3120ed088e6 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_0/MetricReportDefinition_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "1", + "0" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_0 *MetricReportDefinitionV1_1_0; + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_0_CS *MetricReportDefinitionV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_1_0_To_CS (ResoruceRaw, &MetricReportDefinitionV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_1_0 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_1_0)); + if (MetricReportDefinitionV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_1_0; + MetricReportDefinitionV1_1_0->MetricReportDefinition = MetricReportDefinitionV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_1_0_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_0 *MetricReportDefinitionV1_1_0; + + MetricReportDefinitionV1_1_0 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_1_0 *)InterpProp; + DestroyMetricReportDefinition_V1_1_0_CS (MetricReportDefinitionV1_1_0->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_0/RedfishMetricReportDefinition_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_0/RedfishMetricReportDefinition_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..06e08e65739 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_0/RedfishMetricReportDefinition_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_1_0_Dxe + FILE_GUID = 7792e8a2-ff4e-4caf-90bb-3346b22be2cc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_1/MetricReportDefinition_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_1/MetricReportDefinition_V1_1_1_Dxe.c new file mode 100644 index 00000000000..abbd601296e --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_1/MetricReportDefinition_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "1", + "1" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_1 *MetricReportDefinitionV1_1_1; + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_1_CS *MetricReportDefinitionV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_1_1_To_CS (ResoruceRaw, &MetricReportDefinitionV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_1_1 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_1_1)); + if (MetricReportDefinitionV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_1_1; + MetricReportDefinitionV1_1_1->MetricReportDefinition = MetricReportDefinitionV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_1_1_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_1 *MetricReportDefinitionV1_1_1; + + MetricReportDefinitionV1_1_1 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_1_1 *)InterpProp; + DestroyMetricReportDefinition_V1_1_1_CS (MetricReportDefinitionV1_1_1->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_1/RedfishMetricReportDefinition_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_1/RedfishMetricReportDefinition_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..2042cc662c8 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_1/RedfishMetricReportDefinition_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_1_1_Dxe + FILE_GUID = 29e4cdf5-61fa-44a4-83e5-95cfa29ca3f4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_2/MetricReportDefinition_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_2/MetricReportDefinition_V1_1_2_Dxe.c new file mode 100644 index 00000000000..ba49ba4dc27 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_2/MetricReportDefinition_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "1", + "2" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_2 *MetricReportDefinitionV1_1_2; + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_2_CS *MetricReportDefinitionV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_1_2_To_CS (ResoruceRaw, &MetricReportDefinitionV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_1_2 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_1_2)); + if (MetricReportDefinitionV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_1_2; + MetricReportDefinitionV1_1_2->MetricReportDefinition = MetricReportDefinitionV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_1_2_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_2 *MetricReportDefinitionV1_1_2; + + MetricReportDefinitionV1_1_2 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_1_2 *)InterpProp; + DestroyMetricReportDefinition_V1_1_2_CS (MetricReportDefinitionV1_1_2->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_2/RedfishMetricReportDefinition_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_2/RedfishMetricReportDefinition_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..e17618f9ea5 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_2/RedfishMetricReportDefinition_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_1_2_Dxe + FILE_GUID = 5152f1e3-b952-4423-b568-017f25c02d3d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_3/MetricReportDefinition_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_3/MetricReportDefinition_V1_1_3_Dxe.c new file mode 100644 index 00000000000..9b8fd97217a --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_3/MetricReportDefinition_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "1", + "3" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_3 *MetricReportDefinitionV1_1_3; + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_3_CS *MetricReportDefinitionV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_1_3_To_CS (ResoruceRaw, &MetricReportDefinitionV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_1_3 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_1_3)); + if (MetricReportDefinitionV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_1_3; + MetricReportDefinitionV1_1_3->MetricReportDefinition = MetricReportDefinitionV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_1_3_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_3 *MetricReportDefinitionV1_1_3; + + MetricReportDefinitionV1_1_3 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_1_3 *)InterpProp; + DestroyMetricReportDefinition_V1_1_3_CS (MetricReportDefinitionV1_1_3->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_3/RedfishMetricReportDefinition_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_3/RedfishMetricReportDefinition_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..eae683da228 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_3/RedfishMetricReportDefinition_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_1_3_Dxe + FILE_GUID = 001b0e6b-d4d5-4ef3-9560-e0ef1e816a8e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_4/MetricReportDefinition_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_4/MetricReportDefinition_V1_1_4_Dxe.c new file mode 100644 index 00000000000..75a0479072b --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_4/MetricReportDefinition_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "1", + "4" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_4 *MetricReportDefinitionV1_1_4; + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_4_CS *MetricReportDefinitionV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_1_4_To_CS (ResoruceRaw, &MetricReportDefinitionV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_1_4 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_1_4)); + if (MetricReportDefinitionV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_1_4; + MetricReportDefinitionV1_1_4->MetricReportDefinition = MetricReportDefinitionV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_1_4_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_4 *MetricReportDefinitionV1_1_4; + + MetricReportDefinitionV1_1_4 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_1_4 *)InterpProp; + DestroyMetricReportDefinition_V1_1_4_CS (MetricReportDefinitionV1_1_4->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_4/RedfishMetricReportDefinition_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_4/RedfishMetricReportDefinition_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..0260494bc71 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_4/RedfishMetricReportDefinition_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_1_4_Dxe + FILE_GUID = c2005252-db0e-4169-8713-92e1a0d5dd67 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_5/MetricReportDefinition_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_5/MetricReportDefinition_V1_1_5_Dxe.c new file mode 100644 index 00000000000..3b9af0ed479 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_5/MetricReportDefinition_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "1", + "5" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_5 *MetricReportDefinitionV1_1_5; + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_5_CS *MetricReportDefinitionV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_1_5_To_CS (ResoruceRaw, &MetricReportDefinitionV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_1_5 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_1_5)); + if (MetricReportDefinitionV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_1_5; + MetricReportDefinitionV1_1_5->MetricReportDefinition = MetricReportDefinitionV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_1_5_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_5 *MetricReportDefinitionV1_1_5; + + MetricReportDefinitionV1_1_5 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_1_5 *)InterpProp; + DestroyMetricReportDefinition_V1_1_5_CS (MetricReportDefinitionV1_1_5->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_5/RedfishMetricReportDefinition_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_5/RedfishMetricReportDefinition_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..9b3562d8f66 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_5/RedfishMetricReportDefinition_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_1_5_Dxe + FILE_GUID = fdf35e69-fdbb-4263-9ad6-73304f68c387 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_6/MetricReportDefinition_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_6/MetricReportDefinition_V1_1_6_Dxe.c new file mode 100644 index 00000000000..f2037d9226a --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_6/MetricReportDefinition_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "1", + "6" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_6 *MetricReportDefinitionV1_1_6; + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_6_CS *MetricReportDefinitionV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_1_6_To_CS (ResoruceRaw, &MetricReportDefinitionV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_1_6 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_1_6)); + if (MetricReportDefinitionV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_1_6; + MetricReportDefinitionV1_1_6->MetricReportDefinition = MetricReportDefinitionV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_1_6_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_6 *MetricReportDefinitionV1_1_6; + + MetricReportDefinitionV1_1_6 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_1_6 *)InterpProp; + DestroyMetricReportDefinition_V1_1_6_CS (MetricReportDefinitionV1_1_6->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_6/RedfishMetricReportDefinition_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_6/RedfishMetricReportDefinition_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..35c10963a51 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_1_6/RedfishMetricReportDefinition_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_1_6_Dxe + FILE_GUID = 185f2667-fa99-4b8b-9d09-bba05c8e6ee3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_0/MetricReportDefinition_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_0/MetricReportDefinition_V1_2_0_Dxe.c new file mode 100644 index 00000000000..8cf811a22a6 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_0/MetricReportDefinition_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "2", + "0" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_2_0 *MetricReportDefinitionV1_2_0; + EFI_REDFISH_METRICREPORTDEFINITION_V1_2_0_CS *MetricReportDefinitionV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_2_0_To_CS (ResoruceRaw, &MetricReportDefinitionV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_2_0 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_2_0)); + if (MetricReportDefinitionV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_2_0; + MetricReportDefinitionV1_2_0->MetricReportDefinition = MetricReportDefinitionV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_2_0_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_2_0 *MetricReportDefinitionV1_2_0; + + MetricReportDefinitionV1_2_0 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_2_0 *)InterpProp; + DestroyMetricReportDefinition_V1_2_0_CS (MetricReportDefinitionV1_2_0->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_0/RedfishMetricReportDefinition_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_0/RedfishMetricReportDefinition_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..7492d6018fb --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_0/RedfishMetricReportDefinition_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_2_0_Dxe + FILE_GUID = c23298a7-24a8-4ef9-b0f0-fb8a075ed4ac + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_1/MetricReportDefinition_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_1/MetricReportDefinition_V1_2_1_Dxe.c new file mode 100644 index 00000000000..aa6a5ebc728 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_1/MetricReportDefinition_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "2", + "1" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_2_1 *MetricReportDefinitionV1_2_1; + EFI_REDFISH_METRICREPORTDEFINITION_V1_2_1_CS *MetricReportDefinitionV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_2_1_To_CS (ResoruceRaw, &MetricReportDefinitionV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_2_1 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_2_1)); + if (MetricReportDefinitionV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_2_1; + MetricReportDefinitionV1_2_1->MetricReportDefinition = MetricReportDefinitionV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_2_1_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_2_1 *MetricReportDefinitionV1_2_1; + + MetricReportDefinitionV1_2_1 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_2_1 *)InterpProp; + DestroyMetricReportDefinition_V1_2_1_CS (MetricReportDefinitionV1_2_1->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_1/RedfishMetricReportDefinition_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_1/RedfishMetricReportDefinition_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..a8d98b9c25b --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_1/RedfishMetricReportDefinition_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_2_1_Dxe + FILE_GUID = 095b062b-b7c3-4fe9-9b4d-c1f11cda19cb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_2/MetricReportDefinition_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_2/MetricReportDefinition_V1_2_2_Dxe.c new file mode 100644 index 00000000000..a9192bee7e7 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_2/MetricReportDefinition_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "2", + "2" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_2_2 *MetricReportDefinitionV1_2_2; + EFI_REDFISH_METRICREPORTDEFINITION_V1_2_2_CS *MetricReportDefinitionV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_2_2_To_CS (ResoruceRaw, &MetricReportDefinitionV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_2_2 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_2_2)); + if (MetricReportDefinitionV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_2_2; + MetricReportDefinitionV1_2_2->MetricReportDefinition = MetricReportDefinitionV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_2_2_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_2_2 *MetricReportDefinitionV1_2_2; + + MetricReportDefinitionV1_2_2 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_2_2 *)InterpProp; + DestroyMetricReportDefinition_V1_2_2_CS (MetricReportDefinitionV1_2_2->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_2/RedfishMetricReportDefinition_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_2/RedfishMetricReportDefinition_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..1370a3c6556 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_2/RedfishMetricReportDefinition_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_2_2_Dxe + FILE_GUID = 74ebb2ba-551b-49a1-a4a5-1ce5849de8bf + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_3/MetricReportDefinition_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_3/MetricReportDefinition_V1_2_3_Dxe.c new file mode 100644 index 00000000000..6bf1799ba34 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_3/MetricReportDefinition_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "2", + "3" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_2_3 *MetricReportDefinitionV1_2_3; + EFI_REDFISH_METRICREPORTDEFINITION_V1_2_3_CS *MetricReportDefinitionV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_2_3_To_CS (ResoruceRaw, &MetricReportDefinitionV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_2_3 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_2_3)); + if (MetricReportDefinitionV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_2_3; + MetricReportDefinitionV1_2_3->MetricReportDefinition = MetricReportDefinitionV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_2_3_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_2_3 *MetricReportDefinitionV1_2_3; + + MetricReportDefinitionV1_2_3 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_2_3 *)InterpProp; + DestroyMetricReportDefinition_V1_2_3_CS (MetricReportDefinitionV1_2_3->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_3/RedfishMetricReportDefinition_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_3/RedfishMetricReportDefinition_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..db4f03b511d --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_3/RedfishMetricReportDefinition_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_2_3_Dxe + FILE_GUID = 33492b30-d2ff-486d-816d-377c184f2385 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_4/MetricReportDefinition_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_4/MetricReportDefinition_V1_2_4_Dxe.c new file mode 100644 index 00000000000..18014d8b5dd --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_4/MetricReportDefinition_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "2", + "4" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_2_4 *MetricReportDefinitionV1_2_4; + EFI_REDFISH_METRICREPORTDEFINITION_V1_2_4_CS *MetricReportDefinitionV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_2_4_To_CS (ResoruceRaw, &MetricReportDefinitionV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_2_4 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_2_4)); + if (MetricReportDefinitionV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_2_4; + MetricReportDefinitionV1_2_4->MetricReportDefinition = MetricReportDefinitionV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_2_4_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_2_4 *MetricReportDefinitionV1_2_4; + + MetricReportDefinitionV1_2_4 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_2_4 *)InterpProp; + DestroyMetricReportDefinition_V1_2_4_CS (MetricReportDefinitionV1_2_4->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_4/RedfishMetricReportDefinition_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_4/RedfishMetricReportDefinition_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..2a1dcf4fbd2 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_4/RedfishMetricReportDefinition_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_2_4_Dxe + FILE_GUID = 92a14fb0-4065-48d1-9f61-5c1076686e66 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_5/MetricReportDefinition_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_5/MetricReportDefinition_V1_2_5_Dxe.c new file mode 100644 index 00000000000..16f437db0de --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_5/MetricReportDefinition_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "2", + "5" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_2_5 *MetricReportDefinitionV1_2_5; + EFI_REDFISH_METRICREPORTDEFINITION_V1_2_5_CS *MetricReportDefinitionV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_2_5_To_CS (ResoruceRaw, &MetricReportDefinitionV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_2_5 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_2_5)); + if (MetricReportDefinitionV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_2_5; + MetricReportDefinitionV1_2_5->MetricReportDefinition = MetricReportDefinitionV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_2_5_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_2_5 *MetricReportDefinitionV1_2_5; + + MetricReportDefinitionV1_2_5 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_2_5 *)InterpProp; + DestroyMetricReportDefinition_V1_2_5_CS (MetricReportDefinitionV1_2_5->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_5/RedfishMetricReportDefinition_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_5/RedfishMetricReportDefinition_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..0a91d986c5e --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_2_5/RedfishMetricReportDefinition_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_2_5_Dxe + FILE_GUID = 1b92ea51-db03-416d-9928-0c8f8c8e9077 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_0/MetricReportDefinition_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_0/MetricReportDefinition_V1_3_0_Dxe.c new file mode 100644 index 00000000000..b01a5e34857 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_0/MetricReportDefinition_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "3", + "0" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_3_0 *MetricReportDefinitionV1_3_0; + EFI_REDFISH_METRICREPORTDEFINITION_V1_3_0_CS *MetricReportDefinitionV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_3_0_To_CS (ResoruceRaw, &MetricReportDefinitionV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_3_0 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_3_0)); + if (MetricReportDefinitionV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_3_0; + MetricReportDefinitionV1_3_0->MetricReportDefinition = MetricReportDefinitionV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_3_0_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_3_0 *MetricReportDefinitionV1_3_0; + + MetricReportDefinitionV1_3_0 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_3_0 *)InterpProp; + DestroyMetricReportDefinition_V1_3_0_CS (MetricReportDefinitionV1_3_0->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_0/RedfishMetricReportDefinition_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_0/RedfishMetricReportDefinition_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..dbadbb52978 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_0/RedfishMetricReportDefinition_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_3_0_Dxe + FILE_GUID = 6a47a44e-3f2d-4f8f-b45e-dab3eaea4db7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_1/MetricReportDefinition_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_1/MetricReportDefinition_V1_3_1_Dxe.c new file mode 100644 index 00000000000..0f50f1265de --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_1/MetricReportDefinition_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "3", + "1" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_3_1 *MetricReportDefinitionV1_3_1; + EFI_REDFISH_METRICREPORTDEFINITION_V1_3_1_CS *MetricReportDefinitionV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_3_1_To_CS (ResoruceRaw, &MetricReportDefinitionV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_3_1 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_3_1)); + if (MetricReportDefinitionV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_3_1; + MetricReportDefinitionV1_3_1->MetricReportDefinition = MetricReportDefinitionV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_3_1_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_3_1 *MetricReportDefinitionV1_3_1; + + MetricReportDefinitionV1_3_1 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_3_1 *)InterpProp; + DestroyMetricReportDefinition_V1_3_1_CS (MetricReportDefinitionV1_3_1->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_1/RedfishMetricReportDefinition_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_1/RedfishMetricReportDefinition_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..b5ed663792b --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_1/RedfishMetricReportDefinition_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_3_1_Dxe + FILE_GUID = 44d88613-3db3-4aca-833f-b4a0ce759999 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_2/MetricReportDefinition_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_2/MetricReportDefinition_V1_3_2_Dxe.c new file mode 100644 index 00000000000..4c2175551e8 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_2/MetricReportDefinition_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "3", + "2" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_3_2 *MetricReportDefinitionV1_3_2; + EFI_REDFISH_METRICREPORTDEFINITION_V1_3_2_CS *MetricReportDefinitionV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_3_2_To_CS (ResoruceRaw, &MetricReportDefinitionV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_3_2 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_3_2)); + if (MetricReportDefinitionV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_3_2; + MetricReportDefinitionV1_3_2->MetricReportDefinition = MetricReportDefinitionV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_3_2_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_3_2 *MetricReportDefinitionV1_3_2; + + MetricReportDefinitionV1_3_2 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_3_2 *)InterpProp; + DestroyMetricReportDefinition_V1_3_2_CS (MetricReportDefinitionV1_3_2->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_2/RedfishMetricReportDefinition_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_2/RedfishMetricReportDefinition_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..ba8dd82437c --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_2/RedfishMetricReportDefinition_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_3_2_Dxe + FILE_GUID = 7c969d64-3064-4c10-bd03-a16547b74094 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_3/MetricReportDefinition_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_3/MetricReportDefinition_V1_3_3_Dxe.c new file mode 100644 index 00000000000..dd759c5aaa6 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_3/MetricReportDefinition_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "3", + "3" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_3_3 *MetricReportDefinitionV1_3_3; + EFI_REDFISH_METRICREPORTDEFINITION_V1_3_3_CS *MetricReportDefinitionV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_3_3_To_CS (ResoruceRaw, &MetricReportDefinitionV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_3_3 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_3_3)); + if (MetricReportDefinitionV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_3_3; + MetricReportDefinitionV1_3_3->MetricReportDefinition = MetricReportDefinitionV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_3_3_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_3_3 *MetricReportDefinitionV1_3_3; + + MetricReportDefinitionV1_3_3 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_3_3 *)InterpProp; + DestroyMetricReportDefinition_V1_3_3_CS (MetricReportDefinitionV1_3_3->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_3/RedfishMetricReportDefinition_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_3/RedfishMetricReportDefinition_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..ae733329458 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_3/RedfishMetricReportDefinition_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_3_3_Dxe + FILE_GUID = 4487368c-6c2e-4e31-99d3-a12b13e1c148 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_4/MetricReportDefinition_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_4/MetricReportDefinition_V1_3_4_Dxe.c new file mode 100644 index 00000000000..6896b2ca695 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_4/MetricReportDefinition_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "3", + "4" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_3_4 *MetricReportDefinitionV1_3_4; + EFI_REDFISH_METRICREPORTDEFINITION_V1_3_4_CS *MetricReportDefinitionV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_3_4_To_CS (ResoruceRaw, &MetricReportDefinitionV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_3_4 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_3_4)); + if (MetricReportDefinitionV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_3_4; + MetricReportDefinitionV1_3_4->MetricReportDefinition = MetricReportDefinitionV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_3_4_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_3_4 *MetricReportDefinitionV1_3_4; + + MetricReportDefinitionV1_3_4 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_3_4 *)InterpProp; + DestroyMetricReportDefinition_V1_3_4_CS (MetricReportDefinitionV1_3_4->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_4/RedfishMetricReportDefinition_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_4/RedfishMetricReportDefinition_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..decf6fce897 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_3_4/RedfishMetricReportDefinition_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_3_4_Dxe + FILE_GUID = d1abe156-8144-43d5-bdaf-f3eaf5519370 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_4_0/MetricReportDefinition_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinition/v1_4_0/MetricReportDefinition_V1_4_0_Dxe.c new file mode 100644 index 00000000000..342fbb47b47 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_4_0/MetricReportDefinition_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinition.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinition"; +BOOLEAN IsRevisonController = TRUE; + +// Support MetricReportDefinition V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinition", + "1", + "4", + "0" + }, + "MetricReportDefinition" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_4_0 *MetricReportDefinitionV1_4_0; + EFI_REDFISH_METRICREPORTDEFINITION_V1_4_0_CS *MetricReportDefinitionV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinition") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinition_V1_4_0_To_CS (ResoruceRaw, &MetricReportDefinitionV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionV1_4_0 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITION_V1_4_0)); + if (MetricReportDefinitionV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionV1_4_0; + MetricReportDefinitionV1_4_0->MetricReportDefinition = MetricReportDefinitionV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinition")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinition"), "MetricReportDefinition"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinition_V1_4_0_JSON (*((EFI_REDFISH_METRICREPORTDEFINITION_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITION_V1_4_0 *MetricReportDefinitionV1_4_0; + + MetricReportDefinitionV1_4_0 = (EFI_REDFISH_METRICREPORTDEFINITION_V1_4_0 *)InterpProp; + DestroyMetricReportDefinition_V1_4_0_CS (MetricReportDefinitionV1_4_0->MetricReportDefinition); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinition_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionToStructWrapper, + MetricReportDefinitionToJson, + MetricReportDefinitionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinition_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinition/v1_4_0/RedfishMetricReportDefinition_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinition/v1_4_0/RedfishMetricReportDefinition_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..a04540cc1b8 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinition/v1_4_0/RedfishMetricReportDefinition_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinition.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinition_V1_4_0_Dxe + FILE_GUID = 9e4d9275-274b-44e4-9fc5-47c04997eb29 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinition_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinition_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinition_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/MetricReportDefinitionCollection/MetricReportDefinitionCollection_Dxe.c b/RedfishClientPkg/Converter/MetricReportDefinitionCollection/MetricReportDefinitionCollection_Dxe.c new file mode 100644 index 00000000000..f1e4dda309a --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinitionCollection/MetricReportDefinitionCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - MetricReportDefinitionCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#MetricReportDefinitionCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support MetricReportDefinitionCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "MetricReportDefinitionCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "MetricReportDefinitionCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITIONCOLLECTION *MetricReportDefinitionCollection; + EFI_REDFISH_METRICREPORTDEFINITIONCOLLECTION_CS *MetricReportDefinitionCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "MetricReportDefinitionCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_MetricReportDefinitionCollection_To_CS (ResoruceRaw, &MetricReportDefinitionCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + MetricReportDefinitionCollection = (EFI_REDFISH_METRICREPORTDEFINITIONCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_METRICREPORTDEFINITIONCOLLECTION)); + if (MetricReportDefinitionCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)MetricReportDefinitionCollection; + MetricReportDefinitionCollection->MetricReportDefinitionCollection = MetricReportDefinitionCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinitionCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("MetricReportDefinitionCollection"), "MetricReportDefinitionCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("MetricReportDefinitionCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("MetricReportDefinitionCollection"), "MetricReportDefinitionCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of MetricReportDefinitionCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return MetricReportDefinitionCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_MetricReportDefinitionCollection_JSON (*((EFI_REDFISH_METRICREPORTDEFINITIONCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in MetricReportDefinitionCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_METRICREPORTDEFINITIONCOLLECTION *MetricReportDefinitionCollection; + + MetricReportDefinitionCollection = (EFI_REDFISH_METRICREPORTDEFINITIONCOLLECTION *)InterpProp; + DestroyMetricReportDefinitionCollection_CS (MetricReportDefinitionCollection->MetricReportDefinitionCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from MetricReportDefinitionCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +MetricReportDefinitionCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyMetricReportDefinitionCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinitionCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + MetricReportDefinitionCollectionToStructWrapper, + MetricReportDefinitionCollectionToJson, + MetricReportDefinitionCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishMetricReportDefinitionCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/MetricReportDefinitionCollection/RedfishMetricReportDefinitionCollection_Dxe.inf b/RedfishClientPkg/Converter/MetricReportDefinitionCollection/RedfishMetricReportDefinitionCollection_Dxe.inf new file mode 100644 index 00000000000..4c3f00526f7 --- /dev/null +++ b/RedfishClientPkg/Converter/MetricReportDefinitionCollection/RedfishMetricReportDefinitionCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of MetricReportDefinitionCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishMetricReportDefinitionCollection_Dxe + FILE_GUID = 89ebc5ae-9bc5-4f2d-a970-3c55587ecfca + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishMetricReportDefinitionCollectionEntryPoint + UNLOAD_IMAGE = RedfishMetricReportDefinitionCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + MetricReportDefinitionCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + MetricReportDefinitionCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_0_0/NetworkAdapter_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_0/NetworkAdapter_V1_0_0_Dxe.c new file mode 100644 index 00000000000..4ab9bbf39ba --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_0/NetworkAdapter_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "0", + "0" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_0_0 *NetworkAdapterV1_0_0; + EFI_REDFISH_NETWORKADAPTER_V1_0_0_CS *NetworkAdapterV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_0_0_To_CS (ResoruceRaw, &NetworkAdapterV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_0_0 = (EFI_REDFISH_NETWORKADAPTER_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_0_0)); + if (NetworkAdapterV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_0_0; + NetworkAdapterV1_0_0->NetworkAdapter = NetworkAdapterV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_0_0_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_0_0 *NetworkAdapterV1_0_0; + + NetworkAdapterV1_0_0 = (EFI_REDFISH_NETWORKADAPTER_V1_0_0 *)InterpProp; + DestroyNetworkAdapter_V1_0_0_CS (NetworkAdapterV1_0_0->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_0_0/RedfishNetworkAdapter_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_0/RedfishNetworkAdapter_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..d797eb37106 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_0/RedfishNetworkAdapter_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_0_0_Dxe + FILE_GUID = 62f285d5-7780-48d5-ac85-559009dcc333 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_0_1/NetworkAdapter_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_1/NetworkAdapter_V1_0_1_Dxe.c new file mode 100644 index 00000000000..5552e5a5b7f --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_1/NetworkAdapter_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "0", + "1" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_0_1 *NetworkAdapterV1_0_1; + EFI_REDFISH_NETWORKADAPTER_V1_0_1_CS *NetworkAdapterV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_0_1_To_CS (ResoruceRaw, &NetworkAdapterV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_0_1 = (EFI_REDFISH_NETWORKADAPTER_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_0_1)); + if (NetworkAdapterV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_0_1; + NetworkAdapterV1_0_1->NetworkAdapter = NetworkAdapterV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_0_1_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_0_1 *NetworkAdapterV1_0_1; + + NetworkAdapterV1_0_1 = (EFI_REDFISH_NETWORKADAPTER_V1_0_1 *)InterpProp; + DestroyNetworkAdapter_V1_0_1_CS (NetworkAdapterV1_0_1->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_0_1/RedfishNetworkAdapter_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_1/RedfishNetworkAdapter_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..1a7071d4bb8 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_1/RedfishNetworkAdapter_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_0_1_Dxe + FILE_GUID = 41a9231f-d91d-4ec9-b0eb-414c436cb37b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_0_2/NetworkAdapter_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_2/NetworkAdapter_V1_0_2_Dxe.c new file mode 100644 index 00000000000..f981cfa83d6 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_2/NetworkAdapter_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "0", + "2" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_0_2 *NetworkAdapterV1_0_2; + EFI_REDFISH_NETWORKADAPTER_V1_0_2_CS *NetworkAdapterV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_0_2_To_CS (ResoruceRaw, &NetworkAdapterV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_0_2 = (EFI_REDFISH_NETWORKADAPTER_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_0_2)); + if (NetworkAdapterV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_0_2; + NetworkAdapterV1_0_2->NetworkAdapter = NetworkAdapterV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_0_2_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_0_2 *NetworkAdapterV1_0_2; + + NetworkAdapterV1_0_2 = (EFI_REDFISH_NETWORKADAPTER_V1_0_2 *)InterpProp; + DestroyNetworkAdapter_V1_0_2_CS (NetworkAdapterV1_0_2->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_0_2/RedfishNetworkAdapter_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_2/RedfishNetworkAdapter_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..a8262198b06 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_2/RedfishNetworkAdapter_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_0_2_Dxe + FILE_GUID = 4943bbd6-ad84-4993-b3ec-b82cdc16a2cd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_0_3/NetworkAdapter_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_3/NetworkAdapter_V1_0_3_Dxe.c new file mode 100644 index 00000000000..d3466fc059f --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_3/NetworkAdapter_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "0", + "3" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_0_3 *NetworkAdapterV1_0_3; + EFI_REDFISH_NETWORKADAPTER_V1_0_3_CS *NetworkAdapterV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_0_3_To_CS (ResoruceRaw, &NetworkAdapterV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_0_3 = (EFI_REDFISH_NETWORKADAPTER_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_0_3)); + if (NetworkAdapterV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_0_3; + NetworkAdapterV1_0_3->NetworkAdapter = NetworkAdapterV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_0_3_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_0_3 *NetworkAdapterV1_0_3; + + NetworkAdapterV1_0_3 = (EFI_REDFISH_NETWORKADAPTER_V1_0_3 *)InterpProp; + DestroyNetworkAdapter_V1_0_3_CS (NetworkAdapterV1_0_3->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_0_3/RedfishNetworkAdapter_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_3/RedfishNetworkAdapter_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..731d74d0989 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_3/RedfishNetworkAdapter_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_0_3_Dxe + FILE_GUID = 2073a9e8-3638-49e6-8b65-7b1556528b41 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_0_4/NetworkAdapter_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_4/NetworkAdapter_V1_0_4_Dxe.c new file mode 100644 index 00000000000..a232980c46a --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_4/NetworkAdapter_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "0", + "4" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_0_4 *NetworkAdapterV1_0_4; + EFI_REDFISH_NETWORKADAPTER_V1_0_4_CS *NetworkAdapterV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_0_4_To_CS (ResoruceRaw, &NetworkAdapterV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_0_4 = (EFI_REDFISH_NETWORKADAPTER_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_0_4)); + if (NetworkAdapterV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_0_4; + NetworkAdapterV1_0_4->NetworkAdapter = NetworkAdapterV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_0_4_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_0_4 *NetworkAdapterV1_0_4; + + NetworkAdapterV1_0_4 = (EFI_REDFISH_NETWORKADAPTER_V1_0_4 *)InterpProp; + DestroyNetworkAdapter_V1_0_4_CS (NetworkAdapterV1_0_4->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_0_4/RedfishNetworkAdapter_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_4/RedfishNetworkAdapter_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..a180457972f --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_4/RedfishNetworkAdapter_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_0_4_Dxe + FILE_GUID = 867dc269-0c10-43b0-9f21-e00350942bba + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_0_5/NetworkAdapter_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_5/NetworkAdapter_V1_0_5_Dxe.c new file mode 100644 index 00000000000..2da221d30aa --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_5/NetworkAdapter_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "0", + "5" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_0_5 *NetworkAdapterV1_0_5; + EFI_REDFISH_NETWORKADAPTER_V1_0_5_CS *NetworkAdapterV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_0_5_To_CS (ResoruceRaw, &NetworkAdapterV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_0_5 = (EFI_REDFISH_NETWORKADAPTER_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_0_5)); + if (NetworkAdapterV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_0_5; + NetworkAdapterV1_0_5->NetworkAdapter = NetworkAdapterV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_0_5_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_0_5 *NetworkAdapterV1_0_5; + + NetworkAdapterV1_0_5 = (EFI_REDFISH_NETWORKADAPTER_V1_0_5 *)InterpProp; + DestroyNetworkAdapter_V1_0_5_CS (NetworkAdapterV1_0_5->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_0_5/RedfishNetworkAdapter_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_5/RedfishNetworkAdapter_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..b3c8979c23e --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_5/RedfishNetworkAdapter_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_0_5_Dxe + FILE_GUID = ffaa860a-6082-408c-bed9-9e7394ddd899 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_0_6/NetworkAdapter_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_6/NetworkAdapter_V1_0_6_Dxe.c new file mode 100644 index 00000000000..00c032a589f --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_6/NetworkAdapter_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "0", + "6" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_0_6 *NetworkAdapterV1_0_6; + EFI_REDFISH_NETWORKADAPTER_V1_0_6_CS *NetworkAdapterV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_0_6_To_CS (ResoruceRaw, &NetworkAdapterV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_0_6 = (EFI_REDFISH_NETWORKADAPTER_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_0_6)); + if (NetworkAdapterV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_0_6; + NetworkAdapterV1_0_6->NetworkAdapter = NetworkAdapterV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_0_6_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_0_6 *NetworkAdapterV1_0_6; + + NetworkAdapterV1_0_6 = (EFI_REDFISH_NETWORKADAPTER_V1_0_6 *)InterpProp; + DestroyNetworkAdapter_V1_0_6_CS (NetworkAdapterV1_0_6->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_0_6/RedfishNetworkAdapter_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_6/RedfishNetworkAdapter_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..d1af771387d --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_6/RedfishNetworkAdapter_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_0_6_Dxe + FILE_GUID = f3183b2f-5a4e-4c38-9e16-88f1f2b21568 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_0_7/NetworkAdapter_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_7/NetworkAdapter_V1_0_7_Dxe.c new file mode 100644 index 00000000000..8f5cb1f6ea2 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_7/NetworkAdapter_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "0", + "7" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_0_7 *NetworkAdapterV1_0_7; + EFI_REDFISH_NETWORKADAPTER_V1_0_7_CS *NetworkAdapterV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_0_7_To_CS (ResoruceRaw, &NetworkAdapterV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_0_7 = (EFI_REDFISH_NETWORKADAPTER_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_0_7)); + if (NetworkAdapterV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_0_7; + NetworkAdapterV1_0_7->NetworkAdapter = NetworkAdapterV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_0_7_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_0_7 *NetworkAdapterV1_0_7; + + NetworkAdapterV1_0_7 = (EFI_REDFISH_NETWORKADAPTER_V1_0_7 *)InterpProp; + DestroyNetworkAdapter_V1_0_7_CS (NetworkAdapterV1_0_7->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_0_7/RedfishNetworkAdapter_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_7/RedfishNetworkAdapter_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..dc8aed391eb --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_0_7/RedfishNetworkAdapter_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_0_7_Dxe + FILE_GUID = 1e36b4f9-0964-4317-a43a-d1d84969e45b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_1_0/NetworkAdapter_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_0/NetworkAdapter_V1_1_0_Dxe.c new file mode 100644 index 00000000000..a08519e471a --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_0/NetworkAdapter_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "1", + "0" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_1_0 *NetworkAdapterV1_1_0; + EFI_REDFISH_NETWORKADAPTER_V1_1_0_CS *NetworkAdapterV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_1_0_To_CS (ResoruceRaw, &NetworkAdapterV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_1_0 = (EFI_REDFISH_NETWORKADAPTER_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_1_0)); + if (NetworkAdapterV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_1_0; + NetworkAdapterV1_1_0->NetworkAdapter = NetworkAdapterV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_1_0_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_1_0 *NetworkAdapterV1_1_0; + + NetworkAdapterV1_1_0 = (EFI_REDFISH_NETWORKADAPTER_V1_1_0 *)InterpProp; + DestroyNetworkAdapter_V1_1_0_CS (NetworkAdapterV1_1_0->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_1_0/RedfishNetworkAdapter_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_0/RedfishNetworkAdapter_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..e27a7f9cf2d --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_0/RedfishNetworkAdapter_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_1_0_Dxe + FILE_GUID = 5050e241-4b89-4e65-90cc-bce3af98ad04 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_1_1/NetworkAdapter_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_1/NetworkAdapter_V1_1_1_Dxe.c new file mode 100644 index 00000000000..49ab83220ac --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_1/NetworkAdapter_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "1", + "1" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_1_1 *NetworkAdapterV1_1_1; + EFI_REDFISH_NETWORKADAPTER_V1_1_1_CS *NetworkAdapterV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_1_1_To_CS (ResoruceRaw, &NetworkAdapterV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_1_1 = (EFI_REDFISH_NETWORKADAPTER_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_1_1)); + if (NetworkAdapterV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_1_1; + NetworkAdapterV1_1_1->NetworkAdapter = NetworkAdapterV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_1_1_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_1_1 *NetworkAdapterV1_1_1; + + NetworkAdapterV1_1_1 = (EFI_REDFISH_NETWORKADAPTER_V1_1_1 *)InterpProp; + DestroyNetworkAdapter_V1_1_1_CS (NetworkAdapterV1_1_1->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_1_1/RedfishNetworkAdapter_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_1/RedfishNetworkAdapter_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..00a506d08a6 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_1/RedfishNetworkAdapter_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_1_1_Dxe + FILE_GUID = c44f858b-101f-41a2-a540-15da4fbccce2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_1_2/NetworkAdapter_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_2/NetworkAdapter_V1_1_2_Dxe.c new file mode 100644 index 00000000000..4d2240cce70 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_2/NetworkAdapter_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "1", + "2" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_1_2 *NetworkAdapterV1_1_2; + EFI_REDFISH_NETWORKADAPTER_V1_1_2_CS *NetworkAdapterV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_1_2_To_CS (ResoruceRaw, &NetworkAdapterV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_1_2 = (EFI_REDFISH_NETWORKADAPTER_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_1_2)); + if (NetworkAdapterV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_1_2; + NetworkAdapterV1_1_2->NetworkAdapter = NetworkAdapterV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_1_2_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_1_2 *NetworkAdapterV1_1_2; + + NetworkAdapterV1_1_2 = (EFI_REDFISH_NETWORKADAPTER_V1_1_2 *)InterpProp; + DestroyNetworkAdapter_V1_1_2_CS (NetworkAdapterV1_1_2->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_1_2/RedfishNetworkAdapter_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_2/RedfishNetworkAdapter_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..a94577ac050 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_2/RedfishNetworkAdapter_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_1_2_Dxe + FILE_GUID = 5aef8744-f51c-4c9c-9af9-19fa62505ce7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_1_3/NetworkAdapter_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_3/NetworkAdapter_V1_1_3_Dxe.c new file mode 100644 index 00000000000..0a7e61f6139 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_3/NetworkAdapter_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "1", + "3" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_1_3 *NetworkAdapterV1_1_3; + EFI_REDFISH_NETWORKADAPTER_V1_1_3_CS *NetworkAdapterV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_1_3_To_CS (ResoruceRaw, &NetworkAdapterV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_1_3 = (EFI_REDFISH_NETWORKADAPTER_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_1_3)); + if (NetworkAdapterV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_1_3; + NetworkAdapterV1_1_3->NetworkAdapter = NetworkAdapterV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_1_3_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_1_3 *NetworkAdapterV1_1_3; + + NetworkAdapterV1_1_3 = (EFI_REDFISH_NETWORKADAPTER_V1_1_3 *)InterpProp; + DestroyNetworkAdapter_V1_1_3_CS (NetworkAdapterV1_1_3->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_1_3/RedfishNetworkAdapter_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_3/RedfishNetworkAdapter_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..ee501fad0b1 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_3/RedfishNetworkAdapter_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_1_3_Dxe + FILE_GUID = d8f7a95e-16c8-43e4-a1a3-6645f4b48ffb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_1_4/NetworkAdapter_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_4/NetworkAdapter_V1_1_4_Dxe.c new file mode 100644 index 00000000000..b50c32d87c0 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_4/NetworkAdapter_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "1", + "4" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_1_4 *NetworkAdapterV1_1_4; + EFI_REDFISH_NETWORKADAPTER_V1_1_4_CS *NetworkAdapterV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_1_4_To_CS (ResoruceRaw, &NetworkAdapterV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_1_4 = (EFI_REDFISH_NETWORKADAPTER_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_1_4)); + if (NetworkAdapterV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_1_4; + NetworkAdapterV1_1_4->NetworkAdapter = NetworkAdapterV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_1_4_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_1_4 *NetworkAdapterV1_1_4; + + NetworkAdapterV1_1_4 = (EFI_REDFISH_NETWORKADAPTER_V1_1_4 *)InterpProp; + DestroyNetworkAdapter_V1_1_4_CS (NetworkAdapterV1_1_4->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_1_4/RedfishNetworkAdapter_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_4/RedfishNetworkAdapter_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..4ee96ac0a82 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_4/RedfishNetworkAdapter_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_1_4_Dxe + FILE_GUID = 4d611742-d2d1-4b29-9b86-2fa078a02ac6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_1_5/NetworkAdapter_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_5/NetworkAdapter_V1_1_5_Dxe.c new file mode 100644 index 00000000000..bf793325f93 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_5/NetworkAdapter_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "1", + "5" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_1_5 *NetworkAdapterV1_1_5; + EFI_REDFISH_NETWORKADAPTER_V1_1_5_CS *NetworkAdapterV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_1_5_To_CS (ResoruceRaw, &NetworkAdapterV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_1_5 = (EFI_REDFISH_NETWORKADAPTER_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_1_5)); + if (NetworkAdapterV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_1_5; + NetworkAdapterV1_1_5->NetworkAdapter = NetworkAdapterV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_1_5_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_1_5 *NetworkAdapterV1_1_5; + + NetworkAdapterV1_1_5 = (EFI_REDFISH_NETWORKADAPTER_V1_1_5 *)InterpProp; + DestroyNetworkAdapter_V1_1_5_CS (NetworkAdapterV1_1_5->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_1_5/RedfishNetworkAdapter_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_5/RedfishNetworkAdapter_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..eff14ea256d --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_5/RedfishNetworkAdapter_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_1_5_Dxe + FILE_GUID = c4d7db04-565a-4b4d-a470-0760d2862a8f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_1_6/NetworkAdapter_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_6/NetworkAdapter_V1_1_6_Dxe.c new file mode 100644 index 00000000000..4c43fe2253c --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_6/NetworkAdapter_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "1", + "6" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_1_6 *NetworkAdapterV1_1_6; + EFI_REDFISH_NETWORKADAPTER_V1_1_6_CS *NetworkAdapterV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_1_6_To_CS (ResoruceRaw, &NetworkAdapterV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_1_6 = (EFI_REDFISH_NETWORKADAPTER_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_1_6)); + if (NetworkAdapterV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_1_6; + NetworkAdapterV1_1_6->NetworkAdapter = NetworkAdapterV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_1_6_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_1_6 *NetworkAdapterV1_1_6; + + NetworkAdapterV1_1_6 = (EFI_REDFISH_NETWORKADAPTER_V1_1_6 *)InterpProp; + DestroyNetworkAdapter_V1_1_6_CS (NetworkAdapterV1_1_6->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_1_6/RedfishNetworkAdapter_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_6/RedfishNetworkAdapter_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..9cd90608b68 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_1_6/RedfishNetworkAdapter_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_1_6_Dxe + FILE_GUID = fc79b50a-9181-4ba3-a751-1a60c351768b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_2_0/NetworkAdapter_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_2_0/NetworkAdapter_V1_2_0_Dxe.c new file mode 100644 index 00000000000..34898871402 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_2_0/NetworkAdapter_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "2", + "0" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_2_0 *NetworkAdapterV1_2_0; + EFI_REDFISH_NETWORKADAPTER_V1_2_0_CS *NetworkAdapterV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_2_0_To_CS (ResoruceRaw, &NetworkAdapterV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_2_0 = (EFI_REDFISH_NETWORKADAPTER_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_2_0)); + if (NetworkAdapterV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_2_0; + NetworkAdapterV1_2_0->NetworkAdapter = NetworkAdapterV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_2_0_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_2_0 *NetworkAdapterV1_2_0; + + NetworkAdapterV1_2_0 = (EFI_REDFISH_NETWORKADAPTER_V1_2_0 *)InterpProp; + DestroyNetworkAdapter_V1_2_0_CS (NetworkAdapterV1_2_0->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_2_0/RedfishNetworkAdapter_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_2_0/RedfishNetworkAdapter_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..09cceb197fe --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_2_0/RedfishNetworkAdapter_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_2_0_Dxe + FILE_GUID = 1a0dc1aa-0c9e-4eac-ab0a-d175389db2e8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_2_1/NetworkAdapter_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_2_1/NetworkAdapter_V1_2_1_Dxe.c new file mode 100644 index 00000000000..9b43e5dc313 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_2_1/NetworkAdapter_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "2", + "1" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_2_1 *NetworkAdapterV1_2_1; + EFI_REDFISH_NETWORKADAPTER_V1_2_1_CS *NetworkAdapterV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_2_1_To_CS (ResoruceRaw, &NetworkAdapterV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_2_1 = (EFI_REDFISH_NETWORKADAPTER_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_2_1)); + if (NetworkAdapterV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_2_1; + NetworkAdapterV1_2_1->NetworkAdapter = NetworkAdapterV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_2_1_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_2_1 *NetworkAdapterV1_2_1; + + NetworkAdapterV1_2_1 = (EFI_REDFISH_NETWORKADAPTER_V1_2_1 *)InterpProp; + DestroyNetworkAdapter_V1_2_1_CS (NetworkAdapterV1_2_1->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_2_1/RedfishNetworkAdapter_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_2_1/RedfishNetworkAdapter_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..25d8e0fd9b4 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_2_1/RedfishNetworkAdapter_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_2_1_Dxe + FILE_GUID = 44fa1a0e-5b9e-4e0e-96f9-e5e9c99e05b0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_2_2/NetworkAdapter_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_2_2/NetworkAdapter_V1_2_2_Dxe.c new file mode 100644 index 00000000000..14df5e2d8b0 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_2_2/NetworkAdapter_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "2", + "2" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_2_2 *NetworkAdapterV1_2_2; + EFI_REDFISH_NETWORKADAPTER_V1_2_2_CS *NetworkAdapterV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_2_2_To_CS (ResoruceRaw, &NetworkAdapterV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_2_2 = (EFI_REDFISH_NETWORKADAPTER_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_2_2)); + if (NetworkAdapterV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_2_2; + NetworkAdapterV1_2_2->NetworkAdapter = NetworkAdapterV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_2_2_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_2_2 *NetworkAdapterV1_2_2; + + NetworkAdapterV1_2_2 = (EFI_REDFISH_NETWORKADAPTER_V1_2_2 *)InterpProp; + DestroyNetworkAdapter_V1_2_2_CS (NetworkAdapterV1_2_2->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_2_2/RedfishNetworkAdapter_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_2_2/RedfishNetworkAdapter_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..4b8e95bbb84 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_2_2/RedfishNetworkAdapter_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_2_2_Dxe + FILE_GUID = 8456ec37-6803-4546-b90a-f3ca29e253c7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_2_3/NetworkAdapter_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_2_3/NetworkAdapter_V1_2_3_Dxe.c new file mode 100644 index 00000000000..58913a1c178 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_2_3/NetworkAdapter_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "2", + "3" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_2_3 *NetworkAdapterV1_2_3; + EFI_REDFISH_NETWORKADAPTER_V1_2_3_CS *NetworkAdapterV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_2_3_To_CS (ResoruceRaw, &NetworkAdapterV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_2_3 = (EFI_REDFISH_NETWORKADAPTER_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_2_3)); + if (NetworkAdapterV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_2_3; + NetworkAdapterV1_2_3->NetworkAdapter = NetworkAdapterV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_2_3_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_2_3 *NetworkAdapterV1_2_3; + + NetworkAdapterV1_2_3 = (EFI_REDFISH_NETWORKADAPTER_V1_2_3 *)InterpProp; + DestroyNetworkAdapter_V1_2_3_CS (NetworkAdapterV1_2_3->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_2_3/RedfishNetworkAdapter_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_2_3/RedfishNetworkAdapter_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..bd543118d0f --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_2_3/RedfishNetworkAdapter_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_2_3_Dxe + FILE_GUID = 43ea4b04-4fb5-4d85-8014-76fe51e1d238 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_2_4/NetworkAdapter_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_2_4/NetworkAdapter_V1_2_4_Dxe.c new file mode 100644 index 00000000000..4140d6faad3 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_2_4/NetworkAdapter_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "2", + "4" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_2_4 *NetworkAdapterV1_2_4; + EFI_REDFISH_NETWORKADAPTER_V1_2_4_CS *NetworkAdapterV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_2_4_To_CS (ResoruceRaw, &NetworkAdapterV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_2_4 = (EFI_REDFISH_NETWORKADAPTER_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_2_4)); + if (NetworkAdapterV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_2_4; + NetworkAdapterV1_2_4->NetworkAdapter = NetworkAdapterV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_2_4_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_2_4 *NetworkAdapterV1_2_4; + + NetworkAdapterV1_2_4 = (EFI_REDFISH_NETWORKADAPTER_V1_2_4 *)InterpProp; + DestroyNetworkAdapter_V1_2_4_CS (NetworkAdapterV1_2_4->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_2_4/RedfishNetworkAdapter_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_2_4/RedfishNetworkAdapter_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..bc9c6d080e1 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_2_4/RedfishNetworkAdapter_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_2_4_Dxe + FILE_GUID = 14ea2752-0d41-40d9-9b90-1a1648f56be0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_2_5/NetworkAdapter_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_2_5/NetworkAdapter_V1_2_5_Dxe.c new file mode 100644 index 00000000000..1faf17eb19b --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_2_5/NetworkAdapter_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "2", + "5" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_2_5 *NetworkAdapterV1_2_5; + EFI_REDFISH_NETWORKADAPTER_V1_2_5_CS *NetworkAdapterV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_2_5_To_CS (ResoruceRaw, &NetworkAdapterV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_2_5 = (EFI_REDFISH_NETWORKADAPTER_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_2_5)); + if (NetworkAdapterV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_2_5; + NetworkAdapterV1_2_5->NetworkAdapter = NetworkAdapterV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_2_5_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_2_5 *NetworkAdapterV1_2_5; + + NetworkAdapterV1_2_5 = (EFI_REDFISH_NETWORKADAPTER_V1_2_5 *)InterpProp; + DestroyNetworkAdapter_V1_2_5_CS (NetworkAdapterV1_2_5->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_2_5/RedfishNetworkAdapter_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_2_5/RedfishNetworkAdapter_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..95450d8a2b4 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_2_5/RedfishNetworkAdapter_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_2_5_Dxe + FILE_GUID = de7f7d72-ac8c-4299-8cbc-8d0960608a9c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_3_0/NetworkAdapter_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_3_0/NetworkAdapter_V1_3_0_Dxe.c new file mode 100644 index 00000000000..b5fe8004968 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_3_0/NetworkAdapter_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "3", + "0" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_3_0 *NetworkAdapterV1_3_0; + EFI_REDFISH_NETWORKADAPTER_V1_3_0_CS *NetworkAdapterV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_3_0_To_CS (ResoruceRaw, &NetworkAdapterV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_3_0 = (EFI_REDFISH_NETWORKADAPTER_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_3_0)); + if (NetworkAdapterV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_3_0; + NetworkAdapterV1_3_0->NetworkAdapter = NetworkAdapterV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_3_0_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_3_0 *NetworkAdapterV1_3_0; + + NetworkAdapterV1_3_0 = (EFI_REDFISH_NETWORKADAPTER_V1_3_0 *)InterpProp; + DestroyNetworkAdapter_V1_3_0_CS (NetworkAdapterV1_3_0->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_3_0/RedfishNetworkAdapter_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_3_0/RedfishNetworkAdapter_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..42f8e443fcd --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_3_0/RedfishNetworkAdapter_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_3_0_Dxe + FILE_GUID = 29b2e51b-227b-4102-956b-2d83e75b78a5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_3_1/NetworkAdapter_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_3_1/NetworkAdapter_V1_3_1_Dxe.c new file mode 100644 index 00000000000..7c0e07cbf07 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_3_1/NetworkAdapter_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "3", + "1" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_3_1 *NetworkAdapterV1_3_1; + EFI_REDFISH_NETWORKADAPTER_V1_3_1_CS *NetworkAdapterV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_3_1_To_CS (ResoruceRaw, &NetworkAdapterV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_3_1 = (EFI_REDFISH_NETWORKADAPTER_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_3_1)); + if (NetworkAdapterV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_3_1; + NetworkAdapterV1_3_1->NetworkAdapter = NetworkAdapterV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_3_1_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_3_1 *NetworkAdapterV1_3_1; + + NetworkAdapterV1_3_1 = (EFI_REDFISH_NETWORKADAPTER_V1_3_1 *)InterpProp; + DestroyNetworkAdapter_V1_3_1_CS (NetworkAdapterV1_3_1->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_3_1/RedfishNetworkAdapter_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_3_1/RedfishNetworkAdapter_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..ef2654bf8a8 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_3_1/RedfishNetworkAdapter_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_3_1_Dxe + FILE_GUID = fdbd6ace-4342-46f3-bd73-30c79d4f1936 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_3_2/NetworkAdapter_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_3_2/NetworkAdapter_V1_3_2_Dxe.c new file mode 100644 index 00000000000..fd2ae91d082 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_3_2/NetworkAdapter_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "3", + "2" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_3_2 *NetworkAdapterV1_3_2; + EFI_REDFISH_NETWORKADAPTER_V1_3_2_CS *NetworkAdapterV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_3_2_To_CS (ResoruceRaw, &NetworkAdapterV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_3_2 = (EFI_REDFISH_NETWORKADAPTER_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_3_2)); + if (NetworkAdapterV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_3_2; + NetworkAdapterV1_3_2->NetworkAdapter = NetworkAdapterV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_3_2_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_3_2 *NetworkAdapterV1_3_2; + + NetworkAdapterV1_3_2 = (EFI_REDFISH_NETWORKADAPTER_V1_3_2 *)InterpProp; + DestroyNetworkAdapter_V1_3_2_CS (NetworkAdapterV1_3_2->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_3_2/RedfishNetworkAdapter_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_3_2/RedfishNetworkAdapter_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..444be3c677d --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_3_2/RedfishNetworkAdapter_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_3_2_Dxe + FILE_GUID = 5be01339-6d97-4fe5-831a-18730261771d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_3_3/NetworkAdapter_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_3_3/NetworkAdapter_V1_3_3_Dxe.c new file mode 100644 index 00000000000..befd5bded24 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_3_3/NetworkAdapter_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "3", + "3" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_3_3 *NetworkAdapterV1_3_3; + EFI_REDFISH_NETWORKADAPTER_V1_3_3_CS *NetworkAdapterV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_3_3_To_CS (ResoruceRaw, &NetworkAdapterV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_3_3 = (EFI_REDFISH_NETWORKADAPTER_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_3_3)); + if (NetworkAdapterV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_3_3; + NetworkAdapterV1_3_3->NetworkAdapter = NetworkAdapterV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_3_3_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_3_3 *NetworkAdapterV1_3_3; + + NetworkAdapterV1_3_3 = (EFI_REDFISH_NETWORKADAPTER_V1_3_3 *)InterpProp; + DestroyNetworkAdapter_V1_3_3_CS (NetworkAdapterV1_3_3->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_3_3/RedfishNetworkAdapter_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_3_3/RedfishNetworkAdapter_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..4bd88bf5ac5 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_3_3/RedfishNetworkAdapter_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_3_3_Dxe + FILE_GUID = dd8afda7-4e7c-4546-b62e-f70dbc4c73a6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_3_4/NetworkAdapter_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_3_4/NetworkAdapter_V1_3_4_Dxe.c new file mode 100644 index 00000000000..5b308da9de7 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_3_4/NetworkAdapter_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "3", + "4" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_3_4 *NetworkAdapterV1_3_4; + EFI_REDFISH_NETWORKADAPTER_V1_3_4_CS *NetworkAdapterV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_3_4_To_CS (ResoruceRaw, &NetworkAdapterV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_3_4 = (EFI_REDFISH_NETWORKADAPTER_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_3_4)); + if (NetworkAdapterV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_3_4; + NetworkAdapterV1_3_4->NetworkAdapter = NetworkAdapterV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_3_4_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_3_4 *NetworkAdapterV1_3_4; + + NetworkAdapterV1_3_4 = (EFI_REDFISH_NETWORKADAPTER_V1_3_4 *)InterpProp; + DestroyNetworkAdapter_V1_3_4_CS (NetworkAdapterV1_3_4->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_3_4/RedfishNetworkAdapter_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_3_4/RedfishNetworkAdapter_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..27e3d0bddb7 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_3_4/RedfishNetworkAdapter_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_3_4_Dxe + FILE_GUID = 53215ffe-0cb1-4dfc-a610-4f0cf6a35381 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_4_0/NetworkAdapter_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_4_0/NetworkAdapter_V1_4_0_Dxe.c new file mode 100644 index 00000000000..7d7d42b118b --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_4_0/NetworkAdapter_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "4", + "0" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_4_0 *NetworkAdapterV1_4_0; + EFI_REDFISH_NETWORKADAPTER_V1_4_0_CS *NetworkAdapterV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_4_0_To_CS (ResoruceRaw, &NetworkAdapterV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_4_0 = (EFI_REDFISH_NETWORKADAPTER_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_4_0)); + if (NetworkAdapterV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_4_0; + NetworkAdapterV1_4_0->NetworkAdapter = NetworkAdapterV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_4_0_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_4_0 *NetworkAdapterV1_4_0; + + NetworkAdapterV1_4_0 = (EFI_REDFISH_NETWORKADAPTER_V1_4_0 *)InterpProp; + DestroyNetworkAdapter_V1_4_0_CS (NetworkAdapterV1_4_0->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_4_0/RedfishNetworkAdapter_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_4_0/RedfishNetworkAdapter_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..28dfaf281b1 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_4_0/RedfishNetworkAdapter_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_4_0_Dxe + FILE_GUID = b5bda7c4-9954-44e5-aae9-5d4578480285 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_4_1/NetworkAdapter_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_4_1/NetworkAdapter_V1_4_1_Dxe.c new file mode 100644 index 00000000000..98a3befa5b2 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_4_1/NetworkAdapter_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "4", + "1" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_4_1 *NetworkAdapterV1_4_1; + EFI_REDFISH_NETWORKADAPTER_V1_4_1_CS *NetworkAdapterV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_4_1_To_CS (ResoruceRaw, &NetworkAdapterV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_4_1 = (EFI_REDFISH_NETWORKADAPTER_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_4_1)); + if (NetworkAdapterV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_4_1; + NetworkAdapterV1_4_1->NetworkAdapter = NetworkAdapterV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_4_1_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_4_1 *NetworkAdapterV1_4_1; + + NetworkAdapterV1_4_1 = (EFI_REDFISH_NETWORKADAPTER_V1_4_1 *)InterpProp; + DestroyNetworkAdapter_V1_4_1_CS (NetworkAdapterV1_4_1->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_4_1/RedfishNetworkAdapter_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_4_1/RedfishNetworkAdapter_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..b572fce1f16 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_4_1/RedfishNetworkAdapter_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_4_1_Dxe + FILE_GUID = 4eb93ab2-8864-4a98-81e0-d16b3b2ae793 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_5_0/NetworkAdapter_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_5_0/NetworkAdapter_V1_5_0_Dxe.c new file mode 100644 index 00000000000..735e88f03fe --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_5_0/NetworkAdapter_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "5", + "0" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_5_0 *NetworkAdapterV1_5_0; + EFI_REDFISH_NETWORKADAPTER_V1_5_0_CS *NetworkAdapterV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_5_0_To_CS (ResoruceRaw, &NetworkAdapterV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_5_0 = (EFI_REDFISH_NETWORKADAPTER_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_5_0)); + if (NetworkAdapterV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_5_0; + NetworkAdapterV1_5_0->NetworkAdapter = NetworkAdapterV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_5_0_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_5_0 *NetworkAdapterV1_5_0; + + NetworkAdapterV1_5_0 = (EFI_REDFISH_NETWORKADAPTER_V1_5_0 *)InterpProp; + DestroyNetworkAdapter_V1_5_0_CS (NetworkAdapterV1_5_0->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_5_0/RedfishNetworkAdapter_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_5_0/RedfishNetworkAdapter_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..75b57c2a193 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_5_0/RedfishNetworkAdapter_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_5_0_Dxe + FILE_GUID = fcdd256d-611a-40a5-bf48-eca0d55c88db + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_5_1/NetworkAdapter_V1_5_1_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_5_1/NetworkAdapter_V1_5_1_Dxe.c new file mode 100644 index 00000000000..330e60c2015 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_5_1/NetworkAdapter_V1_5_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_5_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "5", + "1" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_5_1 *NetworkAdapterV1_5_1; + EFI_REDFISH_NETWORKADAPTER_V1_5_1_CS *NetworkAdapterV1_5_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_5_1_To_CS (ResoruceRaw, &NetworkAdapterV1_5_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_5_1 = (EFI_REDFISH_NETWORKADAPTER_V1_5_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_5_1)); + if (NetworkAdapterV1_5_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_5_1; + NetworkAdapterV1_5_1->NetworkAdapter = NetworkAdapterV1_5_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_5_1_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_5_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_5_1 *NetworkAdapterV1_5_1; + + NetworkAdapterV1_5_1 = (EFI_REDFISH_NETWORKADAPTER_V1_5_1 *)InterpProp; + DestroyNetworkAdapter_V1_5_1_CS (NetworkAdapterV1_5_1->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_5_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_5_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_5_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_5_1/RedfishNetworkAdapter_V1_5_1_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_5_1/RedfishNetworkAdapter_V1_5_1_Dxe.inf new file mode 100644 index 00000000000..13e731aa26b --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_5_1/RedfishNetworkAdapter_V1_5_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_5_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_5_1_Dxe + FILE_GUID = 033e7e1a-68a6-4f41-bdc5-cbde9905b30c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_5_1EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_5_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_5_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_5_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_6_0/NetworkAdapter_V1_6_0_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapter/v1_6_0/NetworkAdapter_V1_6_0_Dxe.c new file mode 100644 index 00000000000..2aa333210f1 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_6_0/NetworkAdapter_V1_6_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapter.v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapter"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkAdapter V1_6_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapter", + "1", + "6", + "0" + }, + "NetworkAdapter" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_6_0 *NetworkAdapterV1_6_0; + EFI_REDFISH_NETWORKADAPTER_V1_6_0_CS *NetworkAdapterV1_6_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapter") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapter_V1_6_0_To_CS (ResoruceRaw, &NetworkAdapterV1_6_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterV1_6_0 = (EFI_REDFISH_NETWORKADAPTER_V1_6_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTER_V1_6_0)); + if (NetworkAdapterV1_6_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterV1_6_0; + NetworkAdapterV1_6_0->NetworkAdapter = NetworkAdapterV1_6_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapter")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapter"), "NetworkAdapter"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapter_V1_6_0_JSON (*((EFI_REDFISH_NETWORKADAPTER_V1_6_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTER_V1_6_0 *NetworkAdapterV1_6_0; + + NetworkAdapterV1_6_0 = (EFI_REDFISH_NETWORKADAPTER_V1_6_0 *)InterpProp; + DestroyNetworkAdapter_V1_6_0_CS (NetworkAdapterV1_6_0->NetworkAdapter); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapter_V1_6_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_6_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterToStructWrapper, + NetworkAdapterToJson, + NetworkAdapterDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapter_V1_6_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapter/v1_6_0/RedfishNetworkAdapter_V1_6_0_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapter/v1_6_0/RedfishNetworkAdapter_V1_6_0_Dxe.inf new file mode 100644 index 00000000000..91ba49d68fd --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapter/v1_6_0/RedfishNetworkAdapter_V1_6_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapter.v1_6_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapter_V1_6_0_Dxe + FILE_GUID = ce790747-7d74-490d-9a64-ac0d2d27051f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapter_V1_6_0EntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapter_V1_6_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapter_V1_6_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterV1_6_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkAdapterCollection/NetworkAdapterCollection_Dxe.c b/RedfishClientPkg/Converter/NetworkAdapterCollection/NetworkAdapterCollection_Dxe.c new file mode 100644 index 00000000000..de72eba4c73 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapterCollection/NetworkAdapterCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkAdapterCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkAdapterCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support NetworkAdapterCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkAdapterCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "NetworkAdapterCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTERCOLLECTION *NetworkAdapterCollection; + EFI_REDFISH_NETWORKADAPTERCOLLECTION_CS *NetworkAdapterCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkAdapterCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkAdapterCollection_To_CS (ResoruceRaw, &NetworkAdapterCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkAdapterCollection = (EFI_REDFISH_NETWORKADAPTERCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKADAPTERCOLLECTION)); + if (NetworkAdapterCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkAdapterCollection; + NetworkAdapterCollection->NetworkAdapterCollection = NetworkAdapterCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapterCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkAdapterCollection"), "NetworkAdapterCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkAdapterCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkAdapterCollection"), "NetworkAdapterCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkAdapterCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkAdapterCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkAdapterCollection_JSON (*((EFI_REDFISH_NETWORKADAPTERCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkAdapterCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKADAPTERCOLLECTION *NetworkAdapterCollection; + + NetworkAdapterCollection = (EFI_REDFISH_NETWORKADAPTERCOLLECTION *)InterpProp; + DestroyNetworkAdapterCollection_CS (NetworkAdapterCollection->NetworkAdapterCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkAdapterCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkAdapterCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkAdapterCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapterCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkAdapterCollectionToStructWrapper, + NetworkAdapterCollectionToJson, + NetworkAdapterCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkAdapterCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkAdapterCollection/RedfishNetworkAdapterCollection_Dxe.inf b/RedfishClientPkg/Converter/NetworkAdapterCollection/RedfishNetworkAdapterCollection_Dxe.inf new file mode 100644 index 00000000000..a5605b3430b --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkAdapterCollection/RedfishNetworkAdapterCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkAdapterCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkAdapterCollection_Dxe + FILE_GUID = 940c9bb3-eb89-42df-acb3-eca35ecba22b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkAdapterCollectionEntryPoint + UNLOAD_IMAGE = RedfishNetworkAdapterCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkAdapterCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkAdapterCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_0/NetworkDeviceFunction_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_0/NetworkDeviceFunction_V1_0_0_Dxe.c new file mode 100644 index 00000000000..8866310ca9e --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_0/NetworkDeviceFunction_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "0", + "0" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_0 *NetworkDeviceFunctionV1_0_0; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_0_CS *NetworkDeviceFunctionV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_0_0_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_0_0 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_0)); + if (NetworkDeviceFunctionV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_0_0; + NetworkDeviceFunctionV1_0_0->NetworkDeviceFunction = NetworkDeviceFunctionV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_0_0_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_0 *NetworkDeviceFunctionV1_0_0; + + NetworkDeviceFunctionV1_0_0 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_0 *)InterpProp; + DestroyNetworkDeviceFunction_V1_0_0_CS (NetworkDeviceFunctionV1_0_0->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_0/RedfishNetworkDeviceFunction_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_0/RedfishNetworkDeviceFunction_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..39e1eaf0059 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_0/RedfishNetworkDeviceFunction_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_0_0_Dxe + FILE_GUID = 5273b7db-2094-4f27-b834-b8384de1af6c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_1/NetworkDeviceFunction_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_1/NetworkDeviceFunction_V1_0_1_Dxe.c new file mode 100644 index 00000000000..1d103fc97f0 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_1/NetworkDeviceFunction_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "0", + "1" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_1 *NetworkDeviceFunctionV1_0_1; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_1_CS *NetworkDeviceFunctionV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_0_1_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_0_1 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_1)); + if (NetworkDeviceFunctionV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_0_1; + NetworkDeviceFunctionV1_0_1->NetworkDeviceFunction = NetworkDeviceFunctionV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_0_1_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_1 *NetworkDeviceFunctionV1_0_1; + + NetworkDeviceFunctionV1_0_1 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_1 *)InterpProp; + DestroyNetworkDeviceFunction_V1_0_1_CS (NetworkDeviceFunctionV1_0_1->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_1/RedfishNetworkDeviceFunction_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_1/RedfishNetworkDeviceFunction_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..764784d5e36 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_1/RedfishNetworkDeviceFunction_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_0_1_Dxe + FILE_GUID = c56b5504-cd72-441d-980b-3676dffc7da9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_2/NetworkDeviceFunction_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_2/NetworkDeviceFunction_V1_0_2_Dxe.c new file mode 100644 index 00000000000..ffeb51f82e8 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_2/NetworkDeviceFunction_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "0", + "2" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_2 *NetworkDeviceFunctionV1_0_2; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_2_CS *NetworkDeviceFunctionV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_0_2_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_0_2 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_2)); + if (NetworkDeviceFunctionV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_0_2; + NetworkDeviceFunctionV1_0_2->NetworkDeviceFunction = NetworkDeviceFunctionV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_0_2_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_2 *NetworkDeviceFunctionV1_0_2; + + NetworkDeviceFunctionV1_0_2 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_2 *)InterpProp; + DestroyNetworkDeviceFunction_V1_0_2_CS (NetworkDeviceFunctionV1_0_2->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_2/RedfishNetworkDeviceFunction_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_2/RedfishNetworkDeviceFunction_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..2cb5b05ca42 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_2/RedfishNetworkDeviceFunction_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_0_2_Dxe + FILE_GUID = 2cbd6bb9-6ee2-4943-9256-1896d202ee25 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_3/NetworkDeviceFunction_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_3/NetworkDeviceFunction_V1_0_3_Dxe.c new file mode 100644 index 00000000000..26cb1e97339 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_3/NetworkDeviceFunction_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "0", + "3" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_3 *NetworkDeviceFunctionV1_0_3; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_3_CS *NetworkDeviceFunctionV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_0_3_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_0_3 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_3)); + if (NetworkDeviceFunctionV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_0_3; + NetworkDeviceFunctionV1_0_3->NetworkDeviceFunction = NetworkDeviceFunctionV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_0_3_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_3 *NetworkDeviceFunctionV1_0_3; + + NetworkDeviceFunctionV1_0_3 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_3 *)InterpProp; + DestroyNetworkDeviceFunction_V1_0_3_CS (NetworkDeviceFunctionV1_0_3->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_3/RedfishNetworkDeviceFunction_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_3/RedfishNetworkDeviceFunction_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..bd4cc0d2db5 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_3/RedfishNetworkDeviceFunction_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_0_3_Dxe + FILE_GUID = 0cb20e3a-6321-4cad-b4d8-036ac3468c3b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_4/NetworkDeviceFunction_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_4/NetworkDeviceFunction_V1_0_4_Dxe.c new file mode 100644 index 00000000000..11375592a2a --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_4/NetworkDeviceFunction_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "0", + "4" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_4 *NetworkDeviceFunctionV1_0_4; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_4_CS *NetworkDeviceFunctionV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_0_4_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_0_4 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_4)); + if (NetworkDeviceFunctionV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_0_4; + NetworkDeviceFunctionV1_0_4->NetworkDeviceFunction = NetworkDeviceFunctionV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_0_4_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_4 *NetworkDeviceFunctionV1_0_4; + + NetworkDeviceFunctionV1_0_4 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_4 *)InterpProp; + DestroyNetworkDeviceFunction_V1_0_4_CS (NetworkDeviceFunctionV1_0_4->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_4/RedfishNetworkDeviceFunction_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_4/RedfishNetworkDeviceFunction_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..ddacaefd698 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_4/RedfishNetworkDeviceFunction_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_0_4_Dxe + FILE_GUID = 05a2731d-eb36-4510-9f63-c66b60ecb5cd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_5/NetworkDeviceFunction_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_5/NetworkDeviceFunction_V1_0_5_Dxe.c new file mode 100644 index 00000000000..16677e97114 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_5/NetworkDeviceFunction_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "0", + "5" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_5 *NetworkDeviceFunctionV1_0_5; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_5_CS *NetworkDeviceFunctionV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_0_5_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_0_5 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_5)); + if (NetworkDeviceFunctionV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_0_5; + NetworkDeviceFunctionV1_0_5->NetworkDeviceFunction = NetworkDeviceFunctionV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_0_5_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_5 *NetworkDeviceFunctionV1_0_5; + + NetworkDeviceFunctionV1_0_5 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_5 *)InterpProp; + DestroyNetworkDeviceFunction_V1_0_5_CS (NetworkDeviceFunctionV1_0_5->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_5/RedfishNetworkDeviceFunction_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_5/RedfishNetworkDeviceFunction_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..910a12b616c --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_5/RedfishNetworkDeviceFunction_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_0_5_Dxe + FILE_GUID = 682662a2-69c2-4c3c-a5a8-dde8eb08c06e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_6/NetworkDeviceFunction_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_6/NetworkDeviceFunction_V1_0_6_Dxe.c new file mode 100644 index 00000000000..7275ebc98c1 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_6/NetworkDeviceFunction_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "0", + "6" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_6 *NetworkDeviceFunctionV1_0_6; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_6_CS *NetworkDeviceFunctionV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_0_6_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_0_6 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_6)); + if (NetworkDeviceFunctionV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_0_6; + NetworkDeviceFunctionV1_0_6->NetworkDeviceFunction = NetworkDeviceFunctionV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_0_6_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_6 *NetworkDeviceFunctionV1_0_6; + + NetworkDeviceFunctionV1_0_6 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_6 *)InterpProp; + DestroyNetworkDeviceFunction_V1_0_6_CS (NetworkDeviceFunctionV1_0_6->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_6/RedfishNetworkDeviceFunction_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_6/RedfishNetworkDeviceFunction_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..e424d0e95e5 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_6/RedfishNetworkDeviceFunction_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_0_6_Dxe + FILE_GUID = 2df84581-e398-42c5-abbb-0ea299c459f1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_7/NetworkDeviceFunction_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_7/NetworkDeviceFunction_V1_0_7_Dxe.c new file mode 100644 index 00000000000..5db447b912e --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_7/NetworkDeviceFunction_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "0", + "7" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_7 *NetworkDeviceFunctionV1_0_7; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_7_CS *NetworkDeviceFunctionV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_0_7_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_0_7 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_7)); + if (NetworkDeviceFunctionV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_0_7; + NetworkDeviceFunctionV1_0_7->NetworkDeviceFunction = NetworkDeviceFunctionV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_0_7_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_7 *NetworkDeviceFunctionV1_0_7; + + NetworkDeviceFunctionV1_0_7 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_7 *)InterpProp; + DestroyNetworkDeviceFunction_V1_0_7_CS (NetworkDeviceFunctionV1_0_7->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_7/RedfishNetworkDeviceFunction_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_7/RedfishNetworkDeviceFunction_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..659465fff8b --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_7/RedfishNetworkDeviceFunction_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_0_7_Dxe + FILE_GUID = 44218bd8-d864-45e1-bc75-e71b2ad68bff + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_8/NetworkDeviceFunction_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_8/NetworkDeviceFunction_V1_0_8_Dxe.c new file mode 100644 index 00000000000..501053511e7 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_8/NetworkDeviceFunction_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "0", + "8" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_8 *NetworkDeviceFunctionV1_0_8; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_8_CS *NetworkDeviceFunctionV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_0_8_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_0_8 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_8)); + if (NetworkDeviceFunctionV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_0_8; + NetworkDeviceFunctionV1_0_8->NetworkDeviceFunction = NetworkDeviceFunctionV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_0_8_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_8 *NetworkDeviceFunctionV1_0_8; + + NetworkDeviceFunctionV1_0_8 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_8 *)InterpProp; + DestroyNetworkDeviceFunction_V1_0_8_CS (NetworkDeviceFunctionV1_0_8->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_8/RedfishNetworkDeviceFunction_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_8/RedfishNetworkDeviceFunction_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..43fd55ba0cd --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_0_8/RedfishNetworkDeviceFunction_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_0_8_Dxe + FILE_GUID = 23ae571c-0fd7-4037-a9e0-9bd821f3f7a8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_0/NetworkDeviceFunction_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_0/NetworkDeviceFunction_V1_1_0_Dxe.c new file mode 100644 index 00000000000..fc53842305f --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_0/NetworkDeviceFunction_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "1", + "0" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_0 *NetworkDeviceFunctionV1_1_0; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_0_CS *NetworkDeviceFunctionV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_1_0_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_1_0 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_0)); + if (NetworkDeviceFunctionV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_1_0; + NetworkDeviceFunctionV1_1_0->NetworkDeviceFunction = NetworkDeviceFunctionV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_1_0_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_0 *NetworkDeviceFunctionV1_1_0; + + NetworkDeviceFunctionV1_1_0 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_0 *)InterpProp; + DestroyNetworkDeviceFunction_V1_1_0_CS (NetworkDeviceFunctionV1_1_0->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_0/RedfishNetworkDeviceFunction_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_0/RedfishNetworkDeviceFunction_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..4698f23d272 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_0/RedfishNetworkDeviceFunction_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_1_0_Dxe + FILE_GUID = 5620b7a1-89e4-42b9-9104-3f88176e22c9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_1/NetworkDeviceFunction_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_1/NetworkDeviceFunction_V1_1_1_Dxe.c new file mode 100644 index 00000000000..ccfb8a45e63 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_1/NetworkDeviceFunction_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "1", + "1" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_1 *NetworkDeviceFunctionV1_1_1; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_1_CS *NetworkDeviceFunctionV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_1_1_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_1_1 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_1)); + if (NetworkDeviceFunctionV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_1_1; + NetworkDeviceFunctionV1_1_1->NetworkDeviceFunction = NetworkDeviceFunctionV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_1_1_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_1 *NetworkDeviceFunctionV1_1_1; + + NetworkDeviceFunctionV1_1_1 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_1 *)InterpProp; + DestroyNetworkDeviceFunction_V1_1_1_CS (NetworkDeviceFunctionV1_1_1->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_1/RedfishNetworkDeviceFunction_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_1/RedfishNetworkDeviceFunction_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..df6f94c8a89 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_1/RedfishNetworkDeviceFunction_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_1_1_Dxe + FILE_GUID = 49c81c36-0564-4bc2-b01e-7d00af75a041 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_2/NetworkDeviceFunction_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_2/NetworkDeviceFunction_V1_1_2_Dxe.c new file mode 100644 index 00000000000..7ce5da89ba9 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_2/NetworkDeviceFunction_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "1", + "2" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_2 *NetworkDeviceFunctionV1_1_2; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_2_CS *NetworkDeviceFunctionV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_1_2_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_1_2 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_2)); + if (NetworkDeviceFunctionV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_1_2; + NetworkDeviceFunctionV1_1_2->NetworkDeviceFunction = NetworkDeviceFunctionV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_1_2_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_2 *NetworkDeviceFunctionV1_1_2; + + NetworkDeviceFunctionV1_1_2 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_2 *)InterpProp; + DestroyNetworkDeviceFunction_V1_1_2_CS (NetworkDeviceFunctionV1_1_2->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_2/RedfishNetworkDeviceFunction_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_2/RedfishNetworkDeviceFunction_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..97e7d7b6dc1 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_2/RedfishNetworkDeviceFunction_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_1_2_Dxe + FILE_GUID = a29361ab-c245-4b54-a7de-e138929d069b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_3/NetworkDeviceFunction_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_3/NetworkDeviceFunction_V1_1_3_Dxe.c new file mode 100644 index 00000000000..509b6917c9b --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_3/NetworkDeviceFunction_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "1", + "3" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_3 *NetworkDeviceFunctionV1_1_3; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_3_CS *NetworkDeviceFunctionV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_1_3_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_1_3 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_3)); + if (NetworkDeviceFunctionV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_1_3; + NetworkDeviceFunctionV1_1_3->NetworkDeviceFunction = NetworkDeviceFunctionV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_1_3_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_3 *NetworkDeviceFunctionV1_1_3; + + NetworkDeviceFunctionV1_1_3 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_3 *)InterpProp; + DestroyNetworkDeviceFunction_V1_1_3_CS (NetworkDeviceFunctionV1_1_3->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_3/RedfishNetworkDeviceFunction_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_3/RedfishNetworkDeviceFunction_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..bec7ed30edc --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_3/RedfishNetworkDeviceFunction_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_1_3_Dxe + FILE_GUID = ffb1f9f8-30cb-4eb6-bd6f-321dc350699b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_4/NetworkDeviceFunction_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_4/NetworkDeviceFunction_V1_1_4_Dxe.c new file mode 100644 index 00000000000..b16eb999eee --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_4/NetworkDeviceFunction_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "1", + "4" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_4 *NetworkDeviceFunctionV1_1_4; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_4_CS *NetworkDeviceFunctionV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_1_4_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_1_4 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_4)); + if (NetworkDeviceFunctionV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_1_4; + NetworkDeviceFunctionV1_1_4->NetworkDeviceFunction = NetworkDeviceFunctionV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_1_4_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_4 *NetworkDeviceFunctionV1_1_4; + + NetworkDeviceFunctionV1_1_4 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_4 *)InterpProp; + DestroyNetworkDeviceFunction_V1_1_4_CS (NetworkDeviceFunctionV1_1_4->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_4/RedfishNetworkDeviceFunction_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_4/RedfishNetworkDeviceFunction_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..bfc610730f0 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_4/RedfishNetworkDeviceFunction_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_1_4_Dxe + FILE_GUID = d5d840a2-d875-43e9-9dc5-166ad5be8f8a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_5/NetworkDeviceFunction_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_5/NetworkDeviceFunction_V1_1_5_Dxe.c new file mode 100644 index 00000000000..7c69402c1ca --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_5/NetworkDeviceFunction_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "1", + "5" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_5 *NetworkDeviceFunctionV1_1_5; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_5_CS *NetworkDeviceFunctionV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_1_5_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_1_5 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_5)); + if (NetworkDeviceFunctionV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_1_5; + NetworkDeviceFunctionV1_1_5->NetworkDeviceFunction = NetworkDeviceFunctionV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_1_5_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_5 *NetworkDeviceFunctionV1_1_5; + + NetworkDeviceFunctionV1_1_5 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_5 *)InterpProp; + DestroyNetworkDeviceFunction_V1_1_5_CS (NetworkDeviceFunctionV1_1_5->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_5/RedfishNetworkDeviceFunction_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_5/RedfishNetworkDeviceFunction_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..09c2f775865 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_5/RedfishNetworkDeviceFunction_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_1_5_Dxe + FILE_GUID = bcb0571e-a86e-49d8-b068-c857822dbe9c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_6/NetworkDeviceFunction_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_6/NetworkDeviceFunction_V1_1_6_Dxe.c new file mode 100644 index 00000000000..0b1cc8d1e8f --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_6/NetworkDeviceFunction_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "1", + "6" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_6 *NetworkDeviceFunctionV1_1_6; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_6_CS *NetworkDeviceFunctionV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_1_6_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_1_6 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_6)); + if (NetworkDeviceFunctionV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_1_6; + NetworkDeviceFunctionV1_1_6->NetworkDeviceFunction = NetworkDeviceFunctionV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_1_6_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_6 *NetworkDeviceFunctionV1_1_6; + + NetworkDeviceFunctionV1_1_6 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_6 *)InterpProp; + DestroyNetworkDeviceFunction_V1_1_6_CS (NetworkDeviceFunctionV1_1_6->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_6/RedfishNetworkDeviceFunction_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_6/RedfishNetworkDeviceFunction_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..d18f59020ee --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_6/RedfishNetworkDeviceFunction_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_1_6_Dxe + FILE_GUID = 463aeb01-9dbe-49b6-b684-871b8516e318 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_7/NetworkDeviceFunction_V1_1_7_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_7/NetworkDeviceFunction_V1_1_7_Dxe.c new file mode 100644 index 00000000000..a894eb646be --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_7/NetworkDeviceFunction_V1_1_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_1_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "1", + "7" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_7 *NetworkDeviceFunctionV1_1_7; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_7_CS *NetworkDeviceFunctionV1_1_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_1_7_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_1_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_1_7 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_7)); + if (NetworkDeviceFunctionV1_1_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_1_7; + NetworkDeviceFunctionV1_1_7->NetworkDeviceFunction = NetworkDeviceFunctionV1_1_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_1_7_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_7 *NetworkDeviceFunctionV1_1_7; + + NetworkDeviceFunctionV1_1_7 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_7 *)InterpProp; + DestroyNetworkDeviceFunction_V1_1_7_CS (NetworkDeviceFunctionV1_1_7->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_1_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_1_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_1_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_7/RedfishNetworkDeviceFunction_V1_1_7_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_7/RedfishNetworkDeviceFunction_V1_1_7_Dxe.inf new file mode 100644 index 00000000000..4b98d53dce7 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_1_7/RedfishNetworkDeviceFunction_V1_1_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_1_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_1_7_Dxe + FILE_GUID = 3fa30c3f-40ef-4b8a-b9d6-c548922dffa1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_1_7EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_1_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_1_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_1_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_0/NetworkDeviceFunction_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_0/NetworkDeviceFunction_V1_2_0_Dxe.c new file mode 100644 index 00000000000..d1f93e6967d --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_0/NetworkDeviceFunction_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "2", + "0" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_0 *NetworkDeviceFunctionV1_2_0; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_0_CS *NetworkDeviceFunctionV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_2_0_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_2_0 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_0)); + if (NetworkDeviceFunctionV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_2_0; + NetworkDeviceFunctionV1_2_0->NetworkDeviceFunction = NetworkDeviceFunctionV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_2_0_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_0 *NetworkDeviceFunctionV1_2_0; + + NetworkDeviceFunctionV1_2_0 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_0 *)InterpProp; + DestroyNetworkDeviceFunction_V1_2_0_CS (NetworkDeviceFunctionV1_2_0->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_0/RedfishNetworkDeviceFunction_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_0/RedfishNetworkDeviceFunction_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..b6311bd3b97 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_0/RedfishNetworkDeviceFunction_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_2_0_Dxe + FILE_GUID = 9b357e7e-e044-4c64-ba63-ed27e8191b02 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_1/NetworkDeviceFunction_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_1/NetworkDeviceFunction_V1_2_1_Dxe.c new file mode 100644 index 00000000000..4b361ac9f3b --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_1/NetworkDeviceFunction_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "2", + "1" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_1 *NetworkDeviceFunctionV1_2_1; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_1_CS *NetworkDeviceFunctionV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_2_1_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_2_1 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_1)); + if (NetworkDeviceFunctionV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_2_1; + NetworkDeviceFunctionV1_2_1->NetworkDeviceFunction = NetworkDeviceFunctionV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_2_1_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_1 *NetworkDeviceFunctionV1_2_1; + + NetworkDeviceFunctionV1_2_1 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_1 *)InterpProp; + DestroyNetworkDeviceFunction_V1_2_1_CS (NetworkDeviceFunctionV1_2_1->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_1/RedfishNetworkDeviceFunction_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_1/RedfishNetworkDeviceFunction_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..1e778e30a5c --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_1/RedfishNetworkDeviceFunction_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_2_1_Dxe + FILE_GUID = 4f6068ac-7573-414a-bc45-f19fc166de37 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_2/NetworkDeviceFunction_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_2/NetworkDeviceFunction_V1_2_2_Dxe.c new file mode 100644 index 00000000000..3e8e658e3f1 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_2/NetworkDeviceFunction_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "2", + "2" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_2 *NetworkDeviceFunctionV1_2_2; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_2_CS *NetworkDeviceFunctionV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_2_2_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_2_2 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_2)); + if (NetworkDeviceFunctionV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_2_2; + NetworkDeviceFunctionV1_2_2->NetworkDeviceFunction = NetworkDeviceFunctionV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_2_2_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_2 *NetworkDeviceFunctionV1_2_2; + + NetworkDeviceFunctionV1_2_2 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_2 *)InterpProp; + DestroyNetworkDeviceFunction_V1_2_2_CS (NetworkDeviceFunctionV1_2_2->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_2/RedfishNetworkDeviceFunction_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_2/RedfishNetworkDeviceFunction_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..50fffa86755 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_2/RedfishNetworkDeviceFunction_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_2_2_Dxe + FILE_GUID = 8a5f33e1-a4fb-43c0-8e54-fd90869d5fa5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_3/NetworkDeviceFunction_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_3/NetworkDeviceFunction_V1_2_3_Dxe.c new file mode 100644 index 00000000000..0273e314bc1 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_3/NetworkDeviceFunction_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "2", + "3" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_3 *NetworkDeviceFunctionV1_2_3; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_3_CS *NetworkDeviceFunctionV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_2_3_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_2_3 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_3)); + if (NetworkDeviceFunctionV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_2_3; + NetworkDeviceFunctionV1_2_3->NetworkDeviceFunction = NetworkDeviceFunctionV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_2_3_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_3 *NetworkDeviceFunctionV1_2_3; + + NetworkDeviceFunctionV1_2_3 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_3 *)InterpProp; + DestroyNetworkDeviceFunction_V1_2_3_CS (NetworkDeviceFunctionV1_2_3->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_3/RedfishNetworkDeviceFunction_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_3/RedfishNetworkDeviceFunction_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..27f57b55b0d --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_3/RedfishNetworkDeviceFunction_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_2_3_Dxe + FILE_GUID = 97c2817e-519b-4007-ac13-3f8a6df31fb1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_4/NetworkDeviceFunction_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_4/NetworkDeviceFunction_V1_2_4_Dxe.c new file mode 100644 index 00000000000..261f33a5b2d --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_4/NetworkDeviceFunction_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "2", + "4" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_4 *NetworkDeviceFunctionV1_2_4; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_4_CS *NetworkDeviceFunctionV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_2_4_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_2_4 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_4)); + if (NetworkDeviceFunctionV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_2_4; + NetworkDeviceFunctionV1_2_4->NetworkDeviceFunction = NetworkDeviceFunctionV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_2_4_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_4 *NetworkDeviceFunctionV1_2_4; + + NetworkDeviceFunctionV1_2_4 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_4 *)InterpProp; + DestroyNetworkDeviceFunction_V1_2_4_CS (NetworkDeviceFunctionV1_2_4->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_4/RedfishNetworkDeviceFunction_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_4/RedfishNetworkDeviceFunction_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..ee4aeb4f8da --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_4/RedfishNetworkDeviceFunction_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_2_4_Dxe + FILE_GUID = f774961c-3872-40b1-9d29-8ccae360d63d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_5/NetworkDeviceFunction_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_5/NetworkDeviceFunction_V1_2_5_Dxe.c new file mode 100644 index 00000000000..aef2dcdf67e --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_5/NetworkDeviceFunction_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "2", + "5" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_5 *NetworkDeviceFunctionV1_2_5; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_5_CS *NetworkDeviceFunctionV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_2_5_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_2_5 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_5)); + if (NetworkDeviceFunctionV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_2_5; + NetworkDeviceFunctionV1_2_5->NetworkDeviceFunction = NetworkDeviceFunctionV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_2_5_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_5 *NetworkDeviceFunctionV1_2_5; + + NetworkDeviceFunctionV1_2_5 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_5 *)InterpProp; + DestroyNetworkDeviceFunction_V1_2_5_CS (NetworkDeviceFunctionV1_2_5->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_5/RedfishNetworkDeviceFunction_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_5/RedfishNetworkDeviceFunction_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..e0b07156cb5 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_5/RedfishNetworkDeviceFunction_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_2_5_Dxe + FILE_GUID = ed155f14-263f-42f2-b578-51b40a42e587 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_6/NetworkDeviceFunction_V1_2_6_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_6/NetworkDeviceFunction_V1_2_6_Dxe.c new file mode 100644 index 00000000000..9ef7637c59c --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_6/NetworkDeviceFunction_V1_2_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_2_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "2", + "6" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_6 *NetworkDeviceFunctionV1_2_6; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_6_CS *NetworkDeviceFunctionV1_2_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_2_6_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_2_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_2_6 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_6)); + if (NetworkDeviceFunctionV1_2_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_2_6; + NetworkDeviceFunctionV1_2_6->NetworkDeviceFunction = NetworkDeviceFunctionV1_2_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_2_6_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_6 *NetworkDeviceFunctionV1_2_6; + + NetworkDeviceFunctionV1_2_6 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_6 *)InterpProp; + DestroyNetworkDeviceFunction_V1_2_6_CS (NetworkDeviceFunctionV1_2_6->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_2_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_2_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_2_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_6/RedfishNetworkDeviceFunction_V1_2_6_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_6/RedfishNetworkDeviceFunction_V1_2_6_Dxe.inf new file mode 100644 index 00000000000..652098d755c --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_6/RedfishNetworkDeviceFunction_V1_2_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_2_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_2_6_Dxe + FILE_GUID = 629a132a-e7c7-40da-be4f-54114cfa6e98 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_2_6EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_2_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_2_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_2_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_7/NetworkDeviceFunction_V1_2_7_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_7/NetworkDeviceFunction_V1_2_7_Dxe.c new file mode 100644 index 00000000000..11511b0ce50 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_7/NetworkDeviceFunction_V1_2_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_2_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "2", + "7" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_7 *NetworkDeviceFunctionV1_2_7; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_7_CS *NetworkDeviceFunctionV1_2_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_2_7_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_2_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_2_7 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_7)); + if (NetworkDeviceFunctionV1_2_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_2_7; + NetworkDeviceFunctionV1_2_7->NetworkDeviceFunction = NetworkDeviceFunctionV1_2_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_2_7_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_7 *NetworkDeviceFunctionV1_2_7; + + NetworkDeviceFunctionV1_2_7 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_7 *)InterpProp; + DestroyNetworkDeviceFunction_V1_2_7_CS (NetworkDeviceFunctionV1_2_7->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_2_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_2_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_2_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_7/RedfishNetworkDeviceFunction_V1_2_7_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_7/RedfishNetworkDeviceFunction_V1_2_7_Dxe.inf new file mode 100644 index 00000000000..e9af4e64f63 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_2_7/RedfishNetworkDeviceFunction_V1_2_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_2_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_2_7_Dxe + FILE_GUID = ea7788cc-a442-478d-b4ef-f960f7b1cc05 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_2_7EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_2_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_2_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_2_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_0/NetworkDeviceFunction_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_0/NetworkDeviceFunction_V1_3_0_Dxe.c new file mode 100644 index 00000000000..3d7e9e88ad7 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_0/NetworkDeviceFunction_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "3", + "0" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_0 *NetworkDeviceFunctionV1_3_0; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_0_CS *NetworkDeviceFunctionV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_3_0_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_3_0 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_0)); + if (NetworkDeviceFunctionV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_3_0; + NetworkDeviceFunctionV1_3_0->NetworkDeviceFunction = NetworkDeviceFunctionV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_3_0_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_0 *NetworkDeviceFunctionV1_3_0; + + NetworkDeviceFunctionV1_3_0 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_0 *)InterpProp; + DestroyNetworkDeviceFunction_V1_3_0_CS (NetworkDeviceFunctionV1_3_0->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_0/RedfishNetworkDeviceFunction_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_0/RedfishNetworkDeviceFunction_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..4bfec24b95d --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_0/RedfishNetworkDeviceFunction_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_3_0_Dxe + FILE_GUID = 80de1c07-f8cd-4601-b8fc-9d5a96037cfd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_1/NetworkDeviceFunction_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_1/NetworkDeviceFunction_V1_3_1_Dxe.c new file mode 100644 index 00000000000..880497af485 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_1/NetworkDeviceFunction_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "3", + "1" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_1 *NetworkDeviceFunctionV1_3_1; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_1_CS *NetworkDeviceFunctionV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_3_1_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_3_1 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_1)); + if (NetworkDeviceFunctionV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_3_1; + NetworkDeviceFunctionV1_3_1->NetworkDeviceFunction = NetworkDeviceFunctionV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_3_1_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_1 *NetworkDeviceFunctionV1_3_1; + + NetworkDeviceFunctionV1_3_1 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_1 *)InterpProp; + DestroyNetworkDeviceFunction_V1_3_1_CS (NetworkDeviceFunctionV1_3_1->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_1/RedfishNetworkDeviceFunction_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_1/RedfishNetworkDeviceFunction_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..34b4a645a2b --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_1/RedfishNetworkDeviceFunction_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_3_1_Dxe + FILE_GUID = aed2a8ba-88d4-4326-83f4-846c0f5b17f9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_2/NetworkDeviceFunction_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_2/NetworkDeviceFunction_V1_3_2_Dxe.c new file mode 100644 index 00000000000..0a4824c8e3f --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_2/NetworkDeviceFunction_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "3", + "2" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_2 *NetworkDeviceFunctionV1_3_2; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_2_CS *NetworkDeviceFunctionV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_3_2_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_3_2 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_2)); + if (NetworkDeviceFunctionV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_3_2; + NetworkDeviceFunctionV1_3_2->NetworkDeviceFunction = NetworkDeviceFunctionV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_3_2_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_2 *NetworkDeviceFunctionV1_3_2; + + NetworkDeviceFunctionV1_3_2 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_2 *)InterpProp; + DestroyNetworkDeviceFunction_V1_3_2_CS (NetworkDeviceFunctionV1_3_2->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_2/RedfishNetworkDeviceFunction_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_2/RedfishNetworkDeviceFunction_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..5e361a805c3 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_2/RedfishNetworkDeviceFunction_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_3_2_Dxe + FILE_GUID = f666bcd6-1ef7-4a40-a58a-38d7b78c016f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_3/NetworkDeviceFunction_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_3/NetworkDeviceFunction_V1_3_3_Dxe.c new file mode 100644 index 00000000000..7610046c222 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_3/NetworkDeviceFunction_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "3", + "3" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_3 *NetworkDeviceFunctionV1_3_3; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_3_CS *NetworkDeviceFunctionV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_3_3_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_3_3 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_3)); + if (NetworkDeviceFunctionV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_3_3; + NetworkDeviceFunctionV1_3_3->NetworkDeviceFunction = NetworkDeviceFunctionV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_3_3_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_3 *NetworkDeviceFunctionV1_3_3; + + NetworkDeviceFunctionV1_3_3 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_3 *)InterpProp; + DestroyNetworkDeviceFunction_V1_3_3_CS (NetworkDeviceFunctionV1_3_3->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_3/RedfishNetworkDeviceFunction_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_3/RedfishNetworkDeviceFunction_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..0fb44efb625 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_3/RedfishNetworkDeviceFunction_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_3_3_Dxe + FILE_GUID = 502d1d58-c60e-4fde-9ecd-4f1463cf950a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_4/NetworkDeviceFunction_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_4/NetworkDeviceFunction_V1_3_4_Dxe.c new file mode 100644 index 00000000000..85575e2e1f6 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_4/NetworkDeviceFunction_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "3", + "4" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_4 *NetworkDeviceFunctionV1_3_4; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_4_CS *NetworkDeviceFunctionV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_3_4_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_3_4 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_4)); + if (NetworkDeviceFunctionV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_3_4; + NetworkDeviceFunctionV1_3_4->NetworkDeviceFunction = NetworkDeviceFunctionV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_3_4_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_4 *NetworkDeviceFunctionV1_3_4; + + NetworkDeviceFunctionV1_3_4 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_4 *)InterpProp; + DestroyNetworkDeviceFunction_V1_3_4_CS (NetworkDeviceFunctionV1_3_4->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_4/RedfishNetworkDeviceFunction_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_4/RedfishNetworkDeviceFunction_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..6750359a72c --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_4/RedfishNetworkDeviceFunction_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_3_4_Dxe + FILE_GUID = 62a8b50e-a68f-4af7-a90b-61984e2a2caa + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_5/NetworkDeviceFunction_V1_3_5_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_5/NetworkDeviceFunction_V1_3_5_Dxe.c new file mode 100644 index 00000000000..c232572bf20 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_5/NetworkDeviceFunction_V1_3_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_3_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "3", + "5" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_5 *NetworkDeviceFunctionV1_3_5; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_5_CS *NetworkDeviceFunctionV1_3_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_3_5_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_3_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_3_5 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_5)); + if (NetworkDeviceFunctionV1_3_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_3_5; + NetworkDeviceFunctionV1_3_5->NetworkDeviceFunction = NetworkDeviceFunctionV1_3_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_3_5_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_5 *NetworkDeviceFunctionV1_3_5; + + NetworkDeviceFunctionV1_3_5 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_5 *)InterpProp; + DestroyNetworkDeviceFunction_V1_3_5_CS (NetworkDeviceFunctionV1_3_5->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_3_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_3_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_3_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_5/RedfishNetworkDeviceFunction_V1_3_5_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_5/RedfishNetworkDeviceFunction_V1_3_5_Dxe.inf new file mode 100644 index 00000000000..b1d2022aa4a --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_3_5/RedfishNetworkDeviceFunction_V1_3_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_3_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_3_5_Dxe + FILE_GUID = 89b259d5-a04f-41f4-b778-453309f7dbe1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_3_5EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_3_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_3_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_3_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_4_0/NetworkDeviceFunction_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_4_0/NetworkDeviceFunction_V1_4_0_Dxe.c new file mode 100644 index 00000000000..99a6818e733 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_4_0/NetworkDeviceFunction_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "4", + "0" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_0 *NetworkDeviceFunctionV1_4_0; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_0_CS *NetworkDeviceFunctionV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_4_0_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_4_0 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_0)); + if (NetworkDeviceFunctionV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_4_0; + NetworkDeviceFunctionV1_4_0->NetworkDeviceFunction = NetworkDeviceFunctionV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_4_0_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_0 *NetworkDeviceFunctionV1_4_0; + + NetworkDeviceFunctionV1_4_0 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_0 *)InterpProp; + DestroyNetworkDeviceFunction_V1_4_0_CS (NetworkDeviceFunctionV1_4_0->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_4_0/RedfishNetworkDeviceFunction_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_4_0/RedfishNetworkDeviceFunction_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..a25208721e7 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_4_0/RedfishNetworkDeviceFunction_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_4_0_Dxe + FILE_GUID = f1d81106-a821-4aa9-bf46-1e0c0bbe8798 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_4_1/NetworkDeviceFunction_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_4_1/NetworkDeviceFunction_V1_4_1_Dxe.c new file mode 100644 index 00000000000..45149fc6274 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_4_1/NetworkDeviceFunction_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "4", + "1" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_1 *NetworkDeviceFunctionV1_4_1; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_1_CS *NetworkDeviceFunctionV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_4_1_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_4_1 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_1)); + if (NetworkDeviceFunctionV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_4_1; + NetworkDeviceFunctionV1_4_1->NetworkDeviceFunction = NetworkDeviceFunctionV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_4_1_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_1 *NetworkDeviceFunctionV1_4_1; + + NetworkDeviceFunctionV1_4_1 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_1 *)InterpProp; + DestroyNetworkDeviceFunction_V1_4_1_CS (NetworkDeviceFunctionV1_4_1->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_4_1/RedfishNetworkDeviceFunction_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_4_1/RedfishNetworkDeviceFunction_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..3122002fc60 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_4_1/RedfishNetworkDeviceFunction_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_4_1_Dxe + FILE_GUID = a856a543-28d5-4252-b61c-ba94556b373b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_4_2/NetworkDeviceFunction_V1_4_2_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_4_2/NetworkDeviceFunction_V1_4_2_Dxe.c new file mode 100644 index 00000000000..a6ce64653c4 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_4_2/NetworkDeviceFunction_V1_4_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_4_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "4", + "2" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_2 *NetworkDeviceFunctionV1_4_2; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_2_CS *NetworkDeviceFunctionV1_4_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_4_2_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_4_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_4_2 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_2)); + if (NetworkDeviceFunctionV1_4_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_4_2; + NetworkDeviceFunctionV1_4_2->NetworkDeviceFunction = NetworkDeviceFunctionV1_4_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_4_2_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_2 *NetworkDeviceFunctionV1_4_2; + + NetworkDeviceFunctionV1_4_2 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_2 *)InterpProp; + DestroyNetworkDeviceFunction_V1_4_2_CS (NetworkDeviceFunctionV1_4_2->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_4_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_4_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_4_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_4_2/RedfishNetworkDeviceFunction_V1_4_2_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_4_2/RedfishNetworkDeviceFunction_V1_4_2_Dxe.inf new file mode 100644 index 00000000000..e1758833c12 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_4_2/RedfishNetworkDeviceFunction_V1_4_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_4_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_4_2_Dxe + FILE_GUID = af946640-4ee2-45ed-8660-ff12bf247bae + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_4_2EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_4_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_4_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_4_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_5_0/NetworkDeviceFunction_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_5_0/NetworkDeviceFunction_V1_5_0_Dxe.c new file mode 100644 index 00000000000..b02784ea004 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_5_0/NetworkDeviceFunction_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "5", + "0" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_5_0 *NetworkDeviceFunctionV1_5_0; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_5_0_CS *NetworkDeviceFunctionV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_5_0_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_5_0 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_5_0)); + if (NetworkDeviceFunctionV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_5_0; + NetworkDeviceFunctionV1_5_0->NetworkDeviceFunction = NetworkDeviceFunctionV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_5_0_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_5_0 *NetworkDeviceFunctionV1_5_0; + + NetworkDeviceFunctionV1_5_0 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_5_0 *)InterpProp; + DestroyNetworkDeviceFunction_V1_5_0_CS (NetworkDeviceFunctionV1_5_0->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_5_0/RedfishNetworkDeviceFunction_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_5_0/RedfishNetworkDeviceFunction_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..42a9580ac74 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_5_0/RedfishNetworkDeviceFunction_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_5_0_Dxe + FILE_GUID = 802f302f-3c0c-4ca8-b9b9-03c2f5033804 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_5_1/NetworkDeviceFunction_V1_5_1_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_5_1/NetworkDeviceFunction_V1_5_1_Dxe.c new file mode 100644 index 00000000000..01519073a9b --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_5_1/NetworkDeviceFunction_V1_5_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunction.v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkDeviceFunction V1_5_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunction", + "1", + "5", + "1" + }, + "NetworkDeviceFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_5_1 *NetworkDeviceFunctionV1_5_1; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_5_1_CS *NetworkDeviceFunctionV1_5_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunction_V1_5_1_To_CS (ResoruceRaw, &NetworkDeviceFunctionV1_5_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionV1_5_1 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_5_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_5_1)); + if (NetworkDeviceFunctionV1_5_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionV1_5_1; + NetworkDeviceFunctionV1_5_1->NetworkDeviceFunction = NetworkDeviceFunctionV1_5_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunction"), "NetworkDeviceFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunction_V1_5_1_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_5_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_5_1 *NetworkDeviceFunctionV1_5_1; + + NetworkDeviceFunctionV1_5_1 = (EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_5_1 *)InterpProp; + DestroyNetworkDeviceFunction_V1_5_1_CS (NetworkDeviceFunctionV1_5_1->NetworkDeviceFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunction_V1_5_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_5_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionToStructWrapper, + NetworkDeviceFunctionToJson, + NetworkDeviceFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunction_V1_5_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_5_1/RedfishNetworkDeviceFunction_V1_5_1_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_5_1/RedfishNetworkDeviceFunction_V1_5_1_Dxe.inf new file mode 100644 index 00000000000..cb677b5ab58 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunction/v1_5_1/RedfishNetworkDeviceFunction_V1_5_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunction.v1_5_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunction_V1_5_1_Dxe + FILE_GUID = 6eb49d1d-1ae9-4454-bc40-df6190bfd912 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunction_V1_5_1EntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunction_V1_5_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunction_V1_5_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionV1_5_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunctionCollection/NetworkDeviceFunctionCollection_Dxe.c b/RedfishClientPkg/Converter/NetworkDeviceFunctionCollection/NetworkDeviceFunctionCollection_Dxe.c new file mode 100644 index 00000000000..7996b0f9c4e --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunctionCollection/NetworkDeviceFunctionCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkDeviceFunctionCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkDeviceFunctionCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support NetworkDeviceFunctionCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkDeviceFunctionCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "NetworkDeviceFunctionCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTIONCOLLECTION *NetworkDeviceFunctionCollection; + EFI_REDFISH_NETWORKDEVICEFUNCTIONCOLLECTION_CS *NetworkDeviceFunctionCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkDeviceFunctionCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkDeviceFunctionCollection_To_CS (ResoruceRaw, &NetworkDeviceFunctionCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkDeviceFunctionCollection = (EFI_REDFISH_NETWORKDEVICEFUNCTIONCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKDEVICEFUNCTIONCOLLECTION)); + if (NetworkDeviceFunctionCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkDeviceFunctionCollection; + NetworkDeviceFunctionCollection->NetworkDeviceFunctionCollection = NetworkDeviceFunctionCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunctionCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkDeviceFunctionCollection"), "NetworkDeviceFunctionCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkDeviceFunctionCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkDeviceFunctionCollection"), "NetworkDeviceFunctionCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkDeviceFunctionCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkDeviceFunctionCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkDeviceFunctionCollection_JSON (*((EFI_REDFISH_NETWORKDEVICEFUNCTIONCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkDeviceFunctionCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKDEVICEFUNCTIONCOLLECTION *NetworkDeviceFunctionCollection; + + NetworkDeviceFunctionCollection = (EFI_REDFISH_NETWORKDEVICEFUNCTIONCOLLECTION *)InterpProp; + DestroyNetworkDeviceFunctionCollection_CS (NetworkDeviceFunctionCollection->NetworkDeviceFunctionCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkDeviceFunctionCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkDeviceFunctionCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkDeviceFunctionCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunctionCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkDeviceFunctionCollectionToStructWrapper, + NetworkDeviceFunctionCollectionToJson, + NetworkDeviceFunctionCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkDeviceFunctionCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkDeviceFunctionCollection/RedfishNetworkDeviceFunctionCollection_Dxe.inf b/RedfishClientPkg/Converter/NetworkDeviceFunctionCollection/RedfishNetworkDeviceFunctionCollection_Dxe.inf new file mode 100644 index 00000000000..286e7ee52cb --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkDeviceFunctionCollection/RedfishNetworkDeviceFunctionCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkDeviceFunctionCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkDeviceFunctionCollection_Dxe + FILE_GUID = 58710c01-94ca-4004-9463-d02405bf5cb1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkDeviceFunctionCollectionEntryPoint + UNLOAD_IMAGE = RedfishNetworkDeviceFunctionCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkDeviceFunctionCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkDeviceFunctionCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_0_0/NetworkInterface_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/NetworkInterface/v1_0_0/NetworkInterface_V1_0_0_Dxe.c new file mode 100644 index 00000000000..3debb937538 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_0_0/NetworkInterface_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkInterface.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkInterface V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkInterface", + "1", + "0", + "0" + }, + "NetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_0_0 *NetworkInterfaceV1_0_0; + EFI_REDFISH_NETWORKINTERFACE_V1_0_0_CS *NetworkInterfaceV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkInterface_V1_0_0_To_CS (ResoruceRaw, &NetworkInterfaceV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkInterfaceV1_0_0 = (EFI_REDFISH_NETWORKINTERFACE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKINTERFACE_V1_0_0)); + if (NetworkInterfaceV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkInterfaceV1_0_0; + NetworkInterfaceV1_0_0->NetworkInterface = NetworkInterfaceV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkInterface_V1_0_0_JSON (*((EFI_REDFISH_NETWORKINTERFACE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_0_0 *NetworkInterfaceV1_0_0; + + NetworkInterfaceV1_0_0 = (EFI_REDFISH_NETWORKINTERFACE_V1_0_0 *)InterpProp; + DestroyNetworkInterface_V1_0_0_CS (NetworkInterfaceV1_0_0->NetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkInterface_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkInterfaceToStructWrapper, + NetworkInterfaceToJson, + NetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_0_0/RedfishNetworkInterface_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/NetworkInterface/v1_0_0/RedfishNetworkInterface_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..b9d6e7b4e7d --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_0_0/RedfishNetworkInterface_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkInterface.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkInterface_V1_0_0_Dxe + FILE_GUID = 23a22764-d533-4797-8f25-7bd860659baf + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkInterface_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishNetworkInterface_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkInterface_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkInterfaceV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_0_1/NetworkInterface_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/NetworkInterface/v1_0_1/NetworkInterface_V1_0_1_Dxe.c new file mode 100644 index 00000000000..95b482bfd7c --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_0_1/NetworkInterface_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkInterface.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkInterface V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkInterface", + "1", + "0", + "1" + }, + "NetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_0_1 *NetworkInterfaceV1_0_1; + EFI_REDFISH_NETWORKINTERFACE_V1_0_1_CS *NetworkInterfaceV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkInterface_V1_0_1_To_CS (ResoruceRaw, &NetworkInterfaceV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkInterfaceV1_0_1 = (EFI_REDFISH_NETWORKINTERFACE_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKINTERFACE_V1_0_1)); + if (NetworkInterfaceV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkInterfaceV1_0_1; + NetworkInterfaceV1_0_1->NetworkInterface = NetworkInterfaceV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkInterface_V1_0_1_JSON (*((EFI_REDFISH_NETWORKINTERFACE_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_0_1 *NetworkInterfaceV1_0_1; + + NetworkInterfaceV1_0_1 = (EFI_REDFISH_NETWORKINTERFACE_V1_0_1 *)InterpProp; + DestroyNetworkInterface_V1_0_1_CS (NetworkInterfaceV1_0_1->NetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkInterface_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkInterfaceToStructWrapper, + NetworkInterfaceToJson, + NetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_0_1/RedfishNetworkInterface_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/NetworkInterface/v1_0_1/RedfishNetworkInterface_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..7ba1c18ce15 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_0_1/RedfishNetworkInterface_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkInterface.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkInterface_V1_0_1_Dxe + FILE_GUID = da754cf9-2af2-44c0-ac1d-ed25dd4233d3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkInterface_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishNetworkInterface_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkInterface_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkInterfaceV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_0_2/NetworkInterface_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/NetworkInterface/v1_0_2/NetworkInterface_V1_0_2_Dxe.c new file mode 100644 index 00000000000..b0c65e1d142 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_0_2/NetworkInterface_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkInterface.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkInterface V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkInterface", + "1", + "0", + "2" + }, + "NetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_0_2 *NetworkInterfaceV1_0_2; + EFI_REDFISH_NETWORKINTERFACE_V1_0_2_CS *NetworkInterfaceV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkInterface_V1_0_2_To_CS (ResoruceRaw, &NetworkInterfaceV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkInterfaceV1_0_2 = (EFI_REDFISH_NETWORKINTERFACE_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKINTERFACE_V1_0_2)); + if (NetworkInterfaceV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkInterfaceV1_0_2; + NetworkInterfaceV1_0_2->NetworkInterface = NetworkInterfaceV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkInterface_V1_0_2_JSON (*((EFI_REDFISH_NETWORKINTERFACE_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_0_2 *NetworkInterfaceV1_0_2; + + NetworkInterfaceV1_0_2 = (EFI_REDFISH_NETWORKINTERFACE_V1_0_2 *)InterpProp; + DestroyNetworkInterface_V1_0_2_CS (NetworkInterfaceV1_0_2->NetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkInterface_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkInterfaceToStructWrapper, + NetworkInterfaceToJson, + NetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_0_2/RedfishNetworkInterface_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/NetworkInterface/v1_0_2/RedfishNetworkInterface_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..9fe6c74f1df --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_0_2/RedfishNetworkInterface_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkInterface.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkInterface_V1_0_2_Dxe + FILE_GUID = 4713850a-0fb5-4153-bdf2-6ad5c23c7ec6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkInterface_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishNetworkInterface_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkInterface_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkInterfaceV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_0_3/NetworkInterface_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/NetworkInterface/v1_0_3/NetworkInterface_V1_0_3_Dxe.c new file mode 100644 index 00000000000..d3b5e8d4459 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_0_3/NetworkInterface_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkInterface.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkInterface V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkInterface", + "1", + "0", + "3" + }, + "NetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_0_3 *NetworkInterfaceV1_0_3; + EFI_REDFISH_NETWORKINTERFACE_V1_0_3_CS *NetworkInterfaceV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkInterface_V1_0_3_To_CS (ResoruceRaw, &NetworkInterfaceV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkInterfaceV1_0_3 = (EFI_REDFISH_NETWORKINTERFACE_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKINTERFACE_V1_0_3)); + if (NetworkInterfaceV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkInterfaceV1_0_3; + NetworkInterfaceV1_0_3->NetworkInterface = NetworkInterfaceV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkInterface_V1_0_3_JSON (*((EFI_REDFISH_NETWORKINTERFACE_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_0_3 *NetworkInterfaceV1_0_3; + + NetworkInterfaceV1_0_3 = (EFI_REDFISH_NETWORKINTERFACE_V1_0_3 *)InterpProp; + DestroyNetworkInterface_V1_0_3_CS (NetworkInterfaceV1_0_3->NetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkInterface_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkInterfaceToStructWrapper, + NetworkInterfaceToJson, + NetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_0_3/RedfishNetworkInterface_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/NetworkInterface/v1_0_3/RedfishNetworkInterface_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..fc104723f48 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_0_3/RedfishNetworkInterface_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkInterface.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkInterface_V1_0_3_Dxe + FILE_GUID = bbfc9aff-1521-47a5-8239-fbfc52b796db + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkInterface_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishNetworkInterface_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkInterface_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkInterfaceV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_0_4/NetworkInterface_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/NetworkInterface/v1_0_4/NetworkInterface_V1_0_4_Dxe.c new file mode 100644 index 00000000000..6626a5fe091 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_0_4/NetworkInterface_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkInterface.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkInterface V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkInterface", + "1", + "0", + "4" + }, + "NetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_0_4 *NetworkInterfaceV1_0_4; + EFI_REDFISH_NETWORKINTERFACE_V1_0_4_CS *NetworkInterfaceV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkInterface_V1_0_4_To_CS (ResoruceRaw, &NetworkInterfaceV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkInterfaceV1_0_4 = (EFI_REDFISH_NETWORKINTERFACE_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKINTERFACE_V1_0_4)); + if (NetworkInterfaceV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkInterfaceV1_0_4; + NetworkInterfaceV1_0_4->NetworkInterface = NetworkInterfaceV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkInterface_V1_0_4_JSON (*((EFI_REDFISH_NETWORKINTERFACE_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_0_4 *NetworkInterfaceV1_0_4; + + NetworkInterfaceV1_0_4 = (EFI_REDFISH_NETWORKINTERFACE_V1_0_4 *)InterpProp; + DestroyNetworkInterface_V1_0_4_CS (NetworkInterfaceV1_0_4->NetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkInterface_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkInterfaceToStructWrapper, + NetworkInterfaceToJson, + NetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_0_4/RedfishNetworkInterface_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/NetworkInterface/v1_0_4/RedfishNetworkInterface_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..d83a780aab1 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_0_4/RedfishNetworkInterface_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkInterface.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkInterface_V1_0_4_Dxe + FILE_GUID = e26a1bfb-3e4c-4802-81f5-c39455772749 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkInterface_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishNetworkInterface_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkInterface_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkInterfaceV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_0_5/NetworkInterface_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/NetworkInterface/v1_0_5/NetworkInterface_V1_0_5_Dxe.c new file mode 100644 index 00000000000..e9c16b4aeaf --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_0_5/NetworkInterface_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkInterface.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkInterface V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkInterface", + "1", + "0", + "5" + }, + "NetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_0_5 *NetworkInterfaceV1_0_5; + EFI_REDFISH_NETWORKINTERFACE_V1_0_5_CS *NetworkInterfaceV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkInterface_V1_0_5_To_CS (ResoruceRaw, &NetworkInterfaceV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkInterfaceV1_0_5 = (EFI_REDFISH_NETWORKINTERFACE_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKINTERFACE_V1_0_5)); + if (NetworkInterfaceV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkInterfaceV1_0_5; + NetworkInterfaceV1_0_5->NetworkInterface = NetworkInterfaceV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkInterface_V1_0_5_JSON (*((EFI_REDFISH_NETWORKINTERFACE_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_0_5 *NetworkInterfaceV1_0_5; + + NetworkInterfaceV1_0_5 = (EFI_REDFISH_NETWORKINTERFACE_V1_0_5 *)InterpProp; + DestroyNetworkInterface_V1_0_5_CS (NetworkInterfaceV1_0_5->NetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkInterface_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkInterfaceToStructWrapper, + NetworkInterfaceToJson, + NetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_0_5/RedfishNetworkInterface_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/NetworkInterface/v1_0_5/RedfishNetworkInterface_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..5a084b73fe1 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_0_5/RedfishNetworkInterface_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkInterface.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkInterface_V1_0_5_Dxe + FILE_GUID = 910ec78b-d7a1-472a-ac7e-2108d8d62298 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkInterface_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishNetworkInterface_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkInterface_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkInterfaceV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_0_6/NetworkInterface_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/NetworkInterface/v1_0_6/NetworkInterface_V1_0_6_Dxe.c new file mode 100644 index 00000000000..37174d3d6f6 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_0_6/NetworkInterface_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkInterface.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkInterface V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkInterface", + "1", + "0", + "6" + }, + "NetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_0_6 *NetworkInterfaceV1_0_6; + EFI_REDFISH_NETWORKINTERFACE_V1_0_6_CS *NetworkInterfaceV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkInterface_V1_0_6_To_CS (ResoruceRaw, &NetworkInterfaceV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkInterfaceV1_0_6 = (EFI_REDFISH_NETWORKINTERFACE_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKINTERFACE_V1_0_6)); + if (NetworkInterfaceV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkInterfaceV1_0_6; + NetworkInterfaceV1_0_6->NetworkInterface = NetworkInterfaceV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkInterface_V1_0_6_JSON (*((EFI_REDFISH_NETWORKINTERFACE_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_0_6 *NetworkInterfaceV1_0_6; + + NetworkInterfaceV1_0_6 = (EFI_REDFISH_NETWORKINTERFACE_V1_0_6 *)InterpProp; + DestroyNetworkInterface_V1_0_6_CS (NetworkInterfaceV1_0_6->NetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkInterface_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkInterfaceToStructWrapper, + NetworkInterfaceToJson, + NetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_0_6/RedfishNetworkInterface_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/NetworkInterface/v1_0_6/RedfishNetworkInterface_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..748440000a6 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_0_6/RedfishNetworkInterface_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkInterface.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkInterface_V1_0_6_Dxe + FILE_GUID = 259e3bbf-9898-4c5a-95c0-502ee212f7d5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkInterface_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishNetworkInterface_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkInterface_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkInterfaceV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_1_0/NetworkInterface_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/NetworkInterface/v1_1_0/NetworkInterface_V1_1_0_Dxe.c new file mode 100644 index 00000000000..977d60a1e19 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_1_0/NetworkInterface_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkInterface.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkInterface V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkInterface", + "1", + "1", + "0" + }, + "NetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_1_0 *NetworkInterfaceV1_1_0; + EFI_REDFISH_NETWORKINTERFACE_V1_1_0_CS *NetworkInterfaceV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkInterface_V1_1_0_To_CS (ResoruceRaw, &NetworkInterfaceV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkInterfaceV1_1_0 = (EFI_REDFISH_NETWORKINTERFACE_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKINTERFACE_V1_1_0)); + if (NetworkInterfaceV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkInterfaceV1_1_0; + NetworkInterfaceV1_1_0->NetworkInterface = NetworkInterfaceV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkInterface_V1_1_0_JSON (*((EFI_REDFISH_NETWORKINTERFACE_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_1_0 *NetworkInterfaceV1_1_0; + + NetworkInterfaceV1_1_0 = (EFI_REDFISH_NETWORKINTERFACE_V1_1_0 *)InterpProp; + DestroyNetworkInterface_V1_1_0_CS (NetworkInterfaceV1_1_0->NetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkInterface_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkInterfaceToStructWrapper, + NetworkInterfaceToJson, + NetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_1_0/RedfishNetworkInterface_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/NetworkInterface/v1_1_0/RedfishNetworkInterface_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..fbc6aefc424 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_1_0/RedfishNetworkInterface_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkInterface.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkInterface_V1_1_0_Dxe + FILE_GUID = 6065fc05-7e97-4b38-91f1-a456601452b0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkInterface_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishNetworkInterface_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkInterface_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkInterfaceV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_1_1/NetworkInterface_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/NetworkInterface/v1_1_1/NetworkInterface_V1_1_1_Dxe.c new file mode 100644 index 00000000000..c000ba1210f --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_1_1/NetworkInterface_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkInterface.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkInterface V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkInterface", + "1", + "1", + "1" + }, + "NetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_1_1 *NetworkInterfaceV1_1_1; + EFI_REDFISH_NETWORKINTERFACE_V1_1_1_CS *NetworkInterfaceV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkInterface_V1_1_1_To_CS (ResoruceRaw, &NetworkInterfaceV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkInterfaceV1_1_1 = (EFI_REDFISH_NETWORKINTERFACE_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKINTERFACE_V1_1_1)); + if (NetworkInterfaceV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkInterfaceV1_1_1; + NetworkInterfaceV1_1_1->NetworkInterface = NetworkInterfaceV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkInterface_V1_1_1_JSON (*((EFI_REDFISH_NETWORKINTERFACE_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_1_1 *NetworkInterfaceV1_1_1; + + NetworkInterfaceV1_1_1 = (EFI_REDFISH_NETWORKINTERFACE_V1_1_1 *)InterpProp; + DestroyNetworkInterface_V1_1_1_CS (NetworkInterfaceV1_1_1->NetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkInterface_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkInterfaceToStructWrapper, + NetworkInterfaceToJson, + NetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_1_1/RedfishNetworkInterface_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/NetworkInterface/v1_1_1/RedfishNetworkInterface_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..e95074e949c --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_1_1/RedfishNetworkInterface_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkInterface.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkInterface_V1_1_1_Dxe + FILE_GUID = 457848c2-70c6-4e64-abc5-02dc4c379757 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkInterface_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishNetworkInterface_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkInterface_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkInterfaceV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_1_2/NetworkInterface_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/NetworkInterface/v1_1_2/NetworkInterface_V1_1_2_Dxe.c new file mode 100644 index 00000000000..86724ae382b --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_1_2/NetworkInterface_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkInterface.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkInterface V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkInterface", + "1", + "1", + "2" + }, + "NetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_1_2 *NetworkInterfaceV1_1_2; + EFI_REDFISH_NETWORKINTERFACE_V1_1_2_CS *NetworkInterfaceV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkInterface_V1_1_2_To_CS (ResoruceRaw, &NetworkInterfaceV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkInterfaceV1_1_2 = (EFI_REDFISH_NETWORKINTERFACE_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKINTERFACE_V1_1_2)); + if (NetworkInterfaceV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkInterfaceV1_1_2; + NetworkInterfaceV1_1_2->NetworkInterface = NetworkInterfaceV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkInterface_V1_1_2_JSON (*((EFI_REDFISH_NETWORKINTERFACE_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_1_2 *NetworkInterfaceV1_1_2; + + NetworkInterfaceV1_1_2 = (EFI_REDFISH_NETWORKINTERFACE_V1_1_2 *)InterpProp; + DestroyNetworkInterface_V1_1_2_CS (NetworkInterfaceV1_1_2->NetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkInterface_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkInterfaceToStructWrapper, + NetworkInterfaceToJson, + NetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_1_2/RedfishNetworkInterface_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/NetworkInterface/v1_1_2/RedfishNetworkInterface_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..331de8d08eb --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_1_2/RedfishNetworkInterface_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkInterface.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkInterface_V1_1_2_Dxe + FILE_GUID = ece4342d-4656-4dfa-a7ec-77f718f34cd5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkInterface_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishNetworkInterface_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkInterface_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkInterfaceV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_1_3/NetworkInterface_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/NetworkInterface/v1_1_3/NetworkInterface_V1_1_3_Dxe.c new file mode 100644 index 00000000000..492ac64f5d3 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_1_3/NetworkInterface_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkInterface.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkInterface V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkInterface", + "1", + "1", + "3" + }, + "NetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_1_3 *NetworkInterfaceV1_1_3; + EFI_REDFISH_NETWORKINTERFACE_V1_1_3_CS *NetworkInterfaceV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkInterface_V1_1_3_To_CS (ResoruceRaw, &NetworkInterfaceV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkInterfaceV1_1_3 = (EFI_REDFISH_NETWORKINTERFACE_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKINTERFACE_V1_1_3)); + if (NetworkInterfaceV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkInterfaceV1_1_3; + NetworkInterfaceV1_1_3->NetworkInterface = NetworkInterfaceV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkInterface_V1_1_3_JSON (*((EFI_REDFISH_NETWORKINTERFACE_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_1_3 *NetworkInterfaceV1_1_3; + + NetworkInterfaceV1_1_3 = (EFI_REDFISH_NETWORKINTERFACE_V1_1_3 *)InterpProp; + DestroyNetworkInterface_V1_1_3_CS (NetworkInterfaceV1_1_3->NetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkInterface_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkInterfaceToStructWrapper, + NetworkInterfaceToJson, + NetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_1_3/RedfishNetworkInterface_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/NetworkInterface/v1_1_3/RedfishNetworkInterface_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..0aca1d58ca9 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_1_3/RedfishNetworkInterface_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkInterface.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkInterface_V1_1_3_Dxe + FILE_GUID = e1cee6c5-bcfc-422c-af98-eae44f1b81d8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkInterface_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishNetworkInterface_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkInterface_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkInterfaceV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_1_4/NetworkInterface_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/NetworkInterface/v1_1_4/NetworkInterface_V1_1_4_Dxe.c new file mode 100644 index 00000000000..12e00200951 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_1_4/NetworkInterface_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkInterface.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkInterface V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkInterface", + "1", + "1", + "4" + }, + "NetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_1_4 *NetworkInterfaceV1_1_4; + EFI_REDFISH_NETWORKINTERFACE_V1_1_4_CS *NetworkInterfaceV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkInterface_V1_1_4_To_CS (ResoruceRaw, &NetworkInterfaceV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkInterfaceV1_1_4 = (EFI_REDFISH_NETWORKINTERFACE_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKINTERFACE_V1_1_4)); + if (NetworkInterfaceV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkInterfaceV1_1_4; + NetworkInterfaceV1_1_4->NetworkInterface = NetworkInterfaceV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkInterface_V1_1_4_JSON (*((EFI_REDFISH_NETWORKINTERFACE_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_1_4 *NetworkInterfaceV1_1_4; + + NetworkInterfaceV1_1_4 = (EFI_REDFISH_NETWORKINTERFACE_V1_1_4 *)InterpProp; + DestroyNetworkInterface_V1_1_4_CS (NetworkInterfaceV1_1_4->NetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkInterface_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkInterfaceToStructWrapper, + NetworkInterfaceToJson, + NetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_1_4/RedfishNetworkInterface_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/NetworkInterface/v1_1_4/RedfishNetworkInterface_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..00d0c6ee211 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_1_4/RedfishNetworkInterface_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkInterface.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkInterface_V1_1_4_Dxe + FILE_GUID = 050dcba1-0970-46a4-8e57-89ac509a943e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkInterface_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishNetworkInterface_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkInterface_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkInterfaceV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_1_5/NetworkInterface_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/NetworkInterface/v1_1_5/NetworkInterface_V1_1_5_Dxe.c new file mode 100644 index 00000000000..5d83c5e5792 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_1_5/NetworkInterface_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkInterface.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkInterface V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkInterface", + "1", + "1", + "5" + }, + "NetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_1_5 *NetworkInterfaceV1_1_5; + EFI_REDFISH_NETWORKINTERFACE_V1_1_5_CS *NetworkInterfaceV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkInterface_V1_1_5_To_CS (ResoruceRaw, &NetworkInterfaceV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkInterfaceV1_1_5 = (EFI_REDFISH_NETWORKINTERFACE_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKINTERFACE_V1_1_5)); + if (NetworkInterfaceV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkInterfaceV1_1_5; + NetworkInterfaceV1_1_5->NetworkInterface = NetworkInterfaceV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkInterface_V1_1_5_JSON (*((EFI_REDFISH_NETWORKINTERFACE_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_1_5 *NetworkInterfaceV1_1_5; + + NetworkInterfaceV1_1_5 = (EFI_REDFISH_NETWORKINTERFACE_V1_1_5 *)InterpProp; + DestroyNetworkInterface_V1_1_5_CS (NetworkInterfaceV1_1_5->NetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkInterface_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkInterfaceToStructWrapper, + NetworkInterfaceToJson, + NetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_1_5/RedfishNetworkInterface_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/NetworkInterface/v1_1_5/RedfishNetworkInterface_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..d51645e6d60 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_1_5/RedfishNetworkInterface_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkInterface.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkInterface_V1_1_5_Dxe + FILE_GUID = 50474908-933f-4cc1-908b-7589425b1d65 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkInterface_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishNetworkInterface_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkInterface_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkInterfaceV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_2_0/NetworkInterface_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/NetworkInterface/v1_2_0/NetworkInterface_V1_2_0_Dxe.c new file mode 100644 index 00000000000..013b55dc209 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_2_0/NetworkInterface_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkInterface.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkInterface V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkInterface", + "1", + "2", + "0" + }, + "NetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_2_0 *NetworkInterfaceV1_2_0; + EFI_REDFISH_NETWORKINTERFACE_V1_2_0_CS *NetworkInterfaceV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkInterface_V1_2_0_To_CS (ResoruceRaw, &NetworkInterfaceV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkInterfaceV1_2_0 = (EFI_REDFISH_NETWORKINTERFACE_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKINTERFACE_V1_2_0)); + if (NetworkInterfaceV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkInterfaceV1_2_0; + NetworkInterfaceV1_2_0->NetworkInterface = NetworkInterfaceV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkInterface_V1_2_0_JSON (*((EFI_REDFISH_NETWORKINTERFACE_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_2_0 *NetworkInterfaceV1_2_0; + + NetworkInterfaceV1_2_0 = (EFI_REDFISH_NETWORKINTERFACE_V1_2_0 *)InterpProp; + DestroyNetworkInterface_V1_2_0_CS (NetworkInterfaceV1_2_0->NetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkInterface_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkInterfaceToStructWrapper, + NetworkInterfaceToJson, + NetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_2_0/RedfishNetworkInterface_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/NetworkInterface/v1_2_0/RedfishNetworkInterface_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..fa56d16e1ec --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_2_0/RedfishNetworkInterface_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkInterface.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkInterface_V1_2_0_Dxe + FILE_GUID = 704dc4d4-f916-4beb-aed4-beb413522ff5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkInterface_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishNetworkInterface_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkInterface_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkInterfaceV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_2_1/NetworkInterface_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/NetworkInterface/v1_2_1/NetworkInterface_V1_2_1_Dxe.c new file mode 100644 index 00000000000..ed216c910d2 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_2_1/NetworkInterface_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkInterface.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkInterface V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkInterface", + "1", + "2", + "1" + }, + "NetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_2_1 *NetworkInterfaceV1_2_1; + EFI_REDFISH_NETWORKINTERFACE_V1_2_1_CS *NetworkInterfaceV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkInterface_V1_2_1_To_CS (ResoruceRaw, &NetworkInterfaceV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkInterfaceV1_2_1 = (EFI_REDFISH_NETWORKINTERFACE_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKINTERFACE_V1_2_1)); + if (NetworkInterfaceV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkInterfaceV1_2_1; + NetworkInterfaceV1_2_1->NetworkInterface = NetworkInterfaceV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkInterface"), "NetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkInterface_V1_2_1_JSON (*((EFI_REDFISH_NETWORKINTERFACE_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACE_V1_2_1 *NetworkInterfaceV1_2_1; + + NetworkInterfaceV1_2_1 = (EFI_REDFISH_NETWORKINTERFACE_V1_2_1 *)InterpProp; + DestroyNetworkInterface_V1_2_1_CS (NetworkInterfaceV1_2_1->NetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkInterface_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkInterfaceToStructWrapper, + NetworkInterfaceToJson, + NetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterface_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkInterface/v1_2_1/RedfishNetworkInterface_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/NetworkInterface/v1_2_1/RedfishNetworkInterface_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..7e44c8a6232 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterface/v1_2_1/RedfishNetworkInterface_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkInterface.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkInterface_V1_2_1_Dxe + FILE_GUID = 51d99893-c567-447e-8ed4-80307275302b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkInterface_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishNetworkInterface_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkInterface_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkInterfaceV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkInterfaceCollection/NetworkInterfaceCollection_Dxe.c b/RedfishClientPkg/Converter/NetworkInterfaceCollection/NetworkInterfaceCollection_Dxe.c new file mode 100644 index 00000000000..7baa2793508 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterfaceCollection/NetworkInterfaceCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkInterfaceCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkInterfaceCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support NetworkInterfaceCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkInterfaceCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "NetworkInterfaceCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACECOLLECTION *NetworkInterfaceCollection; + EFI_REDFISH_NETWORKINTERFACECOLLECTION_CS *NetworkInterfaceCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkInterfaceCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkInterfaceCollection_To_CS (ResoruceRaw, &NetworkInterfaceCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkInterfaceCollection = (EFI_REDFISH_NETWORKINTERFACECOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKINTERFACECOLLECTION)); + if (NetworkInterfaceCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkInterfaceCollection; + NetworkInterfaceCollection->NetworkInterfaceCollection = NetworkInterfaceCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterfaceCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkInterfaceCollection"), "NetworkInterfaceCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkInterfaceCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkInterfaceCollection"), "NetworkInterfaceCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkInterfaceCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkInterfaceCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkInterfaceCollection_JSON (*((EFI_REDFISH_NETWORKINTERFACECOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkInterfaceCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKINTERFACECOLLECTION *NetworkInterfaceCollection; + + NetworkInterfaceCollection = (EFI_REDFISH_NETWORKINTERFACECOLLECTION *)InterpProp; + DestroyNetworkInterfaceCollection_CS (NetworkInterfaceCollection->NetworkInterfaceCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkInterfaceCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkInterfaceCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkInterfaceCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterfaceCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkInterfaceCollectionToStructWrapper, + NetworkInterfaceCollectionToJson, + NetworkInterfaceCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkInterfaceCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkInterfaceCollection/RedfishNetworkInterfaceCollection_Dxe.inf b/RedfishClientPkg/Converter/NetworkInterfaceCollection/RedfishNetworkInterfaceCollection_Dxe.inf new file mode 100644 index 00000000000..fb8eb3e4e33 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkInterfaceCollection/RedfishNetworkInterfaceCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkInterfaceCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkInterfaceCollection_Dxe + FILE_GUID = 9e184bd9-13ab-44d5-b053-9db2360b7fd9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkInterfaceCollectionEntryPoint + UNLOAD_IMAGE = RedfishNetworkInterfaceCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkInterfaceCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkInterfaceCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_0_0/NetworkPort_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_0_0/NetworkPort_V1_0_0_Dxe.c new file mode 100644 index 00000000000..ba763a6f08e --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_0_0/NetworkPort_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "0", + "0" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_0_0 *NetworkPortV1_0_0; + EFI_REDFISH_NETWORKPORT_V1_0_0_CS *NetworkPortV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_0_0_To_CS (ResoruceRaw, &NetworkPortV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_0_0 = (EFI_REDFISH_NETWORKPORT_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_0_0)); + if (NetworkPortV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_0_0; + NetworkPortV1_0_0->NetworkPort = NetworkPortV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_0_0_JSON (*((EFI_REDFISH_NETWORKPORT_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_0_0 *NetworkPortV1_0_0; + + NetworkPortV1_0_0 = (EFI_REDFISH_NETWORKPORT_V1_0_0 *)InterpProp; + DestroyNetworkPort_V1_0_0_CS (NetworkPortV1_0_0->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_0_0/RedfishNetworkPort_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_0_0/RedfishNetworkPort_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..2e5b0729004 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_0_0/RedfishNetworkPort_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_0_0_Dxe + FILE_GUID = d752e324-1894-4b04-a12a-4f5c97495b90 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_0_1/NetworkPort_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_0_1/NetworkPort_V1_0_1_Dxe.c new file mode 100644 index 00000000000..0a25a67c0cb --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_0_1/NetworkPort_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "0", + "1" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_0_1 *NetworkPortV1_0_1; + EFI_REDFISH_NETWORKPORT_V1_0_1_CS *NetworkPortV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_0_1_To_CS (ResoruceRaw, &NetworkPortV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_0_1 = (EFI_REDFISH_NETWORKPORT_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_0_1)); + if (NetworkPortV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_0_1; + NetworkPortV1_0_1->NetworkPort = NetworkPortV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_0_1_JSON (*((EFI_REDFISH_NETWORKPORT_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_0_1 *NetworkPortV1_0_1; + + NetworkPortV1_0_1 = (EFI_REDFISH_NETWORKPORT_V1_0_1 *)InterpProp; + DestroyNetworkPort_V1_0_1_CS (NetworkPortV1_0_1->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_0_1/RedfishNetworkPort_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_0_1/RedfishNetworkPort_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..bc64b8b48ac --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_0_1/RedfishNetworkPort_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_0_1_Dxe + FILE_GUID = f0b24561-6b4d-49aa-bcc2-5057fb84ed9c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_0_2/NetworkPort_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_0_2/NetworkPort_V1_0_2_Dxe.c new file mode 100644 index 00000000000..e8562a60901 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_0_2/NetworkPort_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "0", + "2" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_0_2 *NetworkPortV1_0_2; + EFI_REDFISH_NETWORKPORT_V1_0_2_CS *NetworkPortV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_0_2_To_CS (ResoruceRaw, &NetworkPortV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_0_2 = (EFI_REDFISH_NETWORKPORT_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_0_2)); + if (NetworkPortV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_0_2; + NetworkPortV1_0_2->NetworkPort = NetworkPortV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_0_2_JSON (*((EFI_REDFISH_NETWORKPORT_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_0_2 *NetworkPortV1_0_2; + + NetworkPortV1_0_2 = (EFI_REDFISH_NETWORKPORT_V1_0_2 *)InterpProp; + DestroyNetworkPort_V1_0_2_CS (NetworkPortV1_0_2->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_0_2/RedfishNetworkPort_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_0_2/RedfishNetworkPort_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..04973d5cc05 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_0_2/RedfishNetworkPort_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_0_2_Dxe + FILE_GUID = 1870a21a-7b9f-4054-b487-e7ec99b4ee9c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_0_3/NetworkPort_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_0_3/NetworkPort_V1_0_3_Dxe.c new file mode 100644 index 00000000000..6d65239f44b --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_0_3/NetworkPort_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "0", + "3" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_0_3 *NetworkPortV1_0_3; + EFI_REDFISH_NETWORKPORT_V1_0_3_CS *NetworkPortV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_0_3_To_CS (ResoruceRaw, &NetworkPortV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_0_3 = (EFI_REDFISH_NETWORKPORT_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_0_3)); + if (NetworkPortV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_0_3; + NetworkPortV1_0_3->NetworkPort = NetworkPortV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_0_3_JSON (*((EFI_REDFISH_NETWORKPORT_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_0_3 *NetworkPortV1_0_3; + + NetworkPortV1_0_3 = (EFI_REDFISH_NETWORKPORT_V1_0_3 *)InterpProp; + DestroyNetworkPort_V1_0_3_CS (NetworkPortV1_0_3->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_0_3/RedfishNetworkPort_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_0_3/RedfishNetworkPort_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..00956d67614 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_0_3/RedfishNetworkPort_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_0_3_Dxe + FILE_GUID = 522056cd-b36b-4cc5-a56b-dc4b76c98948 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_0_4/NetworkPort_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_0_4/NetworkPort_V1_0_4_Dxe.c new file mode 100644 index 00000000000..3d6369e09de --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_0_4/NetworkPort_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "0", + "4" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_0_4 *NetworkPortV1_0_4; + EFI_REDFISH_NETWORKPORT_V1_0_4_CS *NetworkPortV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_0_4_To_CS (ResoruceRaw, &NetworkPortV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_0_4 = (EFI_REDFISH_NETWORKPORT_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_0_4)); + if (NetworkPortV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_0_4; + NetworkPortV1_0_4->NetworkPort = NetworkPortV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_0_4_JSON (*((EFI_REDFISH_NETWORKPORT_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_0_4 *NetworkPortV1_0_4; + + NetworkPortV1_0_4 = (EFI_REDFISH_NETWORKPORT_V1_0_4 *)InterpProp; + DestroyNetworkPort_V1_0_4_CS (NetworkPortV1_0_4->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_0_4/RedfishNetworkPort_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_0_4/RedfishNetworkPort_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..1e5cbd6fea1 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_0_4/RedfishNetworkPort_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_0_4_Dxe + FILE_GUID = 5b8a31ba-5a03-45ce-a0ce-48e13923167d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_0_5/NetworkPort_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_0_5/NetworkPort_V1_0_5_Dxe.c new file mode 100644 index 00000000000..1dbcc88a2c5 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_0_5/NetworkPort_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "0", + "5" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_0_5 *NetworkPortV1_0_5; + EFI_REDFISH_NETWORKPORT_V1_0_5_CS *NetworkPortV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_0_5_To_CS (ResoruceRaw, &NetworkPortV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_0_5 = (EFI_REDFISH_NETWORKPORT_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_0_5)); + if (NetworkPortV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_0_5; + NetworkPortV1_0_5->NetworkPort = NetworkPortV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_0_5_JSON (*((EFI_REDFISH_NETWORKPORT_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_0_5 *NetworkPortV1_0_5; + + NetworkPortV1_0_5 = (EFI_REDFISH_NETWORKPORT_V1_0_5 *)InterpProp; + DestroyNetworkPort_V1_0_5_CS (NetworkPortV1_0_5->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_0_5/RedfishNetworkPort_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_0_5/RedfishNetworkPort_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..7c626b28960 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_0_5/RedfishNetworkPort_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_0_5_Dxe + FILE_GUID = 3438fce9-053d-43f7-a2f4-9b3b75ff7a46 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_0_6/NetworkPort_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_0_6/NetworkPort_V1_0_6_Dxe.c new file mode 100644 index 00000000000..c667f85ec84 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_0_6/NetworkPort_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "0", + "6" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_0_6 *NetworkPortV1_0_6; + EFI_REDFISH_NETWORKPORT_V1_0_6_CS *NetworkPortV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_0_6_To_CS (ResoruceRaw, &NetworkPortV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_0_6 = (EFI_REDFISH_NETWORKPORT_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_0_6)); + if (NetworkPortV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_0_6; + NetworkPortV1_0_6->NetworkPort = NetworkPortV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_0_6_JSON (*((EFI_REDFISH_NETWORKPORT_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_0_6 *NetworkPortV1_0_6; + + NetworkPortV1_0_6 = (EFI_REDFISH_NETWORKPORT_V1_0_6 *)InterpProp; + DestroyNetworkPort_V1_0_6_CS (NetworkPortV1_0_6->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_0_6/RedfishNetworkPort_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_0_6/RedfishNetworkPort_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..fae1753ad0c --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_0_6/RedfishNetworkPort_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_0_6_Dxe + FILE_GUID = 30f87317-5fd4-4de7-93a7-3725b8e7613e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_0_7/NetworkPort_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_0_7/NetworkPort_V1_0_7_Dxe.c new file mode 100644 index 00000000000..df556863bd5 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_0_7/NetworkPort_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "0", + "7" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_0_7 *NetworkPortV1_0_7; + EFI_REDFISH_NETWORKPORT_V1_0_7_CS *NetworkPortV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_0_7_To_CS (ResoruceRaw, &NetworkPortV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_0_7 = (EFI_REDFISH_NETWORKPORT_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_0_7)); + if (NetworkPortV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_0_7; + NetworkPortV1_0_7->NetworkPort = NetworkPortV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_0_7_JSON (*((EFI_REDFISH_NETWORKPORT_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_0_7 *NetworkPortV1_0_7; + + NetworkPortV1_0_7 = (EFI_REDFISH_NETWORKPORT_V1_0_7 *)InterpProp; + DestroyNetworkPort_V1_0_7_CS (NetworkPortV1_0_7->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_0_7/RedfishNetworkPort_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_0_7/RedfishNetworkPort_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..b5c4cb8e6e6 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_0_7/RedfishNetworkPort_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_0_7_Dxe + FILE_GUID = 33dd0b02-7c5d-4bf1-a9df-3067a8c00031 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_0_8/NetworkPort_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_0_8/NetworkPort_V1_0_8_Dxe.c new file mode 100644 index 00000000000..fb4bdb05118 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_0_8/NetworkPort_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "0", + "8" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_0_8 *NetworkPortV1_0_8; + EFI_REDFISH_NETWORKPORT_V1_0_8_CS *NetworkPortV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_0_8_To_CS (ResoruceRaw, &NetworkPortV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_0_8 = (EFI_REDFISH_NETWORKPORT_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_0_8)); + if (NetworkPortV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_0_8; + NetworkPortV1_0_8->NetworkPort = NetworkPortV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_0_8_JSON (*((EFI_REDFISH_NETWORKPORT_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_0_8 *NetworkPortV1_0_8; + + NetworkPortV1_0_8 = (EFI_REDFISH_NETWORKPORT_V1_0_8 *)InterpProp; + DestroyNetworkPort_V1_0_8_CS (NetworkPortV1_0_8->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_0_8/RedfishNetworkPort_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_0_8/RedfishNetworkPort_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..67f558a4669 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_0_8/RedfishNetworkPort_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_0_8_Dxe + FILE_GUID = 01f102f9-edd3-4c4d-a576-a19169cb50db + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_1_0/NetworkPort_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_1_0/NetworkPort_V1_1_0_Dxe.c new file mode 100644 index 00000000000..ef10a64f455 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_1_0/NetworkPort_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "1", + "0" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_1_0 *NetworkPortV1_1_0; + EFI_REDFISH_NETWORKPORT_V1_1_0_CS *NetworkPortV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_1_0_To_CS (ResoruceRaw, &NetworkPortV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_1_0 = (EFI_REDFISH_NETWORKPORT_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_1_0)); + if (NetworkPortV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_1_0; + NetworkPortV1_1_0->NetworkPort = NetworkPortV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_1_0_JSON (*((EFI_REDFISH_NETWORKPORT_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_1_0 *NetworkPortV1_1_0; + + NetworkPortV1_1_0 = (EFI_REDFISH_NETWORKPORT_V1_1_0 *)InterpProp; + DestroyNetworkPort_V1_1_0_CS (NetworkPortV1_1_0->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_1_0/RedfishNetworkPort_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_1_0/RedfishNetworkPort_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..f180710ba74 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_1_0/RedfishNetworkPort_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_1_0_Dxe + FILE_GUID = d356d9a1-04a5-42a7-9b8b-0905e21111e0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_1_1/NetworkPort_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_1_1/NetworkPort_V1_1_1_Dxe.c new file mode 100644 index 00000000000..852ee439406 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_1_1/NetworkPort_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "1", + "1" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_1_1 *NetworkPortV1_1_1; + EFI_REDFISH_NETWORKPORT_V1_1_1_CS *NetworkPortV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_1_1_To_CS (ResoruceRaw, &NetworkPortV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_1_1 = (EFI_REDFISH_NETWORKPORT_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_1_1)); + if (NetworkPortV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_1_1; + NetworkPortV1_1_1->NetworkPort = NetworkPortV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_1_1_JSON (*((EFI_REDFISH_NETWORKPORT_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_1_1 *NetworkPortV1_1_1; + + NetworkPortV1_1_1 = (EFI_REDFISH_NETWORKPORT_V1_1_1 *)InterpProp; + DestroyNetworkPort_V1_1_1_CS (NetworkPortV1_1_1->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_1_1/RedfishNetworkPort_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_1_1/RedfishNetworkPort_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..886e4bd4d20 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_1_1/RedfishNetworkPort_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_1_1_Dxe + FILE_GUID = 9e3d666c-2547-4602-a52a-c25d86c66eb9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_1_2/NetworkPort_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_1_2/NetworkPort_V1_1_2_Dxe.c new file mode 100644 index 00000000000..a64d10c095a --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_1_2/NetworkPort_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "1", + "2" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_1_2 *NetworkPortV1_1_2; + EFI_REDFISH_NETWORKPORT_V1_1_2_CS *NetworkPortV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_1_2_To_CS (ResoruceRaw, &NetworkPortV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_1_2 = (EFI_REDFISH_NETWORKPORT_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_1_2)); + if (NetworkPortV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_1_2; + NetworkPortV1_1_2->NetworkPort = NetworkPortV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_1_2_JSON (*((EFI_REDFISH_NETWORKPORT_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_1_2 *NetworkPortV1_1_2; + + NetworkPortV1_1_2 = (EFI_REDFISH_NETWORKPORT_V1_1_2 *)InterpProp; + DestroyNetworkPort_V1_1_2_CS (NetworkPortV1_1_2->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_1_2/RedfishNetworkPort_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_1_2/RedfishNetworkPort_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..bd832151c24 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_1_2/RedfishNetworkPort_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_1_2_Dxe + FILE_GUID = 2bb75018-b483-4e98-a321-7dcda718a6bc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_1_3/NetworkPort_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_1_3/NetworkPort_V1_1_3_Dxe.c new file mode 100644 index 00000000000..495e40467ea --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_1_3/NetworkPort_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "1", + "3" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_1_3 *NetworkPortV1_1_3; + EFI_REDFISH_NETWORKPORT_V1_1_3_CS *NetworkPortV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_1_3_To_CS (ResoruceRaw, &NetworkPortV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_1_3 = (EFI_REDFISH_NETWORKPORT_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_1_3)); + if (NetworkPortV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_1_3; + NetworkPortV1_1_3->NetworkPort = NetworkPortV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_1_3_JSON (*((EFI_REDFISH_NETWORKPORT_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_1_3 *NetworkPortV1_1_3; + + NetworkPortV1_1_3 = (EFI_REDFISH_NETWORKPORT_V1_1_3 *)InterpProp; + DestroyNetworkPort_V1_1_3_CS (NetworkPortV1_1_3->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_1_3/RedfishNetworkPort_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_1_3/RedfishNetworkPort_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..cd3190058f3 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_1_3/RedfishNetworkPort_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_1_3_Dxe + FILE_GUID = a208cc1f-1a8e-415a-b676-d905a5cc16da + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_1_4/NetworkPort_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_1_4/NetworkPort_V1_1_4_Dxe.c new file mode 100644 index 00000000000..14a5ae927de --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_1_4/NetworkPort_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "1", + "4" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_1_4 *NetworkPortV1_1_4; + EFI_REDFISH_NETWORKPORT_V1_1_4_CS *NetworkPortV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_1_4_To_CS (ResoruceRaw, &NetworkPortV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_1_4 = (EFI_REDFISH_NETWORKPORT_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_1_4)); + if (NetworkPortV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_1_4; + NetworkPortV1_1_4->NetworkPort = NetworkPortV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_1_4_JSON (*((EFI_REDFISH_NETWORKPORT_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_1_4 *NetworkPortV1_1_4; + + NetworkPortV1_1_4 = (EFI_REDFISH_NETWORKPORT_V1_1_4 *)InterpProp; + DestroyNetworkPort_V1_1_4_CS (NetworkPortV1_1_4->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_1_4/RedfishNetworkPort_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_1_4/RedfishNetworkPort_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..69b0f8393a8 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_1_4/RedfishNetworkPort_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_1_4_Dxe + FILE_GUID = dbb4f365-b930-4023-ae90-e56043439f7c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_1_5/NetworkPort_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_1_5/NetworkPort_V1_1_5_Dxe.c new file mode 100644 index 00000000000..36112533b87 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_1_5/NetworkPort_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "1", + "5" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_1_5 *NetworkPortV1_1_5; + EFI_REDFISH_NETWORKPORT_V1_1_5_CS *NetworkPortV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_1_5_To_CS (ResoruceRaw, &NetworkPortV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_1_5 = (EFI_REDFISH_NETWORKPORT_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_1_5)); + if (NetworkPortV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_1_5; + NetworkPortV1_1_5->NetworkPort = NetworkPortV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_1_5_JSON (*((EFI_REDFISH_NETWORKPORT_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_1_5 *NetworkPortV1_1_5; + + NetworkPortV1_1_5 = (EFI_REDFISH_NETWORKPORT_V1_1_5 *)InterpProp; + DestroyNetworkPort_V1_1_5_CS (NetworkPortV1_1_5->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_1_5/RedfishNetworkPort_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_1_5/RedfishNetworkPort_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..a3cf331257c --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_1_5/RedfishNetworkPort_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_1_5_Dxe + FILE_GUID = 45a25128-589a-4294-af5d-e2750ca46931 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_1_6/NetworkPort_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_1_6/NetworkPort_V1_1_6_Dxe.c new file mode 100644 index 00000000000..971825a9a7c --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_1_6/NetworkPort_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "1", + "6" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_1_6 *NetworkPortV1_1_6; + EFI_REDFISH_NETWORKPORT_V1_1_6_CS *NetworkPortV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_1_6_To_CS (ResoruceRaw, &NetworkPortV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_1_6 = (EFI_REDFISH_NETWORKPORT_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_1_6)); + if (NetworkPortV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_1_6; + NetworkPortV1_1_6->NetworkPort = NetworkPortV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_1_6_JSON (*((EFI_REDFISH_NETWORKPORT_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_1_6 *NetworkPortV1_1_6; + + NetworkPortV1_1_6 = (EFI_REDFISH_NETWORKPORT_V1_1_6 *)InterpProp; + DestroyNetworkPort_V1_1_6_CS (NetworkPortV1_1_6->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_1_6/RedfishNetworkPort_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_1_6/RedfishNetworkPort_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..c325cb49b4e --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_1_6/RedfishNetworkPort_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_1_6_Dxe + FILE_GUID = 965429ce-4728-43db-9219-7b39d8e090b5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_1_7/NetworkPort_V1_1_7_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_1_7/NetworkPort_V1_1_7_Dxe.c new file mode 100644 index 00000000000..84fed3cf436 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_1_7/NetworkPort_V1_1_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_1_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "1", + "7" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_1_7 *NetworkPortV1_1_7; + EFI_REDFISH_NETWORKPORT_V1_1_7_CS *NetworkPortV1_1_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_1_7_To_CS (ResoruceRaw, &NetworkPortV1_1_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_1_7 = (EFI_REDFISH_NETWORKPORT_V1_1_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_1_7)); + if (NetworkPortV1_1_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_1_7; + NetworkPortV1_1_7->NetworkPort = NetworkPortV1_1_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_1_7_JSON (*((EFI_REDFISH_NETWORKPORT_V1_1_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_1_7 *NetworkPortV1_1_7; + + NetworkPortV1_1_7 = (EFI_REDFISH_NETWORKPORT_V1_1_7 *)InterpProp; + DestroyNetworkPort_V1_1_7_CS (NetworkPortV1_1_7->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_1_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_1_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_1_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_1_7/RedfishNetworkPort_V1_1_7_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_1_7/RedfishNetworkPort_V1_1_7_Dxe.inf new file mode 100644 index 00000000000..5e01a3ead2c --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_1_7/RedfishNetworkPort_V1_1_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_1_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_1_7_Dxe + FILE_GUID = bb3e1bb7-410c-441c-8959-675d2f53b377 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_1_7EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_1_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_1_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_1_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_2_0/NetworkPort_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_2_0/NetworkPort_V1_2_0_Dxe.c new file mode 100644 index 00000000000..a0a60dcaa24 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_2_0/NetworkPort_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "2", + "0" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_2_0 *NetworkPortV1_2_0; + EFI_REDFISH_NETWORKPORT_V1_2_0_CS *NetworkPortV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_2_0_To_CS (ResoruceRaw, &NetworkPortV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_2_0 = (EFI_REDFISH_NETWORKPORT_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_2_0)); + if (NetworkPortV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_2_0; + NetworkPortV1_2_0->NetworkPort = NetworkPortV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_2_0_JSON (*((EFI_REDFISH_NETWORKPORT_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_2_0 *NetworkPortV1_2_0; + + NetworkPortV1_2_0 = (EFI_REDFISH_NETWORKPORT_V1_2_0 *)InterpProp; + DestroyNetworkPort_V1_2_0_CS (NetworkPortV1_2_0->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_2_0/RedfishNetworkPort_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_2_0/RedfishNetworkPort_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..9d774f8cf16 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_2_0/RedfishNetworkPort_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_2_0_Dxe + FILE_GUID = 5a4355d9-4c4c-4e7c-ae51-afe7173b32e9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_2_1/NetworkPort_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_2_1/NetworkPort_V1_2_1_Dxe.c new file mode 100644 index 00000000000..57398db8428 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_2_1/NetworkPort_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "2", + "1" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_2_1 *NetworkPortV1_2_1; + EFI_REDFISH_NETWORKPORT_V1_2_1_CS *NetworkPortV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_2_1_To_CS (ResoruceRaw, &NetworkPortV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_2_1 = (EFI_REDFISH_NETWORKPORT_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_2_1)); + if (NetworkPortV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_2_1; + NetworkPortV1_2_1->NetworkPort = NetworkPortV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_2_1_JSON (*((EFI_REDFISH_NETWORKPORT_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_2_1 *NetworkPortV1_2_1; + + NetworkPortV1_2_1 = (EFI_REDFISH_NETWORKPORT_V1_2_1 *)InterpProp; + DestroyNetworkPort_V1_2_1_CS (NetworkPortV1_2_1->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_2_1/RedfishNetworkPort_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_2_1/RedfishNetworkPort_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..cf805302f8c --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_2_1/RedfishNetworkPort_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_2_1_Dxe + FILE_GUID = 0c1676b7-b23e-4751-8089-27be037e0460 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_2_2/NetworkPort_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_2_2/NetworkPort_V1_2_2_Dxe.c new file mode 100644 index 00000000000..d0b2c9cc426 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_2_2/NetworkPort_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "2", + "2" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_2_2 *NetworkPortV1_2_2; + EFI_REDFISH_NETWORKPORT_V1_2_2_CS *NetworkPortV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_2_2_To_CS (ResoruceRaw, &NetworkPortV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_2_2 = (EFI_REDFISH_NETWORKPORT_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_2_2)); + if (NetworkPortV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_2_2; + NetworkPortV1_2_2->NetworkPort = NetworkPortV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_2_2_JSON (*((EFI_REDFISH_NETWORKPORT_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_2_2 *NetworkPortV1_2_2; + + NetworkPortV1_2_2 = (EFI_REDFISH_NETWORKPORT_V1_2_2 *)InterpProp; + DestroyNetworkPort_V1_2_2_CS (NetworkPortV1_2_2->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_2_2/RedfishNetworkPort_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_2_2/RedfishNetworkPort_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..4123f023b8e --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_2_2/RedfishNetworkPort_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_2_2_Dxe + FILE_GUID = dcfbe96e-5963-4151-a231-5e0c856e9abd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_2_3/NetworkPort_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_2_3/NetworkPort_V1_2_3_Dxe.c new file mode 100644 index 00000000000..70ab84e96ac --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_2_3/NetworkPort_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "2", + "3" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_2_3 *NetworkPortV1_2_3; + EFI_REDFISH_NETWORKPORT_V1_2_3_CS *NetworkPortV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_2_3_To_CS (ResoruceRaw, &NetworkPortV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_2_3 = (EFI_REDFISH_NETWORKPORT_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_2_3)); + if (NetworkPortV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_2_3; + NetworkPortV1_2_3->NetworkPort = NetworkPortV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_2_3_JSON (*((EFI_REDFISH_NETWORKPORT_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_2_3 *NetworkPortV1_2_3; + + NetworkPortV1_2_3 = (EFI_REDFISH_NETWORKPORT_V1_2_3 *)InterpProp; + DestroyNetworkPort_V1_2_3_CS (NetworkPortV1_2_3->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_2_3/RedfishNetworkPort_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_2_3/RedfishNetworkPort_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..5552e915993 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_2_3/RedfishNetworkPort_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_2_3_Dxe + FILE_GUID = ade64f3a-ca46-41e8-bdca-066aeffe881d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_2_4/NetworkPort_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_2_4/NetworkPort_V1_2_4_Dxe.c new file mode 100644 index 00000000000..0de2d661f77 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_2_4/NetworkPort_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "2", + "4" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_2_4 *NetworkPortV1_2_4; + EFI_REDFISH_NETWORKPORT_V1_2_4_CS *NetworkPortV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_2_4_To_CS (ResoruceRaw, &NetworkPortV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_2_4 = (EFI_REDFISH_NETWORKPORT_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_2_4)); + if (NetworkPortV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_2_4; + NetworkPortV1_2_4->NetworkPort = NetworkPortV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_2_4_JSON (*((EFI_REDFISH_NETWORKPORT_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_2_4 *NetworkPortV1_2_4; + + NetworkPortV1_2_4 = (EFI_REDFISH_NETWORKPORT_V1_2_4 *)InterpProp; + DestroyNetworkPort_V1_2_4_CS (NetworkPortV1_2_4->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_2_4/RedfishNetworkPort_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_2_4/RedfishNetworkPort_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..2478121e080 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_2_4/RedfishNetworkPort_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_2_4_Dxe + FILE_GUID = 25d72f8a-1f3a-4fc3-aa26-4c75f40d9fcb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_2_5/NetworkPort_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_2_5/NetworkPort_V1_2_5_Dxe.c new file mode 100644 index 00000000000..f97006c39b6 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_2_5/NetworkPort_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "2", + "5" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_2_5 *NetworkPortV1_2_5; + EFI_REDFISH_NETWORKPORT_V1_2_5_CS *NetworkPortV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_2_5_To_CS (ResoruceRaw, &NetworkPortV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_2_5 = (EFI_REDFISH_NETWORKPORT_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_2_5)); + if (NetworkPortV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_2_5; + NetworkPortV1_2_5->NetworkPort = NetworkPortV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_2_5_JSON (*((EFI_REDFISH_NETWORKPORT_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_2_5 *NetworkPortV1_2_5; + + NetworkPortV1_2_5 = (EFI_REDFISH_NETWORKPORT_V1_2_5 *)InterpProp; + DestroyNetworkPort_V1_2_5_CS (NetworkPortV1_2_5->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_2_5/RedfishNetworkPort_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_2_5/RedfishNetworkPort_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..210b6b4f38e --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_2_5/RedfishNetworkPort_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_2_5_Dxe + FILE_GUID = 3e4748da-36a6-4fa4-b18f-44556cf9df40 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_2_6/NetworkPort_V1_2_6_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_2_6/NetworkPort_V1_2_6_Dxe.c new file mode 100644 index 00000000000..7c37ceb61a3 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_2_6/NetworkPort_V1_2_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_2_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "2", + "6" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_2_6 *NetworkPortV1_2_6; + EFI_REDFISH_NETWORKPORT_V1_2_6_CS *NetworkPortV1_2_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_2_6_To_CS (ResoruceRaw, &NetworkPortV1_2_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_2_6 = (EFI_REDFISH_NETWORKPORT_V1_2_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_2_6)); + if (NetworkPortV1_2_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_2_6; + NetworkPortV1_2_6->NetworkPort = NetworkPortV1_2_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_2_6_JSON (*((EFI_REDFISH_NETWORKPORT_V1_2_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_2_6 *NetworkPortV1_2_6; + + NetworkPortV1_2_6 = (EFI_REDFISH_NETWORKPORT_V1_2_6 *)InterpProp; + DestroyNetworkPort_V1_2_6_CS (NetworkPortV1_2_6->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_2_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_2_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_2_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_2_6/RedfishNetworkPort_V1_2_6_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_2_6/RedfishNetworkPort_V1_2_6_Dxe.inf new file mode 100644 index 00000000000..c52a113a90d --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_2_6/RedfishNetworkPort_V1_2_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_2_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_2_6_Dxe + FILE_GUID = 509c593f-87e1-481a-9f47-4d307f9fe967 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_2_6EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_2_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_2_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_2_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_3_0/NetworkPort_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_3_0/NetworkPort_V1_3_0_Dxe.c new file mode 100644 index 00000000000..629bf7c5720 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_3_0/NetworkPort_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "3", + "0" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_3_0 *NetworkPortV1_3_0; + EFI_REDFISH_NETWORKPORT_V1_3_0_CS *NetworkPortV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_3_0_To_CS (ResoruceRaw, &NetworkPortV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_3_0 = (EFI_REDFISH_NETWORKPORT_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_3_0)); + if (NetworkPortV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_3_0; + NetworkPortV1_3_0->NetworkPort = NetworkPortV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_3_0_JSON (*((EFI_REDFISH_NETWORKPORT_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_3_0 *NetworkPortV1_3_0; + + NetworkPortV1_3_0 = (EFI_REDFISH_NETWORKPORT_V1_3_0 *)InterpProp; + DestroyNetworkPort_V1_3_0_CS (NetworkPortV1_3_0->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_3_0/RedfishNetworkPort_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_3_0/RedfishNetworkPort_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..2ac5f71877d --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_3_0/RedfishNetworkPort_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_3_0_Dxe + FILE_GUID = e1931c19-21df-4ff1-abc2-57ab69dce3ad + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_3_1/NetworkPort_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_3_1/NetworkPort_V1_3_1_Dxe.c new file mode 100644 index 00000000000..dc1d425eb25 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_3_1/NetworkPort_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "3", + "1" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_3_1 *NetworkPortV1_3_1; + EFI_REDFISH_NETWORKPORT_V1_3_1_CS *NetworkPortV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_3_1_To_CS (ResoruceRaw, &NetworkPortV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_3_1 = (EFI_REDFISH_NETWORKPORT_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_3_1)); + if (NetworkPortV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_3_1; + NetworkPortV1_3_1->NetworkPort = NetworkPortV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_3_1_JSON (*((EFI_REDFISH_NETWORKPORT_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_3_1 *NetworkPortV1_3_1; + + NetworkPortV1_3_1 = (EFI_REDFISH_NETWORKPORT_V1_3_1 *)InterpProp; + DestroyNetworkPort_V1_3_1_CS (NetworkPortV1_3_1->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_3_1/RedfishNetworkPort_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_3_1/RedfishNetworkPort_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..0bdfd6668a7 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_3_1/RedfishNetworkPort_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_3_1_Dxe + FILE_GUID = 3665bc2f-8931-4ddb-bb7d-a0e0bd5c95a4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_4_0/NetworkPort_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/NetworkPort/v1_4_0/NetworkPort_V1_4_0_Dxe.c new file mode 100644 index 00000000000..c90c7665883 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_4_0/NetworkPort_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPort.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPort"; +BOOLEAN IsRevisonController = TRUE; + +// Support NetworkPort V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPort", + "1", + "4", + "0" + }, + "NetworkPort" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_4_0 *NetworkPortV1_4_0; + EFI_REDFISH_NETWORKPORT_V1_4_0_CS *NetworkPortV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPort") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPort_V1_4_0_To_CS (ResoruceRaw, &NetworkPortV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortV1_4_0 = (EFI_REDFISH_NETWORKPORT_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORT_V1_4_0)); + if (NetworkPortV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortV1_4_0; + NetworkPortV1_4_0->NetworkPort = NetworkPortV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPort"), "NetworkPort"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPort")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPort"), "NetworkPort"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPort_V1_4_0_JSON (*((EFI_REDFISH_NETWORKPORT_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORT_V1_4_0 *NetworkPortV1_4_0; + + NetworkPortV1_4_0 = (EFI_REDFISH_NETWORKPORT_V1_4_0 *)InterpProp; + DestroyNetworkPort_V1_4_0_CS (NetworkPortV1_4_0->NetworkPort); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPort_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortToStructWrapper, + NetworkPortToJson, + NetworkPortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPort_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPort/v1_4_0/RedfishNetworkPort_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/NetworkPort/v1_4_0/RedfishNetworkPort_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..1a9623fa858 --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPort/v1_4_0/RedfishNetworkPort_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPort.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPort_V1_4_0_Dxe + FILE_GUID = 4e4fbd50-6bc3-4871-8466-8c6f1cdcc62f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPort_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishNetworkPort_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPort_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/NetworkPortCollection/NetworkPortCollection_Dxe.c b/RedfishClientPkg/Converter/NetworkPortCollection/NetworkPortCollection_Dxe.c new file mode 100644 index 00000000000..63126b1cc3e --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPortCollection/NetworkPortCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - NetworkPortCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#NetworkPortCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support NetworkPortCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "NetworkPortCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "NetworkPortCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_NETWORKPORTCOLLECTION *NetworkPortCollection; + EFI_REDFISH_NETWORKPORTCOLLECTION_CS *NetworkPortCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "NetworkPortCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_NetworkPortCollection_To_CS (ResoruceRaw, &NetworkPortCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + NetworkPortCollection = (EFI_REDFISH_NETWORKPORTCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_NETWORKPORTCOLLECTION)); + if (NetworkPortCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)NetworkPortCollection; + NetworkPortCollection->NetworkPortCollection = NetworkPortCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPortCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("NetworkPortCollection"), "NetworkPortCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("NetworkPortCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("NetworkPortCollection"), "NetworkPortCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of NetworkPortCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return NetworkPortCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_NetworkPortCollection_JSON (*((EFI_REDFISH_NETWORKPORTCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in NetworkPortCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_NETWORKPORTCOLLECTION *NetworkPortCollection; + + NetworkPortCollection = (EFI_REDFISH_NETWORKPORTCOLLECTION *)InterpProp; + DestroyNetworkPortCollection_CS (NetworkPortCollection->NetworkPortCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from NetworkPortCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +NetworkPortCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyNetworkPortCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPortCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + NetworkPortCollectionToStructWrapper, + NetworkPortCollectionToJson, + NetworkPortCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishNetworkPortCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/NetworkPortCollection/RedfishNetworkPortCollection_Dxe.inf b/RedfishClientPkg/Converter/NetworkPortCollection/RedfishNetworkPortCollection_Dxe.inf new file mode 100644 index 00000000000..d9e8f90a19a --- /dev/null +++ b/RedfishClientPkg/Converter/NetworkPortCollection/RedfishNetworkPortCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of NetworkPortCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishNetworkPortCollection_Dxe + FILE_GUID = e4518f7c-7580-43dd-8fd2-ab3f9e6c13bc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishNetworkPortCollectionEntryPoint + UNLOAD_IMAGE = RedfishNetworkPortCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + NetworkPortCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + NetworkPortCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/OperatingConfig/v1_0_0/OperatingConfig_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/OperatingConfig/v1_0_0/OperatingConfig_V1_0_0_Dxe.c new file mode 100644 index 00000000000..a115927be4e --- /dev/null +++ b/RedfishClientPkg/Converter/OperatingConfig/v1_0_0/OperatingConfig_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - OperatingConfig.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#OperatingConfig"; +BOOLEAN IsRevisonController = TRUE; + +// Support OperatingConfig V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "OperatingConfig", + "1", + "0", + "0" + }, + "OperatingConfig" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OperatingConfigToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_OPERATINGCONFIG_V1_0_0 *OperatingConfigV1_0_0; + EFI_REDFISH_OPERATINGCONFIG_V1_0_0_CS *OperatingConfigV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "OperatingConfig") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_OperatingConfig_V1_0_0_To_CS (ResoruceRaw, &OperatingConfigV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + OperatingConfigV1_0_0 = (EFI_REDFISH_OPERATINGCONFIG_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_OPERATINGCONFIG_V1_0_0)); + if (OperatingConfigV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)OperatingConfigV1_0_0; + OperatingConfigV1_0_0->OperatingConfig = OperatingConfigV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("OperatingConfig")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("OperatingConfig"), "OperatingConfig"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("OperatingConfig")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("OperatingConfig"), "OperatingConfig"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of OperatingConfigToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OperatingConfigToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return OperatingConfigToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OperatingConfigToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_OperatingConfig_V1_0_0_JSON (*((EFI_REDFISH_OPERATINGCONFIG_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in OperatingConfigToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OperatingConfigDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_OPERATINGCONFIG_V1_0_0 *OperatingConfigV1_0_0; + + OperatingConfigV1_0_0 = (EFI_REDFISH_OPERATINGCONFIG_V1_0_0 *)InterpProp; + DestroyOperatingConfig_V1_0_0_CS (OperatingConfigV1_0_0->OperatingConfig); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from OperatingConfigFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OperatingConfigDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyOperatingConfig_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishOperatingConfig_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + OperatingConfigToStructWrapper, + OperatingConfigToJson, + OperatingConfigDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishOperatingConfig_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/OperatingConfig/v1_0_0/RedfishOperatingConfig_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/OperatingConfig/v1_0_0/RedfishOperatingConfig_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..b478e016667 --- /dev/null +++ b/RedfishClientPkg/Converter/OperatingConfig/v1_0_0/RedfishOperatingConfig_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of OperatingConfig.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishOperatingConfig_V1_0_0_Dxe + FILE_GUID = 7e7854c5-1565-4d2b-bca1-02c68df55df3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishOperatingConfig_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishOperatingConfig_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + OperatingConfig_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + OperatingConfigV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/OperatingConfig/v1_0_1/OperatingConfig_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/OperatingConfig/v1_0_1/OperatingConfig_V1_0_1_Dxe.c new file mode 100644 index 00000000000..23258aeee61 --- /dev/null +++ b/RedfishClientPkg/Converter/OperatingConfig/v1_0_1/OperatingConfig_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - OperatingConfig.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#OperatingConfig"; +BOOLEAN IsRevisonController = TRUE; + +// Support OperatingConfig V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "OperatingConfig", + "1", + "0", + "1" + }, + "OperatingConfig" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OperatingConfigToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_OPERATINGCONFIG_V1_0_1 *OperatingConfigV1_0_1; + EFI_REDFISH_OPERATINGCONFIG_V1_0_1_CS *OperatingConfigV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "OperatingConfig") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_OperatingConfig_V1_0_1_To_CS (ResoruceRaw, &OperatingConfigV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + OperatingConfigV1_0_1 = (EFI_REDFISH_OPERATINGCONFIG_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_OPERATINGCONFIG_V1_0_1)); + if (OperatingConfigV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)OperatingConfigV1_0_1; + OperatingConfigV1_0_1->OperatingConfig = OperatingConfigV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("OperatingConfig")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("OperatingConfig"), "OperatingConfig"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("OperatingConfig")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("OperatingConfig"), "OperatingConfig"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of OperatingConfigToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OperatingConfigToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return OperatingConfigToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OperatingConfigToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_OperatingConfig_V1_0_1_JSON (*((EFI_REDFISH_OPERATINGCONFIG_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in OperatingConfigToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OperatingConfigDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_OPERATINGCONFIG_V1_0_1 *OperatingConfigV1_0_1; + + OperatingConfigV1_0_1 = (EFI_REDFISH_OPERATINGCONFIG_V1_0_1 *)InterpProp; + DestroyOperatingConfig_V1_0_1_CS (OperatingConfigV1_0_1->OperatingConfig); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from OperatingConfigFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OperatingConfigDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyOperatingConfig_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishOperatingConfig_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + OperatingConfigToStructWrapper, + OperatingConfigToJson, + OperatingConfigDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishOperatingConfig_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/OperatingConfig/v1_0_1/RedfishOperatingConfig_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/OperatingConfig/v1_0_1/RedfishOperatingConfig_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..db8adcf1caa --- /dev/null +++ b/RedfishClientPkg/Converter/OperatingConfig/v1_0_1/RedfishOperatingConfig_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of OperatingConfig.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishOperatingConfig_V1_0_1_Dxe + FILE_GUID = 1a3060cf-77ea-45d6-9879-921070393522 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishOperatingConfig_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishOperatingConfig_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + OperatingConfig_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + OperatingConfigV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/OperatingConfig/v1_0_2/OperatingConfig_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/OperatingConfig/v1_0_2/OperatingConfig_V1_0_2_Dxe.c new file mode 100644 index 00000000000..32457338105 --- /dev/null +++ b/RedfishClientPkg/Converter/OperatingConfig/v1_0_2/OperatingConfig_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - OperatingConfig.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#OperatingConfig"; +BOOLEAN IsRevisonController = TRUE; + +// Support OperatingConfig V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "OperatingConfig", + "1", + "0", + "2" + }, + "OperatingConfig" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OperatingConfigToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_OPERATINGCONFIG_V1_0_2 *OperatingConfigV1_0_2; + EFI_REDFISH_OPERATINGCONFIG_V1_0_2_CS *OperatingConfigV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "OperatingConfig") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_OperatingConfig_V1_0_2_To_CS (ResoruceRaw, &OperatingConfigV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + OperatingConfigV1_0_2 = (EFI_REDFISH_OPERATINGCONFIG_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_OPERATINGCONFIG_V1_0_2)); + if (OperatingConfigV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)OperatingConfigV1_0_2; + OperatingConfigV1_0_2->OperatingConfig = OperatingConfigV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("OperatingConfig")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("OperatingConfig"), "OperatingConfig"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("OperatingConfig")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("OperatingConfig"), "OperatingConfig"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of OperatingConfigToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OperatingConfigToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return OperatingConfigToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OperatingConfigToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_OperatingConfig_V1_0_2_JSON (*((EFI_REDFISH_OPERATINGCONFIG_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in OperatingConfigToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OperatingConfigDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_OPERATINGCONFIG_V1_0_2 *OperatingConfigV1_0_2; + + OperatingConfigV1_0_2 = (EFI_REDFISH_OPERATINGCONFIG_V1_0_2 *)InterpProp; + DestroyOperatingConfig_V1_0_2_CS (OperatingConfigV1_0_2->OperatingConfig); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from OperatingConfigFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OperatingConfigDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyOperatingConfig_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishOperatingConfig_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + OperatingConfigToStructWrapper, + OperatingConfigToJson, + OperatingConfigDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishOperatingConfig_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/OperatingConfig/v1_0_2/RedfishOperatingConfig_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/OperatingConfig/v1_0_2/RedfishOperatingConfig_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..dc34b0b87f5 --- /dev/null +++ b/RedfishClientPkg/Converter/OperatingConfig/v1_0_2/RedfishOperatingConfig_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of OperatingConfig.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishOperatingConfig_V1_0_2_Dxe + FILE_GUID = 00318a88-2f75-4c03-949d-8952b89780d1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishOperatingConfig_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishOperatingConfig_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + OperatingConfig_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + OperatingConfigV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/OperatingConfigCollection/OperatingConfigCollection_Dxe.c b/RedfishClientPkg/Converter/OperatingConfigCollection/OperatingConfigCollection_Dxe.c new file mode 100644 index 00000000000..2a9ab3579af --- /dev/null +++ b/RedfishClientPkg/Converter/OperatingConfigCollection/OperatingConfigCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - OperatingConfigCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#OperatingConfigCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support OperatingConfigCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "OperatingConfigCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "OperatingConfigCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OperatingConfigCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_OPERATINGCONFIGCOLLECTION *OperatingConfigCollection; + EFI_REDFISH_OPERATINGCONFIGCOLLECTION_CS *OperatingConfigCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "OperatingConfigCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_OperatingConfigCollection_To_CS (ResoruceRaw, &OperatingConfigCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + OperatingConfigCollection = (EFI_REDFISH_OPERATINGCONFIGCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_OPERATINGCONFIGCOLLECTION)); + if (OperatingConfigCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)OperatingConfigCollection; + OperatingConfigCollection->OperatingConfigCollection = OperatingConfigCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("OperatingConfigCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("OperatingConfigCollection"), "OperatingConfigCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("OperatingConfigCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("OperatingConfigCollection"), "OperatingConfigCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of OperatingConfigCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OperatingConfigCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return OperatingConfigCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OperatingConfigCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_OperatingConfigCollection_JSON (*((EFI_REDFISH_OPERATINGCONFIGCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in OperatingConfigCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OperatingConfigCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_OPERATINGCONFIGCOLLECTION *OperatingConfigCollection; + + OperatingConfigCollection = (EFI_REDFISH_OPERATINGCONFIGCOLLECTION *)InterpProp; + DestroyOperatingConfigCollection_CS (OperatingConfigCollection->OperatingConfigCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from OperatingConfigCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OperatingConfigCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyOperatingConfigCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishOperatingConfigCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + OperatingConfigCollectionToStructWrapper, + OperatingConfigCollectionToJson, + OperatingConfigCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishOperatingConfigCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/OperatingConfigCollection/RedfishOperatingConfigCollection_Dxe.inf b/RedfishClientPkg/Converter/OperatingConfigCollection/RedfishOperatingConfigCollection_Dxe.inf new file mode 100644 index 00000000000..1ae0323cc2a --- /dev/null +++ b/RedfishClientPkg/Converter/OperatingConfigCollection/RedfishOperatingConfigCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of OperatingConfigCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishOperatingConfigCollection_Dxe + FILE_GUID = b1585821-258c-470d-9f48-9ab8dd72b342 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishOperatingConfigCollectionEntryPoint + UNLOAD_IMAGE = RedfishOperatingConfigCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + OperatingConfigCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + OperatingConfigCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Outlet/v1_0_0/Outlet_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Outlet/v1_0_0/Outlet_V1_0_0_Dxe.c new file mode 100644 index 00000000000..d800a2d81de --- /dev/null +++ b/RedfishClientPkg/Converter/Outlet/v1_0_0/Outlet_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Outlet.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Outlet"; +BOOLEAN IsRevisonController = TRUE; + +// Support Outlet V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Outlet", + "1", + "0", + "0" + }, + "Outlet" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_OUTLET_V1_0_0 *OutletV1_0_0; + EFI_REDFISH_OUTLET_V1_0_0_CS *OutletV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Outlet") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Outlet_V1_0_0_To_CS (ResoruceRaw, &OutletV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + OutletV1_0_0 = (EFI_REDFISH_OUTLET_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_OUTLET_V1_0_0)); + if (OutletV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)OutletV1_0_0; + OutletV1_0_0->Outlet = OutletV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Outlet")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Outlet"), "Outlet"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Outlet")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Outlet"), "Outlet"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of OutletToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return OutletToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Outlet_V1_0_0_JSON (*((EFI_REDFISH_OUTLET_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in OutletToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_OUTLET_V1_0_0 *OutletV1_0_0; + + OutletV1_0_0 = (EFI_REDFISH_OUTLET_V1_0_0 *)InterpProp; + DestroyOutlet_V1_0_0_CS (OutletV1_0_0->Outlet); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from OutletFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyOutlet_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishOutlet_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + OutletToStructWrapper, + OutletToJson, + OutletDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishOutlet_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Outlet/v1_0_0/RedfishOutlet_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Outlet/v1_0_0/RedfishOutlet_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..ccea2d7477b --- /dev/null +++ b/RedfishClientPkg/Converter/Outlet/v1_0_0/RedfishOutlet_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Outlet.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishOutlet_V1_0_0_Dxe + FILE_GUID = ed05b7f9-f985-4e2d-9829-9953027e0db0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishOutlet_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishOutlet_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Outlet_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + OutletV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Outlet/v1_0_1/Outlet_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/Outlet/v1_0_1/Outlet_V1_0_1_Dxe.c new file mode 100644 index 00000000000..1e8d3a4e2e2 --- /dev/null +++ b/RedfishClientPkg/Converter/Outlet/v1_0_1/Outlet_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Outlet.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Outlet"; +BOOLEAN IsRevisonController = TRUE; + +// Support Outlet V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Outlet", + "1", + "0", + "1" + }, + "Outlet" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_OUTLET_V1_0_1 *OutletV1_0_1; + EFI_REDFISH_OUTLET_V1_0_1_CS *OutletV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Outlet") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Outlet_V1_0_1_To_CS (ResoruceRaw, &OutletV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + OutletV1_0_1 = (EFI_REDFISH_OUTLET_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_OUTLET_V1_0_1)); + if (OutletV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)OutletV1_0_1; + OutletV1_0_1->Outlet = OutletV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Outlet")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Outlet"), "Outlet"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Outlet")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Outlet"), "Outlet"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of OutletToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return OutletToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Outlet_V1_0_1_JSON (*((EFI_REDFISH_OUTLET_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in OutletToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_OUTLET_V1_0_1 *OutletV1_0_1; + + OutletV1_0_1 = (EFI_REDFISH_OUTLET_V1_0_1 *)InterpProp; + DestroyOutlet_V1_0_1_CS (OutletV1_0_1->Outlet); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from OutletFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyOutlet_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishOutlet_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + OutletToStructWrapper, + OutletToJson, + OutletDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishOutlet_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Outlet/v1_0_1/RedfishOutlet_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/Outlet/v1_0_1/RedfishOutlet_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..ea435de96be --- /dev/null +++ b/RedfishClientPkg/Converter/Outlet/v1_0_1/RedfishOutlet_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Outlet.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishOutlet_V1_0_1_Dxe + FILE_GUID = 67c99ac3-2244-46b8-998e-c5dd5275a03b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishOutlet_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishOutlet_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Outlet_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + OutletV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Outlet/v1_0_2/Outlet_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Outlet/v1_0_2/Outlet_V1_0_2_Dxe.c new file mode 100644 index 00000000000..32cf9a82bb4 --- /dev/null +++ b/RedfishClientPkg/Converter/Outlet/v1_0_2/Outlet_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Outlet.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Outlet"; +BOOLEAN IsRevisonController = TRUE; + +// Support Outlet V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Outlet", + "1", + "0", + "2" + }, + "Outlet" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_OUTLET_V1_0_2 *OutletV1_0_2; + EFI_REDFISH_OUTLET_V1_0_2_CS *OutletV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Outlet") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Outlet_V1_0_2_To_CS (ResoruceRaw, &OutletV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + OutletV1_0_2 = (EFI_REDFISH_OUTLET_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_OUTLET_V1_0_2)); + if (OutletV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)OutletV1_0_2; + OutletV1_0_2->Outlet = OutletV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Outlet")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Outlet"), "Outlet"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Outlet")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Outlet"), "Outlet"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of OutletToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return OutletToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Outlet_V1_0_2_JSON (*((EFI_REDFISH_OUTLET_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in OutletToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_OUTLET_V1_0_2 *OutletV1_0_2; + + OutletV1_0_2 = (EFI_REDFISH_OUTLET_V1_0_2 *)InterpProp; + DestroyOutlet_V1_0_2_CS (OutletV1_0_2->Outlet); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from OutletFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyOutlet_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishOutlet_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + OutletToStructWrapper, + OutletToJson, + OutletDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishOutlet_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Outlet/v1_0_2/RedfishOutlet_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Outlet/v1_0_2/RedfishOutlet_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..721edf40d0e --- /dev/null +++ b/RedfishClientPkg/Converter/Outlet/v1_0_2/RedfishOutlet_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Outlet.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishOutlet_V1_0_2_Dxe + FILE_GUID = 9b8e3bca-5198-475f-ad3e-1d5fb6860611 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishOutlet_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishOutlet_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Outlet_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + OutletV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Outlet/v1_1_0/Outlet_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/Outlet/v1_1_0/Outlet_V1_1_0_Dxe.c new file mode 100644 index 00000000000..b2bcd079ceb --- /dev/null +++ b/RedfishClientPkg/Converter/Outlet/v1_1_0/Outlet_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Outlet.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Outlet"; +BOOLEAN IsRevisonController = TRUE; + +// Support Outlet V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Outlet", + "1", + "1", + "0" + }, + "Outlet" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_OUTLET_V1_1_0 *OutletV1_1_0; + EFI_REDFISH_OUTLET_V1_1_0_CS *OutletV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Outlet") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Outlet_V1_1_0_To_CS (ResoruceRaw, &OutletV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + OutletV1_1_0 = (EFI_REDFISH_OUTLET_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_OUTLET_V1_1_0)); + if (OutletV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)OutletV1_1_0; + OutletV1_1_0->Outlet = OutletV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Outlet")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Outlet"), "Outlet"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Outlet")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Outlet"), "Outlet"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of OutletToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return OutletToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Outlet_V1_1_0_JSON (*((EFI_REDFISH_OUTLET_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in OutletToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_OUTLET_V1_1_0 *OutletV1_1_0; + + OutletV1_1_0 = (EFI_REDFISH_OUTLET_V1_1_0 *)InterpProp; + DestroyOutlet_V1_1_0_CS (OutletV1_1_0->Outlet); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from OutletFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyOutlet_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishOutlet_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + OutletToStructWrapper, + OutletToJson, + OutletDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishOutlet_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Outlet/v1_1_0/RedfishOutlet_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/Outlet/v1_1_0/RedfishOutlet_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..49e9dc10b05 --- /dev/null +++ b/RedfishClientPkg/Converter/Outlet/v1_1_0/RedfishOutlet_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Outlet.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishOutlet_V1_1_0_Dxe + FILE_GUID = 5b0a79fe-fc78-47c4-8134-ed0f35bff5d9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishOutlet_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishOutlet_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Outlet_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + OutletV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Outlet/v1_1_1/Outlet_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/Outlet/v1_1_1/Outlet_V1_1_1_Dxe.c new file mode 100644 index 00000000000..5cc4658918c --- /dev/null +++ b/RedfishClientPkg/Converter/Outlet/v1_1_1/Outlet_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Outlet.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Outlet"; +BOOLEAN IsRevisonController = TRUE; + +// Support Outlet V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Outlet", + "1", + "1", + "1" + }, + "Outlet" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_OUTLET_V1_1_1 *OutletV1_1_1; + EFI_REDFISH_OUTLET_V1_1_1_CS *OutletV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Outlet") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Outlet_V1_1_1_To_CS (ResoruceRaw, &OutletV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + OutletV1_1_1 = (EFI_REDFISH_OUTLET_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_OUTLET_V1_1_1)); + if (OutletV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)OutletV1_1_1; + OutletV1_1_1->Outlet = OutletV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Outlet")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Outlet"), "Outlet"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Outlet")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Outlet"), "Outlet"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of OutletToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return OutletToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Outlet_V1_1_1_JSON (*((EFI_REDFISH_OUTLET_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in OutletToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_OUTLET_V1_1_1 *OutletV1_1_1; + + OutletV1_1_1 = (EFI_REDFISH_OUTLET_V1_1_1 *)InterpProp; + DestroyOutlet_V1_1_1_CS (OutletV1_1_1->Outlet); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from OutletFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyOutlet_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishOutlet_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + OutletToStructWrapper, + OutletToJson, + OutletDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishOutlet_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Outlet/v1_1_1/RedfishOutlet_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/Outlet/v1_1_1/RedfishOutlet_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..f64299db698 --- /dev/null +++ b/RedfishClientPkg/Converter/Outlet/v1_1_1/RedfishOutlet_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Outlet.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishOutlet_V1_1_1_Dxe + FILE_GUID = 22535661-1703-4bfa-a3bc-46d54209011e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishOutlet_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishOutlet_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Outlet_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + OutletV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/OutletCollection/OutletCollection_Dxe.c b/RedfishClientPkg/Converter/OutletCollection/OutletCollection_Dxe.c new file mode 100644 index 00000000000..37317273168 --- /dev/null +++ b/RedfishClientPkg/Converter/OutletCollection/OutletCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - OutletCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#OutletCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support OutletCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "OutletCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "OutletCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_OUTLETCOLLECTION *OutletCollection; + EFI_REDFISH_OUTLETCOLLECTION_CS *OutletCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "OutletCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_OutletCollection_To_CS (ResoruceRaw, &OutletCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + OutletCollection = (EFI_REDFISH_OUTLETCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_OUTLETCOLLECTION)); + if (OutletCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)OutletCollection; + OutletCollection->OutletCollection = OutletCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("OutletCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("OutletCollection"), "OutletCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("OutletCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("OutletCollection"), "OutletCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of OutletCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return OutletCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_OutletCollection_JSON (*((EFI_REDFISH_OUTLETCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in OutletCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_OUTLETCOLLECTION *OutletCollection; + + OutletCollection = (EFI_REDFISH_OUTLETCOLLECTION *)InterpProp; + DestroyOutletCollection_CS (OutletCollection->OutletCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from OutletCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyOutletCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishOutletCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + OutletCollectionToStructWrapper, + OutletCollectionToJson, + OutletCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishOutletCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/OutletCollection/RedfishOutletCollection_Dxe.inf b/RedfishClientPkg/Converter/OutletCollection/RedfishOutletCollection_Dxe.inf new file mode 100644 index 00000000000..22d8edd083c --- /dev/null +++ b/RedfishClientPkg/Converter/OutletCollection/RedfishOutletCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of OutletCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishOutletCollection_Dxe + FILE_GUID = f01909a2-bc0a-4d61-8976-161af5b3a213 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishOutletCollectionEntryPoint + UNLOAD_IMAGE = RedfishOutletCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + OutletCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + OutletCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/OutletGroup/v1_0_0/OutletGroup_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/OutletGroup/v1_0_0/OutletGroup_V1_0_0_Dxe.c new file mode 100644 index 00000000000..3abed96003e --- /dev/null +++ b/RedfishClientPkg/Converter/OutletGroup/v1_0_0/OutletGroup_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - OutletGroup.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#OutletGroup"; +BOOLEAN IsRevisonController = TRUE; + +// Support OutletGroup V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "OutletGroup", + "1", + "0", + "0" + }, + "OutletGroup" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletGroupToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_OUTLETGROUP_V1_0_0 *OutletGroupV1_0_0; + EFI_REDFISH_OUTLETGROUP_V1_0_0_CS *OutletGroupV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "OutletGroup") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_OutletGroup_V1_0_0_To_CS (ResoruceRaw, &OutletGroupV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + OutletGroupV1_0_0 = (EFI_REDFISH_OUTLETGROUP_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_OUTLETGROUP_V1_0_0)); + if (OutletGroupV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)OutletGroupV1_0_0; + OutletGroupV1_0_0->OutletGroup = OutletGroupV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("OutletGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("OutletGroup"), "OutletGroup"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("OutletGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("OutletGroup"), "OutletGroup"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of OutletGroupToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletGroupToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return OutletGroupToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletGroupToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_OutletGroup_V1_0_0_JSON (*((EFI_REDFISH_OUTLETGROUP_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in OutletGroupToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletGroupDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_OUTLETGROUP_V1_0_0 *OutletGroupV1_0_0; + + OutletGroupV1_0_0 = (EFI_REDFISH_OUTLETGROUP_V1_0_0 *)InterpProp; + DestroyOutletGroup_V1_0_0_CS (OutletGroupV1_0_0->OutletGroup); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from OutletGroupFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletGroupDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyOutletGroup_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishOutletGroup_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + OutletGroupToStructWrapper, + OutletGroupToJson, + OutletGroupDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishOutletGroup_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/OutletGroup/v1_0_0/RedfishOutletGroup_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/OutletGroup/v1_0_0/RedfishOutletGroup_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..321820be809 --- /dev/null +++ b/RedfishClientPkg/Converter/OutletGroup/v1_0_0/RedfishOutletGroup_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of OutletGroup.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishOutletGroup_V1_0_0_Dxe + FILE_GUID = cd05b42d-90fb-423e-9e07-99128ee296e0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishOutletGroup_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishOutletGroup_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + OutletGroup_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + OutletGroupV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/OutletGroup/v1_0_1/OutletGroup_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/OutletGroup/v1_0_1/OutletGroup_V1_0_1_Dxe.c new file mode 100644 index 00000000000..75f28a69f23 --- /dev/null +++ b/RedfishClientPkg/Converter/OutletGroup/v1_0_1/OutletGroup_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - OutletGroup.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#OutletGroup"; +BOOLEAN IsRevisonController = TRUE; + +// Support OutletGroup V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "OutletGroup", + "1", + "0", + "1" + }, + "OutletGroup" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletGroupToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_OUTLETGROUP_V1_0_1 *OutletGroupV1_0_1; + EFI_REDFISH_OUTLETGROUP_V1_0_1_CS *OutletGroupV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "OutletGroup") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_OutletGroup_V1_0_1_To_CS (ResoruceRaw, &OutletGroupV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + OutletGroupV1_0_1 = (EFI_REDFISH_OUTLETGROUP_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_OUTLETGROUP_V1_0_1)); + if (OutletGroupV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)OutletGroupV1_0_1; + OutletGroupV1_0_1->OutletGroup = OutletGroupV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("OutletGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("OutletGroup"), "OutletGroup"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("OutletGroup")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("OutletGroup"), "OutletGroup"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of OutletGroupToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletGroupToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return OutletGroupToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletGroupToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_OutletGroup_V1_0_1_JSON (*((EFI_REDFISH_OUTLETGROUP_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in OutletGroupToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletGroupDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_OUTLETGROUP_V1_0_1 *OutletGroupV1_0_1; + + OutletGroupV1_0_1 = (EFI_REDFISH_OUTLETGROUP_V1_0_1 *)InterpProp; + DestroyOutletGroup_V1_0_1_CS (OutletGroupV1_0_1->OutletGroup); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from OutletGroupFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletGroupDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyOutletGroup_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishOutletGroup_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + OutletGroupToStructWrapper, + OutletGroupToJson, + OutletGroupDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishOutletGroup_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/OutletGroup/v1_0_1/RedfishOutletGroup_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/OutletGroup/v1_0_1/RedfishOutletGroup_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..19e03ddc267 --- /dev/null +++ b/RedfishClientPkg/Converter/OutletGroup/v1_0_1/RedfishOutletGroup_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of OutletGroup.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishOutletGroup_V1_0_1_Dxe + FILE_GUID = d2d32abc-752e-460c-9cbf-86ed2ae6dbce + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishOutletGroup_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishOutletGroup_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + OutletGroup_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + OutletGroupV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/OutletGroupCollection/OutletGroupCollection_Dxe.c b/RedfishClientPkg/Converter/OutletGroupCollection/OutletGroupCollection_Dxe.c new file mode 100644 index 00000000000..52861e2db0b --- /dev/null +++ b/RedfishClientPkg/Converter/OutletGroupCollection/OutletGroupCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - OutletGroupCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#OutletGroupCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support OutletGroupCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "OutletGroupCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "OutletGroupCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletGroupCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_OUTLETGROUPCOLLECTION *OutletGroupCollection; + EFI_REDFISH_OUTLETGROUPCOLLECTION_CS *OutletGroupCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "OutletGroupCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_OutletGroupCollection_To_CS (ResoruceRaw, &OutletGroupCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + OutletGroupCollection = (EFI_REDFISH_OUTLETGROUPCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_OUTLETGROUPCOLLECTION)); + if (OutletGroupCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)OutletGroupCollection; + OutletGroupCollection->OutletGroupCollection = OutletGroupCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("OutletGroupCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("OutletGroupCollection"), "OutletGroupCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("OutletGroupCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("OutletGroupCollection"), "OutletGroupCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of OutletGroupCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletGroupCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return OutletGroupCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletGroupCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_OutletGroupCollection_JSON (*((EFI_REDFISH_OUTLETGROUPCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in OutletGroupCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletGroupCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_OUTLETGROUPCOLLECTION *OutletGroupCollection; + + OutletGroupCollection = (EFI_REDFISH_OUTLETGROUPCOLLECTION *)InterpProp; + DestroyOutletGroupCollection_CS (OutletGroupCollection->OutletGroupCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from OutletGroupCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +OutletGroupCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyOutletGroupCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishOutletGroupCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + OutletGroupCollectionToStructWrapper, + OutletGroupCollectionToJson, + OutletGroupCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishOutletGroupCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/OutletGroupCollection/RedfishOutletGroupCollection_Dxe.inf b/RedfishClientPkg/Converter/OutletGroupCollection/RedfishOutletGroupCollection_Dxe.inf new file mode 100644 index 00000000000..49056c76224 --- /dev/null +++ b/RedfishClientPkg/Converter/OutletGroupCollection/RedfishOutletGroupCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of OutletGroupCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishOutletGroupCollection_Dxe + FILE_GUID = cbb51dbd-fdcc-4f6e-8f4d-25134b4a4ae1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishOutletGroupCollectionEntryPoint + UNLOAD_IMAGE = RedfishOutletGroupCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + OutletGroupCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + OutletGroupCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_0_0/PCIeDevice_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/PCIeDevice/v1_0_0/PCIeDevice_V1_0_0_Dxe.c new file mode 100644 index 00000000000..cb108d01c03 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_0_0/PCIeDevice_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeDevice.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeDevice"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeDevice V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeDevice", + "1", + "0", + "0" + }, + "PCIeDevice" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_0_0 *PCIeDeviceV1_0_0; + EFI_REDFISH_PCIEDEVICE_V1_0_0_CS *PCIeDeviceV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeDevice") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeDevice_V1_0_0_To_CS (ResoruceRaw, &PCIeDeviceV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeDeviceV1_0_0 = (EFI_REDFISH_PCIEDEVICE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEDEVICE_V1_0_0)); + if (PCIeDeviceV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeDeviceV1_0_0; + PCIeDeviceV1_0_0->PCIeDevice = PCIeDeviceV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeDeviceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeDeviceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeDevice_V1_0_0_JSON (*((EFI_REDFISH_PCIEDEVICE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeDeviceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_0_0 *PCIeDeviceV1_0_0; + + PCIeDeviceV1_0_0 = (EFI_REDFISH_PCIEDEVICE_V1_0_0 *)InterpProp; + DestroyPCIeDevice_V1_0_0_CS (PCIeDeviceV1_0_0->PCIeDevice); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeDeviceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeDevice_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeDeviceToStructWrapper, + PCIeDeviceToJson, + PCIeDeviceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_0_0/RedfishPCIeDevice_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/PCIeDevice/v1_0_0/RedfishPCIeDevice_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..ae970e502e7 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_0_0/RedfishPCIeDevice_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeDevice.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeDevice_V1_0_0_Dxe + FILE_GUID = 1354645e-32ba-49d9-ab23-0a05016428b2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeDevice_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishPCIeDevice_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeDevice_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeDeviceV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_0_1/PCIeDevice_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/PCIeDevice/v1_0_1/PCIeDevice_V1_0_1_Dxe.c new file mode 100644 index 00000000000..f5b14b3fdf1 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_0_1/PCIeDevice_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeDevice.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeDevice"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeDevice V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeDevice", + "1", + "0", + "1" + }, + "PCIeDevice" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_0_1 *PCIeDeviceV1_0_1; + EFI_REDFISH_PCIEDEVICE_V1_0_1_CS *PCIeDeviceV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeDevice") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeDevice_V1_0_1_To_CS (ResoruceRaw, &PCIeDeviceV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeDeviceV1_0_1 = (EFI_REDFISH_PCIEDEVICE_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEDEVICE_V1_0_1)); + if (PCIeDeviceV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeDeviceV1_0_1; + PCIeDeviceV1_0_1->PCIeDevice = PCIeDeviceV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeDeviceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeDeviceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeDevice_V1_0_1_JSON (*((EFI_REDFISH_PCIEDEVICE_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeDeviceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_0_1 *PCIeDeviceV1_0_1; + + PCIeDeviceV1_0_1 = (EFI_REDFISH_PCIEDEVICE_V1_0_1 *)InterpProp; + DestroyPCIeDevice_V1_0_1_CS (PCIeDeviceV1_0_1->PCIeDevice); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeDeviceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeDevice_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeDeviceToStructWrapper, + PCIeDeviceToJson, + PCIeDeviceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_0_1/RedfishPCIeDevice_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/PCIeDevice/v1_0_1/RedfishPCIeDevice_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..562f7a26d6d --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_0_1/RedfishPCIeDevice_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeDevice.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeDevice_V1_0_1_Dxe + FILE_GUID = c16b17ec-bd03-413a-a7be-1d5ebcfe17b2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeDevice_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishPCIeDevice_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeDevice_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeDeviceV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_0_2/PCIeDevice_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/PCIeDevice/v1_0_2/PCIeDevice_V1_0_2_Dxe.c new file mode 100644 index 00000000000..e994de9bd8a --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_0_2/PCIeDevice_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeDevice.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeDevice"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeDevice V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeDevice", + "1", + "0", + "2" + }, + "PCIeDevice" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_0_2 *PCIeDeviceV1_0_2; + EFI_REDFISH_PCIEDEVICE_V1_0_2_CS *PCIeDeviceV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeDevice") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeDevice_V1_0_2_To_CS (ResoruceRaw, &PCIeDeviceV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeDeviceV1_0_2 = (EFI_REDFISH_PCIEDEVICE_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEDEVICE_V1_0_2)); + if (PCIeDeviceV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeDeviceV1_0_2; + PCIeDeviceV1_0_2->PCIeDevice = PCIeDeviceV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeDeviceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeDeviceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeDevice_V1_0_2_JSON (*((EFI_REDFISH_PCIEDEVICE_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeDeviceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_0_2 *PCIeDeviceV1_0_2; + + PCIeDeviceV1_0_2 = (EFI_REDFISH_PCIEDEVICE_V1_0_2 *)InterpProp; + DestroyPCIeDevice_V1_0_2_CS (PCIeDeviceV1_0_2->PCIeDevice); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeDeviceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeDevice_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeDeviceToStructWrapper, + PCIeDeviceToJson, + PCIeDeviceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_0_2/RedfishPCIeDevice_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/PCIeDevice/v1_0_2/RedfishPCIeDevice_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..2335b682293 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_0_2/RedfishPCIeDevice_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeDevice.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeDevice_V1_0_2_Dxe + FILE_GUID = 4af0567c-1f9f-4465-82e5-2e16f4cf7a21 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeDevice_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishPCIeDevice_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeDevice_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeDeviceV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_0_3/PCIeDevice_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/PCIeDevice/v1_0_3/PCIeDevice_V1_0_3_Dxe.c new file mode 100644 index 00000000000..b2edca4ac79 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_0_3/PCIeDevice_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeDevice.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeDevice"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeDevice V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeDevice", + "1", + "0", + "3" + }, + "PCIeDevice" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_0_3 *PCIeDeviceV1_0_3; + EFI_REDFISH_PCIEDEVICE_V1_0_3_CS *PCIeDeviceV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeDevice") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeDevice_V1_0_3_To_CS (ResoruceRaw, &PCIeDeviceV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeDeviceV1_0_3 = (EFI_REDFISH_PCIEDEVICE_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEDEVICE_V1_0_3)); + if (PCIeDeviceV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeDeviceV1_0_3; + PCIeDeviceV1_0_3->PCIeDevice = PCIeDeviceV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeDeviceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeDeviceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeDevice_V1_0_3_JSON (*((EFI_REDFISH_PCIEDEVICE_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeDeviceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_0_3 *PCIeDeviceV1_0_3; + + PCIeDeviceV1_0_3 = (EFI_REDFISH_PCIEDEVICE_V1_0_3 *)InterpProp; + DestroyPCIeDevice_V1_0_3_CS (PCIeDeviceV1_0_3->PCIeDevice); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeDeviceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeDevice_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeDeviceToStructWrapper, + PCIeDeviceToJson, + PCIeDeviceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_0_3/RedfishPCIeDevice_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/PCIeDevice/v1_0_3/RedfishPCIeDevice_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..d6916eceade --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_0_3/RedfishPCIeDevice_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeDevice.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeDevice_V1_0_3_Dxe + FILE_GUID = 4789c75d-3024-4fec-860d-01662b3e2b37 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeDevice_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishPCIeDevice_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeDevice_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeDeviceV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_0_4/PCIeDevice_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/PCIeDevice/v1_0_4/PCIeDevice_V1_0_4_Dxe.c new file mode 100644 index 00000000000..95ce9407b76 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_0_4/PCIeDevice_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeDevice.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeDevice"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeDevice V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeDevice", + "1", + "0", + "4" + }, + "PCIeDevice" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_0_4 *PCIeDeviceV1_0_4; + EFI_REDFISH_PCIEDEVICE_V1_0_4_CS *PCIeDeviceV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeDevice") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeDevice_V1_0_4_To_CS (ResoruceRaw, &PCIeDeviceV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeDeviceV1_0_4 = (EFI_REDFISH_PCIEDEVICE_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEDEVICE_V1_0_4)); + if (PCIeDeviceV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeDeviceV1_0_4; + PCIeDeviceV1_0_4->PCIeDevice = PCIeDeviceV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeDeviceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeDeviceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeDevice_V1_0_4_JSON (*((EFI_REDFISH_PCIEDEVICE_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeDeviceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_0_4 *PCIeDeviceV1_0_4; + + PCIeDeviceV1_0_4 = (EFI_REDFISH_PCIEDEVICE_V1_0_4 *)InterpProp; + DestroyPCIeDevice_V1_0_4_CS (PCIeDeviceV1_0_4->PCIeDevice); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeDeviceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeDevice_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeDeviceToStructWrapper, + PCIeDeviceToJson, + PCIeDeviceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_0_4/RedfishPCIeDevice_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/PCIeDevice/v1_0_4/RedfishPCIeDevice_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..144e46707b3 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_0_4/RedfishPCIeDevice_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeDevice.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeDevice_V1_0_4_Dxe + FILE_GUID = 5032b1f7-73d4-4616-9e61-cae50c77b7d9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeDevice_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishPCIeDevice_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeDevice_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeDeviceV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_0_5/PCIeDevice_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/PCIeDevice/v1_0_5/PCIeDevice_V1_0_5_Dxe.c new file mode 100644 index 00000000000..bace85e20df --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_0_5/PCIeDevice_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeDevice.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeDevice"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeDevice V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeDevice", + "1", + "0", + "5" + }, + "PCIeDevice" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_0_5 *PCIeDeviceV1_0_5; + EFI_REDFISH_PCIEDEVICE_V1_0_5_CS *PCIeDeviceV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeDevice") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeDevice_V1_0_5_To_CS (ResoruceRaw, &PCIeDeviceV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeDeviceV1_0_5 = (EFI_REDFISH_PCIEDEVICE_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEDEVICE_V1_0_5)); + if (PCIeDeviceV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeDeviceV1_0_5; + PCIeDeviceV1_0_5->PCIeDevice = PCIeDeviceV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeDeviceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeDeviceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeDevice_V1_0_5_JSON (*((EFI_REDFISH_PCIEDEVICE_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeDeviceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_0_5 *PCIeDeviceV1_0_5; + + PCIeDeviceV1_0_5 = (EFI_REDFISH_PCIEDEVICE_V1_0_5 *)InterpProp; + DestroyPCIeDevice_V1_0_5_CS (PCIeDeviceV1_0_5->PCIeDevice); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeDeviceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeDevice_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeDeviceToStructWrapper, + PCIeDeviceToJson, + PCIeDeviceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_0_5/RedfishPCIeDevice_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/PCIeDevice/v1_0_5/RedfishPCIeDevice_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..80f3e03584b --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_0_5/RedfishPCIeDevice_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeDevice.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeDevice_V1_0_5_Dxe + FILE_GUID = 60cb609e-9c15-4f88-9a42-2304033f6a4b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeDevice_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishPCIeDevice_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeDevice_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeDeviceV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_1_0/PCIeDevice_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/PCIeDevice/v1_1_0/PCIeDevice_V1_1_0_Dxe.c new file mode 100644 index 00000000000..0da99cbe251 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_1_0/PCIeDevice_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeDevice.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeDevice"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeDevice V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeDevice", + "1", + "1", + "0" + }, + "PCIeDevice" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_1_0 *PCIeDeviceV1_1_0; + EFI_REDFISH_PCIEDEVICE_V1_1_0_CS *PCIeDeviceV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeDevice") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeDevice_V1_1_0_To_CS (ResoruceRaw, &PCIeDeviceV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeDeviceV1_1_0 = (EFI_REDFISH_PCIEDEVICE_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEDEVICE_V1_1_0)); + if (PCIeDeviceV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeDeviceV1_1_0; + PCIeDeviceV1_1_0->PCIeDevice = PCIeDeviceV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeDeviceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeDeviceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeDevice_V1_1_0_JSON (*((EFI_REDFISH_PCIEDEVICE_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeDeviceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_1_0 *PCIeDeviceV1_1_0; + + PCIeDeviceV1_1_0 = (EFI_REDFISH_PCIEDEVICE_V1_1_0 *)InterpProp; + DestroyPCIeDevice_V1_1_0_CS (PCIeDeviceV1_1_0->PCIeDevice); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeDeviceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeDevice_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeDeviceToStructWrapper, + PCIeDeviceToJson, + PCIeDeviceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_1_0/RedfishPCIeDevice_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/PCIeDevice/v1_1_0/RedfishPCIeDevice_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..9ed64959961 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_1_0/RedfishPCIeDevice_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeDevice.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeDevice_V1_1_0_Dxe + FILE_GUID = 3579d521-703b-4cc7-b696-d31a02d0a48f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeDevice_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishPCIeDevice_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeDevice_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeDeviceV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_1_1/PCIeDevice_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/PCIeDevice/v1_1_1/PCIeDevice_V1_1_1_Dxe.c new file mode 100644 index 00000000000..62c8d858e94 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_1_1/PCIeDevice_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeDevice.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeDevice"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeDevice V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeDevice", + "1", + "1", + "1" + }, + "PCIeDevice" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_1_1 *PCIeDeviceV1_1_1; + EFI_REDFISH_PCIEDEVICE_V1_1_1_CS *PCIeDeviceV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeDevice") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeDevice_V1_1_1_To_CS (ResoruceRaw, &PCIeDeviceV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeDeviceV1_1_1 = (EFI_REDFISH_PCIEDEVICE_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEDEVICE_V1_1_1)); + if (PCIeDeviceV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeDeviceV1_1_1; + PCIeDeviceV1_1_1->PCIeDevice = PCIeDeviceV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeDeviceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeDeviceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeDevice_V1_1_1_JSON (*((EFI_REDFISH_PCIEDEVICE_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeDeviceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_1_1 *PCIeDeviceV1_1_1; + + PCIeDeviceV1_1_1 = (EFI_REDFISH_PCIEDEVICE_V1_1_1 *)InterpProp; + DestroyPCIeDevice_V1_1_1_CS (PCIeDeviceV1_1_1->PCIeDevice); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeDeviceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeDevice_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeDeviceToStructWrapper, + PCIeDeviceToJson, + PCIeDeviceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_1_1/RedfishPCIeDevice_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/PCIeDevice/v1_1_1/RedfishPCIeDevice_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..5aa7b6d6937 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_1_1/RedfishPCIeDevice_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeDevice.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeDevice_V1_1_1_Dxe + FILE_GUID = c37dde34-8ec5-4f20-b461-efaae23a2393 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeDevice_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishPCIeDevice_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeDevice_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeDeviceV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_1_2/PCIeDevice_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/PCIeDevice/v1_1_2/PCIeDevice_V1_1_2_Dxe.c new file mode 100644 index 00000000000..2eee6db6bdc --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_1_2/PCIeDevice_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeDevice.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeDevice"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeDevice V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeDevice", + "1", + "1", + "2" + }, + "PCIeDevice" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_1_2 *PCIeDeviceV1_1_2; + EFI_REDFISH_PCIEDEVICE_V1_1_2_CS *PCIeDeviceV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeDevice") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeDevice_V1_1_2_To_CS (ResoruceRaw, &PCIeDeviceV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeDeviceV1_1_2 = (EFI_REDFISH_PCIEDEVICE_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEDEVICE_V1_1_2)); + if (PCIeDeviceV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeDeviceV1_1_2; + PCIeDeviceV1_1_2->PCIeDevice = PCIeDeviceV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeDeviceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeDeviceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeDevice_V1_1_2_JSON (*((EFI_REDFISH_PCIEDEVICE_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeDeviceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_1_2 *PCIeDeviceV1_1_2; + + PCIeDeviceV1_1_2 = (EFI_REDFISH_PCIEDEVICE_V1_1_2 *)InterpProp; + DestroyPCIeDevice_V1_1_2_CS (PCIeDeviceV1_1_2->PCIeDevice); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeDeviceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeDevice_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeDeviceToStructWrapper, + PCIeDeviceToJson, + PCIeDeviceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_1_2/RedfishPCIeDevice_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/PCIeDevice/v1_1_2/RedfishPCIeDevice_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..75eafe6ad14 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_1_2/RedfishPCIeDevice_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeDevice.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeDevice_V1_1_2_Dxe + FILE_GUID = c75eceb7-cb49-4123-83bc-621d25992939 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeDevice_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishPCIeDevice_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeDevice_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeDeviceV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_1_3/PCIeDevice_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/PCIeDevice/v1_1_3/PCIeDevice_V1_1_3_Dxe.c new file mode 100644 index 00000000000..e2bdefe9e39 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_1_3/PCIeDevice_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeDevice.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeDevice"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeDevice V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeDevice", + "1", + "1", + "3" + }, + "PCIeDevice" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_1_3 *PCIeDeviceV1_1_3; + EFI_REDFISH_PCIEDEVICE_V1_1_3_CS *PCIeDeviceV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeDevice") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeDevice_V1_1_3_To_CS (ResoruceRaw, &PCIeDeviceV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeDeviceV1_1_3 = (EFI_REDFISH_PCIEDEVICE_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEDEVICE_V1_1_3)); + if (PCIeDeviceV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeDeviceV1_1_3; + PCIeDeviceV1_1_3->PCIeDevice = PCIeDeviceV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeDeviceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeDeviceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeDevice_V1_1_3_JSON (*((EFI_REDFISH_PCIEDEVICE_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeDeviceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_1_3 *PCIeDeviceV1_1_3; + + PCIeDeviceV1_1_3 = (EFI_REDFISH_PCIEDEVICE_V1_1_3 *)InterpProp; + DestroyPCIeDevice_V1_1_3_CS (PCIeDeviceV1_1_3->PCIeDevice); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeDeviceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeDevice_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeDeviceToStructWrapper, + PCIeDeviceToJson, + PCIeDeviceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_1_3/RedfishPCIeDevice_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/PCIeDevice/v1_1_3/RedfishPCIeDevice_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..81c34e00890 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_1_3/RedfishPCIeDevice_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeDevice.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeDevice_V1_1_3_Dxe + FILE_GUID = 88ee7f2c-bc61-4761-920a-c668c0de4fe6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeDevice_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishPCIeDevice_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeDevice_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeDeviceV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_2_0/PCIeDevice_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/PCIeDevice/v1_2_0/PCIeDevice_V1_2_0_Dxe.c new file mode 100644 index 00000000000..3945d76ac2c --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_2_0/PCIeDevice_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeDevice.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeDevice"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeDevice V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeDevice", + "1", + "2", + "0" + }, + "PCIeDevice" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_2_0 *PCIeDeviceV1_2_0; + EFI_REDFISH_PCIEDEVICE_V1_2_0_CS *PCIeDeviceV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeDevice") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeDevice_V1_2_0_To_CS (ResoruceRaw, &PCIeDeviceV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeDeviceV1_2_0 = (EFI_REDFISH_PCIEDEVICE_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEDEVICE_V1_2_0)); + if (PCIeDeviceV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeDeviceV1_2_0; + PCIeDeviceV1_2_0->PCIeDevice = PCIeDeviceV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeDeviceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeDeviceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeDevice_V1_2_0_JSON (*((EFI_REDFISH_PCIEDEVICE_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeDeviceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_2_0 *PCIeDeviceV1_2_0; + + PCIeDeviceV1_2_0 = (EFI_REDFISH_PCIEDEVICE_V1_2_0 *)InterpProp; + DestroyPCIeDevice_V1_2_0_CS (PCIeDeviceV1_2_0->PCIeDevice); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeDeviceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeDevice_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeDeviceToStructWrapper, + PCIeDeviceToJson, + PCIeDeviceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_2_0/RedfishPCIeDevice_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/PCIeDevice/v1_2_0/RedfishPCIeDevice_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..f46f54f57d5 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_2_0/RedfishPCIeDevice_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeDevice.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeDevice_V1_2_0_Dxe + FILE_GUID = c1e1914d-86c3-4e19-ab6c-388cfb0355c3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeDevice_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishPCIeDevice_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeDevice_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeDeviceV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_2_1/PCIeDevice_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/PCIeDevice/v1_2_1/PCIeDevice_V1_2_1_Dxe.c new file mode 100644 index 00000000000..9d3d4145673 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_2_1/PCIeDevice_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeDevice.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeDevice"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeDevice V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeDevice", + "1", + "2", + "1" + }, + "PCIeDevice" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_2_1 *PCIeDeviceV1_2_1; + EFI_REDFISH_PCIEDEVICE_V1_2_1_CS *PCIeDeviceV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeDevice") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeDevice_V1_2_1_To_CS (ResoruceRaw, &PCIeDeviceV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeDeviceV1_2_1 = (EFI_REDFISH_PCIEDEVICE_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEDEVICE_V1_2_1)); + if (PCIeDeviceV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeDeviceV1_2_1; + PCIeDeviceV1_2_1->PCIeDevice = PCIeDeviceV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeDeviceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeDeviceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeDevice_V1_2_1_JSON (*((EFI_REDFISH_PCIEDEVICE_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeDeviceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_2_1 *PCIeDeviceV1_2_1; + + PCIeDeviceV1_2_1 = (EFI_REDFISH_PCIEDEVICE_V1_2_1 *)InterpProp; + DestroyPCIeDevice_V1_2_1_CS (PCIeDeviceV1_2_1->PCIeDevice); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeDeviceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeDevice_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeDeviceToStructWrapper, + PCIeDeviceToJson, + PCIeDeviceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_2_1/RedfishPCIeDevice_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/PCIeDevice/v1_2_1/RedfishPCIeDevice_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..0c63b06afa7 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_2_1/RedfishPCIeDevice_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeDevice.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeDevice_V1_2_1_Dxe + FILE_GUID = 7a0fe84b-7dd2-4728-ad1f-86ebb94e5507 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeDevice_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishPCIeDevice_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeDevice_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeDeviceV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_2_2/PCIeDevice_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/PCIeDevice/v1_2_2/PCIeDevice_V1_2_2_Dxe.c new file mode 100644 index 00000000000..a5530f52db5 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_2_2/PCIeDevice_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeDevice.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeDevice"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeDevice V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeDevice", + "1", + "2", + "2" + }, + "PCIeDevice" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_2_2 *PCIeDeviceV1_2_2; + EFI_REDFISH_PCIEDEVICE_V1_2_2_CS *PCIeDeviceV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeDevice") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeDevice_V1_2_2_To_CS (ResoruceRaw, &PCIeDeviceV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeDeviceV1_2_2 = (EFI_REDFISH_PCIEDEVICE_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEDEVICE_V1_2_2)); + if (PCIeDeviceV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeDeviceV1_2_2; + PCIeDeviceV1_2_2->PCIeDevice = PCIeDeviceV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeDeviceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeDeviceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeDevice_V1_2_2_JSON (*((EFI_REDFISH_PCIEDEVICE_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeDeviceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_2_2 *PCIeDeviceV1_2_2; + + PCIeDeviceV1_2_2 = (EFI_REDFISH_PCIEDEVICE_V1_2_2 *)InterpProp; + DestroyPCIeDevice_V1_2_2_CS (PCIeDeviceV1_2_2->PCIeDevice); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeDeviceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeDevice_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeDeviceToStructWrapper, + PCIeDeviceToJson, + PCIeDeviceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_2_2/RedfishPCIeDevice_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/PCIeDevice/v1_2_2/RedfishPCIeDevice_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..afbb9e8debc --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_2_2/RedfishPCIeDevice_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeDevice.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeDevice_V1_2_2_Dxe + FILE_GUID = 77d9f298-7699-4455-ac99-794db15a6e0c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeDevice_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishPCIeDevice_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeDevice_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeDeviceV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_2_3/PCIeDevice_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/PCIeDevice/v1_2_3/PCIeDevice_V1_2_3_Dxe.c new file mode 100644 index 00000000000..4da0c599299 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_2_3/PCIeDevice_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeDevice.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeDevice"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeDevice V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeDevice", + "1", + "2", + "3" + }, + "PCIeDevice" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_2_3 *PCIeDeviceV1_2_3; + EFI_REDFISH_PCIEDEVICE_V1_2_3_CS *PCIeDeviceV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeDevice") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeDevice_V1_2_3_To_CS (ResoruceRaw, &PCIeDeviceV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeDeviceV1_2_3 = (EFI_REDFISH_PCIEDEVICE_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEDEVICE_V1_2_3)); + if (PCIeDeviceV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeDeviceV1_2_3; + PCIeDeviceV1_2_3->PCIeDevice = PCIeDeviceV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeDeviceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeDeviceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeDevice_V1_2_3_JSON (*((EFI_REDFISH_PCIEDEVICE_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeDeviceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_2_3 *PCIeDeviceV1_2_3; + + PCIeDeviceV1_2_3 = (EFI_REDFISH_PCIEDEVICE_V1_2_3 *)InterpProp; + DestroyPCIeDevice_V1_2_3_CS (PCIeDeviceV1_2_3->PCIeDevice); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeDeviceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeDevice_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeDeviceToStructWrapper, + PCIeDeviceToJson, + PCIeDeviceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_2_3/RedfishPCIeDevice_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/PCIeDevice/v1_2_3/RedfishPCIeDevice_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..49f3a09baf6 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_2_3/RedfishPCIeDevice_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeDevice.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeDevice_V1_2_3_Dxe + FILE_GUID = 781c595c-69d0-4cb6-a982-7033607e1586 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeDevice_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishPCIeDevice_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeDevice_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeDeviceV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_3_0/PCIeDevice_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/PCIeDevice/v1_3_0/PCIeDevice_V1_3_0_Dxe.c new file mode 100644 index 00000000000..a5865d3b090 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_3_0/PCIeDevice_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeDevice.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeDevice"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeDevice V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeDevice", + "1", + "3", + "0" + }, + "PCIeDevice" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_3_0 *PCIeDeviceV1_3_0; + EFI_REDFISH_PCIEDEVICE_V1_3_0_CS *PCIeDeviceV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeDevice") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeDevice_V1_3_0_To_CS (ResoruceRaw, &PCIeDeviceV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeDeviceV1_3_0 = (EFI_REDFISH_PCIEDEVICE_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEDEVICE_V1_3_0)); + if (PCIeDeviceV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeDeviceV1_3_0; + PCIeDeviceV1_3_0->PCIeDevice = PCIeDeviceV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeDeviceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeDeviceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeDevice_V1_3_0_JSON (*((EFI_REDFISH_PCIEDEVICE_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeDeviceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_3_0 *PCIeDeviceV1_3_0; + + PCIeDeviceV1_3_0 = (EFI_REDFISH_PCIEDEVICE_V1_3_0 *)InterpProp; + DestroyPCIeDevice_V1_3_0_CS (PCIeDeviceV1_3_0->PCIeDevice); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeDeviceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeDevice_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeDeviceToStructWrapper, + PCIeDeviceToJson, + PCIeDeviceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_3_0/RedfishPCIeDevice_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/PCIeDevice/v1_3_0/RedfishPCIeDevice_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..ad6385bbe7c --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_3_0/RedfishPCIeDevice_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeDevice.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeDevice_V1_3_0_Dxe + FILE_GUID = 76b38340-6dfa-4de5-9109-7ce202d946d1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeDevice_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishPCIeDevice_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeDevice_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeDeviceV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_3_1/PCIeDevice_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/PCIeDevice/v1_3_1/PCIeDevice_V1_3_1_Dxe.c new file mode 100644 index 00000000000..82831431c2b --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_3_1/PCIeDevice_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeDevice.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeDevice"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeDevice V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeDevice", + "1", + "3", + "1" + }, + "PCIeDevice" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_3_1 *PCIeDeviceV1_3_1; + EFI_REDFISH_PCIEDEVICE_V1_3_1_CS *PCIeDeviceV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeDevice") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeDevice_V1_3_1_To_CS (ResoruceRaw, &PCIeDeviceV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeDeviceV1_3_1 = (EFI_REDFISH_PCIEDEVICE_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEDEVICE_V1_3_1)); + if (PCIeDeviceV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeDeviceV1_3_1; + PCIeDeviceV1_3_1->PCIeDevice = PCIeDeviceV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeDeviceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeDeviceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeDevice_V1_3_1_JSON (*((EFI_REDFISH_PCIEDEVICE_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeDeviceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_3_1 *PCIeDeviceV1_3_1; + + PCIeDeviceV1_3_1 = (EFI_REDFISH_PCIEDEVICE_V1_3_1 *)InterpProp; + DestroyPCIeDevice_V1_3_1_CS (PCIeDeviceV1_3_1->PCIeDevice); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeDeviceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeDevice_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeDeviceToStructWrapper, + PCIeDeviceToJson, + PCIeDeviceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_3_1/RedfishPCIeDevice_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/PCIeDevice/v1_3_1/RedfishPCIeDevice_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..1653380c0ad --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_3_1/RedfishPCIeDevice_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeDevice.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeDevice_V1_3_1_Dxe + FILE_GUID = 094e6a52-009e-4a81-9765-ebe42a8bcc94 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeDevice_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishPCIeDevice_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeDevice_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeDeviceV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_3_2/PCIeDevice_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/PCIeDevice/v1_3_2/PCIeDevice_V1_3_2_Dxe.c new file mode 100644 index 00000000000..ab16d673766 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_3_2/PCIeDevice_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeDevice.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeDevice"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeDevice V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeDevice", + "1", + "3", + "2" + }, + "PCIeDevice" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_3_2 *PCIeDeviceV1_3_2; + EFI_REDFISH_PCIEDEVICE_V1_3_2_CS *PCIeDeviceV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeDevice") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeDevice_V1_3_2_To_CS (ResoruceRaw, &PCIeDeviceV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeDeviceV1_3_2 = (EFI_REDFISH_PCIEDEVICE_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEDEVICE_V1_3_2)); + if (PCIeDeviceV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeDeviceV1_3_2; + PCIeDeviceV1_3_2->PCIeDevice = PCIeDeviceV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeDeviceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeDeviceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeDevice_V1_3_2_JSON (*((EFI_REDFISH_PCIEDEVICE_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeDeviceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_3_2 *PCIeDeviceV1_3_2; + + PCIeDeviceV1_3_2 = (EFI_REDFISH_PCIEDEVICE_V1_3_2 *)InterpProp; + DestroyPCIeDevice_V1_3_2_CS (PCIeDeviceV1_3_2->PCIeDevice); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeDeviceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeDevice_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeDeviceToStructWrapper, + PCIeDeviceToJson, + PCIeDeviceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_3_2/RedfishPCIeDevice_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/PCIeDevice/v1_3_2/RedfishPCIeDevice_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..4094f093671 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_3_2/RedfishPCIeDevice_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeDevice.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeDevice_V1_3_2_Dxe + FILE_GUID = 9f3ac7d4-88f7-4f2e-b54a-c499219e4331 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeDevice_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishPCIeDevice_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeDevice_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeDeviceV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_4_0/PCIeDevice_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/PCIeDevice/v1_4_0/PCIeDevice_V1_4_0_Dxe.c new file mode 100644 index 00000000000..a341eb537b8 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_4_0/PCIeDevice_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeDevice.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeDevice"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeDevice V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeDevice", + "1", + "4", + "0" + }, + "PCIeDevice" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_4_0 *PCIeDeviceV1_4_0; + EFI_REDFISH_PCIEDEVICE_V1_4_0_CS *PCIeDeviceV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeDevice") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeDevice_V1_4_0_To_CS (ResoruceRaw, &PCIeDeviceV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeDeviceV1_4_0 = (EFI_REDFISH_PCIEDEVICE_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEDEVICE_V1_4_0)); + if (PCIeDeviceV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeDeviceV1_4_0; + PCIeDeviceV1_4_0->PCIeDevice = PCIeDeviceV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeDeviceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeDeviceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeDevice_V1_4_0_JSON (*((EFI_REDFISH_PCIEDEVICE_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeDeviceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_4_0 *PCIeDeviceV1_4_0; + + PCIeDeviceV1_4_0 = (EFI_REDFISH_PCIEDEVICE_V1_4_0 *)InterpProp; + DestroyPCIeDevice_V1_4_0_CS (PCIeDeviceV1_4_0->PCIeDevice); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeDeviceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeDevice_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeDeviceToStructWrapper, + PCIeDeviceToJson, + PCIeDeviceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_4_0/RedfishPCIeDevice_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/PCIeDevice/v1_4_0/RedfishPCIeDevice_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..68eb33ca7b1 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_4_0/RedfishPCIeDevice_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeDevice.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeDevice_V1_4_0_Dxe + FILE_GUID = 158eafd6-c4c4-4e5d-ba13-a3bf4050257e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeDevice_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishPCIeDevice_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeDevice_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeDeviceV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_5_0/PCIeDevice_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/PCIeDevice/v1_5_0/PCIeDevice_V1_5_0_Dxe.c new file mode 100644 index 00000000000..4c88ea53656 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_5_0/PCIeDevice_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeDevice.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeDevice"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeDevice V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeDevice", + "1", + "5", + "0" + }, + "PCIeDevice" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_5_0 *PCIeDeviceV1_5_0; + EFI_REDFISH_PCIEDEVICE_V1_5_0_CS *PCIeDeviceV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeDevice") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeDevice_V1_5_0_To_CS (ResoruceRaw, &PCIeDeviceV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeDeviceV1_5_0 = (EFI_REDFISH_PCIEDEVICE_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEDEVICE_V1_5_0)); + if (PCIeDeviceV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeDeviceV1_5_0; + PCIeDeviceV1_5_0->PCIeDevice = PCIeDeviceV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeDeviceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeDeviceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeDevice_V1_5_0_JSON (*((EFI_REDFISH_PCIEDEVICE_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeDeviceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_5_0 *PCIeDeviceV1_5_0; + + PCIeDeviceV1_5_0 = (EFI_REDFISH_PCIEDEVICE_V1_5_0 *)InterpProp; + DestroyPCIeDevice_V1_5_0_CS (PCIeDeviceV1_5_0->PCIeDevice); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeDeviceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeDevice_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeDeviceToStructWrapper, + PCIeDeviceToJson, + PCIeDeviceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_5_0/RedfishPCIeDevice_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/PCIeDevice/v1_5_0/RedfishPCIeDevice_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..ba407eabaa6 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_5_0/RedfishPCIeDevice_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeDevice.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeDevice_V1_5_0_Dxe + FILE_GUID = 145d6445-46be-4c09-bcdc-bce533103021 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeDevice_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishPCIeDevice_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeDevice_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeDeviceV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_6_0/PCIeDevice_V1_6_0_Dxe.c b/RedfishClientPkg/Converter/PCIeDevice/v1_6_0/PCIeDevice_V1_6_0_Dxe.c new file mode 100644 index 00000000000..59e2b72052a --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_6_0/PCIeDevice_V1_6_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeDevice.v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeDevice"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeDevice V1_6_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeDevice", + "1", + "6", + "0" + }, + "PCIeDevice" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_6_0 *PCIeDeviceV1_6_0; + EFI_REDFISH_PCIEDEVICE_V1_6_0_CS *PCIeDeviceV1_6_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeDevice") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeDevice_V1_6_0_To_CS (ResoruceRaw, &PCIeDeviceV1_6_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeDeviceV1_6_0 = (EFI_REDFISH_PCIEDEVICE_V1_6_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEDEVICE_V1_6_0)); + if (PCIeDeviceV1_6_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeDeviceV1_6_0; + PCIeDeviceV1_6_0->PCIeDevice = PCIeDeviceV1_6_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDevice")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeDevice"), "PCIeDevice"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeDeviceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeDeviceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeDevice_V1_6_0_JSON (*((EFI_REDFISH_PCIEDEVICE_V1_6_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeDeviceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEDEVICE_V1_6_0 *PCIeDeviceV1_6_0; + + PCIeDeviceV1_6_0 = (EFI_REDFISH_PCIEDEVICE_V1_6_0 *)InterpProp; + DestroyPCIeDevice_V1_6_0_CS (PCIeDeviceV1_6_0->PCIeDevice); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeDeviceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeDevice_V1_6_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_6_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeDeviceToStructWrapper, + PCIeDeviceToJson, + PCIeDeviceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDevice_V1_6_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeDevice/v1_6_0/RedfishPCIeDevice_V1_6_0_Dxe.inf b/RedfishClientPkg/Converter/PCIeDevice/v1_6_0/RedfishPCIeDevice_V1_6_0_Dxe.inf new file mode 100644 index 00000000000..a6c958b7ad1 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDevice/v1_6_0/RedfishPCIeDevice_V1_6_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeDevice.v1_6_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeDevice_V1_6_0_Dxe + FILE_GUID = 40db899b-bfac-43ad-b0a8-700cc664e76c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeDevice_V1_6_0EntryPoint + UNLOAD_IMAGE = RedfishPCIeDevice_V1_6_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeDevice_V1_6_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeDeviceV1_6_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeDeviceCollection/PCIeDeviceCollection_Dxe.c b/RedfishClientPkg/Converter/PCIeDeviceCollection/PCIeDeviceCollection_Dxe.c new file mode 100644 index 00000000000..89af34f994a --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDeviceCollection/PCIeDeviceCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeDeviceCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeDeviceCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support PCIeDeviceCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeDeviceCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "PCIeDeviceCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEDEVICECOLLECTION *PCIeDeviceCollection; + EFI_REDFISH_PCIEDEVICECOLLECTION_CS *PCIeDeviceCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeDeviceCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeDeviceCollection_To_CS (ResoruceRaw, &PCIeDeviceCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeDeviceCollection = (EFI_REDFISH_PCIEDEVICECOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEDEVICECOLLECTION)); + if (PCIeDeviceCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeDeviceCollection; + PCIeDeviceCollection->PCIeDeviceCollection = PCIeDeviceCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDeviceCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeDeviceCollection"), "PCIeDeviceCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeDeviceCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeDeviceCollection"), "PCIeDeviceCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeDeviceCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeDeviceCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeDeviceCollection_JSON (*((EFI_REDFISH_PCIEDEVICECOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeDeviceCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEDEVICECOLLECTION *PCIeDeviceCollection; + + PCIeDeviceCollection = (EFI_REDFISH_PCIEDEVICECOLLECTION *)InterpProp; + DestroyPCIeDeviceCollection_CS (PCIeDeviceCollection->PCIeDeviceCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeDeviceCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeDeviceCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeDeviceCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDeviceCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeDeviceCollectionToStructWrapper, + PCIeDeviceCollectionToJson, + PCIeDeviceCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeDeviceCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeDeviceCollection/RedfishPCIeDeviceCollection_Dxe.inf b/RedfishClientPkg/Converter/PCIeDeviceCollection/RedfishPCIeDeviceCollection_Dxe.inf new file mode 100644 index 00000000000..c82350629ea --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeDeviceCollection/RedfishPCIeDeviceCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeDeviceCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeDeviceCollection_Dxe + FILE_GUID = ac718ca6-6ece-4e17-a820-dabce3b045c8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeDeviceCollectionEntryPoint + UNLOAD_IMAGE = RedfishPCIeDeviceCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeDeviceCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeDeviceCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_0_0/PCIeFunction_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/PCIeFunction/v1_0_0/PCIeFunction_V1_0_0_Dxe.c new file mode 100644 index 00000000000..d44f266fbe5 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_0_0/PCIeFunction_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeFunction.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeFunction V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeFunction", + "1", + "0", + "0" + }, + "PCIeFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_0_0 *PCIeFunctionV1_0_0; + EFI_REDFISH_PCIEFUNCTION_V1_0_0_CS *PCIeFunctionV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeFunction_V1_0_0_To_CS (ResoruceRaw, &PCIeFunctionV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeFunctionV1_0_0 = (EFI_REDFISH_PCIEFUNCTION_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEFUNCTION_V1_0_0)); + if (PCIeFunctionV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeFunctionV1_0_0; + PCIeFunctionV1_0_0->PCIeFunction = PCIeFunctionV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeFunction_V1_0_0_JSON (*((EFI_REDFISH_PCIEFUNCTION_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_0_0 *PCIeFunctionV1_0_0; + + PCIeFunctionV1_0_0 = (EFI_REDFISH_PCIEFUNCTION_V1_0_0 *)InterpProp; + DestroyPCIeFunction_V1_0_0_CS (PCIeFunctionV1_0_0->PCIeFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeFunction_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeFunctionToStructWrapper, + PCIeFunctionToJson, + PCIeFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_0_0/RedfishPCIeFunction_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/PCIeFunction/v1_0_0/RedfishPCIeFunction_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..8326ee5ff77 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_0_0/RedfishPCIeFunction_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeFunction.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeFunction_V1_0_0_Dxe + FILE_GUID = e215115a-59c6-4f25-b416-0da6da3e3f53 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeFunction_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishPCIeFunction_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeFunction_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeFunctionV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_0_1/PCIeFunction_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/PCIeFunction/v1_0_1/PCIeFunction_V1_0_1_Dxe.c new file mode 100644 index 00000000000..7072307c094 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_0_1/PCIeFunction_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeFunction.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeFunction V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeFunction", + "1", + "0", + "1" + }, + "PCIeFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_0_1 *PCIeFunctionV1_0_1; + EFI_REDFISH_PCIEFUNCTION_V1_0_1_CS *PCIeFunctionV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeFunction_V1_0_1_To_CS (ResoruceRaw, &PCIeFunctionV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeFunctionV1_0_1 = (EFI_REDFISH_PCIEFUNCTION_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEFUNCTION_V1_0_1)); + if (PCIeFunctionV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeFunctionV1_0_1; + PCIeFunctionV1_0_1->PCIeFunction = PCIeFunctionV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeFunction_V1_0_1_JSON (*((EFI_REDFISH_PCIEFUNCTION_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_0_1 *PCIeFunctionV1_0_1; + + PCIeFunctionV1_0_1 = (EFI_REDFISH_PCIEFUNCTION_V1_0_1 *)InterpProp; + DestroyPCIeFunction_V1_0_1_CS (PCIeFunctionV1_0_1->PCIeFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeFunction_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeFunctionToStructWrapper, + PCIeFunctionToJson, + PCIeFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_0_1/RedfishPCIeFunction_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/PCIeFunction/v1_0_1/RedfishPCIeFunction_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..7e66a144fbb --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_0_1/RedfishPCIeFunction_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeFunction.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeFunction_V1_0_1_Dxe + FILE_GUID = 10f1be48-7db9-42bc-9de2-c1cf5f07b33c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeFunction_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishPCIeFunction_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeFunction_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeFunctionV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_0_2/PCIeFunction_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/PCIeFunction/v1_0_2/PCIeFunction_V1_0_2_Dxe.c new file mode 100644 index 00000000000..7987e806e2d --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_0_2/PCIeFunction_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeFunction.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeFunction V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeFunction", + "1", + "0", + "2" + }, + "PCIeFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_0_2 *PCIeFunctionV1_0_2; + EFI_REDFISH_PCIEFUNCTION_V1_0_2_CS *PCIeFunctionV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeFunction_V1_0_2_To_CS (ResoruceRaw, &PCIeFunctionV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeFunctionV1_0_2 = (EFI_REDFISH_PCIEFUNCTION_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEFUNCTION_V1_0_2)); + if (PCIeFunctionV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeFunctionV1_0_2; + PCIeFunctionV1_0_2->PCIeFunction = PCIeFunctionV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeFunction_V1_0_2_JSON (*((EFI_REDFISH_PCIEFUNCTION_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_0_2 *PCIeFunctionV1_0_2; + + PCIeFunctionV1_0_2 = (EFI_REDFISH_PCIEFUNCTION_V1_0_2 *)InterpProp; + DestroyPCIeFunction_V1_0_2_CS (PCIeFunctionV1_0_2->PCIeFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeFunction_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeFunctionToStructWrapper, + PCIeFunctionToJson, + PCIeFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_0_2/RedfishPCIeFunction_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/PCIeFunction/v1_0_2/RedfishPCIeFunction_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..1a45283e66f --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_0_2/RedfishPCIeFunction_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeFunction.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeFunction_V1_0_2_Dxe + FILE_GUID = f0853efb-9982-45bb-92ce-65cea9effd50 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeFunction_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishPCIeFunction_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeFunction_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeFunctionV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_0_3/PCIeFunction_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/PCIeFunction/v1_0_3/PCIeFunction_V1_0_3_Dxe.c new file mode 100644 index 00000000000..7856619c32f --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_0_3/PCIeFunction_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeFunction.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeFunction V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeFunction", + "1", + "0", + "3" + }, + "PCIeFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_0_3 *PCIeFunctionV1_0_3; + EFI_REDFISH_PCIEFUNCTION_V1_0_3_CS *PCIeFunctionV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeFunction_V1_0_3_To_CS (ResoruceRaw, &PCIeFunctionV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeFunctionV1_0_3 = (EFI_REDFISH_PCIEFUNCTION_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEFUNCTION_V1_0_3)); + if (PCIeFunctionV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeFunctionV1_0_3; + PCIeFunctionV1_0_3->PCIeFunction = PCIeFunctionV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeFunction_V1_0_3_JSON (*((EFI_REDFISH_PCIEFUNCTION_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_0_3 *PCIeFunctionV1_0_3; + + PCIeFunctionV1_0_3 = (EFI_REDFISH_PCIEFUNCTION_V1_0_3 *)InterpProp; + DestroyPCIeFunction_V1_0_3_CS (PCIeFunctionV1_0_3->PCIeFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeFunction_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeFunctionToStructWrapper, + PCIeFunctionToJson, + PCIeFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_0_3/RedfishPCIeFunction_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/PCIeFunction/v1_0_3/RedfishPCIeFunction_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..08db2e439ef --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_0_3/RedfishPCIeFunction_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeFunction.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeFunction_V1_0_3_Dxe + FILE_GUID = 28001d48-0d4a-4661-8509-2de285243512 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeFunction_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishPCIeFunction_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeFunction_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeFunctionV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_0_4/PCIeFunction_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/PCIeFunction/v1_0_4/PCIeFunction_V1_0_4_Dxe.c new file mode 100644 index 00000000000..c39a61c4ab0 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_0_4/PCIeFunction_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeFunction.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeFunction V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeFunction", + "1", + "0", + "4" + }, + "PCIeFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_0_4 *PCIeFunctionV1_0_4; + EFI_REDFISH_PCIEFUNCTION_V1_0_4_CS *PCIeFunctionV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeFunction_V1_0_4_To_CS (ResoruceRaw, &PCIeFunctionV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeFunctionV1_0_4 = (EFI_REDFISH_PCIEFUNCTION_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEFUNCTION_V1_0_4)); + if (PCIeFunctionV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeFunctionV1_0_4; + PCIeFunctionV1_0_4->PCIeFunction = PCIeFunctionV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeFunction_V1_0_4_JSON (*((EFI_REDFISH_PCIEFUNCTION_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_0_4 *PCIeFunctionV1_0_4; + + PCIeFunctionV1_0_4 = (EFI_REDFISH_PCIEFUNCTION_V1_0_4 *)InterpProp; + DestroyPCIeFunction_V1_0_4_CS (PCIeFunctionV1_0_4->PCIeFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeFunction_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeFunctionToStructWrapper, + PCIeFunctionToJson, + PCIeFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_0_4/RedfishPCIeFunction_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/PCIeFunction/v1_0_4/RedfishPCIeFunction_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..ddeaf74be80 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_0_4/RedfishPCIeFunction_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeFunction.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeFunction_V1_0_4_Dxe + FILE_GUID = d98df6d0-9ae6-4a8a-a988-5da3fec81df8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeFunction_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishPCIeFunction_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeFunction_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeFunctionV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_0_5/PCIeFunction_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/PCIeFunction/v1_0_5/PCIeFunction_V1_0_5_Dxe.c new file mode 100644 index 00000000000..e1f5cb3509e --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_0_5/PCIeFunction_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeFunction.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeFunction V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeFunction", + "1", + "0", + "5" + }, + "PCIeFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_0_5 *PCIeFunctionV1_0_5; + EFI_REDFISH_PCIEFUNCTION_V1_0_5_CS *PCIeFunctionV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeFunction_V1_0_5_To_CS (ResoruceRaw, &PCIeFunctionV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeFunctionV1_0_5 = (EFI_REDFISH_PCIEFUNCTION_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEFUNCTION_V1_0_5)); + if (PCIeFunctionV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeFunctionV1_0_5; + PCIeFunctionV1_0_5->PCIeFunction = PCIeFunctionV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeFunction_V1_0_5_JSON (*((EFI_REDFISH_PCIEFUNCTION_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_0_5 *PCIeFunctionV1_0_5; + + PCIeFunctionV1_0_5 = (EFI_REDFISH_PCIEFUNCTION_V1_0_5 *)InterpProp; + DestroyPCIeFunction_V1_0_5_CS (PCIeFunctionV1_0_5->PCIeFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeFunction_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeFunctionToStructWrapper, + PCIeFunctionToJson, + PCIeFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_0_5/RedfishPCIeFunction_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/PCIeFunction/v1_0_5/RedfishPCIeFunction_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..4e443749fd3 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_0_5/RedfishPCIeFunction_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeFunction.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeFunction_V1_0_5_Dxe + FILE_GUID = f36246f6-c88a-4cb4-8b76-4cd5119d7a07 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeFunction_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishPCIeFunction_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeFunction_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeFunctionV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_0_6/PCIeFunction_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/PCIeFunction/v1_0_6/PCIeFunction_V1_0_6_Dxe.c new file mode 100644 index 00000000000..768dfe2db8a --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_0_6/PCIeFunction_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeFunction.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeFunction V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeFunction", + "1", + "0", + "6" + }, + "PCIeFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_0_6 *PCIeFunctionV1_0_6; + EFI_REDFISH_PCIEFUNCTION_V1_0_6_CS *PCIeFunctionV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeFunction_V1_0_6_To_CS (ResoruceRaw, &PCIeFunctionV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeFunctionV1_0_6 = (EFI_REDFISH_PCIEFUNCTION_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEFUNCTION_V1_0_6)); + if (PCIeFunctionV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeFunctionV1_0_6; + PCIeFunctionV1_0_6->PCIeFunction = PCIeFunctionV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeFunction_V1_0_6_JSON (*((EFI_REDFISH_PCIEFUNCTION_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_0_6 *PCIeFunctionV1_0_6; + + PCIeFunctionV1_0_6 = (EFI_REDFISH_PCIEFUNCTION_V1_0_6 *)InterpProp; + DestroyPCIeFunction_V1_0_6_CS (PCIeFunctionV1_0_6->PCIeFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeFunction_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeFunctionToStructWrapper, + PCIeFunctionToJson, + PCIeFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_0_6/RedfishPCIeFunction_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/PCIeFunction/v1_0_6/RedfishPCIeFunction_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..b7e45b994e6 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_0_6/RedfishPCIeFunction_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeFunction.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeFunction_V1_0_6_Dxe + FILE_GUID = 5111fa91-ecc4-4bfc-95e1-000936f5a221 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeFunction_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishPCIeFunction_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeFunction_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeFunctionV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_1_0/PCIeFunction_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/PCIeFunction/v1_1_0/PCIeFunction_V1_1_0_Dxe.c new file mode 100644 index 00000000000..00d4d982592 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_1_0/PCIeFunction_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeFunction.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeFunction V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeFunction", + "1", + "1", + "0" + }, + "PCIeFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_1_0 *PCIeFunctionV1_1_0; + EFI_REDFISH_PCIEFUNCTION_V1_1_0_CS *PCIeFunctionV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeFunction_V1_1_0_To_CS (ResoruceRaw, &PCIeFunctionV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeFunctionV1_1_0 = (EFI_REDFISH_PCIEFUNCTION_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEFUNCTION_V1_1_0)); + if (PCIeFunctionV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeFunctionV1_1_0; + PCIeFunctionV1_1_0->PCIeFunction = PCIeFunctionV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeFunction_V1_1_0_JSON (*((EFI_REDFISH_PCIEFUNCTION_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_1_0 *PCIeFunctionV1_1_0; + + PCIeFunctionV1_1_0 = (EFI_REDFISH_PCIEFUNCTION_V1_1_0 *)InterpProp; + DestroyPCIeFunction_V1_1_0_CS (PCIeFunctionV1_1_0->PCIeFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeFunction_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeFunctionToStructWrapper, + PCIeFunctionToJson, + PCIeFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_1_0/RedfishPCIeFunction_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/PCIeFunction/v1_1_0/RedfishPCIeFunction_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..69054a3cd9f --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_1_0/RedfishPCIeFunction_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeFunction.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeFunction_V1_1_0_Dxe + FILE_GUID = e0b0314d-a764-4780-bbb4-c3254419fc36 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeFunction_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishPCIeFunction_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeFunction_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeFunctionV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_1_1/PCIeFunction_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/PCIeFunction/v1_1_1/PCIeFunction_V1_1_1_Dxe.c new file mode 100644 index 00000000000..a07a78188e2 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_1_1/PCIeFunction_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeFunction.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeFunction V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeFunction", + "1", + "1", + "1" + }, + "PCIeFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_1_1 *PCIeFunctionV1_1_1; + EFI_REDFISH_PCIEFUNCTION_V1_1_1_CS *PCIeFunctionV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeFunction_V1_1_1_To_CS (ResoruceRaw, &PCIeFunctionV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeFunctionV1_1_1 = (EFI_REDFISH_PCIEFUNCTION_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEFUNCTION_V1_1_1)); + if (PCIeFunctionV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeFunctionV1_1_1; + PCIeFunctionV1_1_1->PCIeFunction = PCIeFunctionV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeFunction_V1_1_1_JSON (*((EFI_REDFISH_PCIEFUNCTION_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_1_1 *PCIeFunctionV1_1_1; + + PCIeFunctionV1_1_1 = (EFI_REDFISH_PCIEFUNCTION_V1_1_1 *)InterpProp; + DestroyPCIeFunction_V1_1_1_CS (PCIeFunctionV1_1_1->PCIeFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeFunction_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeFunctionToStructWrapper, + PCIeFunctionToJson, + PCIeFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_1_1/RedfishPCIeFunction_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/PCIeFunction/v1_1_1/RedfishPCIeFunction_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..9865fdb8463 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_1_1/RedfishPCIeFunction_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeFunction.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeFunction_V1_1_1_Dxe + FILE_GUID = 40ab7a69-2494-42b7-bd7a-e00e72471b4a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeFunction_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishPCIeFunction_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeFunction_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeFunctionV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_1_2/PCIeFunction_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/PCIeFunction/v1_1_2/PCIeFunction_V1_1_2_Dxe.c new file mode 100644 index 00000000000..bfee6807f28 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_1_2/PCIeFunction_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeFunction.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeFunction V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeFunction", + "1", + "1", + "2" + }, + "PCIeFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_1_2 *PCIeFunctionV1_1_2; + EFI_REDFISH_PCIEFUNCTION_V1_1_2_CS *PCIeFunctionV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeFunction_V1_1_2_To_CS (ResoruceRaw, &PCIeFunctionV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeFunctionV1_1_2 = (EFI_REDFISH_PCIEFUNCTION_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEFUNCTION_V1_1_2)); + if (PCIeFunctionV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeFunctionV1_1_2; + PCIeFunctionV1_1_2->PCIeFunction = PCIeFunctionV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeFunction_V1_1_2_JSON (*((EFI_REDFISH_PCIEFUNCTION_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_1_2 *PCIeFunctionV1_1_2; + + PCIeFunctionV1_1_2 = (EFI_REDFISH_PCIEFUNCTION_V1_1_2 *)InterpProp; + DestroyPCIeFunction_V1_1_2_CS (PCIeFunctionV1_1_2->PCIeFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeFunction_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeFunctionToStructWrapper, + PCIeFunctionToJson, + PCIeFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_1_2/RedfishPCIeFunction_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/PCIeFunction/v1_1_2/RedfishPCIeFunction_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..2c60eb3b885 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_1_2/RedfishPCIeFunction_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeFunction.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeFunction_V1_1_2_Dxe + FILE_GUID = 6b3bd632-83fc-4770-a19d-10581bf794da + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeFunction_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishPCIeFunction_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeFunction_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeFunctionV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_1_3/PCIeFunction_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/PCIeFunction/v1_1_3/PCIeFunction_V1_1_3_Dxe.c new file mode 100644 index 00000000000..03db7653bcc --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_1_3/PCIeFunction_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeFunction.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeFunction V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeFunction", + "1", + "1", + "3" + }, + "PCIeFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_1_3 *PCIeFunctionV1_1_3; + EFI_REDFISH_PCIEFUNCTION_V1_1_3_CS *PCIeFunctionV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeFunction_V1_1_3_To_CS (ResoruceRaw, &PCIeFunctionV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeFunctionV1_1_3 = (EFI_REDFISH_PCIEFUNCTION_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEFUNCTION_V1_1_3)); + if (PCIeFunctionV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeFunctionV1_1_3; + PCIeFunctionV1_1_3->PCIeFunction = PCIeFunctionV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeFunction_V1_1_3_JSON (*((EFI_REDFISH_PCIEFUNCTION_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_1_3 *PCIeFunctionV1_1_3; + + PCIeFunctionV1_1_3 = (EFI_REDFISH_PCIEFUNCTION_V1_1_3 *)InterpProp; + DestroyPCIeFunction_V1_1_3_CS (PCIeFunctionV1_1_3->PCIeFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeFunction_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeFunctionToStructWrapper, + PCIeFunctionToJson, + PCIeFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_1_3/RedfishPCIeFunction_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/PCIeFunction/v1_1_3/RedfishPCIeFunction_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..c1a410d0466 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_1_3/RedfishPCIeFunction_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeFunction.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeFunction_V1_1_3_Dxe + FILE_GUID = f94ca306-81ae-4ef6-a65b-23b256aad3ee + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeFunction_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishPCIeFunction_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeFunction_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeFunctionV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_1_4/PCIeFunction_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/PCIeFunction/v1_1_4/PCIeFunction_V1_1_4_Dxe.c new file mode 100644 index 00000000000..4badc2d2487 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_1_4/PCIeFunction_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeFunction.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeFunction V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeFunction", + "1", + "1", + "4" + }, + "PCIeFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_1_4 *PCIeFunctionV1_1_4; + EFI_REDFISH_PCIEFUNCTION_V1_1_4_CS *PCIeFunctionV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeFunction_V1_1_4_To_CS (ResoruceRaw, &PCIeFunctionV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeFunctionV1_1_4 = (EFI_REDFISH_PCIEFUNCTION_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEFUNCTION_V1_1_4)); + if (PCIeFunctionV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeFunctionV1_1_4; + PCIeFunctionV1_1_4->PCIeFunction = PCIeFunctionV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeFunction_V1_1_4_JSON (*((EFI_REDFISH_PCIEFUNCTION_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_1_4 *PCIeFunctionV1_1_4; + + PCIeFunctionV1_1_4 = (EFI_REDFISH_PCIEFUNCTION_V1_1_4 *)InterpProp; + DestroyPCIeFunction_V1_1_4_CS (PCIeFunctionV1_1_4->PCIeFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeFunction_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeFunctionToStructWrapper, + PCIeFunctionToJson, + PCIeFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_1_4/RedfishPCIeFunction_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/PCIeFunction/v1_1_4/RedfishPCIeFunction_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..55b41cc6f6e --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_1_4/RedfishPCIeFunction_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeFunction.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeFunction_V1_1_4_Dxe + FILE_GUID = 0709b428-718c-4957-b5ac-28e171f4b8ca + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeFunction_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishPCIeFunction_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeFunction_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeFunctionV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_2_0/PCIeFunction_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/PCIeFunction/v1_2_0/PCIeFunction_V1_2_0_Dxe.c new file mode 100644 index 00000000000..e8fcfb09969 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_2_0/PCIeFunction_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeFunction.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeFunction V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeFunction", + "1", + "2", + "0" + }, + "PCIeFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_2_0 *PCIeFunctionV1_2_0; + EFI_REDFISH_PCIEFUNCTION_V1_2_0_CS *PCIeFunctionV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeFunction_V1_2_0_To_CS (ResoruceRaw, &PCIeFunctionV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeFunctionV1_2_0 = (EFI_REDFISH_PCIEFUNCTION_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEFUNCTION_V1_2_0)); + if (PCIeFunctionV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeFunctionV1_2_0; + PCIeFunctionV1_2_0->PCIeFunction = PCIeFunctionV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeFunction_V1_2_0_JSON (*((EFI_REDFISH_PCIEFUNCTION_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_2_0 *PCIeFunctionV1_2_0; + + PCIeFunctionV1_2_0 = (EFI_REDFISH_PCIEFUNCTION_V1_2_0 *)InterpProp; + DestroyPCIeFunction_V1_2_0_CS (PCIeFunctionV1_2_0->PCIeFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeFunction_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeFunctionToStructWrapper, + PCIeFunctionToJson, + PCIeFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_2_0/RedfishPCIeFunction_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/PCIeFunction/v1_2_0/RedfishPCIeFunction_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..7b9ac03bbc4 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_2_0/RedfishPCIeFunction_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeFunction.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeFunction_V1_2_0_Dxe + FILE_GUID = dd7b41a2-4ce9-4f01-87d3-df4dded22120 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeFunction_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishPCIeFunction_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeFunction_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeFunctionV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_2_1/PCIeFunction_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/PCIeFunction/v1_2_1/PCIeFunction_V1_2_1_Dxe.c new file mode 100644 index 00000000000..21f86210e21 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_2_1/PCIeFunction_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeFunction.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeFunction V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeFunction", + "1", + "2", + "1" + }, + "PCIeFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_2_1 *PCIeFunctionV1_2_1; + EFI_REDFISH_PCIEFUNCTION_V1_2_1_CS *PCIeFunctionV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeFunction_V1_2_1_To_CS (ResoruceRaw, &PCIeFunctionV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeFunctionV1_2_1 = (EFI_REDFISH_PCIEFUNCTION_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEFUNCTION_V1_2_1)); + if (PCIeFunctionV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeFunctionV1_2_1; + PCIeFunctionV1_2_1->PCIeFunction = PCIeFunctionV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeFunction_V1_2_1_JSON (*((EFI_REDFISH_PCIEFUNCTION_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_2_1 *PCIeFunctionV1_2_1; + + PCIeFunctionV1_2_1 = (EFI_REDFISH_PCIEFUNCTION_V1_2_1 *)InterpProp; + DestroyPCIeFunction_V1_2_1_CS (PCIeFunctionV1_2_1->PCIeFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeFunction_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeFunctionToStructWrapper, + PCIeFunctionToJson, + PCIeFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_2_1/RedfishPCIeFunction_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/PCIeFunction/v1_2_1/RedfishPCIeFunction_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..0e3bde6ff49 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_2_1/RedfishPCIeFunction_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeFunction.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeFunction_V1_2_1_Dxe + FILE_GUID = ef5a6bc6-5c57-4cb6-b17d-9514583f8171 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeFunction_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishPCIeFunction_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeFunction_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeFunctionV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_2_2/PCIeFunction_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/PCIeFunction/v1_2_2/PCIeFunction_V1_2_2_Dxe.c new file mode 100644 index 00000000000..4f6a2e700f9 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_2_2/PCIeFunction_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeFunction.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeFunction V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeFunction", + "1", + "2", + "2" + }, + "PCIeFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_2_2 *PCIeFunctionV1_2_2; + EFI_REDFISH_PCIEFUNCTION_V1_2_2_CS *PCIeFunctionV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeFunction_V1_2_2_To_CS (ResoruceRaw, &PCIeFunctionV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeFunctionV1_2_2 = (EFI_REDFISH_PCIEFUNCTION_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEFUNCTION_V1_2_2)); + if (PCIeFunctionV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeFunctionV1_2_2; + PCIeFunctionV1_2_2->PCIeFunction = PCIeFunctionV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeFunction_V1_2_2_JSON (*((EFI_REDFISH_PCIEFUNCTION_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_2_2 *PCIeFunctionV1_2_2; + + PCIeFunctionV1_2_2 = (EFI_REDFISH_PCIEFUNCTION_V1_2_2 *)InterpProp; + DestroyPCIeFunction_V1_2_2_CS (PCIeFunctionV1_2_2->PCIeFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeFunction_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeFunctionToStructWrapper, + PCIeFunctionToJson, + PCIeFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_2_2/RedfishPCIeFunction_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/PCIeFunction/v1_2_2/RedfishPCIeFunction_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..701fbd72980 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_2_2/RedfishPCIeFunction_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeFunction.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeFunction_V1_2_2_Dxe + FILE_GUID = c0993ca9-a0bf-4db9-a62c-7369bb07e0b5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeFunction_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishPCIeFunction_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeFunction_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeFunctionV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_2_3/PCIeFunction_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/PCIeFunction/v1_2_3/PCIeFunction_V1_2_3_Dxe.c new file mode 100644 index 00000000000..c5f126fa435 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_2_3/PCIeFunction_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeFunction.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeFunction"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeFunction V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeFunction", + "1", + "2", + "3" + }, + "PCIeFunction" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_2_3 *PCIeFunctionV1_2_3; + EFI_REDFISH_PCIEFUNCTION_V1_2_3_CS *PCIeFunctionV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeFunction") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeFunction_V1_2_3_To_CS (ResoruceRaw, &PCIeFunctionV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeFunctionV1_2_3 = (EFI_REDFISH_PCIEFUNCTION_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEFUNCTION_V1_2_3)); + if (PCIeFunctionV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeFunctionV1_2_3; + PCIeFunctionV1_2_3->PCIeFunction = PCIeFunctionV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunction")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeFunction"), "PCIeFunction"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeFunctionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeFunctionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeFunction_V1_2_3_JSON (*((EFI_REDFISH_PCIEFUNCTION_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeFunctionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTION_V1_2_3 *PCIeFunctionV1_2_3; + + PCIeFunctionV1_2_3 = (EFI_REDFISH_PCIEFUNCTION_V1_2_3 *)InterpProp; + DestroyPCIeFunction_V1_2_3_CS (PCIeFunctionV1_2_3->PCIeFunction); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeFunctionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeFunction_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeFunctionToStructWrapper, + PCIeFunctionToJson, + PCIeFunctionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunction_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeFunction/v1_2_3/RedfishPCIeFunction_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/PCIeFunction/v1_2_3/RedfishPCIeFunction_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..6066cd424d9 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunction/v1_2_3/RedfishPCIeFunction_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeFunction.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeFunction_V1_2_3_Dxe + FILE_GUID = 9aba3541-38b5-47ed-bf5e-2c4f32ff2033 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeFunction_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishPCIeFunction_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeFunction_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeFunctionV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeFunctionCollection/PCIeFunctionCollection_Dxe.c b/RedfishClientPkg/Converter/PCIeFunctionCollection/PCIeFunctionCollection_Dxe.c new file mode 100644 index 00000000000..fc784e2bb2e --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunctionCollection/PCIeFunctionCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeFunctionCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeFunctionCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support PCIeFunctionCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeFunctionCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "PCIeFunctionCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTIONCOLLECTION *PCIeFunctionCollection; + EFI_REDFISH_PCIEFUNCTIONCOLLECTION_CS *PCIeFunctionCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeFunctionCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeFunctionCollection_To_CS (ResoruceRaw, &PCIeFunctionCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeFunctionCollection = (EFI_REDFISH_PCIEFUNCTIONCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIEFUNCTIONCOLLECTION)); + if (PCIeFunctionCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeFunctionCollection; + PCIeFunctionCollection->PCIeFunctionCollection = PCIeFunctionCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunctionCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeFunctionCollection"), "PCIeFunctionCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeFunctionCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeFunctionCollection"), "PCIeFunctionCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeFunctionCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeFunctionCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeFunctionCollection_JSON (*((EFI_REDFISH_PCIEFUNCTIONCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeFunctionCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIEFUNCTIONCOLLECTION *PCIeFunctionCollection; + + PCIeFunctionCollection = (EFI_REDFISH_PCIEFUNCTIONCOLLECTION *)InterpProp; + DestroyPCIeFunctionCollection_CS (PCIeFunctionCollection->PCIeFunctionCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeFunctionCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeFunctionCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeFunctionCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunctionCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeFunctionCollectionToStructWrapper, + PCIeFunctionCollectionToJson, + PCIeFunctionCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeFunctionCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeFunctionCollection/RedfishPCIeFunctionCollection_Dxe.inf b/RedfishClientPkg/Converter/PCIeFunctionCollection/RedfishPCIeFunctionCollection_Dxe.inf new file mode 100644 index 00000000000..4550991c20c --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeFunctionCollection/RedfishPCIeFunctionCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeFunctionCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeFunctionCollection_Dxe + FILE_GUID = b7c0b348-f938-432a-9701-5b8fb3d57c0a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeFunctionCollectionEntryPoint + UNLOAD_IMAGE = RedfishPCIeFunctionCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeFunctionCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeFunctionCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeSlots/v1_0_0/PCIeSlots_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/PCIeSlots/v1_0_0/PCIeSlots_V1_0_0_Dxe.c new file mode 100644 index 00000000000..80243d5ee71 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeSlots/v1_0_0/PCIeSlots_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeSlots.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeSlots"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeSlots V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeSlots", + "1", + "0", + "0" + }, + "PCIeSlots" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIESLOTS_V1_0_0 *PCIeSlotsV1_0_0; + EFI_REDFISH_PCIESLOTS_V1_0_0_CS *PCIeSlotsV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeSlots") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeSlots_V1_0_0_To_CS (ResoruceRaw, &PCIeSlotsV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeSlotsV1_0_0 = (EFI_REDFISH_PCIESLOTS_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIESLOTS_V1_0_0)); + if (PCIeSlotsV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeSlotsV1_0_0; + PCIeSlotsV1_0_0->PCIeSlots = PCIeSlotsV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeSlots")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeSlots"), "PCIeSlots"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeSlots")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeSlots"), "PCIeSlots"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeSlotsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeSlotsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeSlots_V1_0_0_JSON (*((EFI_REDFISH_PCIESLOTS_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeSlotsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIESLOTS_V1_0_0 *PCIeSlotsV1_0_0; + + PCIeSlotsV1_0_0 = (EFI_REDFISH_PCIESLOTS_V1_0_0 *)InterpProp; + DestroyPCIeSlots_V1_0_0_CS (PCIeSlotsV1_0_0->PCIeSlots); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeSlotsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeSlots_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeSlots_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeSlotsToStructWrapper, + PCIeSlotsToJson, + PCIeSlotsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeSlots_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeSlots/v1_0_0/RedfishPCIeSlots_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/PCIeSlots/v1_0_0/RedfishPCIeSlots_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..5940292c46d --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeSlots/v1_0_0/RedfishPCIeSlots_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeSlots.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeSlots_V1_0_0_Dxe + FILE_GUID = 35490bf7-b034-4c08-863f-c4d9ad7b9494 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeSlots_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishPCIeSlots_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeSlots_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeSlotsV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeSlots/v1_0_1/PCIeSlots_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/PCIeSlots/v1_0_1/PCIeSlots_V1_0_1_Dxe.c new file mode 100644 index 00000000000..931fb364524 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeSlots/v1_0_1/PCIeSlots_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeSlots.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeSlots"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeSlots V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeSlots", + "1", + "0", + "1" + }, + "PCIeSlots" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIESLOTS_V1_0_1 *PCIeSlotsV1_0_1; + EFI_REDFISH_PCIESLOTS_V1_0_1_CS *PCIeSlotsV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeSlots") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeSlots_V1_0_1_To_CS (ResoruceRaw, &PCIeSlotsV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeSlotsV1_0_1 = (EFI_REDFISH_PCIESLOTS_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIESLOTS_V1_0_1)); + if (PCIeSlotsV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeSlotsV1_0_1; + PCIeSlotsV1_0_1->PCIeSlots = PCIeSlotsV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeSlots")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeSlots"), "PCIeSlots"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeSlots")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeSlots"), "PCIeSlots"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeSlotsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeSlotsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeSlots_V1_0_1_JSON (*((EFI_REDFISH_PCIESLOTS_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeSlotsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIESLOTS_V1_0_1 *PCIeSlotsV1_0_1; + + PCIeSlotsV1_0_1 = (EFI_REDFISH_PCIESLOTS_V1_0_1 *)InterpProp; + DestroyPCIeSlots_V1_0_1_CS (PCIeSlotsV1_0_1->PCIeSlots); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeSlotsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeSlots_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeSlots_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeSlotsToStructWrapper, + PCIeSlotsToJson, + PCIeSlotsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeSlots_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeSlots/v1_0_1/RedfishPCIeSlots_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/PCIeSlots/v1_0_1/RedfishPCIeSlots_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..5ed9ce52141 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeSlots/v1_0_1/RedfishPCIeSlots_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeSlots.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeSlots_V1_0_1_Dxe + FILE_GUID = f5d7c791-1ca6-4d05-9c8a-0db0570178f9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeSlots_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishPCIeSlots_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeSlots_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeSlotsV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeSlots/v1_0_2/PCIeSlots_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/PCIeSlots/v1_0_2/PCIeSlots_V1_0_2_Dxe.c new file mode 100644 index 00000000000..87e6f74d4b2 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeSlots/v1_0_2/PCIeSlots_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeSlots.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeSlots"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeSlots V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeSlots", + "1", + "0", + "2" + }, + "PCIeSlots" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIESLOTS_V1_0_2 *PCIeSlotsV1_0_2; + EFI_REDFISH_PCIESLOTS_V1_0_2_CS *PCIeSlotsV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeSlots") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeSlots_V1_0_2_To_CS (ResoruceRaw, &PCIeSlotsV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeSlotsV1_0_2 = (EFI_REDFISH_PCIESLOTS_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIESLOTS_V1_0_2)); + if (PCIeSlotsV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeSlotsV1_0_2; + PCIeSlotsV1_0_2->PCIeSlots = PCIeSlotsV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeSlots")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeSlots"), "PCIeSlots"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeSlots")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeSlots"), "PCIeSlots"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeSlotsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeSlotsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeSlots_V1_0_2_JSON (*((EFI_REDFISH_PCIESLOTS_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeSlotsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIESLOTS_V1_0_2 *PCIeSlotsV1_0_2; + + PCIeSlotsV1_0_2 = (EFI_REDFISH_PCIESLOTS_V1_0_2 *)InterpProp; + DestroyPCIeSlots_V1_0_2_CS (PCIeSlotsV1_0_2->PCIeSlots); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeSlotsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeSlots_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeSlots_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeSlotsToStructWrapper, + PCIeSlotsToJson, + PCIeSlotsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeSlots_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeSlots/v1_0_2/RedfishPCIeSlots_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/PCIeSlots/v1_0_2/RedfishPCIeSlots_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..cc92ffe8c1f --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeSlots/v1_0_2/RedfishPCIeSlots_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeSlots.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeSlots_V1_0_2_Dxe + FILE_GUID = 32384e9e-999f-4df9-b031-d5b83882012b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeSlots_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishPCIeSlots_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeSlots_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeSlotsV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeSlots/v1_0_3/PCIeSlots_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/PCIeSlots/v1_0_3/PCIeSlots_V1_0_3_Dxe.c new file mode 100644 index 00000000000..9effb8bbf6c --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeSlots/v1_0_3/PCIeSlots_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeSlots.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeSlots"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeSlots V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeSlots", + "1", + "0", + "3" + }, + "PCIeSlots" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIESLOTS_V1_0_3 *PCIeSlotsV1_0_3; + EFI_REDFISH_PCIESLOTS_V1_0_3_CS *PCIeSlotsV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeSlots") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeSlots_V1_0_3_To_CS (ResoruceRaw, &PCIeSlotsV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeSlotsV1_0_3 = (EFI_REDFISH_PCIESLOTS_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIESLOTS_V1_0_3)); + if (PCIeSlotsV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeSlotsV1_0_3; + PCIeSlotsV1_0_3->PCIeSlots = PCIeSlotsV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeSlots")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeSlots"), "PCIeSlots"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeSlots")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeSlots"), "PCIeSlots"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeSlotsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeSlotsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeSlots_V1_0_3_JSON (*((EFI_REDFISH_PCIESLOTS_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeSlotsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIESLOTS_V1_0_3 *PCIeSlotsV1_0_3; + + PCIeSlotsV1_0_3 = (EFI_REDFISH_PCIESLOTS_V1_0_3 *)InterpProp; + DestroyPCIeSlots_V1_0_3_CS (PCIeSlotsV1_0_3->PCIeSlots); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeSlotsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeSlots_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeSlots_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeSlotsToStructWrapper, + PCIeSlotsToJson, + PCIeSlotsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeSlots_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeSlots/v1_0_3/RedfishPCIeSlots_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/PCIeSlots/v1_0_3/RedfishPCIeSlots_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..c30c9cad868 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeSlots/v1_0_3/RedfishPCIeSlots_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeSlots.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeSlots_V1_0_3_Dxe + FILE_GUID = f7a326cc-4afc-440c-8da3-f9eb48928d09 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeSlots_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishPCIeSlots_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeSlots_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeSlotsV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeSlots/v1_1_0/PCIeSlots_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/PCIeSlots/v1_1_0/PCIeSlots_V1_1_0_Dxe.c new file mode 100644 index 00000000000..deffb8fa2b0 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeSlots/v1_1_0/PCIeSlots_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeSlots.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeSlots"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeSlots V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeSlots", + "1", + "1", + "0" + }, + "PCIeSlots" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIESLOTS_V1_1_0 *PCIeSlotsV1_1_0; + EFI_REDFISH_PCIESLOTS_V1_1_0_CS *PCIeSlotsV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeSlots") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeSlots_V1_1_0_To_CS (ResoruceRaw, &PCIeSlotsV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeSlotsV1_1_0 = (EFI_REDFISH_PCIESLOTS_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIESLOTS_V1_1_0)); + if (PCIeSlotsV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeSlotsV1_1_0; + PCIeSlotsV1_1_0->PCIeSlots = PCIeSlotsV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeSlots")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeSlots"), "PCIeSlots"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeSlots")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeSlots"), "PCIeSlots"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeSlotsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeSlotsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeSlots_V1_1_0_JSON (*((EFI_REDFISH_PCIESLOTS_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeSlotsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIESLOTS_V1_1_0 *PCIeSlotsV1_1_0; + + PCIeSlotsV1_1_0 = (EFI_REDFISH_PCIESLOTS_V1_1_0 *)InterpProp; + DestroyPCIeSlots_V1_1_0_CS (PCIeSlotsV1_1_0->PCIeSlots); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeSlotsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeSlots_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeSlots_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeSlotsToStructWrapper, + PCIeSlotsToJson, + PCIeSlotsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeSlots_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeSlots/v1_1_0/RedfishPCIeSlots_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/PCIeSlots/v1_1_0/RedfishPCIeSlots_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..cbd0a0097bd --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeSlots/v1_1_0/RedfishPCIeSlots_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeSlots.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeSlots_V1_1_0_Dxe + FILE_GUID = cbb6561b-ab59-47e7-9357-cd727809ee16 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeSlots_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishPCIeSlots_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeSlots_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeSlotsV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeSlots/v1_1_1/PCIeSlots_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/PCIeSlots/v1_1_1/PCIeSlots_V1_1_1_Dxe.c new file mode 100644 index 00000000000..77abdbeb6d1 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeSlots/v1_1_1/PCIeSlots_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeSlots.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeSlots"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeSlots V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeSlots", + "1", + "1", + "1" + }, + "PCIeSlots" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIESLOTS_V1_1_1 *PCIeSlotsV1_1_1; + EFI_REDFISH_PCIESLOTS_V1_1_1_CS *PCIeSlotsV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeSlots") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeSlots_V1_1_1_To_CS (ResoruceRaw, &PCIeSlotsV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeSlotsV1_1_1 = (EFI_REDFISH_PCIESLOTS_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIESLOTS_V1_1_1)); + if (PCIeSlotsV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeSlotsV1_1_1; + PCIeSlotsV1_1_1->PCIeSlots = PCIeSlotsV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeSlots")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeSlots"), "PCIeSlots"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeSlots")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeSlots"), "PCIeSlots"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeSlotsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeSlotsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeSlots_V1_1_1_JSON (*((EFI_REDFISH_PCIESLOTS_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeSlotsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIESLOTS_V1_1_1 *PCIeSlotsV1_1_1; + + PCIeSlotsV1_1_1 = (EFI_REDFISH_PCIESLOTS_V1_1_1 *)InterpProp; + DestroyPCIeSlots_V1_1_1_CS (PCIeSlotsV1_1_1->PCIeSlots); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeSlotsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeSlots_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeSlots_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeSlotsToStructWrapper, + PCIeSlotsToJson, + PCIeSlotsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeSlots_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeSlots/v1_1_1/RedfishPCIeSlots_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/PCIeSlots/v1_1_1/RedfishPCIeSlots_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..2538ae1fb3b --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeSlots/v1_1_1/RedfishPCIeSlots_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeSlots.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeSlots_V1_1_1_Dxe + FILE_GUID = c30c5854-26b6-4e0c-aa17-92f2156e8b4a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeSlots_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishPCIeSlots_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeSlots_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeSlotsV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeSlots/v1_1_2/PCIeSlots_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/PCIeSlots/v1_1_2/PCIeSlots_V1_1_2_Dxe.c new file mode 100644 index 00000000000..7b451d80f00 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeSlots/v1_1_2/PCIeSlots_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeSlots.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeSlots"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeSlots V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeSlots", + "1", + "1", + "2" + }, + "PCIeSlots" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIESLOTS_V1_1_2 *PCIeSlotsV1_1_2; + EFI_REDFISH_PCIESLOTS_V1_1_2_CS *PCIeSlotsV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeSlots") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeSlots_V1_1_2_To_CS (ResoruceRaw, &PCIeSlotsV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeSlotsV1_1_2 = (EFI_REDFISH_PCIESLOTS_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIESLOTS_V1_1_2)); + if (PCIeSlotsV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeSlotsV1_1_2; + PCIeSlotsV1_1_2->PCIeSlots = PCIeSlotsV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeSlots")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeSlots"), "PCIeSlots"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeSlots")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeSlots"), "PCIeSlots"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeSlotsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeSlotsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeSlots_V1_1_2_JSON (*((EFI_REDFISH_PCIESLOTS_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeSlotsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIESLOTS_V1_1_2 *PCIeSlotsV1_1_2; + + PCIeSlotsV1_1_2 = (EFI_REDFISH_PCIESLOTS_V1_1_2 *)InterpProp; + DestroyPCIeSlots_V1_1_2_CS (PCIeSlotsV1_1_2->PCIeSlots); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeSlotsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeSlots_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeSlots_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeSlotsToStructWrapper, + PCIeSlotsToJson, + PCIeSlotsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeSlots_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeSlots/v1_1_2/RedfishPCIeSlots_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/PCIeSlots/v1_1_2/RedfishPCIeSlots_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..ee6766995e8 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeSlots/v1_1_2/RedfishPCIeSlots_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeSlots.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeSlots_V1_1_2_Dxe + FILE_GUID = 4740368a-8543-4e36-9b38-b1c0d4652200 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeSlots_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishPCIeSlots_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeSlots_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeSlotsV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeSlots/v1_2_0/PCIeSlots_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/PCIeSlots/v1_2_0/PCIeSlots_V1_2_0_Dxe.c new file mode 100644 index 00000000000..4530f5a2aec --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeSlots/v1_2_0/PCIeSlots_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeSlots.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeSlots"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeSlots V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeSlots", + "1", + "2", + "0" + }, + "PCIeSlots" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIESLOTS_V1_2_0 *PCIeSlotsV1_2_0; + EFI_REDFISH_PCIESLOTS_V1_2_0_CS *PCIeSlotsV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeSlots") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeSlots_V1_2_0_To_CS (ResoruceRaw, &PCIeSlotsV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeSlotsV1_2_0 = (EFI_REDFISH_PCIESLOTS_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIESLOTS_V1_2_0)); + if (PCIeSlotsV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeSlotsV1_2_0; + PCIeSlotsV1_2_0->PCIeSlots = PCIeSlotsV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeSlots")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeSlots"), "PCIeSlots"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeSlots")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeSlots"), "PCIeSlots"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeSlotsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeSlotsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeSlots_V1_2_0_JSON (*((EFI_REDFISH_PCIESLOTS_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeSlotsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIESLOTS_V1_2_0 *PCIeSlotsV1_2_0; + + PCIeSlotsV1_2_0 = (EFI_REDFISH_PCIESLOTS_V1_2_0 *)InterpProp; + DestroyPCIeSlots_V1_2_0_CS (PCIeSlotsV1_2_0->PCIeSlots); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeSlotsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeSlots_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeSlots_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeSlotsToStructWrapper, + PCIeSlotsToJson, + PCIeSlotsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeSlots_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeSlots/v1_2_0/RedfishPCIeSlots_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/PCIeSlots/v1_2_0/RedfishPCIeSlots_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..d3c62d75689 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeSlots/v1_2_0/RedfishPCIeSlots_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeSlots.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeSlots_V1_2_0_Dxe + FILE_GUID = 9b56240d-ba94-4bce-bdee-c1fd8f69945c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeSlots_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishPCIeSlots_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeSlots_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeSlotsV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeSlots/v1_3_0/PCIeSlots_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/PCIeSlots/v1_3_0/PCIeSlots_V1_3_0_Dxe.c new file mode 100644 index 00000000000..5c6a64645cf --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeSlots/v1_3_0/PCIeSlots_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeSlots.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeSlots"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeSlots V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeSlots", + "1", + "3", + "0" + }, + "PCIeSlots" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIESLOTS_V1_3_0 *PCIeSlotsV1_3_0; + EFI_REDFISH_PCIESLOTS_V1_3_0_CS *PCIeSlotsV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeSlots") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeSlots_V1_3_0_To_CS (ResoruceRaw, &PCIeSlotsV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeSlotsV1_3_0 = (EFI_REDFISH_PCIESLOTS_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIESLOTS_V1_3_0)); + if (PCIeSlotsV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeSlotsV1_3_0; + PCIeSlotsV1_3_0->PCIeSlots = PCIeSlotsV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeSlots")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeSlots"), "PCIeSlots"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeSlots")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeSlots"), "PCIeSlots"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeSlotsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeSlotsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeSlots_V1_3_0_JSON (*((EFI_REDFISH_PCIESLOTS_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeSlotsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIESLOTS_V1_3_0 *PCIeSlotsV1_3_0; + + PCIeSlotsV1_3_0 = (EFI_REDFISH_PCIESLOTS_V1_3_0 *)InterpProp; + DestroyPCIeSlots_V1_3_0_CS (PCIeSlotsV1_3_0->PCIeSlots); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeSlotsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeSlots_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeSlots_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeSlotsToStructWrapper, + PCIeSlotsToJson, + PCIeSlotsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeSlots_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeSlots/v1_3_0/RedfishPCIeSlots_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/PCIeSlots/v1_3_0/RedfishPCIeSlots_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..f0d06b9b5ea --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeSlots/v1_3_0/RedfishPCIeSlots_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeSlots.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeSlots_V1_3_0_Dxe + FILE_GUID = 82c0acb7-4751-47e3-b5af-7fb311392e84 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeSlots_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishPCIeSlots_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeSlots_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeSlotsV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeSlots/v1_4_0/PCIeSlots_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/PCIeSlots/v1_4_0/PCIeSlots_V1_4_0_Dxe.c new file mode 100644 index 00000000000..2395c1200d2 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeSlots/v1_4_0/PCIeSlots_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeSlots.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeSlots"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeSlots V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeSlots", + "1", + "4", + "0" + }, + "PCIeSlots" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIESLOTS_V1_4_0 *PCIeSlotsV1_4_0; + EFI_REDFISH_PCIESLOTS_V1_4_0_CS *PCIeSlotsV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeSlots") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeSlots_V1_4_0_To_CS (ResoruceRaw, &PCIeSlotsV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeSlotsV1_4_0 = (EFI_REDFISH_PCIESLOTS_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIESLOTS_V1_4_0)); + if (PCIeSlotsV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeSlotsV1_4_0; + PCIeSlotsV1_4_0->PCIeSlots = PCIeSlotsV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeSlots")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeSlots"), "PCIeSlots"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeSlots")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeSlots"), "PCIeSlots"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeSlotsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeSlotsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeSlots_V1_4_0_JSON (*((EFI_REDFISH_PCIESLOTS_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeSlotsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIESLOTS_V1_4_0 *PCIeSlotsV1_4_0; + + PCIeSlotsV1_4_0 = (EFI_REDFISH_PCIESLOTS_V1_4_0 *)InterpProp; + DestroyPCIeSlots_V1_4_0_CS (PCIeSlotsV1_4_0->PCIeSlots); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeSlotsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeSlots_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeSlots_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeSlotsToStructWrapper, + PCIeSlotsToJson, + PCIeSlotsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeSlots_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeSlots/v1_4_0/RedfishPCIeSlots_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/PCIeSlots/v1_4_0/RedfishPCIeSlots_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..d2bacbcca79 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeSlots/v1_4_0/RedfishPCIeSlots_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeSlots.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeSlots_V1_4_0_Dxe + FILE_GUID = c89fe8aa-a813-4868-8ce0-62a4c451fd5a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeSlots_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishPCIeSlots_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeSlots_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeSlotsV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PCIeSlots/v1_4_1/PCIeSlots_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/PCIeSlots/v1_4_1/PCIeSlots_V1_4_1_Dxe.c new file mode 100644 index 00000000000..f135ee06bdd --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeSlots/v1_4_1/PCIeSlots_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PCIeSlots.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PCIeSlots"; +BOOLEAN IsRevisonController = TRUE; + +// Support PCIeSlots V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PCIeSlots", + "1", + "4", + "1" + }, + "PCIeSlots" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PCIESLOTS_V1_4_1 *PCIeSlotsV1_4_1; + EFI_REDFISH_PCIESLOTS_V1_4_1_CS *PCIeSlotsV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PCIeSlots") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PCIeSlots_V1_4_1_To_CS (ResoruceRaw, &PCIeSlotsV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PCIeSlotsV1_4_1 = (EFI_REDFISH_PCIESLOTS_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PCIESLOTS_V1_4_1)); + if (PCIeSlotsV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PCIeSlotsV1_4_1; + PCIeSlotsV1_4_1->PCIeSlots = PCIeSlotsV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeSlots")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PCIeSlots"), "PCIeSlots"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PCIeSlots")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PCIeSlots"), "PCIeSlots"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PCIeSlotsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PCIeSlotsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PCIeSlots_V1_4_1_JSON (*((EFI_REDFISH_PCIESLOTS_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PCIeSlotsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PCIESLOTS_V1_4_1 *PCIeSlotsV1_4_1; + + PCIeSlotsV1_4_1 = (EFI_REDFISH_PCIESLOTS_V1_4_1 *)InterpProp; + DestroyPCIeSlots_V1_4_1_CS (PCIeSlotsV1_4_1->PCIeSlots); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PCIeSlotsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PCIeSlotsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPCIeSlots_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPCIeSlots_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PCIeSlotsToStructWrapper, + PCIeSlotsToJson, + PCIeSlotsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPCIeSlots_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PCIeSlots/v1_4_1/RedfishPCIeSlots_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/PCIeSlots/v1_4_1/RedfishPCIeSlots_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..0bf94c03621 --- /dev/null +++ b/RedfishClientPkg/Converter/PCIeSlots/v1_4_1/RedfishPCIeSlots_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PCIeSlots.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPCIeSlots_V1_4_1_Dxe + FILE_GUID = 3ca3dc73-3435-4ec9-8819-9134d14b3bfb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPCIeSlots_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishPCIeSlots_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PCIeSlots_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PCIeSlotsV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Port/v1_0_0/Port_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Port/v1_0_0/Port_V1_0_0_Dxe.c new file mode 100644 index 00000000000..b5be5076386 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_0_0/Port_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Port.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Port"; +BOOLEAN IsRevisonController = TRUE; + +// Support Port V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Port", + "1", + "0", + "0" + }, + "Port" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PORT_V1_0_0 *PortV1_0_0; + EFI_REDFISH_PORT_V1_0_0_CS *PortV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Port") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Port_V1_0_0_To_CS (ResoruceRaw, &PortV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PortV1_0_0 = (EFI_REDFISH_PORT_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PORT_V1_0_0)); + if (PortV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PortV1_0_0; + PortV1_0_0->Port = PortV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Port"), "Port"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Port"), "Port"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Port_V1_0_0_JSON (*((EFI_REDFISH_PORT_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PORT_V1_0_0 *PortV1_0_0; + + PortV1_0_0 = (EFI_REDFISH_PORT_V1_0_0 *)InterpProp; + DestroyPort_V1_0_0_CS (PortV1_0_0->Port); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPort_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PortToStructWrapper, + PortToJson, + PortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Port/v1_0_0/RedfishPort_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Port/v1_0_0/RedfishPort_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..b7e443cefa4 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_0_0/RedfishPort_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Port.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPort_V1_0_0_Dxe + FILE_GUID = d130ae43-3680-4d18-af6b-89b344088020 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPort_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishPort_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Port_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PortV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Port/v1_0_1/Port_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/Port/v1_0_1/Port_V1_0_1_Dxe.c new file mode 100644 index 00000000000..70cd479037f --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_0_1/Port_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Port.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Port"; +BOOLEAN IsRevisonController = TRUE; + +// Support Port V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Port", + "1", + "0", + "1" + }, + "Port" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PORT_V1_0_1 *PortV1_0_1; + EFI_REDFISH_PORT_V1_0_1_CS *PortV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Port") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Port_V1_0_1_To_CS (ResoruceRaw, &PortV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PortV1_0_1 = (EFI_REDFISH_PORT_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PORT_V1_0_1)); + if (PortV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PortV1_0_1; + PortV1_0_1->Port = PortV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Port"), "Port"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Port"), "Port"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Port_V1_0_1_JSON (*((EFI_REDFISH_PORT_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PORT_V1_0_1 *PortV1_0_1; + + PortV1_0_1 = (EFI_REDFISH_PORT_V1_0_1 *)InterpProp; + DestroyPort_V1_0_1_CS (PortV1_0_1->Port); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPort_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PortToStructWrapper, + PortToJson, + PortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Port/v1_0_1/RedfishPort_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/Port/v1_0_1/RedfishPort_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..4c7580cb7a4 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_0_1/RedfishPort_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Port.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPort_V1_0_1_Dxe + FILE_GUID = 3554e5ef-7fa8-44c9-a647-5f2c4859a1f7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPort_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishPort_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Port_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PortV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Port/v1_0_2/Port_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Port/v1_0_2/Port_V1_0_2_Dxe.c new file mode 100644 index 00000000000..10fae69665c --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_0_2/Port_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Port.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Port"; +BOOLEAN IsRevisonController = TRUE; + +// Support Port V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Port", + "1", + "0", + "2" + }, + "Port" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PORT_V1_0_2 *PortV1_0_2; + EFI_REDFISH_PORT_V1_0_2_CS *PortV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Port") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Port_V1_0_2_To_CS (ResoruceRaw, &PortV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PortV1_0_2 = (EFI_REDFISH_PORT_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PORT_V1_0_2)); + if (PortV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PortV1_0_2; + PortV1_0_2->Port = PortV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Port"), "Port"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Port"), "Port"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Port_V1_0_2_JSON (*((EFI_REDFISH_PORT_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PORT_V1_0_2 *PortV1_0_2; + + PortV1_0_2 = (EFI_REDFISH_PORT_V1_0_2 *)InterpProp; + DestroyPort_V1_0_2_CS (PortV1_0_2->Port); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPort_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PortToStructWrapper, + PortToJson, + PortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Port/v1_0_2/RedfishPort_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Port/v1_0_2/RedfishPort_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..4fff836f97b --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_0_2/RedfishPort_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Port.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPort_V1_0_2_Dxe + FILE_GUID = 72dca3fd-1783-46b1-bd38-7d48a167fb82 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPort_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishPort_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Port_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PortV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Port/v1_0_3/Port_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/Port/v1_0_3/Port_V1_0_3_Dxe.c new file mode 100644 index 00000000000..7ce8972736b --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_0_3/Port_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Port.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Port"; +BOOLEAN IsRevisonController = TRUE; + +// Support Port V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Port", + "1", + "0", + "3" + }, + "Port" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PORT_V1_0_3 *PortV1_0_3; + EFI_REDFISH_PORT_V1_0_3_CS *PortV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Port") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Port_V1_0_3_To_CS (ResoruceRaw, &PortV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PortV1_0_3 = (EFI_REDFISH_PORT_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PORT_V1_0_3)); + if (PortV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PortV1_0_3; + PortV1_0_3->Port = PortV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Port"), "Port"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Port"), "Port"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Port_V1_0_3_JSON (*((EFI_REDFISH_PORT_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PORT_V1_0_3 *PortV1_0_3; + + PortV1_0_3 = (EFI_REDFISH_PORT_V1_0_3 *)InterpProp; + DestroyPort_V1_0_3_CS (PortV1_0_3->Port); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPort_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PortToStructWrapper, + PortToJson, + PortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Port/v1_0_3/RedfishPort_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/Port/v1_0_3/RedfishPort_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..7fa4072bf85 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_0_3/RedfishPort_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Port.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPort_V1_0_3_Dxe + FILE_GUID = 29dbaac8-e179-456d-92b1-40f6857e1bf9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPort_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishPort_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Port_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PortV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Port/v1_0_4/Port_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/Port/v1_0_4/Port_V1_0_4_Dxe.c new file mode 100644 index 00000000000..fb0d4cc8427 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_0_4/Port_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Port.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Port"; +BOOLEAN IsRevisonController = TRUE; + +// Support Port V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Port", + "1", + "0", + "4" + }, + "Port" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PORT_V1_0_4 *PortV1_0_4; + EFI_REDFISH_PORT_V1_0_4_CS *PortV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Port") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Port_V1_0_4_To_CS (ResoruceRaw, &PortV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PortV1_0_4 = (EFI_REDFISH_PORT_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PORT_V1_0_4)); + if (PortV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PortV1_0_4; + PortV1_0_4->Port = PortV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Port"), "Port"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Port"), "Port"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Port_V1_0_4_JSON (*((EFI_REDFISH_PORT_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PORT_V1_0_4 *PortV1_0_4; + + PortV1_0_4 = (EFI_REDFISH_PORT_V1_0_4 *)InterpProp; + DestroyPort_V1_0_4_CS (PortV1_0_4->Port); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPort_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PortToStructWrapper, + PortToJson, + PortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Port/v1_0_4/RedfishPort_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/Port/v1_0_4/RedfishPort_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..afe0d4e430d --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_0_4/RedfishPort_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Port.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPort_V1_0_4_Dxe + FILE_GUID = b5e9d46a-baae-4751-8170-1d2217cf8dd7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPort_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishPort_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Port_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PortV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Port/v1_0_5/Port_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/Port/v1_0_5/Port_V1_0_5_Dxe.c new file mode 100644 index 00000000000..181fe317fe4 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_0_5/Port_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Port.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Port"; +BOOLEAN IsRevisonController = TRUE; + +// Support Port V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Port", + "1", + "0", + "5" + }, + "Port" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PORT_V1_0_5 *PortV1_0_5; + EFI_REDFISH_PORT_V1_0_5_CS *PortV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Port") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Port_V1_0_5_To_CS (ResoruceRaw, &PortV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PortV1_0_5 = (EFI_REDFISH_PORT_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PORT_V1_0_5)); + if (PortV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PortV1_0_5; + PortV1_0_5->Port = PortV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Port"), "Port"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Port"), "Port"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Port_V1_0_5_JSON (*((EFI_REDFISH_PORT_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PORT_V1_0_5 *PortV1_0_5; + + PortV1_0_5 = (EFI_REDFISH_PORT_V1_0_5 *)InterpProp; + DestroyPort_V1_0_5_CS (PortV1_0_5->Port); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPort_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PortToStructWrapper, + PortToJson, + PortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Port/v1_0_5/RedfishPort_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/Port/v1_0_5/RedfishPort_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..d61ac28c753 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_0_5/RedfishPort_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Port.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPort_V1_0_5_Dxe + FILE_GUID = c43d4660-b6aa-4673-b77a-2c8dcb8d2a11 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPort_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishPort_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Port_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PortV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Port/v1_0_6/Port_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/Port/v1_0_6/Port_V1_0_6_Dxe.c new file mode 100644 index 00000000000..0a9fd9455a0 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_0_6/Port_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Port.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Port"; +BOOLEAN IsRevisonController = TRUE; + +// Support Port V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Port", + "1", + "0", + "6" + }, + "Port" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PORT_V1_0_6 *PortV1_0_6; + EFI_REDFISH_PORT_V1_0_6_CS *PortV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Port") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Port_V1_0_6_To_CS (ResoruceRaw, &PortV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PortV1_0_6 = (EFI_REDFISH_PORT_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PORT_V1_0_6)); + if (PortV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PortV1_0_6; + PortV1_0_6->Port = PortV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Port"), "Port"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Port"), "Port"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Port_V1_0_6_JSON (*((EFI_REDFISH_PORT_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PORT_V1_0_6 *PortV1_0_6; + + PortV1_0_6 = (EFI_REDFISH_PORT_V1_0_6 *)InterpProp; + DestroyPort_V1_0_6_CS (PortV1_0_6->Port); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPort_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PortToStructWrapper, + PortToJson, + PortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Port/v1_0_6/RedfishPort_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/Port/v1_0_6/RedfishPort_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..a395c57533d --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_0_6/RedfishPort_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Port.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPort_V1_0_6_Dxe + FILE_GUID = 75084345-dd34-4052-94c6-7b4b74df006a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPort_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishPort_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Port_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PortV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Port/v1_0_7/Port_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/Port/v1_0_7/Port_V1_0_7_Dxe.c new file mode 100644 index 00000000000..f177179ef2d --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_0_7/Port_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Port.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Port"; +BOOLEAN IsRevisonController = TRUE; + +// Support Port V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Port", + "1", + "0", + "7" + }, + "Port" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PORT_V1_0_7 *PortV1_0_7; + EFI_REDFISH_PORT_V1_0_7_CS *PortV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Port") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Port_V1_0_7_To_CS (ResoruceRaw, &PortV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PortV1_0_7 = (EFI_REDFISH_PORT_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PORT_V1_0_7)); + if (PortV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PortV1_0_7; + PortV1_0_7->Port = PortV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Port"), "Port"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Port"), "Port"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Port_V1_0_7_JSON (*((EFI_REDFISH_PORT_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PORT_V1_0_7 *PortV1_0_7; + + PortV1_0_7 = (EFI_REDFISH_PORT_V1_0_7 *)InterpProp; + DestroyPort_V1_0_7_CS (PortV1_0_7->Port); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPort_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PortToStructWrapper, + PortToJson, + PortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Port/v1_0_7/RedfishPort_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/Port/v1_0_7/RedfishPort_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..43137bda323 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_0_7/RedfishPort_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Port.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPort_V1_0_7_Dxe + FILE_GUID = 493a0ecb-d731-4bb0-b0dc-e6a7c7e2e09e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPort_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishPort_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Port_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PortV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Port/v1_0_8/Port_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/Port/v1_0_8/Port_V1_0_8_Dxe.c new file mode 100644 index 00000000000..a17cacaca93 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_0_8/Port_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Port.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Port"; +BOOLEAN IsRevisonController = TRUE; + +// Support Port V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Port", + "1", + "0", + "8" + }, + "Port" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PORT_V1_0_8 *PortV1_0_8; + EFI_REDFISH_PORT_V1_0_8_CS *PortV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Port") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Port_V1_0_8_To_CS (ResoruceRaw, &PortV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PortV1_0_8 = (EFI_REDFISH_PORT_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PORT_V1_0_8)); + if (PortV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PortV1_0_8; + PortV1_0_8->Port = PortV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Port"), "Port"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Port"), "Port"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Port_V1_0_8_JSON (*((EFI_REDFISH_PORT_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PORT_V1_0_8 *PortV1_0_8; + + PortV1_0_8 = (EFI_REDFISH_PORT_V1_0_8 *)InterpProp; + DestroyPort_V1_0_8_CS (PortV1_0_8->Port); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPort_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PortToStructWrapper, + PortToJson, + PortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Port/v1_0_8/RedfishPort_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/Port/v1_0_8/RedfishPort_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..92b9fbf632f --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_0_8/RedfishPort_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Port.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPort_V1_0_8_Dxe + FILE_GUID = 69894d2f-7ebc-4af0-afc5-84c4b9b0ea08 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPort_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishPort_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Port_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PortV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Port/v1_1_0/Port_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/Port/v1_1_0/Port_V1_1_0_Dxe.c new file mode 100644 index 00000000000..f2102e462ee --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_1_0/Port_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Port.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Port"; +BOOLEAN IsRevisonController = TRUE; + +// Support Port V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Port", + "1", + "1", + "0" + }, + "Port" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PORT_V1_1_0 *PortV1_1_0; + EFI_REDFISH_PORT_V1_1_0_CS *PortV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Port") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Port_V1_1_0_To_CS (ResoruceRaw, &PortV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PortV1_1_0 = (EFI_REDFISH_PORT_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PORT_V1_1_0)); + if (PortV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PortV1_1_0; + PortV1_1_0->Port = PortV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Port"), "Port"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Port"), "Port"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Port_V1_1_0_JSON (*((EFI_REDFISH_PORT_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PORT_V1_1_0 *PortV1_1_0; + + PortV1_1_0 = (EFI_REDFISH_PORT_V1_1_0 *)InterpProp; + DestroyPort_V1_1_0_CS (PortV1_1_0->Port); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPort_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PortToStructWrapper, + PortToJson, + PortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Port/v1_1_0/RedfishPort_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/Port/v1_1_0/RedfishPort_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..f4359c7ccf0 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_1_0/RedfishPort_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Port.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPort_V1_1_0_Dxe + FILE_GUID = 0cea2fe0-98b3-4fb8-a1de-cfdc1ee2dbf0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPort_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishPort_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Port_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PortV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Port/v1_1_1/Port_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/Port/v1_1_1/Port_V1_1_1_Dxe.c new file mode 100644 index 00000000000..712c2b2fa52 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_1_1/Port_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Port.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Port"; +BOOLEAN IsRevisonController = TRUE; + +// Support Port V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Port", + "1", + "1", + "1" + }, + "Port" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PORT_V1_1_1 *PortV1_1_1; + EFI_REDFISH_PORT_V1_1_1_CS *PortV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Port") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Port_V1_1_1_To_CS (ResoruceRaw, &PortV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PortV1_1_1 = (EFI_REDFISH_PORT_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PORT_V1_1_1)); + if (PortV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PortV1_1_1; + PortV1_1_1->Port = PortV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Port"), "Port"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Port"), "Port"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Port_V1_1_1_JSON (*((EFI_REDFISH_PORT_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PORT_V1_1_1 *PortV1_1_1; + + PortV1_1_1 = (EFI_REDFISH_PORT_V1_1_1 *)InterpProp; + DestroyPort_V1_1_1_CS (PortV1_1_1->Port); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPort_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PortToStructWrapper, + PortToJson, + PortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Port/v1_1_1/RedfishPort_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/Port/v1_1_1/RedfishPort_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..7137729ff30 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_1_1/RedfishPort_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Port.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPort_V1_1_1_Dxe + FILE_GUID = 61d0dc79-e5c9-4388-a586-25bae4b2fdb6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPort_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishPort_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Port_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PortV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Port/v1_1_2/Port_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/Port/v1_1_2/Port_V1_1_2_Dxe.c new file mode 100644 index 00000000000..281c8a8c249 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_1_2/Port_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Port.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Port"; +BOOLEAN IsRevisonController = TRUE; + +// Support Port V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Port", + "1", + "1", + "2" + }, + "Port" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PORT_V1_1_2 *PortV1_1_2; + EFI_REDFISH_PORT_V1_1_2_CS *PortV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Port") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Port_V1_1_2_To_CS (ResoruceRaw, &PortV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PortV1_1_2 = (EFI_REDFISH_PORT_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PORT_V1_1_2)); + if (PortV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PortV1_1_2; + PortV1_1_2->Port = PortV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Port"), "Port"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Port"), "Port"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Port_V1_1_2_JSON (*((EFI_REDFISH_PORT_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PORT_V1_1_2 *PortV1_1_2; + + PortV1_1_2 = (EFI_REDFISH_PORT_V1_1_2 *)InterpProp; + DestroyPort_V1_1_2_CS (PortV1_1_2->Port); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPort_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PortToStructWrapper, + PortToJson, + PortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Port/v1_1_2/RedfishPort_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/Port/v1_1_2/RedfishPort_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..5d347845c9a --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_1_2/RedfishPort_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Port.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPort_V1_1_2_Dxe + FILE_GUID = 7271cbb0-c563-4780-9d80-e82e3215644d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPort_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishPort_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Port_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PortV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Port/v1_1_3/Port_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/Port/v1_1_3/Port_V1_1_3_Dxe.c new file mode 100644 index 00000000000..9381b7e13f8 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_1_3/Port_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Port.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Port"; +BOOLEAN IsRevisonController = TRUE; + +// Support Port V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Port", + "1", + "1", + "3" + }, + "Port" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PORT_V1_1_3 *PortV1_1_3; + EFI_REDFISH_PORT_V1_1_3_CS *PortV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Port") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Port_V1_1_3_To_CS (ResoruceRaw, &PortV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PortV1_1_3 = (EFI_REDFISH_PORT_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PORT_V1_1_3)); + if (PortV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PortV1_1_3; + PortV1_1_3->Port = PortV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Port"), "Port"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Port"), "Port"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Port_V1_1_3_JSON (*((EFI_REDFISH_PORT_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PORT_V1_1_3 *PortV1_1_3; + + PortV1_1_3 = (EFI_REDFISH_PORT_V1_1_3 *)InterpProp; + DestroyPort_V1_1_3_CS (PortV1_1_3->Port); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPort_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PortToStructWrapper, + PortToJson, + PortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Port/v1_1_3/RedfishPort_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/Port/v1_1_3/RedfishPort_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..b3b1ba2bd6a --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_1_3/RedfishPort_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Port.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPort_V1_1_3_Dxe + FILE_GUID = 7725bf37-c52d-43d1-8718-8fb418cf01e8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPort_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishPort_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Port_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PortV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Port/v1_1_4/Port_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/Port/v1_1_4/Port_V1_1_4_Dxe.c new file mode 100644 index 00000000000..e3dd3026f67 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_1_4/Port_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Port.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Port"; +BOOLEAN IsRevisonController = TRUE; + +// Support Port V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Port", + "1", + "1", + "4" + }, + "Port" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PORT_V1_1_4 *PortV1_1_4; + EFI_REDFISH_PORT_V1_1_4_CS *PortV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Port") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Port_V1_1_4_To_CS (ResoruceRaw, &PortV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PortV1_1_4 = (EFI_REDFISH_PORT_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PORT_V1_1_4)); + if (PortV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PortV1_1_4; + PortV1_1_4->Port = PortV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Port"), "Port"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Port"), "Port"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Port_V1_1_4_JSON (*((EFI_REDFISH_PORT_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PORT_V1_1_4 *PortV1_1_4; + + PortV1_1_4 = (EFI_REDFISH_PORT_V1_1_4 *)InterpProp; + DestroyPort_V1_1_4_CS (PortV1_1_4->Port); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPort_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PortToStructWrapper, + PortToJson, + PortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Port/v1_1_4/RedfishPort_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/Port/v1_1_4/RedfishPort_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..fb2f0cb1e81 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_1_4/RedfishPort_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Port.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPort_V1_1_4_Dxe + FILE_GUID = 9be3d573-ebf5-43f9-ba53-ac24139a154a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPort_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishPort_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Port_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PortV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Port/v1_1_5/Port_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/Port/v1_1_5/Port_V1_1_5_Dxe.c new file mode 100644 index 00000000000..34cf4bf2e76 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_1_5/Port_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Port.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Port"; +BOOLEAN IsRevisonController = TRUE; + +// Support Port V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Port", + "1", + "1", + "5" + }, + "Port" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PORT_V1_1_5 *PortV1_1_5; + EFI_REDFISH_PORT_V1_1_5_CS *PortV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Port") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Port_V1_1_5_To_CS (ResoruceRaw, &PortV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PortV1_1_5 = (EFI_REDFISH_PORT_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PORT_V1_1_5)); + if (PortV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PortV1_1_5; + PortV1_1_5->Port = PortV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Port"), "Port"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Port"), "Port"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Port_V1_1_5_JSON (*((EFI_REDFISH_PORT_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PORT_V1_1_5 *PortV1_1_5; + + PortV1_1_5 = (EFI_REDFISH_PORT_V1_1_5 *)InterpProp; + DestroyPort_V1_1_5_CS (PortV1_1_5->Port); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPort_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PortToStructWrapper, + PortToJson, + PortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Port/v1_1_5/RedfishPort_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/Port/v1_1_5/RedfishPort_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..b03722d4a09 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_1_5/RedfishPort_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Port.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPort_V1_1_5_Dxe + FILE_GUID = f510b49b-69a9-4d93-8fd4-5eebbb478447 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPort_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishPort_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Port_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PortV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Port/v1_2_0/Port_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/Port/v1_2_0/Port_V1_2_0_Dxe.c new file mode 100644 index 00000000000..8ea6a1d51e2 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_2_0/Port_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Port.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Port"; +BOOLEAN IsRevisonController = TRUE; + +// Support Port V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Port", + "1", + "2", + "0" + }, + "Port" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PORT_V1_2_0 *PortV1_2_0; + EFI_REDFISH_PORT_V1_2_0_CS *PortV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Port") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Port_V1_2_0_To_CS (ResoruceRaw, &PortV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PortV1_2_0 = (EFI_REDFISH_PORT_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PORT_V1_2_0)); + if (PortV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PortV1_2_0; + PortV1_2_0->Port = PortV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Port"), "Port"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Port"), "Port"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Port_V1_2_0_JSON (*((EFI_REDFISH_PORT_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PORT_V1_2_0 *PortV1_2_0; + + PortV1_2_0 = (EFI_REDFISH_PORT_V1_2_0 *)InterpProp; + DestroyPort_V1_2_0_CS (PortV1_2_0->Port); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPort_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PortToStructWrapper, + PortToJson, + PortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Port/v1_2_0/RedfishPort_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/Port/v1_2_0/RedfishPort_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..7cb75994af7 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_2_0/RedfishPort_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Port.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPort_V1_2_0_Dxe + FILE_GUID = cd76e7a5-1df2-414f-af0b-ebcfc0c55ccc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPort_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishPort_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Port_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PortV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Port/v1_2_1/Port_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/Port/v1_2_1/Port_V1_2_1_Dxe.c new file mode 100644 index 00000000000..bc386436442 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_2_1/Port_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Port.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Port"; +BOOLEAN IsRevisonController = TRUE; + +// Support Port V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Port", + "1", + "2", + "1" + }, + "Port" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PORT_V1_2_1 *PortV1_2_1; + EFI_REDFISH_PORT_V1_2_1_CS *PortV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Port") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Port_V1_2_1_To_CS (ResoruceRaw, &PortV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PortV1_2_1 = (EFI_REDFISH_PORT_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PORT_V1_2_1)); + if (PortV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PortV1_2_1; + PortV1_2_1->Port = PortV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Port"), "Port"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Port"), "Port"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Port_V1_2_1_JSON (*((EFI_REDFISH_PORT_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PORT_V1_2_1 *PortV1_2_1; + + PortV1_2_1 = (EFI_REDFISH_PORT_V1_2_1 *)InterpProp; + DestroyPort_V1_2_1_CS (PortV1_2_1->Port); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPort_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PortToStructWrapper, + PortToJson, + PortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Port/v1_2_1/RedfishPort_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/Port/v1_2_1/RedfishPort_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..4c3d5137f39 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_2_1/RedfishPort_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Port.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPort_V1_2_1_Dxe + FILE_GUID = f721130b-c886-43d5-8cfa-7be8694e9671 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPort_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishPort_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Port_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PortV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Port/v1_2_2/Port_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/Port/v1_2_2/Port_V1_2_2_Dxe.c new file mode 100644 index 00000000000..d00126f806d --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_2_2/Port_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Port.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Port"; +BOOLEAN IsRevisonController = TRUE; + +// Support Port V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Port", + "1", + "2", + "2" + }, + "Port" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PORT_V1_2_2 *PortV1_2_2; + EFI_REDFISH_PORT_V1_2_2_CS *PortV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Port") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Port_V1_2_2_To_CS (ResoruceRaw, &PortV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PortV1_2_2 = (EFI_REDFISH_PORT_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PORT_V1_2_2)); + if (PortV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PortV1_2_2; + PortV1_2_2->Port = PortV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Port"), "Port"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Port"), "Port"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Port_V1_2_2_JSON (*((EFI_REDFISH_PORT_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PORT_V1_2_2 *PortV1_2_2; + + PortV1_2_2 = (EFI_REDFISH_PORT_V1_2_2 *)InterpProp; + DestroyPort_V1_2_2_CS (PortV1_2_2->Port); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPort_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PortToStructWrapper, + PortToJson, + PortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Port/v1_2_2/RedfishPort_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/Port/v1_2_2/RedfishPort_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..09f8e53e9e0 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_2_2/RedfishPort_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Port.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPort_V1_2_2_Dxe + FILE_GUID = 279abb6f-70b3-41c3-b434-53a495ad68b1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPort_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishPort_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Port_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PortV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Port/v1_2_3/Port_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/Port/v1_2_3/Port_V1_2_3_Dxe.c new file mode 100644 index 00000000000..fe8aa68a953 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_2_3/Port_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Port.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Port"; +BOOLEAN IsRevisonController = TRUE; + +// Support Port V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Port", + "1", + "2", + "3" + }, + "Port" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PORT_V1_2_3 *PortV1_2_3; + EFI_REDFISH_PORT_V1_2_3_CS *PortV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Port") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Port_V1_2_3_To_CS (ResoruceRaw, &PortV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PortV1_2_3 = (EFI_REDFISH_PORT_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PORT_V1_2_3)); + if (PortV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PortV1_2_3; + PortV1_2_3->Port = PortV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Port"), "Port"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Port"), "Port"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Port_V1_2_3_JSON (*((EFI_REDFISH_PORT_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PORT_V1_2_3 *PortV1_2_3; + + PortV1_2_3 = (EFI_REDFISH_PORT_V1_2_3 *)InterpProp; + DestroyPort_V1_2_3_CS (PortV1_2_3->Port); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPort_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PortToStructWrapper, + PortToJson, + PortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Port/v1_2_3/RedfishPort_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/Port/v1_2_3/RedfishPort_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..68394e104f8 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_2_3/RedfishPort_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Port.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPort_V1_2_3_Dxe + FILE_GUID = 29c1db4a-9258-42da-b298-799e0d393e1c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPort_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishPort_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Port_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PortV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Port/v1_3_0/Port_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/Port/v1_3_0/Port_V1_3_0_Dxe.c new file mode 100644 index 00000000000..97a7a3c588e --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_3_0/Port_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Port.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Port"; +BOOLEAN IsRevisonController = TRUE; + +// Support Port V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Port", + "1", + "3", + "0" + }, + "Port" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PORT_V1_3_0 *PortV1_3_0; + EFI_REDFISH_PORT_V1_3_0_CS *PortV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Port") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Port_V1_3_0_To_CS (ResoruceRaw, &PortV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PortV1_3_0 = (EFI_REDFISH_PORT_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PORT_V1_3_0)); + if (PortV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PortV1_3_0; + PortV1_3_0->Port = PortV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Port"), "Port"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Port"), "Port"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Port_V1_3_0_JSON (*((EFI_REDFISH_PORT_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PORT_V1_3_0 *PortV1_3_0; + + PortV1_3_0 = (EFI_REDFISH_PORT_V1_3_0 *)InterpProp; + DestroyPort_V1_3_0_CS (PortV1_3_0->Port); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPort_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PortToStructWrapper, + PortToJson, + PortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Port/v1_3_0/RedfishPort_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/Port/v1_3_0/RedfishPort_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..9a63e7068ba --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_3_0/RedfishPort_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Port.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPort_V1_3_0_Dxe + FILE_GUID = ad6be3b0-637f-4a4d-a328-db151a3cfd5f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPort_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishPort_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Port_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PortV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Port/v1_3_1/Port_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/Port/v1_3_1/Port_V1_3_1_Dxe.c new file mode 100644 index 00000000000..60c32f44efc --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_3_1/Port_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Port.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Port"; +BOOLEAN IsRevisonController = TRUE; + +// Support Port V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Port", + "1", + "3", + "1" + }, + "Port" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PORT_V1_3_1 *PortV1_3_1; + EFI_REDFISH_PORT_V1_3_1_CS *PortV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Port") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Port_V1_3_1_To_CS (ResoruceRaw, &PortV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PortV1_3_1 = (EFI_REDFISH_PORT_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PORT_V1_3_1)); + if (PortV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PortV1_3_1; + PortV1_3_1->Port = PortV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Port"), "Port"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Port")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Port"), "Port"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PortToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PortToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Port_V1_3_1_JSON (*((EFI_REDFISH_PORT_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PortToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PORT_V1_3_1 *PortV1_3_1; + + PortV1_3_1 = (EFI_REDFISH_PORT_V1_3_1 *)InterpProp; + DestroyPort_V1_3_1_CS (PortV1_3_1->Port); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PortFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPort_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PortToStructWrapper, + PortToJson, + PortDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPort_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Port/v1_3_1/RedfishPort_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/Port/v1_3_1/RedfishPort_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..cb6c568c1f9 --- /dev/null +++ b/RedfishClientPkg/Converter/Port/v1_3_1/RedfishPort_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Port.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPort_V1_3_1_Dxe + FILE_GUID = 32f976a2-374b-44b7-8643-db99d0502e40 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPort_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishPort_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Port_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PortV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PortCollection/PortCollection_Dxe.c b/RedfishClientPkg/Converter/PortCollection/PortCollection_Dxe.c new file mode 100644 index 00000000000..bbaf20af61b --- /dev/null +++ b/RedfishClientPkg/Converter/PortCollection/PortCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PortCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PortCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support PortCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PortCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "PortCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PORTCOLLECTION *PortCollection; + EFI_REDFISH_PORTCOLLECTION_CS *PortCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PortCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PortCollection_To_CS (ResoruceRaw, &PortCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + PortCollection = (EFI_REDFISH_PORTCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PORTCOLLECTION)); + if (PortCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PortCollection; + PortCollection->PortCollection = PortCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PortCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PortCollection"), "PortCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PortCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PortCollection"), "PortCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PortCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PortCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PortCollection_JSON (*((EFI_REDFISH_PORTCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PortCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PORTCOLLECTION *PortCollection; + + PortCollection = (EFI_REDFISH_PORTCOLLECTION *)InterpProp; + DestroyPortCollection_CS (PortCollection->PortCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PortCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPortCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPortCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PortCollectionToStructWrapper, + PortCollectionToJson, + PortCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPortCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PortCollection/RedfishPortCollection_Dxe.inf b/RedfishClientPkg/Converter/PortCollection/RedfishPortCollection_Dxe.inf new file mode 100644 index 00000000000..d242d23da92 --- /dev/null +++ b/RedfishClientPkg/Converter/PortCollection/RedfishPortCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PortCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPortCollection_Dxe + FILE_GUID = 066cca98-984e-46c2-8b83-e9d3dded8b9f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPortCollectionEntryPoint + UNLOAD_IMAGE = RedfishPortCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PortCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PortCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PortMetrics/v1_0_0/PortMetrics_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/PortMetrics/v1_0_0/PortMetrics_V1_0_0_Dxe.c new file mode 100644 index 00000000000..63f5946ae1a --- /dev/null +++ b/RedfishClientPkg/Converter/PortMetrics/v1_0_0/PortMetrics_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PortMetrics.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PortMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support PortMetrics V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PortMetrics", + "1", + "0", + "0" + }, + "PortMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PORTMETRICS_V1_0_0 *PortMetricsV1_0_0; + EFI_REDFISH_PORTMETRICS_V1_0_0_CS *PortMetricsV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PortMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PortMetrics_V1_0_0_To_CS (ResoruceRaw, &PortMetricsV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PortMetricsV1_0_0 = (EFI_REDFISH_PORTMETRICS_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PORTMETRICS_V1_0_0)); + if (PortMetricsV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PortMetricsV1_0_0; + PortMetricsV1_0_0->PortMetrics = PortMetricsV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PortMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PortMetrics"), "PortMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PortMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PortMetrics"), "PortMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PortMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PortMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PortMetrics_V1_0_0_JSON (*((EFI_REDFISH_PORTMETRICS_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PortMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PORTMETRICS_V1_0_0 *PortMetricsV1_0_0; + + PortMetricsV1_0_0 = (EFI_REDFISH_PORTMETRICS_V1_0_0 *)InterpProp; + DestroyPortMetrics_V1_0_0_CS (PortMetricsV1_0_0->PortMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PortMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPortMetrics_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPortMetrics_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PortMetricsToStructWrapper, + PortMetricsToJson, + PortMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPortMetrics_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PortMetrics/v1_0_0/RedfishPortMetrics_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/PortMetrics/v1_0_0/RedfishPortMetrics_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..505c001347d --- /dev/null +++ b/RedfishClientPkg/Converter/PortMetrics/v1_0_0/RedfishPortMetrics_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PortMetrics.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPortMetrics_V1_0_0_Dxe + FILE_GUID = 15b2b661-e9fa-43f3-a2e1-b9e413bf66c6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPortMetrics_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishPortMetrics_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PortMetrics_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PortMetricsV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PortMetrics/v1_0_1/PortMetrics_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/PortMetrics/v1_0_1/PortMetrics_V1_0_1_Dxe.c new file mode 100644 index 00000000000..aad837c9f29 --- /dev/null +++ b/RedfishClientPkg/Converter/PortMetrics/v1_0_1/PortMetrics_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PortMetrics.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PortMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support PortMetrics V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PortMetrics", + "1", + "0", + "1" + }, + "PortMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PORTMETRICS_V1_0_1 *PortMetricsV1_0_1; + EFI_REDFISH_PORTMETRICS_V1_0_1_CS *PortMetricsV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PortMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PortMetrics_V1_0_1_To_CS (ResoruceRaw, &PortMetricsV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PortMetricsV1_0_1 = (EFI_REDFISH_PORTMETRICS_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PORTMETRICS_V1_0_1)); + if (PortMetricsV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PortMetricsV1_0_1; + PortMetricsV1_0_1->PortMetrics = PortMetricsV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PortMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PortMetrics"), "PortMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PortMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PortMetrics"), "PortMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PortMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PortMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PortMetrics_V1_0_1_JSON (*((EFI_REDFISH_PORTMETRICS_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PortMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PORTMETRICS_V1_0_1 *PortMetricsV1_0_1; + + PortMetricsV1_0_1 = (EFI_REDFISH_PORTMETRICS_V1_0_1 *)InterpProp; + DestroyPortMetrics_V1_0_1_CS (PortMetricsV1_0_1->PortMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PortMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PortMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPortMetrics_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPortMetrics_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PortMetricsToStructWrapper, + PortMetricsToJson, + PortMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPortMetrics_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PortMetrics/v1_0_1/RedfishPortMetrics_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/PortMetrics/v1_0_1/RedfishPortMetrics_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..36259cbac9b --- /dev/null +++ b/RedfishClientPkg/Converter/PortMetrics/v1_0_1/RedfishPortMetrics_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PortMetrics.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPortMetrics_V1_0_1_Dxe + FILE_GUID = 56c2e214-4d97-41d9-974d-7975c525e95e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPortMetrics_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishPortMetrics_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PortMetrics_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PortMetricsV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_0_0/Power_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Power/v1_0_0/Power_V1_0_0_Dxe.c new file mode 100644 index 00000000000..c2bb93214af --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_0/Power_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "0", + "0" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_0 *PowerV1_0_0; + EFI_REDFISH_POWER_V1_0_0_CS *PowerV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_0_0_To_CS (ResoruceRaw, &PowerV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_0_0 = (EFI_REDFISH_POWER_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_0_0)); + if (PowerV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_0_0; + PowerV1_0_0->Power = PowerV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_0_0_JSON (*((EFI_REDFISH_POWER_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_0 *PowerV1_0_0; + + PowerV1_0_0 = (EFI_REDFISH_POWER_V1_0_0 *)InterpProp; + DestroyPower_V1_0_0_CS (PowerV1_0_0->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_0_0/RedfishPower_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_0_0/RedfishPower_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..7c90ceb21fc --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_0/RedfishPower_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_0_0_Dxe + FILE_GUID = 103ad893-d8fc-42e9-a313-6fbe104aec48 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_0_1/Power_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/Power/v1_0_1/Power_V1_0_1_Dxe.c new file mode 100644 index 00000000000..446828b3474 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_1/Power_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "0", + "1" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_1 *PowerV1_0_1; + EFI_REDFISH_POWER_V1_0_1_CS *PowerV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_0_1_To_CS (ResoruceRaw, &PowerV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_0_1 = (EFI_REDFISH_POWER_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_0_1)); + if (PowerV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_0_1; + PowerV1_0_1->Power = PowerV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_0_1_JSON (*((EFI_REDFISH_POWER_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_1 *PowerV1_0_1; + + PowerV1_0_1 = (EFI_REDFISH_POWER_V1_0_1 *)InterpProp; + DestroyPower_V1_0_1_CS (PowerV1_0_1->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_0_1/RedfishPower_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_0_1/RedfishPower_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..7cf369d060c --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_1/RedfishPower_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_0_1_Dxe + FILE_GUID = 0d3469da-31c9-4c9c-8715-157f746fd794 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_0_10/Power_V1_0_10_Dxe.c b/RedfishClientPkg/Converter/Power/v1_0_10/Power_V1_0_10_Dxe.c new file mode 100644 index 00000000000..0cb1415e684 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_10/Power_V1_0_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_0_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "0", + "10" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_10 *PowerV1_0_10; + EFI_REDFISH_POWER_V1_0_10_CS *PowerV1_0_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_0_10_To_CS (ResoruceRaw, &PowerV1_0_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_0_10 = (EFI_REDFISH_POWER_V1_0_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_0_10)); + if (PowerV1_0_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_0_10; + PowerV1_0_10->Power = PowerV1_0_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_0_10_JSON (*((EFI_REDFISH_POWER_V1_0_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_10 *PowerV1_0_10; + + PowerV1_0_10 = (EFI_REDFISH_POWER_V1_0_10 *)InterpProp; + DestroyPower_V1_0_10_CS (PowerV1_0_10->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_0_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_0_10/RedfishPower_V1_0_10_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_0_10/RedfishPower_V1_0_10_Dxe.inf new file mode 100644 index 00000000000..fedd11e2b28 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_10/RedfishPower_V1_0_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_0_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_0_10_Dxe + FILE_GUID = 9bc1139d-b349-41e9-ac75-b69a9408125d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_0_10EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_0_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_0_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_0_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_0_11/Power_V1_0_11_Dxe.c b/RedfishClientPkg/Converter/Power/v1_0_11/Power_V1_0_11_Dxe.c new file mode 100644 index 00000000000..b5cab7476d0 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_11/Power_V1_0_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_0_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "0", + "11" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_11 *PowerV1_0_11; + EFI_REDFISH_POWER_V1_0_11_CS *PowerV1_0_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_0_11_To_CS (ResoruceRaw, &PowerV1_0_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_0_11 = (EFI_REDFISH_POWER_V1_0_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_0_11)); + if (PowerV1_0_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_0_11; + PowerV1_0_11->Power = PowerV1_0_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_0_11_JSON (*((EFI_REDFISH_POWER_V1_0_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_11 *PowerV1_0_11; + + PowerV1_0_11 = (EFI_REDFISH_POWER_V1_0_11 *)InterpProp; + DestroyPower_V1_0_11_CS (PowerV1_0_11->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_0_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_0_11/RedfishPower_V1_0_11_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_0_11/RedfishPower_V1_0_11_Dxe.inf new file mode 100644 index 00000000000..318e9da1236 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_11/RedfishPower_V1_0_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_0_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_0_11_Dxe + FILE_GUID = 1664b685-f426-4af4-8d19-01773ea5ea5f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_0_11EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_0_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_0_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_0_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_0_12/Power_V1_0_12_Dxe.c b/RedfishClientPkg/Converter/Power/v1_0_12/Power_V1_0_12_Dxe.c new file mode 100644 index 00000000000..de35117e266 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_12/Power_V1_0_12_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_0_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_0_12 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "0", + "12" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_12 *PowerV1_0_12; + EFI_REDFISH_POWER_V1_0_12_CS *PowerV1_0_12Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "12") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_0_12_To_CS (ResoruceRaw, &PowerV1_0_12Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_0_12 = (EFI_REDFISH_POWER_V1_0_12 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_0_12)); + if (PowerV1_0_12 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_0_12; + PowerV1_0_12->Power = PowerV1_0_12Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "12"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_0_12_JSON (*((EFI_REDFISH_POWER_V1_0_12_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_12 *PowerV1_0_12; + + PowerV1_0_12 = (EFI_REDFISH_POWER_V1_0_12 *)InterpProp; + DestroyPower_V1_0_12_CS (PowerV1_0_12->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_0_12_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_12EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_12Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_0_12/RedfishPower_V1_0_12_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_0_12/RedfishPower_V1_0_12_Dxe.inf new file mode 100644 index 00000000000..3773c9f2e4d --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_12/RedfishPower_V1_0_12_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_0_12 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_0_12_Dxe + FILE_GUID = dbb2c669-f32c-4658-97d9-c3dad8778915 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_0_12EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_0_12Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_0_12_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_0_12Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_0_2/Power_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Power/v1_0_2/Power_V1_0_2_Dxe.c new file mode 100644 index 00000000000..e090fcca0b8 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_2/Power_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "0", + "2" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_2 *PowerV1_0_2; + EFI_REDFISH_POWER_V1_0_2_CS *PowerV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_0_2_To_CS (ResoruceRaw, &PowerV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_0_2 = (EFI_REDFISH_POWER_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_0_2)); + if (PowerV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_0_2; + PowerV1_0_2->Power = PowerV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_0_2_JSON (*((EFI_REDFISH_POWER_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_2 *PowerV1_0_2; + + PowerV1_0_2 = (EFI_REDFISH_POWER_V1_0_2 *)InterpProp; + DestroyPower_V1_0_2_CS (PowerV1_0_2->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_0_2/RedfishPower_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_0_2/RedfishPower_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..8e137f7fd99 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_2/RedfishPower_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_0_2_Dxe + FILE_GUID = 21cbdbed-febe-478a-ae72-17b8d7a13d91 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_0_3/Power_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/Power/v1_0_3/Power_V1_0_3_Dxe.c new file mode 100644 index 00000000000..73f49742489 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_3/Power_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "0", + "3" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_3 *PowerV1_0_3; + EFI_REDFISH_POWER_V1_0_3_CS *PowerV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_0_3_To_CS (ResoruceRaw, &PowerV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_0_3 = (EFI_REDFISH_POWER_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_0_3)); + if (PowerV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_0_3; + PowerV1_0_3->Power = PowerV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_0_3_JSON (*((EFI_REDFISH_POWER_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_3 *PowerV1_0_3; + + PowerV1_0_3 = (EFI_REDFISH_POWER_V1_0_3 *)InterpProp; + DestroyPower_V1_0_3_CS (PowerV1_0_3->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_0_3/RedfishPower_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_0_3/RedfishPower_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..64fa9f321cf --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_3/RedfishPower_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_0_3_Dxe + FILE_GUID = bc143dc2-e7db-476e-9d89-bc05452299b6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_0_4/Power_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/Power/v1_0_4/Power_V1_0_4_Dxe.c new file mode 100644 index 00000000000..cc683085f44 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_4/Power_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "0", + "4" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_4 *PowerV1_0_4; + EFI_REDFISH_POWER_V1_0_4_CS *PowerV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_0_4_To_CS (ResoruceRaw, &PowerV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_0_4 = (EFI_REDFISH_POWER_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_0_4)); + if (PowerV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_0_4; + PowerV1_0_4->Power = PowerV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_0_4_JSON (*((EFI_REDFISH_POWER_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_4 *PowerV1_0_4; + + PowerV1_0_4 = (EFI_REDFISH_POWER_V1_0_4 *)InterpProp; + DestroyPower_V1_0_4_CS (PowerV1_0_4->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_0_4/RedfishPower_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_0_4/RedfishPower_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..6d9fa425dfc --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_4/RedfishPower_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_0_4_Dxe + FILE_GUID = f61cc8a6-2c70-4328-b2da-08fa7136a4d8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_0_5/Power_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/Power/v1_0_5/Power_V1_0_5_Dxe.c new file mode 100644 index 00000000000..84c3cfb0448 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_5/Power_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "0", + "5" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_5 *PowerV1_0_5; + EFI_REDFISH_POWER_V1_0_5_CS *PowerV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_0_5_To_CS (ResoruceRaw, &PowerV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_0_5 = (EFI_REDFISH_POWER_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_0_5)); + if (PowerV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_0_5; + PowerV1_0_5->Power = PowerV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_0_5_JSON (*((EFI_REDFISH_POWER_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_5 *PowerV1_0_5; + + PowerV1_0_5 = (EFI_REDFISH_POWER_V1_0_5 *)InterpProp; + DestroyPower_V1_0_5_CS (PowerV1_0_5->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_0_5/RedfishPower_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_0_5/RedfishPower_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..04c4d6edc7b --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_5/RedfishPower_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_0_5_Dxe + FILE_GUID = fa2ccb0f-9547-4c9b-b65e-ccf99e038143 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_0_6/Power_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/Power/v1_0_6/Power_V1_0_6_Dxe.c new file mode 100644 index 00000000000..a3bde2570cc --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_6/Power_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "0", + "6" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_6 *PowerV1_0_6; + EFI_REDFISH_POWER_V1_0_6_CS *PowerV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_0_6_To_CS (ResoruceRaw, &PowerV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_0_6 = (EFI_REDFISH_POWER_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_0_6)); + if (PowerV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_0_6; + PowerV1_0_6->Power = PowerV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_0_6_JSON (*((EFI_REDFISH_POWER_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_6 *PowerV1_0_6; + + PowerV1_0_6 = (EFI_REDFISH_POWER_V1_0_6 *)InterpProp; + DestroyPower_V1_0_6_CS (PowerV1_0_6->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_0_6/RedfishPower_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_0_6/RedfishPower_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..c5b9288485f --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_6/RedfishPower_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_0_6_Dxe + FILE_GUID = 5d350889-b7ec-42ee-a8b9-74b4e0c97d28 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_0_7/Power_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/Power/v1_0_7/Power_V1_0_7_Dxe.c new file mode 100644 index 00000000000..9cb3c788a35 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_7/Power_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "0", + "7" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_7 *PowerV1_0_7; + EFI_REDFISH_POWER_V1_0_7_CS *PowerV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_0_7_To_CS (ResoruceRaw, &PowerV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_0_7 = (EFI_REDFISH_POWER_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_0_7)); + if (PowerV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_0_7; + PowerV1_0_7->Power = PowerV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_0_7_JSON (*((EFI_REDFISH_POWER_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_7 *PowerV1_0_7; + + PowerV1_0_7 = (EFI_REDFISH_POWER_V1_0_7 *)InterpProp; + DestroyPower_V1_0_7_CS (PowerV1_0_7->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_0_7/RedfishPower_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_0_7/RedfishPower_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..c72334eb0d9 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_7/RedfishPower_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_0_7_Dxe + FILE_GUID = 0f0a3982-22b2-44e3-8ba6-80ef07188b71 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_0_8/Power_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/Power/v1_0_8/Power_V1_0_8_Dxe.c new file mode 100644 index 00000000000..5bfffe6e0cf --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_8/Power_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "0", + "8" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_8 *PowerV1_0_8; + EFI_REDFISH_POWER_V1_0_8_CS *PowerV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_0_8_To_CS (ResoruceRaw, &PowerV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_0_8 = (EFI_REDFISH_POWER_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_0_8)); + if (PowerV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_0_8; + PowerV1_0_8->Power = PowerV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_0_8_JSON (*((EFI_REDFISH_POWER_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_8 *PowerV1_0_8; + + PowerV1_0_8 = (EFI_REDFISH_POWER_V1_0_8 *)InterpProp; + DestroyPower_V1_0_8_CS (PowerV1_0_8->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_0_8/RedfishPower_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_0_8/RedfishPower_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..7b4adc4e5f5 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_8/RedfishPower_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_0_8_Dxe + FILE_GUID = ad1a5bf4-9734-4201-9730-1a15168bb807 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_0_9/Power_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/Power/v1_0_9/Power_V1_0_9_Dxe.c new file mode 100644 index 00000000000..da86cd8a1d5 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_9/Power_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "0", + "9" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_9 *PowerV1_0_9; + EFI_REDFISH_POWER_V1_0_9_CS *PowerV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_0_9_To_CS (ResoruceRaw, &PowerV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_0_9 = (EFI_REDFISH_POWER_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_0_9)); + if (PowerV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_0_9; + PowerV1_0_9->Power = PowerV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_0_9_JSON (*((EFI_REDFISH_POWER_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_0_9 *PowerV1_0_9; + + PowerV1_0_9 = (EFI_REDFISH_POWER_V1_0_9 *)InterpProp; + DestroyPower_V1_0_9_CS (PowerV1_0_9->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_0_9/RedfishPower_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_0_9/RedfishPower_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..fa0737e6b6d --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_0_9/RedfishPower_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_0_9_Dxe + FILE_GUID = c8451746-e7f2-43c7-a70f-57b6e607e210 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_1_0/Power_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/Power/v1_1_0/Power_V1_1_0_Dxe.c new file mode 100644 index 00000000000..16cbbb06bf7 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_1_0/Power_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "1", + "0" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_1_0 *PowerV1_1_0; + EFI_REDFISH_POWER_V1_1_0_CS *PowerV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_1_0_To_CS (ResoruceRaw, &PowerV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_1_0 = (EFI_REDFISH_POWER_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_1_0)); + if (PowerV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_1_0; + PowerV1_1_0->Power = PowerV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_1_0_JSON (*((EFI_REDFISH_POWER_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_1_0 *PowerV1_1_0; + + PowerV1_1_0 = (EFI_REDFISH_POWER_V1_1_0 *)InterpProp; + DestroyPower_V1_1_0_CS (PowerV1_1_0->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_1_0/RedfishPower_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_1_0/RedfishPower_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..68405038ad0 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_1_0/RedfishPower_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_1_0_Dxe + FILE_GUID = 858cbda5-c663-436d-a8e6-aa8bd758ebf9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_1_1/Power_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/Power/v1_1_1/Power_V1_1_1_Dxe.c new file mode 100644 index 00000000000..29d32385377 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_1_1/Power_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "1", + "1" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_1_1 *PowerV1_1_1; + EFI_REDFISH_POWER_V1_1_1_CS *PowerV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_1_1_To_CS (ResoruceRaw, &PowerV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_1_1 = (EFI_REDFISH_POWER_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_1_1)); + if (PowerV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_1_1; + PowerV1_1_1->Power = PowerV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_1_1_JSON (*((EFI_REDFISH_POWER_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_1_1 *PowerV1_1_1; + + PowerV1_1_1 = (EFI_REDFISH_POWER_V1_1_1 *)InterpProp; + DestroyPower_V1_1_1_CS (PowerV1_1_1->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_1_1/RedfishPower_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_1_1/RedfishPower_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..69591e87e90 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_1_1/RedfishPower_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_1_1_Dxe + FILE_GUID = 2d10e42b-e79c-41d7-bb90-cfe6a7b586c5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_1_10/Power_V1_1_10_Dxe.c b/RedfishClientPkg/Converter/Power/v1_1_10/Power_V1_1_10_Dxe.c new file mode 100644 index 00000000000..0d921a99385 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_1_10/Power_V1_1_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_1_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_1_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "1", + "10" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_1_10 *PowerV1_1_10; + EFI_REDFISH_POWER_V1_1_10_CS *PowerV1_1_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_1_10_To_CS (ResoruceRaw, &PowerV1_1_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_1_10 = (EFI_REDFISH_POWER_V1_1_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_1_10)); + if (PowerV1_1_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_1_10; + PowerV1_1_10->Power = PowerV1_1_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_1_10_JSON (*((EFI_REDFISH_POWER_V1_1_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_1_10 *PowerV1_1_10; + + PowerV1_1_10 = (EFI_REDFISH_POWER_V1_1_10 *)InterpProp; + DestroyPower_V1_1_10_CS (PowerV1_1_10->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_1_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_1_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_1_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_1_10/RedfishPower_V1_1_10_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_1_10/RedfishPower_V1_1_10_Dxe.inf new file mode 100644 index 00000000000..d20aaed0495 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_1_10/RedfishPower_V1_1_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_1_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_1_10_Dxe + FILE_GUID = 424be78a-61e3-4fb8-ae3e-cac970fe79f2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_1_10EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_1_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_1_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_1_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_1_2/Power_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/Power/v1_1_2/Power_V1_1_2_Dxe.c new file mode 100644 index 00000000000..8ae804220f0 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_1_2/Power_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "1", + "2" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_1_2 *PowerV1_1_2; + EFI_REDFISH_POWER_V1_1_2_CS *PowerV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_1_2_To_CS (ResoruceRaw, &PowerV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_1_2 = (EFI_REDFISH_POWER_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_1_2)); + if (PowerV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_1_2; + PowerV1_1_2->Power = PowerV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_1_2_JSON (*((EFI_REDFISH_POWER_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_1_2 *PowerV1_1_2; + + PowerV1_1_2 = (EFI_REDFISH_POWER_V1_1_2 *)InterpProp; + DestroyPower_V1_1_2_CS (PowerV1_1_2->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_1_2/RedfishPower_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_1_2/RedfishPower_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..16b1b0ba328 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_1_2/RedfishPower_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_1_2_Dxe + FILE_GUID = 35f7043f-e5dd-48d4-8b62-cedd6a4927e3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_1_3/Power_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/Power/v1_1_3/Power_V1_1_3_Dxe.c new file mode 100644 index 00000000000..460688cb266 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_1_3/Power_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "1", + "3" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_1_3 *PowerV1_1_3; + EFI_REDFISH_POWER_V1_1_3_CS *PowerV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_1_3_To_CS (ResoruceRaw, &PowerV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_1_3 = (EFI_REDFISH_POWER_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_1_3)); + if (PowerV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_1_3; + PowerV1_1_3->Power = PowerV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_1_3_JSON (*((EFI_REDFISH_POWER_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_1_3 *PowerV1_1_3; + + PowerV1_1_3 = (EFI_REDFISH_POWER_V1_1_3 *)InterpProp; + DestroyPower_V1_1_3_CS (PowerV1_1_3->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_1_3/RedfishPower_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_1_3/RedfishPower_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..1f0ff403169 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_1_3/RedfishPower_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_1_3_Dxe + FILE_GUID = 75a23b03-296e-400b-bbf6-6b02a1fabd0a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_1_4/Power_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/Power/v1_1_4/Power_V1_1_4_Dxe.c new file mode 100644 index 00000000000..3dd19120ef0 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_1_4/Power_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "1", + "4" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_1_4 *PowerV1_1_4; + EFI_REDFISH_POWER_V1_1_4_CS *PowerV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_1_4_To_CS (ResoruceRaw, &PowerV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_1_4 = (EFI_REDFISH_POWER_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_1_4)); + if (PowerV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_1_4; + PowerV1_1_4->Power = PowerV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_1_4_JSON (*((EFI_REDFISH_POWER_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_1_4 *PowerV1_1_4; + + PowerV1_1_4 = (EFI_REDFISH_POWER_V1_1_4 *)InterpProp; + DestroyPower_V1_1_4_CS (PowerV1_1_4->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_1_4/RedfishPower_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_1_4/RedfishPower_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..31571d3834f --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_1_4/RedfishPower_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_1_4_Dxe + FILE_GUID = b0585b62-886a-4ed2-b91e-ca4f9aa2fa1d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_1_5/Power_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/Power/v1_1_5/Power_V1_1_5_Dxe.c new file mode 100644 index 00000000000..03c458ac5d4 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_1_5/Power_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "1", + "5" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_1_5 *PowerV1_1_5; + EFI_REDFISH_POWER_V1_1_5_CS *PowerV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_1_5_To_CS (ResoruceRaw, &PowerV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_1_5 = (EFI_REDFISH_POWER_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_1_5)); + if (PowerV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_1_5; + PowerV1_1_5->Power = PowerV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_1_5_JSON (*((EFI_REDFISH_POWER_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_1_5 *PowerV1_1_5; + + PowerV1_1_5 = (EFI_REDFISH_POWER_V1_1_5 *)InterpProp; + DestroyPower_V1_1_5_CS (PowerV1_1_5->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_1_5/RedfishPower_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_1_5/RedfishPower_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..a0e24b4605f --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_1_5/RedfishPower_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_1_5_Dxe + FILE_GUID = 3bfb3587-d9ed-4654-8843-58f428c0a4e4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_1_6/Power_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/Power/v1_1_6/Power_V1_1_6_Dxe.c new file mode 100644 index 00000000000..cf044f8ad88 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_1_6/Power_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "1", + "6" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_1_6 *PowerV1_1_6; + EFI_REDFISH_POWER_V1_1_6_CS *PowerV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_1_6_To_CS (ResoruceRaw, &PowerV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_1_6 = (EFI_REDFISH_POWER_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_1_6)); + if (PowerV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_1_6; + PowerV1_1_6->Power = PowerV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_1_6_JSON (*((EFI_REDFISH_POWER_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_1_6 *PowerV1_1_6; + + PowerV1_1_6 = (EFI_REDFISH_POWER_V1_1_6 *)InterpProp; + DestroyPower_V1_1_6_CS (PowerV1_1_6->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_1_6/RedfishPower_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_1_6/RedfishPower_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..c9678fa4058 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_1_6/RedfishPower_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_1_6_Dxe + FILE_GUID = ee102e46-0932-4849-a923-0b697335bf6e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_1_7/Power_V1_1_7_Dxe.c b/RedfishClientPkg/Converter/Power/v1_1_7/Power_V1_1_7_Dxe.c new file mode 100644 index 00000000000..09cbb7bb607 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_1_7/Power_V1_1_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_1_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "1", + "7" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_1_7 *PowerV1_1_7; + EFI_REDFISH_POWER_V1_1_7_CS *PowerV1_1_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_1_7_To_CS (ResoruceRaw, &PowerV1_1_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_1_7 = (EFI_REDFISH_POWER_V1_1_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_1_7)); + if (PowerV1_1_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_1_7; + PowerV1_1_7->Power = PowerV1_1_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_1_7_JSON (*((EFI_REDFISH_POWER_V1_1_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_1_7 *PowerV1_1_7; + + PowerV1_1_7 = (EFI_REDFISH_POWER_V1_1_7 *)InterpProp; + DestroyPower_V1_1_7_CS (PowerV1_1_7->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_1_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_1_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_1_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_1_7/RedfishPower_V1_1_7_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_1_7/RedfishPower_V1_1_7_Dxe.inf new file mode 100644 index 00000000000..38ab5857822 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_1_7/RedfishPower_V1_1_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_1_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_1_7_Dxe + FILE_GUID = 75f50d93-09f2-49d5-ae7d-1a4125e4c562 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_1_7EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_1_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_1_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_1_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_1_8/Power_V1_1_8_Dxe.c b/RedfishClientPkg/Converter/Power/v1_1_8/Power_V1_1_8_Dxe.c new file mode 100644 index 00000000000..d5a5fe67dde --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_1_8/Power_V1_1_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_1_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "1", + "8" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_1_8 *PowerV1_1_8; + EFI_REDFISH_POWER_V1_1_8_CS *PowerV1_1_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_1_8_To_CS (ResoruceRaw, &PowerV1_1_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_1_8 = (EFI_REDFISH_POWER_V1_1_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_1_8)); + if (PowerV1_1_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_1_8; + PowerV1_1_8->Power = PowerV1_1_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_1_8_JSON (*((EFI_REDFISH_POWER_V1_1_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_1_8 *PowerV1_1_8; + + PowerV1_1_8 = (EFI_REDFISH_POWER_V1_1_8 *)InterpProp; + DestroyPower_V1_1_8_CS (PowerV1_1_8->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_1_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_1_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_1_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_1_8/RedfishPower_V1_1_8_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_1_8/RedfishPower_V1_1_8_Dxe.inf new file mode 100644 index 00000000000..31b074309a8 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_1_8/RedfishPower_V1_1_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_1_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_1_8_Dxe + FILE_GUID = 3302386d-7a6a-45de-9937-f7865417adbc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_1_8EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_1_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_1_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_1_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_1_9/Power_V1_1_9_Dxe.c b/RedfishClientPkg/Converter/Power/v1_1_9/Power_V1_1_9_Dxe.c new file mode 100644 index 00000000000..b929d39fcde --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_1_9/Power_V1_1_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_1_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "1", + "9" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_1_9 *PowerV1_1_9; + EFI_REDFISH_POWER_V1_1_9_CS *PowerV1_1_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_1_9_To_CS (ResoruceRaw, &PowerV1_1_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_1_9 = (EFI_REDFISH_POWER_V1_1_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_1_9)); + if (PowerV1_1_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_1_9; + PowerV1_1_9->Power = PowerV1_1_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_1_9_JSON (*((EFI_REDFISH_POWER_V1_1_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_1_9 *PowerV1_1_9; + + PowerV1_1_9 = (EFI_REDFISH_POWER_V1_1_9 *)InterpProp; + DestroyPower_V1_1_9_CS (PowerV1_1_9->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_1_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_1_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_1_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_1_9/RedfishPower_V1_1_9_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_1_9/RedfishPower_V1_1_9_Dxe.inf new file mode 100644 index 00000000000..887ead5588c --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_1_9/RedfishPower_V1_1_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_1_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_1_9_Dxe + FILE_GUID = 4d30bb9b-2bc7-411f-998d-5e8ae5e400f1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_1_9EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_1_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_1_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_1_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_2_0/Power_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/Power/v1_2_0/Power_V1_2_0_Dxe.c new file mode 100644 index 00000000000..044ed5cca65 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_2_0/Power_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "2", + "0" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_2_0 *PowerV1_2_0; + EFI_REDFISH_POWER_V1_2_0_CS *PowerV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_2_0_To_CS (ResoruceRaw, &PowerV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_2_0 = (EFI_REDFISH_POWER_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_2_0)); + if (PowerV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_2_0; + PowerV1_2_0->Power = PowerV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_2_0_JSON (*((EFI_REDFISH_POWER_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_2_0 *PowerV1_2_0; + + PowerV1_2_0 = (EFI_REDFISH_POWER_V1_2_0 *)InterpProp; + DestroyPower_V1_2_0_CS (PowerV1_2_0->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_2_0/RedfishPower_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_2_0/RedfishPower_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..d67a7e770f2 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_2_0/RedfishPower_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_2_0_Dxe + FILE_GUID = 20fdb5bb-4959-402e-a8a7-22e3eebd7ca4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_2_1/Power_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/Power/v1_2_1/Power_V1_2_1_Dxe.c new file mode 100644 index 00000000000..2c457214fbb --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_2_1/Power_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "2", + "1" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_2_1 *PowerV1_2_1; + EFI_REDFISH_POWER_V1_2_1_CS *PowerV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_2_1_To_CS (ResoruceRaw, &PowerV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_2_1 = (EFI_REDFISH_POWER_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_2_1)); + if (PowerV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_2_1; + PowerV1_2_1->Power = PowerV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_2_1_JSON (*((EFI_REDFISH_POWER_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_2_1 *PowerV1_2_1; + + PowerV1_2_1 = (EFI_REDFISH_POWER_V1_2_1 *)InterpProp; + DestroyPower_V1_2_1_CS (PowerV1_2_1->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_2_1/RedfishPower_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_2_1/RedfishPower_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..67fffb83c15 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_2_1/RedfishPower_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_2_1_Dxe + FILE_GUID = 3a5e6349-c9f1-47d7-a5a1-de481b35ede2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_2_10/Power_V1_2_10_Dxe.c b/RedfishClientPkg/Converter/Power/v1_2_10/Power_V1_2_10_Dxe.c new file mode 100644 index 00000000000..e06bf470ce6 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_2_10/Power_V1_2_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_2_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_2_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "2", + "10" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_2_10 *PowerV1_2_10; + EFI_REDFISH_POWER_V1_2_10_CS *PowerV1_2_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_2_10_To_CS (ResoruceRaw, &PowerV1_2_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_2_10 = (EFI_REDFISH_POWER_V1_2_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_2_10)); + if (PowerV1_2_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_2_10; + PowerV1_2_10->Power = PowerV1_2_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_2_10_JSON (*((EFI_REDFISH_POWER_V1_2_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_2_10 *PowerV1_2_10; + + PowerV1_2_10 = (EFI_REDFISH_POWER_V1_2_10 *)InterpProp; + DestroyPower_V1_2_10_CS (PowerV1_2_10->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_2_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_2_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_2_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_2_10/RedfishPower_V1_2_10_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_2_10/RedfishPower_V1_2_10_Dxe.inf new file mode 100644 index 00000000000..81756e1a5d8 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_2_10/RedfishPower_V1_2_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_2_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_2_10_Dxe + FILE_GUID = 90436882-78ee-4505-8159-ae7c2e3dd3e9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_2_10EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_2_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_2_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_2_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_2_2/Power_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/Power/v1_2_2/Power_V1_2_2_Dxe.c new file mode 100644 index 00000000000..10719722b1f --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_2_2/Power_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "2", + "2" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_2_2 *PowerV1_2_2; + EFI_REDFISH_POWER_V1_2_2_CS *PowerV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_2_2_To_CS (ResoruceRaw, &PowerV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_2_2 = (EFI_REDFISH_POWER_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_2_2)); + if (PowerV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_2_2; + PowerV1_2_2->Power = PowerV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_2_2_JSON (*((EFI_REDFISH_POWER_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_2_2 *PowerV1_2_2; + + PowerV1_2_2 = (EFI_REDFISH_POWER_V1_2_2 *)InterpProp; + DestroyPower_V1_2_2_CS (PowerV1_2_2->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_2_2/RedfishPower_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_2_2/RedfishPower_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..ff84c9eb566 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_2_2/RedfishPower_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_2_2_Dxe + FILE_GUID = 3245ff74-31dd-4d74-afe0-7f557ea18826 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_2_3/Power_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/Power/v1_2_3/Power_V1_2_3_Dxe.c new file mode 100644 index 00000000000..11249361bbe --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_2_3/Power_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "2", + "3" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_2_3 *PowerV1_2_3; + EFI_REDFISH_POWER_V1_2_3_CS *PowerV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_2_3_To_CS (ResoruceRaw, &PowerV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_2_3 = (EFI_REDFISH_POWER_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_2_3)); + if (PowerV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_2_3; + PowerV1_2_3->Power = PowerV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_2_3_JSON (*((EFI_REDFISH_POWER_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_2_3 *PowerV1_2_3; + + PowerV1_2_3 = (EFI_REDFISH_POWER_V1_2_3 *)InterpProp; + DestroyPower_V1_2_3_CS (PowerV1_2_3->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_2_3/RedfishPower_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_2_3/RedfishPower_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..d094a5f3778 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_2_3/RedfishPower_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_2_3_Dxe + FILE_GUID = de5df697-b9ea-4620-9893-d4c0349589a7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_2_4/Power_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/Power/v1_2_4/Power_V1_2_4_Dxe.c new file mode 100644 index 00000000000..41050569e4b --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_2_4/Power_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "2", + "4" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_2_4 *PowerV1_2_4; + EFI_REDFISH_POWER_V1_2_4_CS *PowerV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_2_4_To_CS (ResoruceRaw, &PowerV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_2_4 = (EFI_REDFISH_POWER_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_2_4)); + if (PowerV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_2_4; + PowerV1_2_4->Power = PowerV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_2_4_JSON (*((EFI_REDFISH_POWER_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_2_4 *PowerV1_2_4; + + PowerV1_2_4 = (EFI_REDFISH_POWER_V1_2_4 *)InterpProp; + DestroyPower_V1_2_4_CS (PowerV1_2_4->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_2_4/RedfishPower_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_2_4/RedfishPower_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..8b6b3c6dc4d --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_2_4/RedfishPower_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_2_4_Dxe + FILE_GUID = 863ba7e0-e17b-4cb1-8594-ab9bea7c42ad + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_2_5/Power_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/Power/v1_2_5/Power_V1_2_5_Dxe.c new file mode 100644 index 00000000000..09632254ea6 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_2_5/Power_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "2", + "5" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_2_5 *PowerV1_2_5; + EFI_REDFISH_POWER_V1_2_5_CS *PowerV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_2_5_To_CS (ResoruceRaw, &PowerV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_2_5 = (EFI_REDFISH_POWER_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_2_5)); + if (PowerV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_2_5; + PowerV1_2_5->Power = PowerV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_2_5_JSON (*((EFI_REDFISH_POWER_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_2_5 *PowerV1_2_5; + + PowerV1_2_5 = (EFI_REDFISH_POWER_V1_2_5 *)InterpProp; + DestroyPower_V1_2_5_CS (PowerV1_2_5->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_2_5/RedfishPower_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_2_5/RedfishPower_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..d0f53737aed --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_2_5/RedfishPower_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_2_5_Dxe + FILE_GUID = 91d28f37-93cd-42d6-8faf-cfbb82138b7f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_2_6/Power_V1_2_6_Dxe.c b/RedfishClientPkg/Converter/Power/v1_2_6/Power_V1_2_6_Dxe.c new file mode 100644 index 00000000000..3b1ce9c5f53 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_2_6/Power_V1_2_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_2_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "2", + "6" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_2_6 *PowerV1_2_6; + EFI_REDFISH_POWER_V1_2_6_CS *PowerV1_2_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_2_6_To_CS (ResoruceRaw, &PowerV1_2_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_2_6 = (EFI_REDFISH_POWER_V1_2_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_2_6)); + if (PowerV1_2_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_2_6; + PowerV1_2_6->Power = PowerV1_2_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_2_6_JSON (*((EFI_REDFISH_POWER_V1_2_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_2_6 *PowerV1_2_6; + + PowerV1_2_6 = (EFI_REDFISH_POWER_V1_2_6 *)InterpProp; + DestroyPower_V1_2_6_CS (PowerV1_2_6->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_2_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_2_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_2_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_2_6/RedfishPower_V1_2_6_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_2_6/RedfishPower_V1_2_6_Dxe.inf new file mode 100644 index 00000000000..e876d646ce1 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_2_6/RedfishPower_V1_2_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_2_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_2_6_Dxe + FILE_GUID = caf151ec-00d0-48c4-ad41-b4cd2bc28a07 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_2_6EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_2_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_2_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_2_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_2_7/Power_V1_2_7_Dxe.c b/RedfishClientPkg/Converter/Power/v1_2_7/Power_V1_2_7_Dxe.c new file mode 100644 index 00000000000..3edfb12c9ef --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_2_7/Power_V1_2_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_2_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "2", + "7" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_2_7 *PowerV1_2_7; + EFI_REDFISH_POWER_V1_2_7_CS *PowerV1_2_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_2_7_To_CS (ResoruceRaw, &PowerV1_2_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_2_7 = (EFI_REDFISH_POWER_V1_2_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_2_7)); + if (PowerV1_2_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_2_7; + PowerV1_2_7->Power = PowerV1_2_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_2_7_JSON (*((EFI_REDFISH_POWER_V1_2_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_2_7 *PowerV1_2_7; + + PowerV1_2_7 = (EFI_REDFISH_POWER_V1_2_7 *)InterpProp; + DestroyPower_V1_2_7_CS (PowerV1_2_7->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_2_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_2_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_2_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_2_7/RedfishPower_V1_2_7_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_2_7/RedfishPower_V1_2_7_Dxe.inf new file mode 100644 index 00000000000..642d24e125d --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_2_7/RedfishPower_V1_2_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_2_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_2_7_Dxe + FILE_GUID = c84e637b-5a3b-4af0-9740-16cd83223453 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_2_7EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_2_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_2_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_2_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_2_8/Power_V1_2_8_Dxe.c b/RedfishClientPkg/Converter/Power/v1_2_8/Power_V1_2_8_Dxe.c new file mode 100644 index 00000000000..5b0bc5b5226 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_2_8/Power_V1_2_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_2_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "2", + "8" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_2_8 *PowerV1_2_8; + EFI_REDFISH_POWER_V1_2_8_CS *PowerV1_2_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_2_8_To_CS (ResoruceRaw, &PowerV1_2_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_2_8 = (EFI_REDFISH_POWER_V1_2_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_2_8)); + if (PowerV1_2_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_2_8; + PowerV1_2_8->Power = PowerV1_2_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_2_8_JSON (*((EFI_REDFISH_POWER_V1_2_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_2_8 *PowerV1_2_8; + + PowerV1_2_8 = (EFI_REDFISH_POWER_V1_2_8 *)InterpProp; + DestroyPower_V1_2_8_CS (PowerV1_2_8->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_2_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_2_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_2_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_2_8/RedfishPower_V1_2_8_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_2_8/RedfishPower_V1_2_8_Dxe.inf new file mode 100644 index 00000000000..456eb3d18f6 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_2_8/RedfishPower_V1_2_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_2_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_2_8_Dxe + FILE_GUID = b0973919-1c7c-4b3c-a92d-453e652b0aa5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_2_8EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_2_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_2_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_2_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_2_9/Power_V1_2_9_Dxe.c b/RedfishClientPkg/Converter/Power/v1_2_9/Power_V1_2_9_Dxe.c new file mode 100644 index 00000000000..d90f7f6a9ea --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_2_9/Power_V1_2_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_2_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_2_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "2", + "9" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_2_9 *PowerV1_2_9; + EFI_REDFISH_POWER_V1_2_9_CS *PowerV1_2_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_2_9_To_CS (ResoruceRaw, &PowerV1_2_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_2_9 = (EFI_REDFISH_POWER_V1_2_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_2_9)); + if (PowerV1_2_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_2_9; + PowerV1_2_9->Power = PowerV1_2_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_2_9_JSON (*((EFI_REDFISH_POWER_V1_2_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_2_9 *PowerV1_2_9; + + PowerV1_2_9 = (EFI_REDFISH_POWER_V1_2_9 *)InterpProp; + DestroyPower_V1_2_9_CS (PowerV1_2_9->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_2_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_2_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_2_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_2_9/RedfishPower_V1_2_9_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_2_9/RedfishPower_V1_2_9_Dxe.inf new file mode 100644 index 00000000000..0c0df8d8a00 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_2_9/RedfishPower_V1_2_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_2_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_2_9_Dxe + FILE_GUID = 57987f05-3361-466c-9176-c589f4649441 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_2_9EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_2_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_2_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_2_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_3_0/Power_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/Power/v1_3_0/Power_V1_3_0_Dxe.c new file mode 100644 index 00000000000..b10d855378c --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_3_0/Power_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "3", + "0" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_3_0 *PowerV1_3_0; + EFI_REDFISH_POWER_V1_3_0_CS *PowerV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_3_0_To_CS (ResoruceRaw, &PowerV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_3_0 = (EFI_REDFISH_POWER_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_3_0)); + if (PowerV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_3_0; + PowerV1_3_0->Power = PowerV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_3_0_JSON (*((EFI_REDFISH_POWER_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_3_0 *PowerV1_3_0; + + PowerV1_3_0 = (EFI_REDFISH_POWER_V1_3_0 *)InterpProp; + DestroyPower_V1_3_0_CS (PowerV1_3_0->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_3_0/RedfishPower_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_3_0/RedfishPower_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..09aa9162f41 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_3_0/RedfishPower_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_3_0_Dxe + FILE_GUID = 0609b171-e45c-45bc-b1f7-53298f8df52d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_3_1/Power_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/Power/v1_3_1/Power_V1_3_1_Dxe.c new file mode 100644 index 00000000000..c00f7429e67 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_3_1/Power_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "3", + "1" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_3_1 *PowerV1_3_1; + EFI_REDFISH_POWER_V1_3_1_CS *PowerV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_3_1_To_CS (ResoruceRaw, &PowerV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_3_1 = (EFI_REDFISH_POWER_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_3_1)); + if (PowerV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_3_1; + PowerV1_3_1->Power = PowerV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_3_1_JSON (*((EFI_REDFISH_POWER_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_3_1 *PowerV1_3_1; + + PowerV1_3_1 = (EFI_REDFISH_POWER_V1_3_1 *)InterpProp; + DestroyPower_V1_3_1_CS (PowerV1_3_1->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_3_1/RedfishPower_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_3_1/RedfishPower_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..82945fc7a99 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_3_1/RedfishPower_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_3_1_Dxe + FILE_GUID = 906b5b2b-a05d-42b1-a903-76faa1d542d8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_3_2/Power_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/Power/v1_3_2/Power_V1_3_2_Dxe.c new file mode 100644 index 00000000000..8d114f9431a --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_3_2/Power_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "3", + "2" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_3_2 *PowerV1_3_2; + EFI_REDFISH_POWER_V1_3_2_CS *PowerV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_3_2_To_CS (ResoruceRaw, &PowerV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_3_2 = (EFI_REDFISH_POWER_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_3_2)); + if (PowerV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_3_2; + PowerV1_3_2->Power = PowerV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_3_2_JSON (*((EFI_REDFISH_POWER_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_3_2 *PowerV1_3_2; + + PowerV1_3_2 = (EFI_REDFISH_POWER_V1_3_2 *)InterpProp; + DestroyPower_V1_3_2_CS (PowerV1_3_2->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_3_2/RedfishPower_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_3_2/RedfishPower_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..ed5678da066 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_3_2/RedfishPower_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_3_2_Dxe + FILE_GUID = ee6f35dc-5b79-4a06-8b0b-0e438f2229ca + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_3_3/Power_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/Power/v1_3_3/Power_V1_3_3_Dxe.c new file mode 100644 index 00000000000..ca2ca26c29d --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_3_3/Power_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "3", + "3" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_3_3 *PowerV1_3_3; + EFI_REDFISH_POWER_V1_3_3_CS *PowerV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_3_3_To_CS (ResoruceRaw, &PowerV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_3_3 = (EFI_REDFISH_POWER_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_3_3)); + if (PowerV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_3_3; + PowerV1_3_3->Power = PowerV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_3_3_JSON (*((EFI_REDFISH_POWER_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_3_3 *PowerV1_3_3; + + PowerV1_3_3 = (EFI_REDFISH_POWER_V1_3_3 *)InterpProp; + DestroyPower_V1_3_3_CS (PowerV1_3_3->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_3_3/RedfishPower_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_3_3/RedfishPower_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..a752e6f5f2f --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_3_3/RedfishPower_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_3_3_Dxe + FILE_GUID = 02d4d4d1-27d9-452f-9a24-e6d99cceedfa + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_3_4/Power_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/Power/v1_3_4/Power_V1_3_4_Dxe.c new file mode 100644 index 00000000000..536d09a2bb1 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_3_4/Power_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "3", + "4" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_3_4 *PowerV1_3_4; + EFI_REDFISH_POWER_V1_3_4_CS *PowerV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_3_4_To_CS (ResoruceRaw, &PowerV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_3_4 = (EFI_REDFISH_POWER_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_3_4)); + if (PowerV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_3_4; + PowerV1_3_4->Power = PowerV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_3_4_JSON (*((EFI_REDFISH_POWER_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_3_4 *PowerV1_3_4; + + PowerV1_3_4 = (EFI_REDFISH_POWER_V1_3_4 *)InterpProp; + DestroyPower_V1_3_4_CS (PowerV1_3_4->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_3_4/RedfishPower_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_3_4/RedfishPower_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..416ad89bf34 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_3_4/RedfishPower_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_3_4_Dxe + FILE_GUID = f9f95411-efea-4814-8baf-76b9479a53f6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_3_5/Power_V1_3_5_Dxe.c b/RedfishClientPkg/Converter/Power/v1_3_5/Power_V1_3_5_Dxe.c new file mode 100644 index 00000000000..0c3cbfc2d23 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_3_5/Power_V1_3_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_3_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "3", + "5" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_3_5 *PowerV1_3_5; + EFI_REDFISH_POWER_V1_3_5_CS *PowerV1_3_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_3_5_To_CS (ResoruceRaw, &PowerV1_3_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_3_5 = (EFI_REDFISH_POWER_V1_3_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_3_5)); + if (PowerV1_3_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_3_5; + PowerV1_3_5->Power = PowerV1_3_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_3_5_JSON (*((EFI_REDFISH_POWER_V1_3_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_3_5 *PowerV1_3_5; + + PowerV1_3_5 = (EFI_REDFISH_POWER_V1_3_5 *)InterpProp; + DestroyPower_V1_3_5_CS (PowerV1_3_5->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_3_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_3_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_3_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_3_5/RedfishPower_V1_3_5_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_3_5/RedfishPower_V1_3_5_Dxe.inf new file mode 100644 index 00000000000..3306f0abe6f --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_3_5/RedfishPower_V1_3_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_3_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_3_5_Dxe + FILE_GUID = 4b98b948-08df-4fb3-9642-26a06d4a6973 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_3_5EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_3_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_3_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_3_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_3_6/Power_V1_3_6_Dxe.c b/RedfishClientPkg/Converter/Power/v1_3_6/Power_V1_3_6_Dxe.c new file mode 100644 index 00000000000..e0a9bbc4d22 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_3_6/Power_V1_3_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_3_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "3", + "6" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_3_6 *PowerV1_3_6; + EFI_REDFISH_POWER_V1_3_6_CS *PowerV1_3_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_3_6_To_CS (ResoruceRaw, &PowerV1_3_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_3_6 = (EFI_REDFISH_POWER_V1_3_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_3_6)); + if (PowerV1_3_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_3_6; + PowerV1_3_6->Power = PowerV1_3_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_3_6_JSON (*((EFI_REDFISH_POWER_V1_3_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_3_6 *PowerV1_3_6; + + PowerV1_3_6 = (EFI_REDFISH_POWER_V1_3_6 *)InterpProp; + DestroyPower_V1_3_6_CS (PowerV1_3_6->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_3_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_3_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_3_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_3_6/RedfishPower_V1_3_6_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_3_6/RedfishPower_V1_3_6_Dxe.inf new file mode 100644 index 00000000000..315008b32ec --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_3_6/RedfishPower_V1_3_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_3_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_3_6_Dxe + FILE_GUID = d51acf2a-a944-463a-b4de-4d140652f55d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_3_6EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_3_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_3_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_3_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_3_7/Power_V1_3_7_Dxe.c b/RedfishClientPkg/Converter/Power/v1_3_7/Power_V1_3_7_Dxe.c new file mode 100644 index 00000000000..2c247819862 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_3_7/Power_V1_3_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_3_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_3_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "3", + "7" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_3_7 *PowerV1_3_7; + EFI_REDFISH_POWER_V1_3_7_CS *PowerV1_3_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_3_7_To_CS (ResoruceRaw, &PowerV1_3_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_3_7 = (EFI_REDFISH_POWER_V1_3_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_3_7)); + if (PowerV1_3_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_3_7; + PowerV1_3_7->Power = PowerV1_3_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_3_7_JSON (*((EFI_REDFISH_POWER_V1_3_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_3_7 *PowerV1_3_7; + + PowerV1_3_7 = (EFI_REDFISH_POWER_V1_3_7 *)InterpProp; + DestroyPower_V1_3_7_CS (PowerV1_3_7->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_3_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_3_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_3_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_3_7/RedfishPower_V1_3_7_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_3_7/RedfishPower_V1_3_7_Dxe.inf new file mode 100644 index 00000000000..c9babd93754 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_3_7/RedfishPower_V1_3_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_3_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_3_7_Dxe + FILE_GUID = b66e32c1-e6a3-4f84-966d-a2a9a3f0fbb6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_3_7EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_3_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_3_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_3_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_3_8/Power_V1_3_8_Dxe.c b/RedfishClientPkg/Converter/Power/v1_3_8/Power_V1_3_8_Dxe.c new file mode 100644 index 00000000000..01cafeec2ac --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_3_8/Power_V1_3_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_3_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_3_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "3", + "8" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_3_8 *PowerV1_3_8; + EFI_REDFISH_POWER_V1_3_8_CS *PowerV1_3_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_3_8_To_CS (ResoruceRaw, &PowerV1_3_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_3_8 = (EFI_REDFISH_POWER_V1_3_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_3_8)); + if (PowerV1_3_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_3_8; + PowerV1_3_8->Power = PowerV1_3_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_3_8_JSON (*((EFI_REDFISH_POWER_V1_3_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_3_8 *PowerV1_3_8; + + PowerV1_3_8 = (EFI_REDFISH_POWER_V1_3_8 *)InterpProp; + DestroyPower_V1_3_8_CS (PowerV1_3_8->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_3_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_3_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_3_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_3_8/RedfishPower_V1_3_8_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_3_8/RedfishPower_V1_3_8_Dxe.inf new file mode 100644 index 00000000000..f143896409d --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_3_8/RedfishPower_V1_3_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_3_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_3_8_Dxe + FILE_GUID = 388fd5c2-5ee0-46c3-93f8-5846dd12d2d8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_3_8EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_3_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_3_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_3_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_4_0/Power_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/Power/v1_4_0/Power_V1_4_0_Dxe.c new file mode 100644 index 00000000000..d3042405757 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_4_0/Power_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "4", + "0" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_4_0 *PowerV1_4_0; + EFI_REDFISH_POWER_V1_4_0_CS *PowerV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_4_0_To_CS (ResoruceRaw, &PowerV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_4_0 = (EFI_REDFISH_POWER_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_4_0)); + if (PowerV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_4_0; + PowerV1_4_0->Power = PowerV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_4_0_JSON (*((EFI_REDFISH_POWER_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_4_0 *PowerV1_4_0; + + PowerV1_4_0 = (EFI_REDFISH_POWER_V1_4_0 *)InterpProp; + DestroyPower_V1_4_0_CS (PowerV1_4_0->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_4_0/RedfishPower_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_4_0/RedfishPower_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..d7645dce716 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_4_0/RedfishPower_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_4_0_Dxe + FILE_GUID = b61bbdb5-6a5b-47ba-b3d1-c2957d88253c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_4_1/Power_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/Power/v1_4_1/Power_V1_4_1_Dxe.c new file mode 100644 index 00000000000..1c3895714ae --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_4_1/Power_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "4", + "1" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_4_1 *PowerV1_4_1; + EFI_REDFISH_POWER_V1_4_1_CS *PowerV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_4_1_To_CS (ResoruceRaw, &PowerV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_4_1 = (EFI_REDFISH_POWER_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_4_1)); + if (PowerV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_4_1; + PowerV1_4_1->Power = PowerV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_4_1_JSON (*((EFI_REDFISH_POWER_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_4_1 *PowerV1_4_1; + + PowerV1_4_1 = (EFI_REDFISH_POWER_V1_4_1 *)InterpProp; + DestroyPower_V1_4_1_CS (PowerV1_4_1->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_4_1/RedfishPower_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_4_1/RedfishPower_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..334fefb736e --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_4_1/RedfishPower_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_4_1_Dxe + FILE_GUID = 9447524f-cc9a-4b61-a5b4-a2d85aa15b4e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_4_2/Power_V1_4_2_Dxe.c b/RedfishClientPkg/Converter/Power/v1_4_2/Power_V1_4_2_Dxe.c new file mode 100644 index 00000000000..c41ba0ccbf8 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_4_2/Power_V1_4_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_4_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "4", + "2" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_4_2 *PowerV1_4_2; + EFI_REDFISH_POWER_V1_4_2_CS *PowerV1_4_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_4_2_To_CS (ResoruceRaw, &PowerV1_4_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_4_2 = (EFI_REDFISH_POWER_V1_4_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_4_2)); + if (PowerV1_4_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_4_2; + PowerV1_4_2->Power = PowerV1_4_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_4_2_JSON (*((EFI_REDFISH_POWER_V1_4_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_4_2 *PowerV1_4_2; + + PowerV1_4_2 = (EFI_REDFISH_POWER_V1_4_2 *)InterpProp; + DestroyPower_V1_4_2_CS (PowerV1_4_2->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_4_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_4_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_4_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_4_2/RedfishPower_V1_4_2_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_4_2/RedfishPower_V1_4_2_Dxe.inf new file mode 100644 index 00000000000..71e1bd7e631 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_4_2/RedfishPower_V1_4_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_4_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_4_2_Dxe + FILE_GUID = 936f42a3-29e7-4784-a32c-f7ac90ab41cb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_4_2EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_4_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_4_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_4_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_4_3/Power_V1_4_3_Dxe.c b/RedfishClientPkg/Converter/Power/v1_4_3/Power_V1_4_3_Dxe.c new file mode 100644 index 00000000000..4b73704577f --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_4_3/Power_V1_4_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_4_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "4", + "3" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_4_3 *PowerV1_4_3; + EFI_REDFISH_POWER_V1_4_3_CS *PowerV1_4_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_4_3_To_CS (ResoruceRaw, &PowerV1_4_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_4_3 = (EFI_REDFISH_POWER_V1_4_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_4_3)); + if (PowerV1_4_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_4_3; + PowerV1_4_3->Power = PowerV1_4_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_4_3_JSON (*((EFI_REDFISH_POWER_V1_4_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_4_3 *PowerV1_4_3; + + PowerV1_4_3 = (EFI_REDFISH_POWER_V1_4_3 *)InterpProp; + DestroyPower_V1_4_3_CS (PowerV1_4_3->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_4_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_4_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_4_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_4_3/RedfishPower_V1_4_3_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_4_3/RedfishPower_V1_4_3_Dxe.inf new file mode 100644 index 00000000000..21688213ba1 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_4_3/RedfishPower_V1_4_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_4_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_4_3_Dxe + FILE_GUID = c2bda539-a11d-46d8-8f48-2db18de6ca8e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_4_3EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_4_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_4_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_4_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_4_4/Power_V1_4_4_Dxe.c b/RedfishClientPkg/Converter/Power/v1_4_4/Power_V1_4_4_Dxe.c new file mode 100644 index 00000000000..dc702be11a9 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_4_4/Power_V1_4_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_4_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "4", + "4" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_4_4 *PowerV1_4_4; + EFI_REDFISH_POWER_V1_4_4_CS *PowerV1_4_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_4_4_To_CS (ResoruceRaw, &PowerV1_4_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_4_4 = (EFI_REDFISH_POWER_V1_4_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_4_4)); + if (PowerV1_4_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_4_4; + PowerV1_4_4->Power = PowerV1_4_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_4_4_JSON (*((EFI_REDFISH_POWER_V1_4_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_4_4 *PowerV1_4_4; + + PowerV1_4_4 = (EFI_REDFISH_POWER_V1_4_4 *)InterpProp; + DestroyPower_V1_4_4_CS (PowerV1_4_4->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_4_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_4_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_4_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_4_4/RedfishPower_V1_4_4_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_4_4/RedfishPower_V1_4_4_Dxe.inf new file mode 100644 index 00000000000..9f0207c3be2 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_4_4/RedfishPower_V1_4_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_4_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_4_4_Dxe + FILE_GUID = 5d183dc0-5b9f-4a96-8ff0-c1a688e37ec5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_4_4EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_4_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_4_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_4_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_4_5/Power_V1_4_5_Dxe.c b/RedfishClientPkg/Converter/Power/v1_4_5/Power_V1_4_5_Dxe.c new file mode 100644 index 00000000000..9a2dce3bce0 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_4_5/Power_V1_4_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_4_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "4", + "5" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_4_5 *PowerV1_4_5; + EFI_REDFISH_POWER_V1_4_5_CS *PowerV1_4_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_4_5_To_CS (ResoruceRaw, &PowerV1_4_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_4_5 = (EFI_REDFISH_POWER_V1_4_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_4_5)); + if (PowerV1_4_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_4_5; + PowerV1_4_5->Power = PowerV1_4_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_4_5_JSON (*((EFI_REDFISH_POWER_V1_4_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_4_5 *PowerV1_4_5; + + PowerV1_4_5 = (EFI_REDFISH_POWER_V1_4_5 *)InterpProp; + DestroyPower_V1_4_5_CS (PowerV1_4_5->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_4_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_4_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_4_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_4_5/RedfishPower_V1_4_5_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_4_5/RedfishPower_V1_4_5_Dxe.inf new file mode 100644 index 00000000000..2fccd0a26f3 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_4_5/RedfishPower_V1_4_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_4_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_4_5_Dxe + FILE_GUID = 2de459e2-d349-44f5-9de9-dcc0445ef55e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_4_5EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_4_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_4_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_4_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_4_6/Power_V1_4_6_Dxe.c b/RedfishClientPkg/Converter/Power/v1_4_6/Power_V1_4_6_Dxe.c new file mode 100644 index 00000000000..b9e1bab3dde --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_4_6/Power_V1_4_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_4_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_4_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "4", + "6" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_4_6 *PowerV1_4_6; + EFI_REDFISH_POWER_V1_4_6_CS *PowerV1_4_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_4_6_To_CS (ResoruceRaw, &PowerV1_4_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_4_6 = (EFI_REDFISH_POWER_V1_4_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_4_6)); + if (PowerV1_4_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_4_6; + PowerV1_4_6->Power = PowerV1_4_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_4_6_JSON (*((EFI_REDFISH_POWER_V1_4_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_4_6 *PowerV1_4_6; + + PowerV1_4_6 = (EFI_REDFISH_POWER_V1_4_6 *)InterpProp; + DestroyPower_V1_4_6_CS (PowerV1_4_6->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_4_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_4_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_4_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_4_6/RedfishPower_V1_4_6_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_4_6/RedfishPower_V1_4_6_Dxe.inf new file mode 100644 index 00000000000..8959f255fb5 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_4_6/RedfishPower_V1_4_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_4_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_4_6_Dxe + FILE_GUID = b7d706c2-c86e-4692-ab7f-b23f64836965 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_4_6EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_4_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_4_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_4_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_4_7/Power_V1_4_7_Dxe.c b/RedfishClientPkg/Converter/Power/v1_4_7/Power_V1_4_7_Dxe.c new file mode 100644 index 00000000000..f5a3d49f6cd --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_4_7/Power_V1_4_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_4_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_4_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "4", + "7" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_4_7 *PowerV1_4_7; + EFI_REDFISH_POWER_V1_4_7_CS *PowerV1_4_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_4_7_To_CS (ResoruceRaw, &PowerV1_4_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_4_7 = (EFI_REDFISH_POWER_V1_4_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_4_7)); + if (PowerV1_4_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_4_7; + PowerV1_4_7->Power = PowerV1_4_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_4_7_JSON (*((EFI_REDFISH_POWER_V1_4_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_4_7 *PowerV1_4_7; + + PowerV1_4_7 = (EFI_REDFISH_POWER_V1_4_7 *)InterpProp; + DestroyPower_V1_4_7_CS (PowerV1_4_7->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_4_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_4_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_4_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_4_7/RedfishPower_V1_4_7_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_4_7/RedfishPower_V1_4_7_Dxe.inf new file mode 100644 index 00000000000..dcf02eeaabb --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_4_7/RedfishPower_V1_4_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_4_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_4_7_Dxe + FILE_GUID = 71e675ac-3efc-4d13-9d79-9b1562c172c9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_4_7EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_4_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_4_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_4_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_5_0/Power_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/Power/v1_5_0/Power_V1_5_0_Dxe.c new file mode 100644 index 00000000000..f9f3a9ebd1e --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_5_0/Power_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "5", + "0" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_5_0 *PowerV1_5_0; + EFI_REDFISH_POWER_V1_5_0_CS *PowerV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_5_0_To_CS (ResoruceRaw, &PowerV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_5_0 = (EFI_REDFISH_POWER_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_5_0)); + if (PowerV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_5_0; + PowerV1_5_0->Power = PowerV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_5_0_JSON (*((EFI_REDFISH_POWER_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_5_0 *PowerV1_5_0; + + PowerV1_5_0 = (EFI_REDFISH_POWER_V1_5_0 *)InterpProp; + DestroyPower_V1_5_0_CS (PowerV1_5_0->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_5_0/RedfishPower_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_5_0/RedfishPower_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..5e6dd8db1b2 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_5_0/RedfishPower_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_5_0_Dxe + FILE_GUID = 4e297429-1f6e-4f09-9aaf-99f409495657 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_5_1/Power_V1_5_1_Dxe.c b/RedfishClientPkg/Converter/Power/v1_5_1/Power_V1_5_1_Dxe.c new file mode 100644 index 00000000000..0851340a9bb --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_5_1/Power_V1_5_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_5_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "5", + "1" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_5_1 *PowerV1_5_1; + EFI_REDFISH_POWER_V1_5_1_CS *PowerV1_5_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_5_1_To_CS (ResoruceRaw, &PowerV1_5_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_5_1 = (EFI_REDFISH_POWER_V1_5_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_5_1)); + if (PowerV1_5_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_5_1; + PowerV1_5_1->Power = PowerV1_5_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_5_1_JSON (*((EFI_REDFISH_POWER_V1_5_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_5_1 *PowerV1_5_1; + + PowerV1_5_1 = (EFI_REDFISH_POWER_V1_5_1 *)InterpProp; + DestroyPower_V1_5_1_CS (PowerV1_5_1->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_5_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_5_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_5_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_5_1/RedfishPower_V1_5_1_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_5_1/RedfishPower_V1_5_1_Dxe.inf new file mode 100644 index 00000000000..efda4a54d3c --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_5_1/RedfishPower_V1_5_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_5_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_5_1_Dxe + FILE_GUID = 2a5b3f6d-f777-4dcf-a661-4cb98e8aa38b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_5_1EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_5_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_5_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_5_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_5_2/Power_V1_5_2_Dxe.c b/RedfishClientPkg/Converter/Power/v1_5_2/Power_V1_5_2_Dxe.c new file mode 100644 index 00000000000..10b72ae164f --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_5_2/Power_V1_5_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_5_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "5", + "2" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_5_2 *PowerV1_5_2; + EFI_REDFISH_POWER_V1_5_2_CS *PowerV1_5_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_5_2_To_CS (ResoruceRaw, &PowerV1_5_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_5_2 = (EFI_REDFISH_POWER_V1_5_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_5_2)); + if (PowerV1_5_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_5_2; + PowerV1_5_2->Power = PowerV1_5_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_5_2_JSON (*((EFI_REDFISH_POWER_V1_5_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_5_2 *PowerV1_5_2; + + PowerV1_5_2 = (EFI_REDFISH_POWER_V1_5_2 *)InterpProp; + DestroyPower_V1_5_2_CS (PowerV1_5_2->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_5_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_5_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_5_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_5_2/RedfishPower_V1_5_2_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_5_2/RedfishPower_V1_5_2_Dxe.inf new file mode 100644 index 00000000000..c90b62148d5 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_5_2/RedfishPower_V1_5_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_5_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_5_2_Dxe + FILE_GUID = 18c750db-76ca-4eca-81e4-589f21529843 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_5_2EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_5_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_5_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_5_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_5_3/Power_V1_5_3_Dxe.c b/RedfishClientPkg/Converter/Power/v1_5_3/Power_V1_5_3_Dxe.c new file mode 100644 index 00000000000..656d3e17f2e --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_5_3/Power_V1_5_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_5_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "5", + "3" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_5_3 *PowerV1_5_3; + EFI_REDFISH_POWER_V1_5_3_CS *PowerV1_5_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_5_3_To_CS (ResoruceRaw, &PowerV1_5_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_5_3 = (EFI_REDFISH_POWER_V1_5_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_5_3)); + if (PowerV1_5_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_5_3; + PowerV1_5_3->Power = PowerV1_5_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_5_3_JSON (*((EFI_REDFISH_POWER_V1_5_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_5_3 *PowerV1_5_3; + + PowerV1_5_3 = (EFI_REDFISH_POWER_V1_5_3 *)InterpProp; + DestroyPower_V1_5_3_CS (PowerV1_5_3->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_5_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_5_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_5_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_5_3/RedfishPower_V1_5_3_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_5_3/RedfishPower_V1_5_3_Dxe.inf new file mode 100644 index 00000000000..6aafe864319 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_5_3/RedfishPower_V1_5_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_5_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_5_3_Dxe + FILE_GUID = 9dab7638-cfc7-4037-a933-8e205d433f72 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_5_3EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_5_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_5_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_5_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_5_4/Power_V1_5_4_Dxe.c b/RedfishClientPkg/Converter/Power/v1_5_4/Power_V1_5_4_Dxe.c new file mode 100644 index 00000000000..744120268b8 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_5_4/Power_V1_5_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_5_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "5", + "4" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_5_4 *PowerV1_5_4; + EFI_REDFISH_POWER_V1_5_4_CS *PowerV1_5_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_5_4_To_CS (ResoruceRaw, &PowerV1_5_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_5_4 = (EFI_REDFISH_POWER_V1_5_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_5_4)); + if (PowerV1_5_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_5_4; + PowerV1_5_4->Power = PowerV1_5_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_5_4_JSON (*((EFI_REDFISH_POWER_V1_5_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_5_4 *PowerV1_5_4; + + PowerV1_5_4 = (EFI_REDFISH_POWER_V1_5_4 *)InterpProp; + DestroyPower_V1_5_4_CS (PowerV1_5_4->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_5_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_5_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_5_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_5_4/RedfishPower_V1_5_4_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_5_4/RedfishPower_V1_5_4_Dxe.inf new file mode 100644 index 00000000000..fc97d82f196 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_5_4/RedfishPower_V1_5_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_5_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_5_4_Dxe + FILE_GUID = f9f38637-b950-4c18-9a28-fabe451394bd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_5_4EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_5_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_5_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_5_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_5_5/Power_V1_5_5_Dxe.c b/RedfishClientPkg/Converter/Power/v1_5_5/Power_V1_5_5_Dxe.c new file mode 100644 index 00000000000..b2d180a9242 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_5_5/Power_V1_5_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_5_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_5_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "5", + "5" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_5_5 *PowerV1_5_5; + EFI_REDFISH_POWER_V1_5_5_CS *PowerV1_5_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_5_5_To_CS (ResoruceRaw, &PowerV1_5_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_5_5 = (EFI_REDFISH_POWER_V1_5_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_5_5)); + if (PowerV1_5_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_5_5; + PowerV1_5_5->Power = PowerV1_5_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_5_5_JSON (*((EFI_REDFISH_POWER_V1_5_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_5_5 *PowerV1_5_5; + + PowerV1_5_5 = (EFI_REDFISH_POWER_V1_5_5 *)InterpProp; + DestroyPower_V1_5_5_CS (PowerV1_5_5->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_5_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_5_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_5_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_5_5/RedfishPower_V1_5_5_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_5_5/RedfishPower_V1_5_5_Dxe.inf new file mode 100644 index 00000000000..d9c9c4e853f --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_5_5/RedfishPower_V1_5_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_5_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_5_5_Dxe + FILE_GUID = 796fdda2-2d72-4e12-a5f8-b5a979a12036 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_5_5EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_5_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_5_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_5_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_5_6/Power_V1_5_6_Dxe.c b/RedfishClientPkg/Converter/Power/v1_5_6/Power_V1_5_6_Dxe.c new file mode 100644 index 00000000000..2031edb22d3 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_5_6/Power_V1_5_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_5_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_5_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "5", + "6" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_5_6 *PowerV1_5_6; + EFI_REDFISH_POWER_V1_5_6_CS *PowerV1_5_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_5_6_To_CS (ResoruceRaw, &PowerV1_5_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_5_6 = (EFI_REDFISH_POWER_V1_5_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_5_6)); + if (PowerV1_5_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_5_6; + PowerV1_5_6->Power = PowerV1_5_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_5_6_JSON (*((EFI_REDFISH_POWER_V1_5_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_5_6 *PowerV1_5_6; + + PowerV1_5_6 = (EFI_REDFISH_POWER_V1_5_6 *)InterpProp; + DestroyPower_V1_5_6_CS (PowerV1_5_6->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_5_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_5_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_5_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_5_6/RedfishPower_V1_5_6_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_5_6/RedfishPower_V1_5_6_Dxe.inf new file mode 100644 index 00000000000..64e44af10e0 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_5_6/RedfishPower_V1_5_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_5_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_5_6_Dxe + FILE_GUID = 63dbb105-2700-434a-8f52-acb3e8c1a342 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_5_6EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_5_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_5_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_5_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_6_0/Power_V1_6_0_Dxe.c b/RedfishClientPkg/Converter/Power/v1_6_0/Power_V1_6_0_Dxe.c new file mode 100644 index 00000000000..042a991c6ea --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_6_0/Power_V1_6_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_6_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "6", + "0" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_6_0 *PowerV1_6_0; + EFI_REDFISH_POWER_V1_6_0_CS *PowerV1_6_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_6_0_To_CS (ResoruceRaw, &PowerV1_6_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_6_0 = (EFI_REDFISH_POWER_V1_6_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_6_0)); + if (PowerV1_6_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_6_0; + PowerV1_6_0->Power = PowerV1_6_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_6_0_JSON (*((EFI_REDFISH_POWER_V1_6_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_6_0 *PowerV1_6_0; + + PowerV1_6_0 = (EFI_REDFISH_POWER_V1_6_0 *)InterpProp; + DestroyPower_V1_6_0_CS (PowerV1_6_0->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_6_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_6_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_6_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_6_0/RedfishPower_V1_6_0_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_6_0/RedfishPower_V1_6_0_Dxe.inf new file mode 100644 index 00000000000..ea2da2defd4 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_6_0/RedfishPower_V1_6_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_6_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_6_0_Dxe + FILE_GUID = e13905df-44ba-4814-ae60-f01b3133a7e9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_6_0EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_6_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_6_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_6_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_6_1/Power_V1_6_1_Dxe.c b/RedfishClientPkg/Converter/Power/v1_6_1/Power_V1_6_1_Dxe.c new file mode 100644 index 00000000000..8422e501b02 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_6_1/Power_V1_6_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_6_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "6", + "1" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_6_1 *PowerV1_6_1; + EFI_REDFISH_POWER_V1_6_1_CS *PowerV1_6_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_6_1_To_CS (ResoruceRaw, &PowerV1_6_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_6_1 = (EFI_REDFISH_POWER_V1_6_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_6_1)); + if (PowerV1_6_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_6_1; + PowerV1_6_1->Power = PowerV1_6_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_6_1_JSON (*((EFI_REDFISH_POWER_V1_6_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_6_1 *PowerV1_6_1; + + PowerV1_6_1 = (EFI_REDFISH_POWER_V1_6_1 *)InterpProp; + DestroyPower_V1_6_1_CS (PowerV1_6_1->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_6_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_6_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_6_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_6_1/RedfishPower_V1_6_1_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_6_1/RedfishPower_V1_6_1_Dxe.inf new file mode 100644 index 00000000000..d38b9dcbc28 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_6_1/RedfishPower_V1_6_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_6_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_6_1_Dxe + FILE_GUID = cb7f5cf2-b3a3-4a69-ac35-ffcb4c4ebcf5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_6_1EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_6_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_6_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_6_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_6_2/Power_V1_6_2_Dxe.c b/RedfishClientPkg/Converter/Power/v1_6_2/Power_V1_6_2_Dxe.c new file mode 100644 index 00000000000..e862673618f --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_6_2/Power_V1_6_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_6_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "6", + "2" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_6_2 *PowerV1_6_2; + EFI_REDFISH_POWER_V1_6_2_CS *PowerV1_6_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_6_2_To_CS (ResoruceRaw, &PowerV1_6_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_6_2 = (EFI_REDFISH_POWER_V1_6_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_6_2)); + if (PowerV1_6_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_6_2; + PowerV1_6_2->Power = PowerV1_6_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_6_2_JSON (*((EFI_REDFISH_POWER_V1_6_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_6_2 *PowerV1_6_2; + + PowerV1_6_2 = (EFI_REDFISH_POWER_V1_6_2 *)InterpProp; + DestroyPower_V1_6_2_CS (PowerV1_6_2->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_6_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_6_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_6_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_6_2/RedfishPower_V1_6_2_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_6_2/RedfishPower_V1_6_2_Dxe.inf new file mode 100644 index 00000000000..51c365a5c10 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_6_2/RedfishPower_V1_6_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_6_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_6_2_Dxe + FILE_GUID = 1859c47b-8505-4255-a0aa-9b1469f5f008 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_6_2EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_6_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_6_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_6_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Power/v1_7_0/Power_V1_7_0_Dxe.c b/RedfishClientPkg/Converter/Power/v1_7_0/Power_V1_7_0_Dxe.c new file mode 100644 index 00000000000..bab9d654abd --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_7_0/Power_V1_7_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Power.v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Power"; +BOOLEAN IsRevisonController = TRUE; + +// Support Power V1_7_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Power", + "1", + "7", + "0" + }, + "Power" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWER_V1_7_0 *PowerV1_7_0; + EFI_REDFISH_POWER_V1_7_0_CS *PowerV1_7_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Power") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Power_V1_7_0_To_CS (ResoruceRaw, &PowerV1_7_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerV1_7_0 = (EFI_REDFISH_POWER_V1_7_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWER_V1_7_0)); + if (PowerV1_7_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerV1_7_0; + PowerV1_7_0->Power = PowerV1_7_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Power"), "Power"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Power")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Power"), "Power"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Power_V1_7_0_JSON (*((EFI_REDFISH_POWER_V1_7_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWER_V1_7_0 *PowerV1_7_0; + + PowerV1_7_0 = (EFI_REDFISH_POWER_V1_7_0 *)InterpProp; + DestroyPower_V1_7_0_CS (PowerV1_7_0->Power); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPower_V1_7_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_7_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerToStructWrapper, + PowerToJson, + PowerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPower_V1_7_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Power/v1_7_0/RedfishPower_V1_7_0_Dxe.inf b/RedfishClientPkg/Converter/Power/v1_7_0/RedfishPower_V1_7_0_Dxe.inf new file mode 100644 index 00000000000..90d416881e8 --- /dev/null +++ b/RedfishClientPkg/Converter/Power/v1_7_0/RedfishPower_V1_7_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Power.v1_7_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPower_V1_7_0_Dxe + FILE_GUID = bd5edf91-61d3-492e-a812-7818afea661d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPower_V1_7_0EntryPoint + UNLOAD_IMAGE = RedfishPower_V1_7_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Power_V1_7_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerV1_7_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PowerDistribution/v1_0_0/PowerDistribution_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/PowerDistribution/v1_0_0/PowerDistribution_V1_0_0_Dxe.c new file mode 100644 index 00000000000..5771475bbf1 --- /dev/null +++ b/RedfishClientPkg/Converter/PowerDistribution/v1_0_0/PowerDistribution_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PowerDistribution.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PowerDistribution"; +BOOLEAN IsRevisonController = TRUE; + +// Support PowerDistribution V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PowerDistribution", + "1", + "0", + "0" + }, + "PowerDistribution" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDistributionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWERDISTRIBUTION_V1_0_0 *PowerDistributionV1_0_0; + EFI_REDFISH_POWERDISTRIBUTION_V1_0_0_CS *PowerDistributionV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PowerDistribution") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PowerDistribution_V1_0_0_To_CS (ResoruceRaw, &PowerDistributionV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerDistributionV1_0_0 = (EFI_REDFISH_POWERDISTRIBUTION_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWERDISTRIBUTION_V1_0_0)); + if (PowerDistributionV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerDistributionV1_0_0; + PowerDistributionV1_0_0->PowerDistribution = PowerDistributionV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerDistribution")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PowerDistribution"), "PowerDistribution"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerDistribution")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PowerDistribution"), "PowerDistribution"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerDistributionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDistributionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerDistributionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDistributionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PowerDistribution_V1_0_0_JSON (*((EFI_REDFISH_POWERDISTRIBUTION_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerDistributionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDistributionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWERDISTRIBUTION_V1_0_0 *PowerDistributionV1_0_0; + + PowerDistributionV1_0_0 = (EFI_REDFISH_POWERDISTRIBUTION_V1_0_0 *)InterpProp; + DestroyPowerDistribution_V1_0_0_CS (PowerDistributionV1_0_0->PowerDistribution); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerDistributionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDistributionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPowerDistribution_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPowerDistribution_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerDistributionToStructWrapper, + PowerDistributionToJson, + PowerDistributionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPowerDistribution_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PowerDistribution/v1_0_0/RedfishPowerDistribution_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/PowerDistribution/v1_0_0/RedfishPowerDistribution_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..a839db3efe4 --- /dev/null +++ b/RedfishClientPkg/Converter/PowerDistribution/v1_0_0/RedfishPowerDistribution_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PowerDistribution.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPowerDistribution_V1_0_0_Dxe + FILE_GUID = 75fbc72b-4fa3-45a0-86dd-0f6853691ac7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPowerDistribution_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishPowerDistribution_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PowerDistribution_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerDistributionV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PowerDistribution/v1_0_1/PowerDistribution_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/PowerDistribution/v1_0_1/PowerDistribution_V1_0_1_Dxe.c new file mode 100644 index 00000000000..4d361349f8e --- /dev/null +++ b/RedfishClientPkg/Converter/PowerDistribution/v1_0_1/PowerDistribution_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PowerDistribution.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PowerDistribution"; +BOOLEAN IsRevisonController = TRUE; + +// Support PowerDistribution V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PowerDistribution", + "1", + "0", + "1" + }, + "PowerDistribution" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDistributionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWERDISTRIBUTION_V1_0_1 *PowerDistributionV1_0_1; + EFI_REDFISH_POWERDISTRIBUTION_V1_0_1_CS *PowerDistributionV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PowerDistribution") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PowerDistribution_V1_0_1_To_CS (ResoruceRaw, &PowerDistributionV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerDistributionV1_0_1 = (EFI_REDFISH_POWERDISTRIBUTION_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWERDISTRIBUTION_V1_0_1)); + if (PowerDistributionV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerDistributionV1_0_1; + PowerDistributionV1_0_1->PowerDistribution = PowerDistributionV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerDistribution")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PowerDistribution"), "PowerDistribution"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerDistribution")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PowerDistribution"), "PowerDistribution"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerDistributionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDistributionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerDistributionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDistributionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PowerDistribution_V1_0_1_JSON (*((EFI_REDFISH_POWERDISTRIBUTION_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerDistributionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDistributionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWERDISTRIBUTION_V1_0_1 *PowerDistributionV1_0_1; + + PowerDistributionV1_0_1 = (EFI_REDFISH_POWERDISTRIBUTION_V1_0_1 *)InterpProp; + DestroyPowerDistribution_V1_0_1_CS (PowerDistributionV1_0_1->PowerDistribution); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerDistributionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDistributionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPowerDistribution_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPowerDistribution_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerDistributionToStructWrapper, + PowerDistributionToJson, + PowerDistributionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPowerDistribution_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PowerDistribution/v1_0_1/RedfishPowerDistribution_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/PowerDistribution/v1_0_1/RedfishPowerDistribution_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..01c689bae86 --- /dev/null +++ b/RedfishClientPkg/Converter/PowerDistribution/v1_0_1/RedfishPowerDistribution_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PowerDistribution.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPowerDistribution_V1_0_1_Dxe + FILE_GUID = f9bfb768-f4ef-4c90-92ab-21fce418e1ff + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPowerDistribution_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishPowerDistribution_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PowerDistribution_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerDistributionV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PowerDistribution/v1_0_2/PowerDistribution_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/PowerDistribution/v1_0_2/PowerDistribution_V1_0_2_Dxe.c new file mode 100644 index 00000000000..2dda7c27985 --- /dev/null +++ b/RedfishClientPkg/Converter/PowerDistribution/v1_0_2/PowerDistribution_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PowerDistribution.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PowerDistribution"; +BOOLEAN IsRevisonController = TRUE; + +// Support PowerDistribution V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PowerDistribution", + "1", + "0", + "2" + }, + "PowerDistribution" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDistributionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWERDISTRIBUTION_V1_0_2 *PowerDistributionV1_0_2; + EFI_REDFISH_POWERDISTRIBUTION_V1_0_2_CS *PowerDistributionV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PowerDistribution") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PowerDistribution_V1_0_2_To_CS (ResoruceRaw, &PowerDistributionV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerDistributionV1_0_2 = (EFI_REDFISH_POWERDISTRIBUTION_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWERDISTRIBUTION_V1_0_2)); + if (PowerDistributionV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerDistributionV1_0_2; + PowerDistributionV1_0_2->PowerDistribution = PowerDistributionV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerDistribution")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PowerDistribution"), "PowerDistribution"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerDistribution")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PowerDistribution"), "PowerDistribution"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerDistributionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDistributionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerDistributionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDistributionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PowerDistribution_V1_0_2_JSON (*((EFI_REDFISH_POWERDISTRIBUTION_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerDistributionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDistributionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWERDISTRIBUTION_V1_0_2 *PowerDistributionV1_0_2; + + PowerDistributionV1_0_2 = (EFI_REDFISH_POWERDISTRIBUTION_V1_0_2 *)InterpProp; + DestroyPowerDistribution_V1_0_2_CS (PowerDistributionV1_0_2->PowerDistribution); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerDistributionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDistributionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPowerDistribution_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPowerDistribution_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerDistributionToStructWrapper, + PowerDistributionToJson, + PowerDistributionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPowerDistribution_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PowerDistribution/v1_0_2/RedfishPowerDistribution_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/PowerDistribution/v1_0_2/RedfishPowerDistribution_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..5912c2e5722 --- /dev/null +++ b/RedfishClientPkg/Converter/PowerDistribution/v1_0_2/RedfishPowerDistribution_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PowerDistribution.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPowerDistribution_V1_0_2_Dxe + FILE_GUID = ff49fb6a-6cc1-4f1d-bca7-88ebb2fa0ac4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPowerDistribution_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishPowerDistribution_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PowerDistribution_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerDistributionV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PowerDistributionCollection/PowerDistributionCollection_Dxe.c b/RedfishClientPkg/Converter/PowerDistributionCollection/PowerDistributionCollection_Dxe.c new file mode 100644 index 00000000000..17dd1790e50 --- /dev/null +++ b/RedfishClientPkg/Converter/PowerDistributionCollection/PowerDistributionCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PowerDistributionCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PowerDistributionCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support PowerDistributionCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PowerDistributionCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "PowerDistributionCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDistributionCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWERDISTRIBUTIONCOLLECTION *PowerDistributionCollection; + EFI_REDFISH_POWERDISTRIBUTIONCOLLECTION_CS *PowerDistributionCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PowerDistributionCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PowerDistributionCollection_To_CS (ResoruceRaw, &PowerDistributionCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerDistributionCollection = (EFI_REDFISH_POWERDISTRIBUTIONCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWERDISTRIBUTIONCOLLECTION)); + if (PowerDistributionCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerDistributionCollection; + PowerDistributionCollection->PowerDistributionCollection = PowerDistributionCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerDistributionCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PowerDistributionCollection"), "PowerDistributionCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerDistributionCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PowerDistributionCollection"), "PowerDistributionCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerDistributionCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDistributionCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerDistributionCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDistributionCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PowerDistributionCollection_JSON (*((EFI_REDFISH_POWERDISTRIBUTIONCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerDistributionCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDistributionCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWERDISTRIBUTIONCOLLECTION *PowerDistributionCollection; + + PowerDistributionCollection = (EFI_REDFISH_POWERDISTRIBUTIONCOLLECTION *)InterpProp; + DestroyPowerDistributionCollection_CS (PowerDistributionCollection->PowerDistributionCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerDistributionCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDistributionCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPowerDistributionCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPowerDistributionCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerDistributionCollectionToStructWrapper, + PowerDistributionCollectionToJson, + PowerDistributionCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPowerDistributionCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PowerDistributionCollection/RedfishPowerDistributionCollection_Dxe.inf b/RedfishClientPkg/Converter/PowerDistributionCollection/RedfishPowerDistributionCollection_Dxe.inf new file mode 100644 index 00000000000..057a88ee93f --- /dev/null +++ b/RedfishClientPkg/Converter/PowerDistributionCollection/RedfishPowerDistributionCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PowerDistributionCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPowerDistributionCollection_Dxe + FILE_GUID = 9294706f-f058-4e2d-a43b-d400383a9ab3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPowerDistributionCollectionEntryPoint + UNLOAD_IMAGE = RedfishPowerDistributionCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PowerDistributionCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerDistributionCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PowerDistributionMetrics/v1_0_0/PowerDistributionMetrics_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/PowerDistributionMetrics/v1_0_0/PowerDistributionMetrics_V1_0_0_Dxe.c new file mode 100644 index 00000000000..47122dd4fce --- /dev/null +++ b/RedfishClientPkg/Converter/PowerDistributionMetrics/v1_0_0/PowerDistributionMetrics_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PowerDistributionMetrics.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PowerDistributionMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support PowerDistributionMetrics V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PowerDistributionMetrics", + "1", + "0", + "0" + }, + "PowerDistributionMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDistributionMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWERDISTRIBUTIONMETRICS_V1_0_0 *PowerDistributionMetricsV1_0_0; + EFI_REDFISH_POWERDISTRIBUTIONMETRICS_V1_0_0_CS *PowerDistributionMetricsV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PowerDistributionMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PowerDistributionMetrics_V1_0_0_To_CS (ResoruceRaw, &PowerDistributionMetricsV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerDistributionMetricsV1_0_0 = (EFI_REDFISH_POWERDISTRIBUTIONMETRICS_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWERDISTRIBUTIONMETRICS_V1_0_0)); + if (PowerDistributionMetricsV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerDistributionMetricsV1_0_0; + PowerDistributionMetricsV1_0_0->PowerDistributionMetrics = PowerDistributionMetricsV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerDistributionMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PowerDistributionMetrics"), "PowerDistributionMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerDistributionMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PowerDistributionMetrics"), "PowerDistributionMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerDistributionMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDistributionMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerDistributionMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDistributionMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PowerDistributionMetrics_V1_0_0_JSON (*((EFI_REDFISH_POWERDISTRIBUTIONMETRICS_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerDistributionMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDistributionMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWERDISTRIBUTIONMETRICS_V1_0_0 *PowerDistributionMetricsV1_0_0; + + PowerDistributionMetricsV1_0_0 = (EFI_REDFISH_POWERDISTRIBUTIONMETRICS_V1_0_0 *)InterpProp; + DestroyPowerDistributionMetrics_V1_0_0_CS (PowerDistributionMetricsV1_0_0->PowerDistributionMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerDistributionMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDistributionMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPowerDistributionMetrics_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPowerDistributionMetrics_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerDistributionMetricsToStructWrapper, + PowerDistributionMetricsToJson, + PowerDistributionMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPowerDistributionMetrics_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PowerDistributionMetrics/v1_0_0/RedfishPowerDistributionMetrics_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/PowerDistributionMetrics/v1_0_0/RedfishPowerDistributionMetrics_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..4bcc0df97a9 --- /dev/null +++ b/RedfishClientPkg/Converter/PowerDistributionMetrics/v1_0_0/RedfishPowerDistributionMetrics_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PowerDistributionMetrics.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPowerDistributionMetrics_V1_0_0_Dxe + FILE_GUID = 262bec61-1cf7-4c2f-bd32-562de9cb8169 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPowerDistributionMetrics_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishPowerDistributionMetrics_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PowerDistributionMetrics_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerDistributionMetricsV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PowerDomain/v1_0_0/PowerDomain_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/PowerDomain/v1_0_0/PowerDomain_V1_0_0_Dxe.c new file mode 100644 index 00000000000..6ae69dab625 --- /dev/null +++ b/RedfishClientPkg/Converter/PowerDomain/v1_0_0/PowerDomain_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PowerDomain.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PowerDomain"; +BOOLEAN IsRevisonController = TRUE; + +// Support PowerDomain V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PowerDomain", + "1", + "0", + "0" + }, + "PowerDomain" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDomainToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWERDOMAIN_V1_0_0 *PowerDomainV1_0_0; + EFI_REDFISH_POWERDOMAIN_V1_0_0_CS *PowerDomainV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PowerDomain") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PowerDomain_V1_0_0_To_CS (ResoruceRaw, &PowerDomainV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerDomainV1_0_0 = (EFI_REDFISH_POWERDOMAIN_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWERDOMAIN_V1_0_0)); + if (PowerDomainV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerDomainV1_0_0; + PowerDomainV1_0_0->PowerDomain = PowerDomainV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PowerDomain"), "PowerDomain"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PowerDomain"), "PowerDomain"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerDomainToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDomainToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerDomainToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDomainToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PowerDomain_V1_0_0_JSON (*((EFI_REDFISH_POWERDOMAIN_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerDomainToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDomainDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWERDOMAIN_V1_0_0 *PowerDomainV1_0_0; + + PowerDomainV1_0_0 = (EFI_REDFISH_POWERDOMAIN_V1_0_0 *)InterpProp; + DestroyPowerDomain_V1_0_0_CS (PowerDomainV1_0_0->PowerDomain); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerDomainFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDomainDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPowerDomain_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPowerDomain_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerDomainToStructWrapper, + PowerDomainToJson, + PowerDomainDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPowerDomain_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PowerDomain/v1_0_0/RedfishPowerDomain_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/PowerDomain/v1_0_0/RedfishPowerDomain_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..68826b5342b --- /dev/null +++ b/RedfishClientPkg/Converter/PowerDomain/v1_0_0/RedfishPowerDomain_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PowerDomain.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPowerDomain_V1_0_0_Dxe + FILE_GUID = 1127255e-f8f8-4704-b208-9889c260bb72 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPowerDomain_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishPowerDomain_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PowerDomain_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerDomainV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PowerDomain/v1_0_1/PowerDomain_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/PowerDomain/v1_0_1/PowerDomain_V1_0_1_Dxe.c new file mode 100644 index 00000000000..fdec9b2300c --- /dev/null +++ b/RedfishClientPkg/Converter/PowerDomain/v1_0_1/PowerDomain_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PowerDomain.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PowerDomain"; +BOOLEAN IsRevisonController = TRUE; + +// Support PowerDomain V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PowerDomain", + "1", + "0", + "1" + }, + "PowerDomain" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDomainToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWERDOMAIN_V1_0_1 *PowerDomainV1_0_1; + EFI_REDFISH_POWERDOMAIN_V1_0_1_CS *PowerDomainV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PowerDomain") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PowerDomain_V1_0_1_To_CS (ResoruceRaw, &PowerDomainV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerDomainV1_0_1 = (EFI_REDFISH_POWERDOMAIN_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWERDOMAIN_V1_0_1)); + if (PowerDomainV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerDomainV1_0_1; + PowerDomainV1_0_1->PowerDomain = PowerDomainV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PowerDomain"), "PowerDomain"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerDomain")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PowerDomain"), "PowerDomain"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerDomainToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDomainToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerDomainToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDomainToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PowerDomain_V1_0_1_JSON (*((EFI_REDFISH_POWERDOMAIN_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerDomainToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDomainDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWERDOMAIN_V1_0_1 *PowerDomainV1_0_1; + + PowerDomainV1_0_1 = (EFI_REDFISH_POWERDOMAIN_V1_0_1 *)InterpProp; + DestroyPowerDomain_V1_0_1_CS (PowerDomainV1_0_1->PowerDomain); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerDomainFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDomainDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPowerDomain_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPowerDomain_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerDomainToStructWrapper, + PowerDomainToJson, + PowerDomainDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPowerDomain_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PowerDomain/v1_0_1/RedfishPowerDomain_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/PowerDomain/v1_0_1/RedfishPowerDomain_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..f4a44d0fcd5 --- /dev/null +++ b/RedfishClientPkg/Converter/PowerDomain/v1_0_1/RedfishPowerDomain_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PowerDomain.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPowerDomain_V1_0_1_Dxe + FILE_GUID = af40882e-8823-4287-b8d1-f4d39c6e6ea6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPowerDomain_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishPowerDomain_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PowerDomain_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerDomainV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PowerDomainCollection/PowerDomainCollection_Dxe.c b/RedfishClientPkg/Converter/PowerDomainCollection/PowerDomainCollection_Dxe.c new file mode 100644 index 00000000000..ccddb586abb --- /dev/null +++ b/RedfishClientPkg/Converter/PowerDomainCollection/PowerDomainCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PowerDomainCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PowerDomainCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support PowerDomainCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PowerDomainCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "PowerDomainCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDomainCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWERDOMAINCOLLECTION *PowerDomainCollection; + EFI_REDFISH_POWERDOMAINCOLLECTION_CS *PowerDomainCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PowerDomainCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PowerDomainCollection_To_CS (ResoruceRaw, &PowerDomainCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerDomainCollection = (EFI_REDFISH_POWERDOMAINCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWERDOMAINCOLLECTION)); + if (PowerDomainCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerDomainCollection; + PowerDomainCollection->PowerDomainCollection = PowerDomainCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerDomainCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PowerDomainCollection"), "PowerDomainCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerDomainCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PowerDomainCollection"), "PowerDomainCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerDomainCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDomainCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerDomainCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDomainCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PowerDomainCollection_JSON (*((EFI_REDFISH_POWERDOMAINCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerDomainCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDomainCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWERDOMAINCOLLECTION *PowerDomainCollection; + + PowerDomainCollection = (EFI_REDFISH_POWERDOMAINCOLLECTION *)InterpProp; + DestroyPowerDomainCollection_CS (PowerDomainCollection->PowerDomainCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerDomainCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerDomainCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPowerDomainCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPowerDomainCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerDomainCollectionToStructWrapper, + PowerDomainCollectionToJson, + PowerDomainCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPowerDomainCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PowerDomainCollection/RedfishPowerDomainCollection_Dxe.inf b/RedfishClientPkg/Converter/PowerDomainCollection/RedfishPowerDomainCollection_Dxe.inf new file mode 100644 index 00000000000..f6267e9141f --- /dev/null +++ b/RedfishClientPkg/Converter/PowerDomainCollection/RedfishPowerDomainCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PowerDomainCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPowerDomainCollection_Dxe + FILE_GUID = a948fc2b-80b5-4b7e-9d09-63647cdd3880 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPowerDomainCollectionEntryPoint + UNLOAD_IMAGE = RedfishPowerDomainCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PowerDomainCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerDomainCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PowerEquipment/v1_0_0/PowerEquipment_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/PowerEquipment/v1_0_0/PowerEquipment_V1_0_0_Dxe.c new file mode 100644 index 00000000000..40e1d49230c --- /dev/null +++ b/RedfishClientPkg/Converter/PowerEquipment/v1_0_0/PowerEquipment_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PowerEquipment.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PowerEquipment"; +BOOLEAN IsRevisonController = TRUE; + +// Support PowerEquipment V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PowerEquipment", + "1", + "0", + "0" + }, + "PowerEquipment" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerEquipmentToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWEREQUIPMENT_V1_0_0 *PowerEquipmentV1_0_0; + EFI_REDFISH_POWEREQUIPMENT_V1_0_0_CS *PowerEquipmentV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PowerEquipment") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PowerEquipment_V1_0_0_To_CS (ResoruceRaw, &PowerEquipmentV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerEquipmentV1_0_0 = (EFI_REDFISH_POWEREQUIPMENT_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWEREQUIPMENT_V1_0_0)); + if (PowerEquipmentV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerEquipmentV1_0_0; + PowerEquipmentV1_0_0->PowerEquipment = PowerEquipmentV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerEquipment")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PowerEquipment"), "PowerEquipment"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerEquipment")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PowerEquipment"), "PowerEquipment"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerEquipmentToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerEquipmentToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerEquipmentToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerEquipmentToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PowerEquipment_V1_0_0_JSON (*((EFI_REDFISH_POWEREQUIPMENT_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerEquipmentToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerEquipmentDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWEREQUIPMENT_V1_0_0 *PowerEquipmentV1_0_0; + + PowerEquipmentV1_0_0 = (EFI_REDFISH_POWEREQUIPMENT_V1_0_0 *)InterpProp; + DestroyPowerEquipment_V1_0_0_CS (PowerEquipmentV1_0_0->PowerEquipment); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerEquipmentFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerEquipmentDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPowerEquipment_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPowerEquipment_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerEquipmentToStructWrapper, + PowerEquipmentToJson, + PowerEquipmentDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPowerEquipment_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PowerEquipment/v1_0_0/RedfishPowerEquipment_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/PowerEquipment/v1_0_0/RedfishPowerEquipment_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..a4b12215cad --- /dev/null +++ b/RedfishClientPkg/Converter/PowerEquipment/v1_0_0/RedfishPowerEquipment_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PowerEquipment.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPowerEquipment_V1_0_0_Dxe + FILE_GUID = 2a388714-d3a0-48fc-9725-c00fbbc05c02 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPowerEquipment_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishPowerEquipment_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PowerEquipment_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerEquipmentV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PowerSubsystem/v1_0_0/PowerSubsystem_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/PowerSubsystem/v1_0_0/PowerSubsystem_V1_0_0_Dxe.c new file mode 100644 index 00000000000..f739a8e54fb --- /dev/null +++ b/RedfishClientPkg/Converter/PowerSubsystem/v1_0_0/PowerSubsystem_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PowerSubsystem.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PowerSubsystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support PowerSubsystem V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PowerSubsystem", + "1", + "0", + "0" + }, + "PowerSubsystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerSubsystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWERSUBSYSTEM_V1_0_0 *PowerSubsystemV1_0_0; + EFI_REDFISH_POWERSUBSYSTEM_V1_0_0_CS *PowerSubsystemV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PowerSubsystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PowerSubsystem_V1_0_0_To_CS (ResoruceRaw, &PowerSubsystemV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerSubsystemV1_0_0 = (EFI_REDFISH_POWERSUBSYSTEM_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWERSUBSYSTEM_V1_0_0)); + if (PowerSubsystemV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerSubsystemV1_0_0; + PowerSubsystemV1_0_0->PowerSubsystem = PowerSubsystemV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerSubsystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PowerSubsystem"), "PowerSubsystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerSubsystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PowerSubsystem"), "PowerSubsystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerSubsystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerSubsystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerSubsystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerSubsystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PowerSubsystem_V1_0_0_JSON (*((EFI_REDFISH_POWERSUBSYSTEM_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerSubsystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerSubsystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWERSUBSYSTEM_V1_0_0 *PowerSubsystemV1_0_0; + + PowerSubsystemV1_0_0 = (EFI_REDFISH_POWERSUBSYSTEM_V1_0_0 *)InterpProp; + DestroyPowerSubsystem_V1_0_0_CS (PowerSubsystemV1_0_0->PowerSubsystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerSubsystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerSubsystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPowerSubsystem_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPowerSubsystem_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerSubsystemToStructWrapper, + PowerSubsystemToJson, + PowerSubsystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPowerSubsystem_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PowerSubsystem/v1_0_0/RedfishPowerSubsystem_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/PowerSubsystem/v1_0_0/RedfishPowerSubsystem_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..ad98f7efa38 --- /dev/null +++ b/RedfishClientPkg/Converter/PowerSubsystem/v1_0_0/RedfishPowerSubsystem_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PowerSubsystem.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPowerSubsystem_V1_0_0_Dxe + FILE_GUID = 5e94e2d6-b8a2-4ed0-9de1-5989aeae6095 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPowerSubsystem_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishPowerSubsystem_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PowerSubsystem_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerSubsystemV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PowerSupply/v1_0_0/PowerSupply_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/PowerSupply/v1_0_0/PowerSupply_V1_0_0_Dxe.c new file mode 100644 index 00000000000..4ba37e49f38 --- /dev/null +++ b/RedfishClientPkg/Converter/PowerSupply/v1_0_0/PowerSupply_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PowerSupply.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PowerSupply"; +BOOLEAN IsRevisonController = TRUE; + +// Support PowerSupply V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PowerSupply", + "1", + "0", + "0" + }, + "PowerSupply" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerSupplyToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWERSUPPLY_V1_0_0 *PowerSupplyV1_0_0; + EFI_REDFISH_POWERSUPPLY_V1_0_0_CS *PowerSupplyV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PowerSupply") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PowerSupply_V1_0_0_To_CS (ResoruceRaw, &PowerSupplyV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerSupplyV1_0_0 = (EFI_REDFISH_POWERSUPPLY_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWERSUPPLY_V1_0_0)); + if (PowerSupplyV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerSupplyV1_0_0; + PowerSupplyV1_0_0->PowerSupply = PowerSupplyV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerSupply")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PowerSupply"), "PowerSupply"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerSupply")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PowerSupply"), "PowerSupply"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerSupplyToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerSupplyToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerSupplyToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerSupplyToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PowerSupply_V1_0_0_JSON (*((EFI_REDFISH_POWERSUPPLY_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerSupplyToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerSupplyDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWERSUPPLY_V1_0_0 *PowerSupplyV1_0_0; + + PowerSupplyV1_0_0 = (EFI_REDFISH_POWERSUPPLY_V1_0_0 *)InterpProp; + DestroyPowerSupply_V1_0_0_CS (PowerSupplyV1_0_0->PowerSupply); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerSupplyFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerSupplyDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPowerSupply_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPowerSupply_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerSupplyToStructWrapper, + PowerSupplyToJson, + PowerSupplyDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPowerSupply_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PowerSupply/v1_0_0/RedfishPowerSupply_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/PowerSupply/v1_0_0/RedfishPowerSupply_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..0e8fb30c062 --- /dev/null +++ b/RedfishClientPkg/Converter/PowerSupply/v1_0_0/RedfishPowerSupply_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PowerSupply.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPowerSupply_V1_0_0_Dxe + FILE_GUID = ad02fa63-75eb-4d7d-82e5-b5d0ec82bde8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPowerSupply_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishPowerSupply_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PowerSupply_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerSupplyV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PowerSupplyCollection/PowerSupplyCollection_Dxe.c b/RedfishClientPkg/Converter/PowerSupplyCollection/PowerSupplyCollection_Dxe.c new file mode 100644 index 00000000000..efc1ceb9413 --- /dev/null +++ b/RedfishClientPkg/Converter/PowerSupplyCollection/PowerSupplyCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PowerSupplyCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PowerSupplyCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support PowerSupplyCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PowerSupplyCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "PowerSupplyCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerSupplyCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWERSUPPLYCOLLECTION *PowerSupplyCollection; + EFI_REDFISH_POWERSUPPLYCOLLECTION_CS *PowerSupplyCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PowerSupplyCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PowerSupplyCollection_To_CS (ResoruceRaw, &PowerSupplyCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerSupplyCollection = (EFI_REDFISH_POWERSUPPLYCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWERSUPPLYCOLLECTION)); + if (PowerSupplyCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerSupplyCollection; + PowerSupplyCollection->PowerSupplyCollection = PowerSupplyCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerSupplyCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PowerSupplyCollection"), "PowerSupplyCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerSupplyCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PowerSupplyCollection"), "PowerSupplyCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerSupplyCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerSupplyCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerSupplyCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerSupplyCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PowerSupplyCollection_JSON (*((EFI_REDFISH_POWERSUPPLYCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerSupplyCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerSupplyCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWERSUPPLYCOLLECTION *PowerSupplyCollection; + + PowerSupplyCollection = (EFI_REDFISH_POWERSUPPLYCOLLECTION *)InterpProp; + DestroyPowerSupplyCollection_CS (PowerSupplyCollection->PowerSupplyCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerSupplyCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerSupplyCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPowerSupplyCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPowerSupplyCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerSupplyCollectionToStructWrapper, + PowerSupplyCollectionToJson, + PowerSupplyCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPowerSupplyCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PowerSupplyCollection/RedfishPowerSupplyCollection_Dxe.inf b/RedfishClientPkg/Converter/PowerSupplyCollection/RedfishPowerSupplyCollection_Dxe.inf new file mode 100644 index 00000000000..039af9d040a --- /dev/null +++ b/RedfishClientPkg/Converter/PowerSupplyCollection/RedfishPowerSupplyCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PowerSupplyCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPowerSupplyCollection_Dxe + FILE_GUID = eeced71d-d840-4675-8f53-2723e159edd8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPowerSupplyCollectionEntryPoint + UNLOAD_IMAGE = RedfishPowerSupplyCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PowerSupplyCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerSupplyCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PowerSupplyMetrics/v1_0_0/PowerSupplyMetrics_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/PowerSupplyMetrics/v1_0_0/PowerSupplyMetrics_V1_0_0_Dxe.c new file mode 100644 index 00000000000..a35c358bd31 --- /dev/null +++ b/RedfishClientPkg/Converter/PowerSupplyMetrics/v1_0_0/PowerSupplyMetrics_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PowerSupplyMetrics.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PowerSupplyMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support PowerSupplyMetrics V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PowerSupplyMetrics", + "1", + "0", + "0" + }, + "PowerSupplyMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerSupplyMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_POWERSUPPLYMETRICS_V1_0_0 *PowerSupplyMetricsV1_0_0; + EFI_REDFISH_POWERSUPPLYMETRICS_V1_0_0_CS *PowerSupplyMetricsV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PowerSupplyMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PowerSupplyMetrics_V1_0_0_To_CS (ResoruceRaw, &PowerSupplyMetricsV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PowerSupplyMetricsV1_0_0 = (EFI_REDFISH_POWERSUPPLYMETRICS_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_POWERSUPPLYMETRICS_V1_0_0)); + if (PowerSupplyMetricsV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PowerSupplyMetricsV1_0_0; + PowerSupplyMetricsV1_0_0->PowerSupplyMetrics = PowerSupplyMetricsV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerSupplyMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PowerSupplyMetrics"), "PowerSupplyMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PowerSupplyMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PowerSupplyMetrics"), "PowerSupplyMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PowerSupplyMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerSupplyMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PowerSupplyMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerSupplyMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PowerSupplyMetrics_V1_0_0_JSON (*((EFI_REDFISH_POWERSUPPLYMETRICS_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PowerSupplyMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerSupplyMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_POWERSUPPLYMETRICS_V1_0_0 *PowerSupplyMetricsV1_0_0; + + PowerSupplyMetricsV1_0_0 = (EFI_REDFISH_POWERSUPPLYMETRICS_V1_0_0 *)InterpProp; + DestroyPowerSupplyMetrics_V1_0_0_CS (PowerSupplyMetricsV1_0_0->PowerSupplyMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PowerSupplyMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PowerSupplyMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPowerSupplyMetrics_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPowerSupplyMetrics_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PowerSupplyMetricsToStructWrapper, + PowerSupplyMetricsToJson, + PowerSupplyMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPowerSupplyMetrics_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PowerSupplyMetrics/v1_0_0/RedfishPowerSupplyMetrics_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/PowerSupplyMetrics/v1_0_0/RedfishPowerSupplyMetrics_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..379f8ed0c4f --- /dev/null +++ b/RedfishClientPkg/Converter/PowerSupplyMetrics/v1_0_0/RedfishPowerSupplyMetrics_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PowerSupplyMetrics.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPowerSupplyMetrics_V1_0_0_Dxe + FILE_GUID = 5fa146a8-e4fd-425c-9e25-070285b3fbe4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPowerSupplyMetrics_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishPowerSupplyMetrics_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PowerSupplyMetrics_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PowerSupplyMetricsV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_0/PrivilegeRegistry_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_0/PrivilegeRegistry_V1_0_0_Dxe.c new file mode 100644 index 00000000000..c4b58a7f392 --- /dev/null +++ b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_0/PrivilegeRegistry_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PrivilegeRegistry.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PrivilegeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support PrivilegeRegistry V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PrivilegeRegistry", + "1", + "0", + "0" + }, + "PrivilegeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_0 *PrivilegeRegistryV1_0_0; + EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_0_CS *PrivilegeRegistryV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PrivilegeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PrivilegeRegistry_V1_0_0_To_CS (ResoruceRaw, &PrivilegeRegistryV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PrivilegeRegistryV1_0_0 = (EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_0)); + if (PrivilegeRegistryV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PrivilegeRegistryV1_0_0; + PrivilegeRegistryV1_0_0->PrivilegeRegistry = PrivilegeRegistryV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PrivilegeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PrivilegeRegistry"), "PrivilegeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PrivilegeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PrivilegeRegistry"), "PrivilegeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PrivilegeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PrivilegeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PrivilegeRegistry_V1_0_0_JSON (*((EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PrivilegeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_0 *PrivilegeRegistryV1_0_0; + + PrivilegeRegistryV1_0_0 = (EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_0 *)InterpProp; + DestroyPrivilegeRegistry_V1_0_0_CS (PrivilegeRegistryV1_0_0->PrivilegeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PrivilegeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPrivilegeRegistry_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPrivilegeRegistry_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PrivilegeRegistryToStructWrapper, + PrivilegeRegistryToJson, + PrivilegeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPrivilegeRegistry_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_0/RedfishPrivilegeRegistry_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_0/RedfishPrivilegeRegistry_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..13c849c2bce --- /dev/null +++ b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_0/RedfishPrivilegeRegistry_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PrivilegeRegistry.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPrivilegeRegistry_V1_0_0_Dxe + FILE_GUID = 56d91770-2522-4733-834a-a24b12b5391f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPrivilegeRegistry_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishPrivilegeRegistry_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PrivilegeRegistry_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PrivilegeRegistryV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_1/PrivilegeRegistry_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_1/PrivilegeRegistry_V1_0_1_Dxe.c new file mode 100644 index 00000000000..6e7536ca8b3 --- /dev/null +++ b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_1/PrivilegeRegistry_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PrivilegeRegistry.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PrivilegeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support PrivilegeRegistry V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PrivilegeRegistry", + "1", + "0", + "1" + }, + "PrivilegeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_1 *PrivilegeRegistryV1_0_1; + EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_1_CS *PrivilegeRegistryV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PrivilegeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PrivilegeRegistry_V1_0_1_To_CS (ResoruceRaw, &PrivilegeRegistryV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PrivilegeRegistryV1_0_1 = (EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_1)); + if (PrivilegeRegistryV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PrivilegeRegistryV1_0_1; + PrivilegeRegistryV1_0_1->PrivilegeRegistry = PrivilegeRegistryV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PrivilegeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PrivilegeRegistry"), "PrivilegeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PrivilegeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PrivilegeRegistry"), "PrivilegeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PrivilegeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PrivilegeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PrivilegeRegistry_V1_0_1_JSON (*((EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PrivilegeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_1 *PrivilegeRegistryV1_0_1; + + PrivilegeRegistryV1_0_1 = (EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_1 *)InterpProp; + DestroyPrivilegeRegistry_V1_0_1_CS (PrivilegeRegistryV1_0_1->PrivilegeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PrivilegeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPrivilegeRegistry_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPrivilegeRegistry_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PrivilegeRegistryToStructWrapper, + PrivilegeRegistryToJson, + PrivilegeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPrivilegeRegistry_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_1/RedfishPrivilegeRegistry_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_1/RedfishPrivilegeRegistry_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..485a7e2923c --- /dev/null +++ b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_1/RedfishPrivilegeRegistry_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PrivilegeRegistry.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPrivilegeRegistry_V1_0_1_Dxe + FILE_GUID = 43a0fcfc-2802-4321-9919-e98475a3d30a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPrivilegeRegistry_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishPrivilegeRegistry_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PrivilegeRegistry_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PrivilegeRegistryV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_2/PrivilegeRegistry_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_2/PrivilegeRegistry_V1_0_2_Dxe.c new file mode 100644 index 00000000000..71839927f88 --- /dev/null +++ b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_2/PrivilegeRegistry_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PrivilegeRegistry.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PrivilegeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support PrivilegeRegistry V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PrivilegeRegistry", + "1", + "0", + "2" + }, + "PrivilegeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_2 *PrivilegeRegistryV1_0_2; + EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_2_CS *PrivilegeRegistryV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PrivilegeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PrivilegeRegistry_V1_0_2_To_CS (ResoruceRaw, &PrivilegeRegistryV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PrivilegeRegistryV1_0_2 = (EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_2)); + if (PrivilegeRegistryV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PrivilegeRegistryV1_0_2; + PrivilegeRegistryV1_0_2->PrivilegeRegistry = PrivilegeRegistryV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PrivilegeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PrivilegeRegistry"), "PrivilegeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PrivilegeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PrivilegeRegistry"), "PrivilegeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PrivilegeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PrivilegeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PrivilegeRegistry_V1_0_2_JSON (*((EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PrivilegeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_2 *PrivilegeRegistryV1_0_2; + + PrivilegeRegistryV1_0_2 = (EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_2 *)InterpProp; + DestroyPrivilegeRegistry_V1_0_2_CS (PrivilegeRegistryV1_0_2->PrivilegeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PrivilegeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPrivilegeRegistry_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPrivilegeRegistry_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PrivilegeRegistryToStructWrapper, + PrivilegeRegistryToJson, + PrivilegeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPrivilegeRegistry_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_2/RedfishPrivilegeRegistry_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_2/RedfishPrivilegeRegistry_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..a8948ccff13 --- /dev/null +++ b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_2/RedfishPrivilegeRegistry_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PrivilegeRegistry.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPrivilegeRegistry_V1_0_2_Dxe + FILE_GUID = ed767112-f91b-4193-9f98-5f48eeb853a8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPrivilegeRegistry_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishPrivilegeRegistry_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PrivilegeRegistry_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PrivilegeRegistryV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_3/PrivilegeRegistry_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_3/PrivilegeRegistry_V1_0_3_Dxe.c new file mode 100644 index 00000000000..549cf5d0a3b --- /dev/null +++ b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_3/PrivilegeRegistry_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PrivilegeRegistry.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PrivilegeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support PrivilegeRegistry V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PrivilegeRegistry", + "1", + "0", + "3" + }, + "PrivilegeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_3 *PrivilegeRegistryV1_0_3; + EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_3_CS *PrivilegeRegistryV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PrivilegeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PrivilegeRegistry_V1_0_3_To_CS (ResoruceRaw, &PrivilegeRegistryV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PrivilegeRegistryV1_0_3 = (EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_3)); + if (PrivilegeRegistryV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PrivilegeRegistryV1_0_3; + PrivilegeRegistryV1_0_3->PrivilegeRegistry = PrivilegeRegistryV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PrivilegeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PrivilegeRegistry"), "PrivilegeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PrivilegeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PrivilegeRegistry"), "PrivilegeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PrivilegeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PrivilegeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PrivilegeRegistry_V1_0_3_JSON (*((EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PrivilegeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_3 *PrivilegeRegistryV1_0_3; + + PrivilegeRegistryV1_0_3 = (EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_3 *)InterpProp; + DestroyPrivilegeRegistry_V1_0_3_CS (PrivilegeRegistryV1_0_3->PrivilegeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PrivilegeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPrivilegeRegistry_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPrivilegeRegistry_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PrivilegeRegistryToStructWrapper, + PrivilegeRegistryToJson, + PrivilegeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPrivilegeRegistry_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_3/RedfishPrivilegeRegistry_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_3/RedfishPrivilegeRegistry_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..2f911a32bae --- /dev/null +++ b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_3/RedfishPrivilegeRegistry_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PrivilegeRegistry.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPrivilegeRegistry_V1_0_3_Dxe + FILE_GUID = 674b824e-48ab-4003-b271-22952ba6a94e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPrivilegeRegistry_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishPrivilegeRegistry_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PrivilegeRegistry_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PrivilegeRegistryV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_4/PrivilegeRegistry_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_4/PrivilegeRegistry_V1_0_4_Dxe.c new file mode 100644 index 00000000000..63c18419d1d --- /dev/null +++ b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_4/PrivilegeRegistry_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PrivilegeRegistry.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PrivilegeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support PrivilegeRegistry V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PrivilegeRegistry", + "1", + "0", + "4" + }, + "PrivilegeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_4 *PrivilegeRegistryV1_0_4; + EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_4_CS *PrivilegeRegistryV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PrivilegeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PrivilegeRegistry_V1_0_4_To_CS (ResoruceRaw, &PrivilegeRegistryV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PrivilegeRegistryV1_0_4 = (EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_4)); + if (PrivilegeRegistryV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PrivilegeRegistryV1_0_4; + PrivilegeRegistryV1_0_4->PrivilegeRegistry = PrivilegeRegistryV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PrivilegeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PrivilegeRegistry"), "PrivilegeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PrivilegeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PrivilegeRegistry"), "PrivilegeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PrivilegeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PrivilegeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PrivilegeRegistry_V1_0_4_JSON (*((EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PrivilegeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_4 *PrivilegeRegistryV1_0_4; + + PrivilegeRegistryV1_0_4 = (EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_4 *)InterpProp; + DestroyPrivilegeRegistry_V1_0_4_CS (PrivilegeRegistryV1_0_4->PrivilegeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PrivilegeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPrivilegeRegistry_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPrivilegeRegistry_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PrivilegeRegistryToStructWrapper, + PrivilegeRegistryToJson, + PrivilegeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPrivilegeRegistry_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_4/RedfishPrivilegeRegistry_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_4/RedfishPrivilegeRegistry_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..adaa4c0ea03 --- /dev/null +++ b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_4/RedfishPrivilegeRegistry_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PrivilegeRegistry.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPrivilegeRegistry_V1_0_4_Dxe + FILE_GUID = 5ec198f5-9454-4428-b566-bef8e141db36 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPrivilegeRegistry_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishPrivilegeRegistry_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PrivilegeRegistry_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PrivilegeRegistryV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_5/PrivilegeRegistry_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_5/PrivilegeRegistry_V1_0_5_Dxe.c new file mode 100644 index 00000000000..c9b543f2a26 --- /dev/null +++ b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_5/PrivilegeRegistry_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PrivilegeRegistry.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PrivilegeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support PrivilegeRegistry V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PrivilegeRegistry", + "1", + "0", + "5" + }, + "PrivilegeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_5 *PrivilegeRegistryV1_0_5; + EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_5_CS *PrivilegeRegistryV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PrivilegeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PrivilegeRegistry_V1_0_5_To_CS (ResoruceRaw, &PrivilegeRegistryV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PrivilegeRegistryV1_0_5 = (EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_5)); + if (PrivilegeRegistryV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PrivilegeRegistryV1_0_5; + PrivilegeRegistryV1_0_5->PrivilegeRegistry = PrivilegeRegistryV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PrivilegeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PrivilegeRegistry"), "PrivilegeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PrivilegeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PrivilegeRegistry"), "PrivilegeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PrivilegeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PrivilegeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PrivilegeRegistry_V1_0_5_JSON (*((EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PrivilegeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_5 *PrivilegeRegistryV1_0_5; + + PrivilegeRegistryV1_0_5 = (EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_5 *)InterpProp; + DestroyPrivilegeRegistry_V1_0_5_CS (PrivilegeRegistryV1_0_5->PrivilegeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PrivilegeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPrivilegeRegistry_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPrivilegeRegistry_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PrivilegeRegistryToStructWrapper, + PrivilegeRegistryToJson, + PrivilegeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPrivilegeRegistry_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_5/RedfishPrivilegeRegistry_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_5/RedfishPrivilegeRegistry_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..267132ff7f2 --- /dev/null +++ b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_0_5/RedfishPrivilegeRegistry_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PrivilegeRegistry.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPrivilegeRegistry_V1_0_5_Dxe + FILE_GUID = 8b6cb4d5-5742-40c9-a503-1961a5f44e85 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPrivilegeRegistry_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishPrivilegeRegistry_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PrivilegeRegistry_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PrivilegeRegistryV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_0/PrivilegeRegistry_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_0/PrivilegeRegistry_V1_1_0_Dxe.c new file mode 100644 index 00000000000..52a478ecf97 --- /dev/null +++ b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_0/PrivilegeRegistry_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PrivilegeRegistry.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PrivilegeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support PrivilegeRegistry V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PrivilegeRegistry", + "1", + "1", + "0" + }, + "PrivilegeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_0 *PrivilegeRegistryV1_1_0; + EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_0_CS *PrivilegeRegistryV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PrivilegeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PrivilegeRegistry_V1_1_0_To_CS (ResoruceRaw, &PrivilegeRegistryV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PrivilegeRegistryV1_1_0 = (EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_0)); + if (PrivilegeRegistryV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PrivilegeRegistryV1_1_0; + PrivilegeRegistryV1_1_0->PrivilegeRegistry = PrivilegeRegistryV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PrivilegeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PrivilegeRegistry"), "PrivilegeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PrivilegeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PrivilegeRegistry"), "PrivilegeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PrivilegeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PrivilegeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PrivilegeRegistry_V1_1_0_JSON (*((EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PrivilegeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_0 *PrivilegeRegistryV1_1_0; + + PrivilegeRegistryV1_1_0 = (EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_0 *)InterpProp; + DestroyPrivilegeRegistry_V1_1_0_CS (PrivilegeRegistryV1_1_0->PrivilegeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PrivilegeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPrivilegeRegistry_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPrivilegeRegistry_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PrivilegeRegistryToStructWrapper, + PrivilegeRegistryToJson, + PrivilegeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPrivilegeRegistry_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_0/RedfishPrivilegeRegistry_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_0/RedfishPrivilegeRegistry_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..274945ee081 --- /dev/null +++ b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_0/RedfishPrivilegeRegistry_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PrivilegeRegistry.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPrivilegeRegistry_V1_1_0_Dxe + FILE_GUID = d7ae5308-7d25-4932-a97f-71a821a33914 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPrivilegeRegistry_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishPrivilegeRegistry_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PrivilegeRegistry_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PrivilegeRegistryV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_1/PrivilegeRegistry_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_1/PrivilegeRegistry_V1_1_1_Dxe.c new file mode 100644 index 00000000000..f368dc57e33 --- /dev/null +++ b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_1/PrivilegeRegistry_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PrivilegeRegistry.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PrivilegeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support PrivilegeRegistry V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PrivilegeRegistry", + "1", + "1", + "1" + }, + "PrivilegeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_1 *PrivilegeRegistryV1_1_1; + EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_1_CS *PrivilegeRegistryV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PrivilegeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PrivilegeRegistry_V1_1_1_To_CS (ResoruceRaw, &PrivilegeRegistryV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PrivilegeRegistryV1_1_1 = (EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_1)); + if (PrivilegeRegistryV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PrivilegeRegistryV1_1_1; + PrivilegeRegistryV1_1_1->PrivilegeRegistry = PrivilegeRegistryV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PrivilegeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PrivilegeRegistry"), "PrivilegeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PrivilegeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PrivilegeRegistry"), "PrivilegeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PrivilegeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PrivilegeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PrivilegeRegistry_V1_1_1_JSON (*((EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PrivilegeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_1 *PrivilegeRegistryV1_1_1; + + PrivilegeRegistryV1_1_1 = (EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_1 *)InterpProp; + DestroyPrivilegeRegistry_V1_1_1_CS (PrivilegeRegistryV1_1_1->PrivilegeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PrivilegeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPrivilegeRegistry_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPrivilegeRegistry_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PrivilegeRegistryToStructWrapper, + PrivilegeRegistryToJson, + PrivilegeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPrivilegeRegistry_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_1/RedfishPrivilegeRegistry_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_1/RedfishPrivilegeRegistry_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..790b2421f78 --- /dev/null +++ b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_1/RedfishPrivilegeRegistry_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PrivilegeRegistry.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPrivilegeRegistry_V1_1_1_Dxe + FILE_GUID = 3bd09071-5bad-452d-8065-ca0b486aee85 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPrivilegeRegistry_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishPrivilegeRegistry_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PrivilegeRegistry_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PrivilegeRegistryV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_2/PrivilegeRegistry_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_2/PrivilegeRegistry_V1_1_2_Dxe.c new file mode 100644 index 00000000000..c236ba46aaf --- /dev/null +++ b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_2/PrivilegeRegistry_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PrivilegeRegistry.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PrivilegeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support PrivilegeRegistry V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PrivilegeRegistry", + "1", + "1", + "2" + }, + "PrivilegeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_2 *PrivilegeRegistryV1_1_2; + EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_2_CS *PrivilegeRegistryV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PrivilegeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PrivilegeRegistry_V1_1_2_To_CS (ResoruceRaw, &PrivilegeRegistryV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PrivilegeRegistryV1_1_2 = (EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_2)); + if (PrivilegeRegistryV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PrivilegeRegistryV1_1_2; + PrivilegeRegistryV1_1_2->PrivilegeRegistry = PrivilegeRegistryV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PrivilegeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PrivilegeRegistry"), "PrivilegeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PrivilegeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PrivilegeRegistry"), "PrivilegeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PrivilegeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PrivilegeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PrivilegeRegistry_V1_1_2_JSON (*((EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PrivilegeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_2 *PrivilegeRegistryV1_1_2; + + PrivilegeRegistryV1_1_2 = (EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_2 *)InterpProp; + DestroyPrivilegeRegistry_V1_1_2_CS (PrivilegeRegistryV1_1_2->PrivilegeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PrivilegeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPrivilegeRegistry_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPrivilegeRegistry_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PrivilegeRegistryToStructWrapper, + PrivilegeRegistryToJson, + PrivilegeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPrivilegeRegistry_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_2/RedfishPrivilegeRegistry_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_2/RedfishPrivilegeRegistry_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..d2630cf8ca5 --- /dev/null +++ b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_2/RedfishPrivilegeRegistry_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PrivilegeRegistry.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPrivilegeRegistry_V1_1_2_Dxe + FILE_GUID = 8d84fe85-d3db-4aa7-b673-e5e79cd50770 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPrivilegeRegistry_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishPrivilegeRegistry_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PrivilegeRegistry_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PrivilegeRegistryV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_3/PrivilegeRegistry_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_3/PrivilegeRegistry_V1_1_3_Dxe.c new file mode 100644 index 00000000000..cab90d988f4 --- /dev/null +++ b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_3/PrivilegeRegistry_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PrivilegeRegistry.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PrivilegeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support PrivilegeRegistry V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PrivilegeRegistry", + "1", + "1", + "3" + }, + "PrivilegeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_3 *PrivilegeRegistryV1_1_3; + EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_3_CS *PrivilegeRegistryV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PrivilegeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PrivilegeRegistry_V1_1_3_To_CS (ResoruceRaw, &PrivilegeRegistryV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PrivilegeRegistryV1_1_3 = (EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_3)); + if (PrivilegeRegistryV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PrivilegeRegistryV1_1_3; + PrivilegeRegistryV1_1_3->PrivilegeRegistry = PrivilegeRegistryV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PrivilegeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PrivilegeRegistry"), "PrivilegeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PrivilegeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PrivilegeRegistry"), "PrivilegeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PrivilegeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PrivilegeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PrivilegeRegistry_V1_1_3_JSON (*((EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PrivilegeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_3 *PrivilegeRegistryV1_1_3; + + PrivilegeRegistryV1_1_3 = (EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_3 *)InterpProp; + DestroyPrivilegeRegistry_V1_1_3_CS (PrivilegeRegistryV1_1_3->PrivilegeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PrivilegeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPrivilegeRegistry_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPrivilegeRegistry_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PrivilegeRegistryToStructWrapper, + PrivilegeRegistryToJson, + PrivilegeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPrivilegeRegistry_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_3/RedfishPrivilegeRegistry_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_3/RedfishPrivilegeRegistry_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..0f70862858a --- /dev/null +++ b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_3/RedfishPrivilegeRegistry_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PrivilegeRegistry.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPrivilegeRegistry_V1_1_3_Dxe + FILE_GUID = 40b2bd96-85e7-4de1-a36d-54702d88e8d8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPrivilegeRegistry_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishPrivilegeRegistry_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PrivilegeRegistry_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PrivilegeRegistryV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_4/PrivilegeRegistry_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_4/PrivilegeRegistry_V1_1_4_Dxe.c new file mode 100644 index 00000000000..d7b5e505d7f --- /dev/null +++ b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_4/PrivilegeRegistry_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - PrivilegeRegistry.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#PrivilegeRegistry"; +BOOLEAN IsRevisonController = TRUE; + +// Support PrivilegeRegistry V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "PrivilegeRegistry", + "1", + "1", + "4" + }, + "PrivilegeRegistry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_4 *PrivilegeRegistryV1_1_4; + EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_4_CS *PrivilegeRegistryV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "PrivilegeRegistry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_PrivilegeRegistry_V1_1_4_To_CS (ResoruceRaw, &PrivilegeRegistryV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + PrivilegeRegistryV1_1_4 = (EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_4)); + if (PrivilegeRegistryV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)PrivilegeRegistryV1_1_4; + PrivilegeRegistryV1_1_4->PrivilegeRegistry = PrivilegeRegistryV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("PrivilegeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("PrivilegeRegistry"), "PrivilegeRegistry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("PrivilegeRegistry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("PrivilegeRegistry"), "PrivilegeRegistry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of PrivilegeRegistryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return PrivilegeRegistryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_PrivilegeRegistry_V1_1_4_JSON (*((EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in PrivilegeRegistryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_4 *PrivilegeRegistryV1_1_4; + + PrivilegeRegistryV1_1_4 = (EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_4 *)InterpProp; + DestroyPrivilegeRegistry_V1_1_4_CS (PrivilegeRegistryV1_1_4->PrivilegeRegistry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from PrivilegeRegistryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +PrivilegeRegistryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyPrivilegeRegistry_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishPrivilegeRegistry_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + PrivilegeRegistryToStructWrapper, + PrivilegeRegistryToJson, + PrivilegeRegistryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishPrivilegeRegistry_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_4/RedfishPrivilegeRegistry_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_4/RedfishPrivilegeRegistry_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..e6c416cec2e --- /dev/null +++ b/RedfishClientPkg/Converter/PrivilegeRegistry/v1_1_4/RedfishPrivilegeRegistry_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of PrivilegeRegistry.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishPrivilegeRegistry_V1_1_4_Dxe + FILE_GUID = 27fe6179-b5bc-4b4d-8a21-f200f845745c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishPrivilegeRegistry_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishPrivilegeRegistry_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + PrivilegeRegistry_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + PrivilegeRegistryV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_0_0/Processor_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_0_0/Processor_V1_0_0_Dxe.c new file mode 100644 index 00000000000..1f675795123 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_0_0/Processor_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "0", + "0" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_0_0 *ProcessorV1_0_0; + EFI_REDFISH_PROCESSOR_V1_0_0_CS *ProcessorV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_0_0_To_CS (ResoruceRaw, &ProcessorV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_0_0 = (EFI_REDFISH_PROCESSOR_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_0_0)); + if (ProcessorV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_0_0; + ProcessorV1_0_0->Processor = ProcessorV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_0_0_JSON (*((EFI_REDFISH_PROCESSOR_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_0_0 *ProcessorV1_0_0; + + ProcessorV1_0_0 = (EFI_REDFISH_PROCESSOR_V1_0_0 *)InterpProp; + DestroyProcessor_V1_0_0_CS (ProcessorV1_0_0->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_0_0/RedfishProcessor_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_0_0/RedfishProcessor_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..8962ec3b5c9 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_0_0/RedfishProcessor_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_0_0_Dxe + FILE_GUID = cfa65d52-6ecf-420d-a625-b6fb7c188648 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_0_10/Processor_V1_0_10_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_0_10/Processor_V1_0_10_Dxe.c new file mode 100644 index 00000000000..b047b57ecdf --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_0_10/Processor_V1_0_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_0_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "0", + "10" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_0_10 *ProcessorV1_0_10; + EFI_REDFISH_PROCESSOR_V1_0_10_CS *ProcessorV1_0_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_0_10_To_CS (ResoruceRaw, &ProcessorV1_0_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_0_10 = (EFI_REDFISH_PROCESSOR_V1_0_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_0_10)); + if (ProcessorV1_0_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_0_10; + ProcessorV1_0_10->Processor = ProcessorV1_0_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_0_10_JSON (*((EFI_REDFISH_PROCESSOR_V1_0_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_0_10 *ProcessorV1_0_10; + + ProcessorV1_0_10 = (EFI_REDFISH_PROCESSOR_V1_0_10 *)InterpProp; + DestroyProcessor_V1_0_10_CS (ProcessorV1_0_10->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_0_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_0_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_0_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_0_10/RedfishProcessor_V1_0_10_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_0_10/RedfishProcessor_V1_0_10_Dxe.inf new file mode 100644 index 00000000000..418f52aecdf --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_0_10/RedfishProcessor_V1_0_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_0_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_0_10_Dxe + FILE_GUID = 173c6289-ca88-485d-815a-9248ced9f7c1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_0_10EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_0_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_0_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_0_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_0_11/Processor_V1_0_11_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_0_11/Processor_V1_0_11_Dxe.c new file mode 100644 index 00000000000..991978427b5 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_0_11/Processor_V1_0_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_0_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "0", + "11" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_0_11 *ProcessorV1_0_11; + EFI_REDFISH_PROCESSOR_V1_0_11_CS *ProcessorV1_0_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_0_11_To_CS (ResoruceRaw, &ProcessorV1_0_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_0_11 = (EFI_REDFISH_PROCESSOR_V1_0_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_0_11)); + if (ProcessorV1_0_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_0_11; + ProcessorV1_0_11->Processor = ProcessorV1_0_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_0_11_JSON (*((EFI_REDFISH_PROCESSOR_V1_0_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_0_11 *ProcessorV1_0_11; + + ProcessorV1_0_11 = (EFI_REDFISH_PROCESSOR_V1_0_11 *)InterpProp; + DestroyProcessor_V1_0_11_CS (ProcessorV1_0_11->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_0_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_0_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_0_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_0_11/RedfishProcessor_V1_0_11_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_0_11/RedfishProcessor_V1_0_11_Dxe.inf new file mode 100644 index 00000000000..f8c619872bd --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_0_11/RedfishProcessor_V1_0_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_0_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_0_11_Dxe + FILE_GUID = 2630fa09-7d04-41ef-9fff-d54cdcb34eae + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_0_11EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_0_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_0_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_0_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_0_12/Processor_V1_0_12_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_0_12/Processor_V1_0_12_Dxe.c new file mode 100644 index 00000000000..fa7923fd7bf --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_0_12/Processor_V1_0_12_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_0_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_0_12 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "0", + "12" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_0_12 *ProcessorV1_0_12; + EFI_REDFISH_PROCESSOR_V1_0_12_CS *ProcessorV1_0_12Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "12") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_0_12_To_CS (ResoruceRaw, &ProcessorV1_0_12Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_0_12 = (EFI_REDFISH_PROCESSOR_V1_0_12 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_0_12)); + if (ProcessorV1_0_12 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_0_12; + ProcessorV1_0_12->Processor = ProcessorV1_0_12Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "12"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_0_12_JSON (*((EFI_REDFISH_PROCESSOR_V1_0_12_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_0_12 *ProcessorV1_0_12; + + ProcessorV1_0_12 = (EFI_REDFISH_PROCESSOR_V1_0_12 *)InterpProp; + DestroyProcessor_V1_0_12_CS (ProcessorV1_0_12->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_0_12_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_0_12EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_0_12Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_0_12/RedfishProcessor_V1_0_12_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_0_12/RedfishProcessor_V1_0_12_Dxe.inf new file mode 100644 index 00000000000..b1096c80697 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_0_12/RedfishProcessor_V1_0_12_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_0_12 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_0_12_Dxe + FILE_GUID = 848e0043-7b28-40f9-97dd-e14c96841aae + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_0_12EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_0_12Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_0_12_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_0_12Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_0_2/Processor_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_0_2/Processor_V1_0_2_Dxe.c new file mode 100644 index 00000000000..da3b7da6356 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_0_2/Processor_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "0", + "2" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_0_2 *ProcessorV1_0_2; + EFI_REDFISH_PROCESSOR_V1_0_2_CS *ProcessorV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_0_2_To_CS (ResoruceRaw, &ProcessorV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_0_2 = (EFI_REDFISH_PROCESSOR_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_0_2)); + if (ProcessorV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_0_2; + ProcessorV1_0_2->Processor = ProcessorV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_0_2_JSON (*((EFI_REDFISH_PROCESSOR_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_0_2 *ProcessorV1_0_2; + + ProcessorV1_0_2 = (EFI_REDFISH_PROCESSOR_V1_0_2 *)InterpProp; + DestroyProcessor_V1_0_2_CS (ProcessorV1_0_2->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_0_2/RedfishProcessor_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_0_2/RedfishProcessor_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..92b30a9e5d5 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_0_2/RedfishProcessor_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_0_2_Dxe + FILE_GUID = e73a586c-9998-4cd4-9471-fb3c939348b9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_0_3/Processor_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_0_3/Processor_V1_0_3_Dxe.c new file mode 100644 index 00000000000..fb0171eb27b --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_0_3/Processor_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "0", + "3" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_0_3 *ProcessorV1_0_3; + EFI_REDFISH_PROCESSOR_V1_0_3_CS *ProcessorV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_0_3_To_CS (ResoruceRaw, &ProcessorV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_0_3 = (EFI_REDFISH_PROCESSOR_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_0_3)); + if (ProcessorV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_0_3; + ProcessorV1_0_3->Processor = ProcessorV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_0_3_JSON (*((EFI_REDFISH_PROCESSOR_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_0_3 *ProcessorV1_0_3; + + ProcessorV1_0_3 = (EFI_REDFISH_PROCESSOR_V1_0_3 *)InterpProp; + DestroyProcessor_V1_0_3_CS (ProcessorV1_0_3->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_0_3/RedfishProcessor_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_0_3/RedfishProcessor_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..d2c70ae87d4 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_0_3/RedfishProcessor_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_0_3_Dxe + FILE_GUID = 56a32032-9204-4140-9f57-7f461df92cbe + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_0_4/Processor_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_0_4/Processor_V1_0_4_Dxe.c new file mode 100644 index 00000000000..74da65db350 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_0_4/Processor_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "0", + "4" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_0_4 *ProcessorV1_0_4; + EFI_REDFISH_PROCESSOR_V1_0_4_CS *ProcessorV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_0_4_To_CS (ResoruceRaw, &ProcessorV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_0_4 = (EFI_REDFISH_PROCESSOR_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_0_4)); + if (ProcessorV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_0_4; + ProcessorV1_0_4->Processor = ProcessorV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_0_4_JSON (*((EFI_REDFISH_PROCESSOR_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_0_4 *ProcessorV1_0_4; + + ProcessorV1_0_4 = (EFI_REDFISH_PROCESSOR_V1_0_4 *)InterpProp; + DestroyProcessor_V1_0_4_CS (ProcessorV1_0_4->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_0_4/RedfishProcessor_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_0_4/RedfishProcessor_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..11ac18c7e06 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_0_4/RedfishProcessor_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_0_4_Dxe + FILE_GUID = 2a7d64b7-3bc6-4609-bbd3-e4d77cbcdcb5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_0_5/Processor_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_0_5/Processor_V1_0_5_Dxe.c new file mode 100644 index 00000000000..4c963da924a --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_0_5/Processor_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "0", + "5" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_0_5 *ProcessorV1_0_5; + EFI_REDFISH_PROCESSOR_V1_0_5_CS *ProcessorV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_0_5_To_CS (ResoruceRaw, &ProcessorV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_0_5 = (EFI_REDFISH_PROCESSOR_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_0_5)); + if (ProcessorV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_0_5; + ProcessorV1_0_5->Processor = ProcessorV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_0_5_JSON (*((EFI_REDFISH_PROCESSOR_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_0_5 *ProcessorV1_0_5; + + ProcessorV1_0_5 = (EFI_REDFISH_PROCESSOR_V1_0_5 *)InterpProp; + DestroyProcessor_V1_0_5_CS (ProcessorV1_0_5->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_0_5/RedfishProcessor_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_0_5/RedfishProcessor_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..94a396b996e --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_0_5/RedfishProcessor_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_0_5_Dxe + FILE_GUID = 5931ea62-f7d8-40af-80fa-1bf682377f1a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_0_6/Processor_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_0_6/Processor_V1_0_6_Dxe.c new file mode 100644 index 00000000000..384f75e013e --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_0_6/Processor_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "0", + "6" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_0_6 *ProcessorV1_0_6; + EFI_REDFISH_PROCESSOR_V1_0_6_CS *ProcessorV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_0_6_To_CS (ResoruceRaw, &ProcessorV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_0_6 = (EFI_REDFISH_PROCESSOR_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_0_6)); + if (ProcessorV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_0_6; + ProcessorV1_0_6->Processor = ProcessorV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_0_6_JSON (*((EFI_REDFISH_PROCESSOR_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_0_6 *ProcessorV1_0_6; + + ProcessorV1_0_6 = (EFI_REDFISH_PROCESSOR_V1_0_6 *)InterpProp; + DestroyProcessor_V1_0_6_CS (ProcessorV1_0_6->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_0_6/RedfishProcessor_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_0_6/RedfishProcessor_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..fb7406fb066 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_0_6/RedfishProcessor_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_0_6_Dxe + FILE_GUID = af71e7e0-e1eb-4ac2-9365-7f928831ee81 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_0_7/Processor_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_0_7/Processor_V1_0_7_Dxe.c new file mode 100644 index 00000000000..8ceee05c89e --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_0_7/Processor_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "0", + "7" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_0_7 *ProcessorV1_0_7; + EFI_REDFISH_PROCESSOR_V1_0_7_CS *ProcessorV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_0_7_To_CS (ResoruceRaw, &ProcessorV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_0_7 = (EFI_REDFISH_PROCESSOR_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_0_7)); + if (ProcessorV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_0_7; + ProcessorV1_0_7->Processor = ProcessorV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_0_7_JSON (*((EFI_REDFISH_PROCESSOR_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_0_7 *ProcessorV1_0_7; + + ProcessorV1_0_7 = (EFI_REDFISH_PROCESSOR_V1_0_7 *)InterpProp; + DestroyProcessor_V1_0_7_CS (ProcessorV1_0_7->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_0_7/RedfishProcessor_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_0_7/RedfishProcessor_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..9f3ee9289d1 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_0_7/RedfishProcessor_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_0_7_Dxe + FILE_GUID = bd4bcae5-9d68-436e-bdc7-82a722fe5940 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_0_8/Processor_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_0_8/Processor_V1_0_8_Dxe.c new file mode 100644 index 00000000000..016e95121ef --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_0_8/Processor_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "0", + "8" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_0_8 *ProcessorV1_0_8; + EFI_REDFISH_PROCESSOR_V1_0_8_CS *ProcessorV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_0_8_To_CS (ResoruceRaw, &ProcessorV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_0_8 = (EFI_REDFISH_PROCESSOR_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_0_8)); + if (ProcessorV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_0_8; + ProcessorV1_0_8->Processor = ProcessorV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_0_8_JSON (*((EFI_REDFISH_PROCESSOR_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_0_8 *ProcessorV1_0_8; + + ProcessorV1_0_8 = (EFI_REDFISH_PROCESSOR_V1_0_8 *)InterpProp; + DestroyProcessor_V1_0_8_CS (ProcessorV1_0_8->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_0_8/RedfishProcessor_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_0_8/RedfishProcessor_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..1b6b903627e --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_0_8/RedfishProcessor_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_0_8_Dxe + FILE_GUID = dd81a2bd-6b71-4ba3-9497-5611754171f0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_0_9/Processor_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_0_9/Processor_V1_0_9_Dxe.c new file mode 100644 index 00000000000..eb59564f7f9 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_0_9/Processor_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "0", + "9" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_0_9 *ProcessorV1_0_9; + EFI_REDFISH_PROCESSOR_V1_0_9_CS *ProcessorV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_0_9_To_CS (ResoruceRaw, &ProcessorV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_0_9 = (EFI_REDFISH_PROCESSOR_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_0_9)); + if (ProcessorV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_0_9; + ProcessorV1_0_9->Processor = ProcessorV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_0_9_JSON (*((EFI_REDFISH_PROCESSOR_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_0_9 *ProcessorV1_0_9; + + ProcessorV1_0_9 = (EFI_REDFISH_PROCESSOR_V1_0_9 *)InterpProp; + DestroyProcessor_V1_0_9_CS (ProcessorV1_0_9->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_0_9/RedfishProcessor_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_0_9/RedfishProcessor_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..3f84727b4af --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_0_9/RedfishProcessor_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_0_9_Dxe + FILE_GUID = 8c7c627e-a7db-47d3-bc42-1b2cdbf3b0ce + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_10_0/Processor_V1_10_0_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_10_0/Processor_V1_10_0_Dxe.c new file mode 100644 index 00000000000..f9de461814b --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_10_0/Processor_V1_10_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_10_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_10_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "10", + "0" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_10_0 *ProcessorV1_10_0; + EFI_REDFISH_PROCESSOR_V1_10_0_CS *ProcessorV1_10_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_10_0_To_CS (ResoruceRaw, &ProcessorV1_10_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_10_0 = (EFI_REDFISH_PROCESSOR_V1_10_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_10_0)); + if (ProcessorV1_10_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_10_0; + ProcessorV1_10_0->Processor = ProcessorV1_10_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "10"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_10_0_JSON (*((EFI_REDFISH_PROCESSOR_V1_10_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_10_0 *ProcessorV1_10_0; + + ProcessorV1_10_0 = (EFI_REDFISH_PROCESSOR_V1_10_0 *)InterpProp; + DestroyProcessor_V1_10_0_CS (ProcessorV1_10_0->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_10_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_10_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_10_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_10_0/RedfishProcessor_V1_10_0_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_10_0/RedfishProcessor_V1_10_0_Dxe.inf new file mode 100644 index 00000000000..275c46abab3 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_10_0/RedfishProcessor_V1_10_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_10_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_10_0_Dxe + FILE_GUID = 2fe0dbc7-f8c1-42f5-92e7-17a4f4bc5682 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_10_0EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_10_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_10_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_10_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_10_1/Processor_V1_10_1_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_10_1/Processor_V1_10_1_Dxe.c new file mode 100644 index 00000000000..7344cf238b2 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_10_1/Processor_V1_10_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_10_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_10_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "10", + "1" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_10_1 *ProcessorV1_10_1; + EFI_REDFISH_PROCESSOR_V1_10_1_CS *ProcessorV1_10_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_10_1_To_CS (ResoruceRaw, &ProcessorV1_10_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_10_1 = (EFI_REDFISH_PROCESSOR_V1_10_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_10_1)); + if (ProcessorV1_10_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_10_1; + ProcessorV1_10_1->Processor = ProcessorV1_10_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "10"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_10_1_JSON (*((EFI_REDFISH_PROCESSOR_V1_10_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_10_1 *ProcessorV1_10_1; + + ProcessorV1_10_1 = (EFI_REDFISH_PROCESSOR_V1_10_1 *)InterpProp; + DestroyProcessor_V1_10_1_CS (ProcessorV1_10_1->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_10_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_10_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_10_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_10_1/RedfishProcessor_V1_10_1_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_10_1/RedfishProcessor_V1_10_1_Dxe.inf new file mode 100644 index 00000000000..e219e454ddd --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_10_1/RedfishProcessor_V1_10_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_10_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_10_1_Dxe + FILE_GUID = ad150ca6-61c5-4461-9d59-292411949387 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_10_1EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_10_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_10_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_10_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_11_0/Processor_V1_11_0_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_11_0/Processor_V1_11_0_Dxe.c new file mode 100644 index 00000000000..520a23d7cba --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_11_0/Processor_V1_11_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_11_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_11_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "11", + "0" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_11_0 *ProcessorV1_11_0; + EFI_REDFISH_PROCESSOR_V1_11_0_CS *ProcessorV1_11_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_11_0_To_CS (ResoruceRaw, &ProcessorV1_11_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_11_0 = (EFI_REDFISH_PROCESSOR_V1_11_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_11_0)); + if (ProcessorV1_11_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_11_0; + ProcessorV1_11_0->Processor = ProcessorV1_11_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "11"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_11_0_JSON (*((EFI_REDFISH_PROCESSOR_V1_11_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_11_0 *ProcessorV1_11_0; + + ProcessorV1_11_0 = (EFI_REDFISH_PROCESSOR_V1_11_0 *)InterpProp; + DestroyProcessor_V1_11_0_CS (ProcessorV1_11_0->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_11_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_11_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_11_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_11_0/RedfishProcessor_V1_11_0_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_11_0/RedfishProcessor_V1_11_0_Dxe.inf new file mode 100644 index 00000000000..6ba21e8fab1 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_11_0/RedfishProcessor_V1_11_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_11_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_11_0_Dxe + FILE_GUID = d27b9f46-b4e5-49f6-ba14-ef742dec6e79 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_11_0EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_11_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_11_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_11_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_1_0/Processor_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_1_0/Processor_V1_1_0_Dxe.c new file mode 100644 index 00000000000..2584a80a042 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_1_0/Processor_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "1", + "0" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_1_0 *ProcessorV1_1_0; + EFI_REDFISH_PROCESSOR_V1_1_0_CS *ProcessorV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_1_0_To_CS (ResoruceRaw, &ProcessorV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_1_0 = (EFI_REDFISH_PROCESSOR_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_1_0)); + if (ProcessorV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_1_0; + ProcessorV1_1_0->Processor = ProcessorV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_1_0_JSON (*((EFI_REDFISH_PROCESSOR_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_1_0 *ProcessorV1_1_0; + + ProcessorV1_1_0 = (EFI_REDFISH_PROCESSOR_V1_1_0 *)InterpProp; + DestroyProcessor_V1_1_0_CS (ProcessorV1_1_0->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_1_0/RedfishProcessor_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_1_0/RedfishProcessor_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..6c64fae66c9 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_1_0/RedfishProcessor_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_1_0_Dxe + FILE_GUID = f04fa7da-ebf0-4678-b26f-4a5d6596b211 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_1_1/Processor_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_1_1/Processor_V1_1_1_Dxe.c new file mode 100644 index 00000000000..32c7ec95a8b --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_1_1/Processor_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "1", + "1" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_1_1 *ProcessorV1_1_1; + EFI_REDFISH_PROCESSOR_V1_1_1_CS *ProcessorV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_1_1_To_CS (ResoruceRaw, &ProcessorV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_1_1 = (EFI_REDFISH_PROCESSOR_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_1_1)); + if (ProcessorV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_1_1; + ProcessorV1_1_1->Processor = ProcessorV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_1_1_JSON (*((EFI_REDFISH_PROCESSOR_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_1_1 *ProcessorV1_1_1; + + ProcessorV1_1_1 = (EFI_REDFISH_PROCESSOR_V1_1_1 *)InterpProp; + DestroyProcessor_V1_1_1_CS (ProcessorV1_1_1->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_1_1/RedfishProcessor_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_1_1/RedfishProcessor_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..4d941a069cc --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_1_1/RedfishProcessor_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_1_1_Dxe + FILE_GUID = 891a1a39-5387-4e20-8956-cde6dbd7e4a3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_1_2/Processor_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_1_2/Processor_V1_1_2_Dxe.c new file mode 100644 index 00000000000..2ff92a6386e --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_1_2/Processor_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "1", + "2" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_1_2 *ProcessorV1_1_2; + EFI_REDFISH_PROCESSOR_V1_1_2_CS *ProcessorV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_1_2_To_CS (ResoruceRaw, &ProcessorV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_1_2 = (EFI_REDFISH_PROCESSOR_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_1_2)); + if (ProcessorV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_1_2; + ProcessorV1_1_2->Processor = ProcessorV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_1_2_JSON (*((EFI_REDFISH_PROCESSOR_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_1_2 *ProcessorV1_1_2; + + ProcessorV1_1_2 = (EFI_REDFISH_PROCESSOR_V1_1_2 *)InterpProp; + DestroyProcessor_V1_1_2_CS (ProcessorV1_1_2->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_1_2/RedfishProcessor_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_1_2/RedfishProcessor_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..d8148d7917a --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_1_2/RedfishProcessor_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_1_2_Dxe + FILE_GUID = 1c988b27-178e-4df7-99ff-bcb5a9500810 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_1_3/Processor_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_1_3/Processor_V1_1_3_Dxe.c new file mode 100644 index 00000000000..00367d3a841 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_1_3/Processor_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "1", + "3" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_1_3 *ProcessorV1_1_3; + EFI_REDFISH_PROCESSOR_V1_1_3_CS *ProcessorV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_1_3_To_CS (ResoruceRaw, &ProcessorV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_1_3 = (EFI_REDFISH_PROCESSOR_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_1_3)); + if (ProcessorV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_1_3; + ProcessorV1_1_3->Processor = ProcessorV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_1_3_JSON (*((EFI_REDFISH_PROCESSOR_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_1_3 *ProcessorV1_1_3; + + ProcessorV1_1_3 = (EFI_REDFISH_PROCESSOR_V1_1_3 *)InterpProp; + DestroyProcessor_V1_1_3_CS (ProcessorV1_1_3->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_1_3/RedfishProcessor_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_1_3/RedfishProcessor_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..c6bbbbd4633 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_1_3/RedfishProcessor_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_1_3_Dxe + FILE_GUID = b6ab093e-956f-46b9-9f2b-f7d2e9060ba7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_1_4/Processor_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_1_4/Processor_V1_1_4_Dxe.c new file mode 100644 index 00000000000..6c6d3da71e2 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_1_4/Processor_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "1", + "4" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_1_4 *ProcessorV1_1_4; + EFI_REDFISH_PROCESSOR_V1_1_4_CS *ProcessorV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_1_4_To_CS (ResoruceRaw, &ProcessorV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_1_4 = (EFI_REDFISH_PROCESSOR_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_1_4)); + if (ProcessorV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_1_4; + ProcessorV1_1_4->Processor = ProcessorV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_1_4_JSON (*((EFI_REDFISH_PROCESSOR_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_1_4 *ProcessorV1_1_4; + + ProcessorV1_1_4 = (EFI_REDFISH_PROCESSOR_V1_1_4 *)InterpProp; + DestroyProcessor_V1_1_4_CS (ProcessorV1_1_4->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_1_4/RedfishProcessor_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_1_4/RedfishProcessor_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..6fcf346186f --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_1_4/RedfishProcessor_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_1_4_Dxe + FILE_GUID = b25cbdd1-aae3-4d3a-aeba-44f3f6d6ca80 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_1_5/Processor_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_1_5/Processor_V1_1_5_Dxe.c new file mode 100644 index 00000000000..b45cc17d99b --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_1_5/Processor_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "1", + "5" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_1_5 *ProcessorV1_1_5; + EFI_REDFISH_PROCESSOR_V1_1_5_CS *ProcessorV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_1_5_To_CS (ResoruceRaw, &ProcessorV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_1_5 = (EFI_REDFISH_PROCESSOR_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_1_5)); + if (ProcessorV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_1_5; + ProcessorV1_1_5->Processor = ProcessorV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_1_5_JSON (*((EFI_REDFISH_PROCESSOR_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_1_5 *ProcessorV1_1_5; + + ProcessorV1_1_5 = (EFI_REDFISH_PROCESSOR_V1_1_5 *)InterpProp; + DestroyProcessor_V1_1_5_CS (ProcessorV1_1_5->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_1_5/RedfishProcessor_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_1_5/RedfishProcessor_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..4c51089f504 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_1_5/RedfishProcessor_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_1_5_Dxe + FILE_GUID = 4c42b8fb-d7fd-4273-a5e0-c897ce8178f6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_1_6/Processor_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_1_6/Processor_V1_1_6_Dxe.c new file mode 100644 index 00000000000..ab3f571aff4 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_1_6/Processor_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "1", + "6" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_1_6 *ProcessorV1_1_6; + EFI_REDFISH_PROCESSOR_V1_1_6_CS *ProcessorV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_1_6_To_CS (ResoruceRaw, &ProcessorV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_1_6 = (EFI_REDFISH_PROCESSOR_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_1_6)); + if (ProcessorV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_1_6; + ProcessorV1_1_6->Processor = ProcessorV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_1_6_JSON (*((EFI_REDFISH_PROCESSOR_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_1_6 *ProcessorV1_1_6; + + ProcessorV1_1_6 = (EFI_REDFISH_PROCESSOR_V1_1_6 *)InterpProp; + DestroyProcessor_V1_1_6_CS (ProcessorV1_1_6->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_1_6/RedfishProcessor_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_1_6/RedfishProcessor_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..7209f1d561a --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_1_6/RedfishProcessor_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_1_6_Dxe + FILE_GUID = df18d155-5d59-4ae5-917d-a4df8ff10d03 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_1_7/Processor_V1_1_7_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_1_7/Processor_V1_1_7_Dxe.c new file mode 100644 index 00000000000..6f28b34320a --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_1_7/Processor_V1_1_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_1_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "1", + "7" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_1_7 *ProcessorV1_1_7; + EFI_REDFISH_PROCESSOR_V1_1_7_CS *ProcessorV1_1_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_1_7_To_CS (ResoruceRaw, &ProcessorV1_1_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_1_7 = (EFI_REDFISH_PROCESSOR_V1_1_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_1_7)); + if (ProcessorV1_1_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_1_7; + ProcessorV1_1_7->Processor = ProcessorV1_1_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_1_7_JSON (*((EFI_REDFISH_PROCESSOR_V1_1_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_1_7 *ProcessorV1_1_7; + + ProcessorV1_1_7 = (EFI_REDFISH_PROCESSOR_V1_1_7 *)InterpProp; + DestroyProcessor_V1_1_7_CS (ProcessorV1_1_7->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_1_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_1_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_1_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_1_7/RedfishProcessor_V1_1_7_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_1_7/RedfishProcessor_V1_1_7_Dxe.inf new file mode 100644 index 00000000000..f0be276af6c --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_1_7/RedfishProcessor_V1_1_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_1_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_1_7_Dxe + FILE_GUID = d77df74c-d32c-49a5-bbd0-2aaae214f381 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_1_7EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_1_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_1_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_1_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_1_8/Processor_V1_1_8_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_1_8/Processor_V1_1_8_Dxe.c new file mode 100644 index 00000000000..428910bafa9 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_1_8/Processor_V1_1_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_1_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "1", + "8" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_1_8 *ProcessorV1_1_8; + EFI_REDFISH_PROCESSOR_V1_1_8_CS *ProcessorV1_1_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_1_8_To_CS (ResoruceRaw, &ProcessorV1_1_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_1_8 = (EFI_REDFISH_PROCESSOR_V1_1_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_1_8)); + if (ProcessorV1_1_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_1_8; + ProcessorV1_1_8->Processor = ProcessorV1_1_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_1_8_JSON (*((EFI_REDFISH_PROCESSOR_V1_1_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_1_8 *ProcessorV1_1_8; + + ProcessorV1_1_8 = (EFI_REDFISH_PROCESSOR_V1_1_8 *)InterpProp; + DestroyProcessor_V1_1_8_CS (ProcessorV1_1_8->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_1_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_1_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_1_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_1_8/RedfishProcessor_V1_1_8_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_1_8/RedfishProcessor_V1_1_8_Dxe.inf new file mode 100644 index 00000000000..9593577574f --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_1_8/RedfishProcessor_V1_1_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_1_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_1_8_Dxe + FILE_GUID = d723e15b-3409-48c8-85d9-8a4ba7b423ac + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_1_8EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_1_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_1_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_1_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_2_0/Processor_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_2_0/Processor_V1_2_0_Dxe.c new file mode 100644 index 00000000000..68618a26139 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_2_0/Processor_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "2", + "0" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_2_0 *ProcessorV1_2_0; + EFI_REDFISH_PROCESSOR_V1_2_0_CS *ProcessorV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_2_0_To_CS (ResoruceRaw, &ProcessorV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_2_0 = (EFI_REDFISH_PROCESSOR_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_2_0)); + if (ProcessorV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_2_0; + ProcessorV1_2_0->Processor = ProcessorV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_2_0_JSON (*((EFI_REDFISH_PROCESSOR_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_2_0 *ProcessorV1_2_0; + + ProcessorV1_2_0 = (EFI_REDFISH_PROCESSOR_V1_2_0 *)InterpProp; + DestroyProcessor_V1_2_0_CS (ProcessorV1_2_0->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_2_0/RedfishProcessor_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_2_0/RedfishProcessor_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..31189a4c964 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_2_0/RedfishProcessor_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_2_0_Dxe + FILE_GUID = 612b6a8e-c562-44be-bb83-ea1fea535c0a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_2_1/Processor_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_2_1/Processor_V1_2_1_Dxe.c new file mode 100644 index 00000000000..c0a054a08d4 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_2_1/Processor_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "2", + "1" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_2_1 *ProcessorV1_2_1; + EFI_REDFISH_PROCESSOR_V1_2_1_CS *ProcessorV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_2_1_To_CS (ResoruceRaw, &ProcessorV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_2_1 = (EFI_REDFISH_PROCESSOR_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_2_1)); + if (ProcessorV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_2_1; + ProcessorV1_2_1->Processor = ProcessorV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_2_1_JSON (*((EFI_REDFISH_PROCESSOR_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_2_1 *ProcessorV1_2_1; + + ProcessorV1_2_1 = (EFI_REDFISH_PROCESSOR_V1_2_1 *)InterpProp; + DestroyProcessor_V1_2_1_CS (ProcessorV1_2_1->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_2_1/RedfishProcessor_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_2_1/RedfishProcessor_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..64ad1a9a58f --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_2_1/RedfishProcessor_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_2_1_Dxe + FILE_GUID = 493c958b-ed3f-4a6e-8435-50ecafd55456 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_2_2/Processor_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_2_2/Processor_V1_2_2_Dxe.c new file mode 100644 index 00000000000..4be3407fbb2 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_2_2/Processor_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "2", + "2" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_2_2 *ProcessorV1_2_2; + EFI_REDFISH_PROCESSOR_V1_2_2_CS *ProcessorV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_2_2_To_CS (ResoruceRaw, &ProcessorV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_2_2 = (EFI_REDFISH_PROCESSOR_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_2_2)); + if (ProcessorV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_2_2; + ProcessorV1_2_2->Processor = ProcessorV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_2_2_JSON (*((EFI_REDFISH_PROCESSOR_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_2_2 *ProcessorV1_2_2; + + ProcessorV1_2_2 = (EFI_REDFISH_PROCESSOR_V1_2_2 *)InterpProp; + DestroyProcessor_V1_2_2_CS (ProcessorV1_2_2->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_2_2/RedfishProcessor_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_2_2/RedfishProcessor_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..7aa11e6aea6 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_2_2/RedfishProcessor_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_2_2_Dxe + FILE_GUID = 4964bf7b-0815-480b-996d-bc623329794b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_2_3/Processor_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_2_3/Processor_V1_2_3_Dxe.c new file mode 100644 index 00000000000..ae061d9d093 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_2_3/Processor_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "2", + "3" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_2_3 *ProcessorV1_2_3; + EFI_REDFISH_PROCESSOR_V1_2_3_CS *ProcessorV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_2_3_To_CS (ResoruceRaw, &ProcessorV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_2_3 = (EFI_REDFISH_PROCESSOR_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_2_3)); + if (ProcessorV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_2_3; + ProcessorV1_2_3->Processor = ProcessorV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_2_3_JSON (*((EFI_REDFISH_PROCESSOR_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_2_3 *ProcessorV1_2_3; + + ProcessorV1_2_3 = (EFI_REDFISH_PROCESSOR_V1_2_3 *)InterpProp; + DestroyProcessor_V1_2_3_CS (ProcessorV1_2_3->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_2_3/RedfishProcessor_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_2_3/RedfishProcessor_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..39ad35d5464 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_2_3/RedfishProcessor_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_2_3_Dxe + FILE_GUID = b50e6673-cb34-4a2c-9e6c-2c0fdd63cf0c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_2_4/Processor_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_2_4/Processor_V1_2_4_Dxe.c new file mode 100644 index 00000000000..4dfb1ffff71 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_2_4/Processor_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "2", + "4" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_2_4 *ProcessorV1_2_4; + EFI_REDFISH_PROCESSOR_V1_2_4_CS *ProcessorV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_2_4_To_CS (ResoruceRaw, &ProcessorV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_2_4 = (EFI_REDFISH_PROCESSOR_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_2_4)); + if (ProcessorV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_2_4; + ProcessorV1_2_4->Processor = ProcessorV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_2_4_JSON (*((EFI_REDFISH_PROCESSOR_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_2_4 *ProcessorV1_2_4; + + ProcessorV1_2_4 = (EFI_REDFISH_PROCESSOR_V1_2_4 *)InterpProp; + DestroyProcessor_V1_2_4_CS (ProcessorV1_2_4->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_2_4/RedfishProcessor_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_2_4/RedfishProcessor_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..e1985887b37 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_2_4/RedfishProcessor_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_2_4_Dxe + FILE_GUID = 219ed760-7059-4bc7-8c7d-702a4ffbbbd1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_2_5/Processor_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_2_5/Processor_V1_2_5_Dxe.c new file mode 100644 index 00000000000..0e9098e0d75 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_2_5/Processor_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "2", + "5" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_2_5 *ProcessorV1_2_5; + EFI_REDFISH_PROCESSOR_V1_2_5_CS *ProcessorV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_2_5_To_CS (ResoruceRaw, &ProcessorV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_2_5 = (EFI_REDFISH_PROCESSOR_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_2_5)); + if (ProcessorV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_2_5; + ProcessorV1_2_5->Processor = ProcessorV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_2_5_JSON (*((EFI_REDFISH_PROCESSOR_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_2_5 *ProcessorV1_2_5; + + ProcessorV1_2_5 = (EFI_REDFISH_PROCESSOR_V1_2_5 *)InterpProp; + DestroyProcessor_V1_2_5_CS (ProcessorV1_2_5->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_2_5/RedfishProcessor_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_2_5/RedfishProcessor_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..f801fddccec --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_2_5/RedfishProcessor_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_2_5_Dxe + FILE_GUID = b2eb9cf2-b98a-4fd4-af01-c6293f63bf8d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_2_6/Processor_V1_2_6_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_2_6/Processor_V1_2_6_Dxe.c new file mode 100644 index 00000000000..7750f0e27a4 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_2_6/Processor_V1_2_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_2_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "2", + "6" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_2_6 *ProcessorV1_2_6; + EFI_REDFISH_PROCESSOR_V1_2_6_CS *ProcessorV1_2_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_2_6_To_CS (ResoruceRaw, &ProcessorV1_2_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_2_6 = (EFI_REDFISH_PROCESSOR_V1_2_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_2_6)); + if (ProcessorV1_2_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_2_6; + ProcessorV1_2_6->Processor = ProcessorV1_2_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_2_6_JSON (*((EFI_REDFISH_PROCESSOR_V1_2_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_2_6 *ProcessorV1_2_6; + + ProcessorV1_2_6 = (EFI_REDFISH_PROCESSOR_V1_2_6 *)InterpProp; + DestroyProcessor_V1_2_6_CS (ProcessorV1_2_6->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_2_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_2_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_2_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_2_6/RedfishProcessor_V1_2_6_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_2_6/RedfishProcessor_V1_2_6_Dxe.inf new file mode 100644 index 00000000000..29140cf1fd9 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_2_6/RedfishProcessor_V1_2_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_2_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_2_6_Dxe + FILE_GUID = b830db61-320f-4f8d-9177-356b0683dd2f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_2_6EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_2_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_2_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_2_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_2_7/Processor_V1_2_7_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_2_7/Processor_V1_2_7_Dxe.c new file mode 100644 index 00000000000..fce309dcf3a --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_2_7/Processor_V1_2_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_2_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "2", + "7" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_2_7 *ProcessorV1_2_7; + EFI_REDFISH_PROCESSOR_V1_2_7_CS *ProcessorV1_2_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_2_7_To_CS (ResoruceRaw, &ProcessorV1_2_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_2_7 = (EFI_REDFISH_PROCESSOR_V1_2_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_2_7)); + if (ProcessorV1_2_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_2_7; + ProcessorV1_2_7->Processor = ProcessorV1_2_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_2_7_JSON (*((EFI_REDFISH_PROCESSOR_V1_2_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_2_7 *ProcessorV1_2_7; + + ProcessorV1_2_7 = (EFI_REDFISH_PROCESSOR_V1_2_7 *)InterpProp; + DestroyProcessor_V1_2_7_CS (ProcessorV1_2_7->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_2_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_2_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_2_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_2_7/RedfishProcessor_V1_2_7_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_2_7/RedfishProcessor_V1_2_7_Dxe.inf new file mode 100644 index 00000000000..25e3c654ae5 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_2_7/RedfishProcessor_V1_2_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_2_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_2_7_Dxe + FILE_GUID = 42b529fa-ac3d-492b-adb5-205e0afbf61e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_2_7EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_2_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_2_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_2_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_2_8/Processor_V1_2_8_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_2_8/Processor_V1_2_8_Dxe.c new file mode 100644 index 00000000000..44b07dca33e --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_2_8/Processor_V1_2_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_2_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "2", + "8" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_2_8 *ProcessorV1_2_8; + EFI_REDFISH_PROCESSOR_V1_2_8_CS *ProcessorV1_2_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_2_8_To_CS (ResoruceRaw, &ProcessorV1_2_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_2_8 = (EFI_REDFISH_PROCESSOR_V1_2_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_2_8)); + if (ProcessorV1_2_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_2_8; + ProcessorV1_2_8->Processor = ProcessorV1_2_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_2_8_JSON (*((EFI_REDFISH_PROCESSOR_V1_2_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_2_8 *ProcessorV1_2_8; + + ProcessorV1_2_8 = (EFI_REDFISH_PROCESSOR_V1_2_8 *)InterpProp; + DestroyProcessor_V1_2_8_CS (ProcessorV1_2_8->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_2_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_2_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_2_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_2_8/RedfishProcessor_V1_2_8_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_2_8/RedfishProcessor_V1_2_8_Dxe.inf new file mode 100644 index 00000000000..98dbb2d201d --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_2_8/RedfishProcessor_V1_2_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_2_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_2_8_Dxe + FILE_GUID = cbd3fcaf-2a04-438b-a6e4-5c82f52b5e00 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_2_8EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_2_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_2_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_2_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_3_0/Processor_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_3_0/Processor_V1_3_0_Dxe.c new file mode 100644 index 00000000000..d31b2f21603 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_3_0/Processor_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "3", + "0" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_3_0 *ProcessorV1_3_0; + EFI_REDFISH_PROCESSOR_V1_3_0_CS *ProcessorV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_3_0_To_CS (ResoruceRaw, &ProcessorV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_3_0 = (EFI_REDFISH_PROCESSOR_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_3_0)); + if (ProcessorV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_3_0; + ProcessorV1_3_0->Processor = ProcessorV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_3_0_JSON (*((EFI_REDFISH_PROCESSOR_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_3_0 *ProcessorV1_3_0; + + ProcessorV1_3_0 = (EFI_REDFISH_PROCESSOR_V1_3_0 *)InterpProp; + DestroyProcessor_V1_3_0_CS (ProcessorV1_3_0->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_3_0/RedfishProcessor_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_3_0/RedfishProcessor_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..be11ae60cf5 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_3_0/RedfishProcessor_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_3_0_Dxe + FILE_GUID = ec387d9b-faa0-4bd1-9a18-5b69c856415a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_3_1/Processor_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_3_1/Processor_V1_3_1_Dxe.c new file mode 100644 index 00000000000..7c59e428a0f --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_3_1/Processor_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "3", + "1" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_3_1 *ProcessorV1_3_1; + EFI_REDFISH_PROCESSOR_V1_3_1_CS *ProcessorV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_3_1_To_CS (ResoruceRaw, &ProcessorV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_3_1 = (EFI_REDFISH_PROCESSOR_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_3_1)); + if (ProcessorV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_3_1; + ProcessorV1_3_1->Processor = ProcessorV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_3_1_JSON (*((EFI_REDFISH_PROCESSOR_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_3_1 *ProcessorV1_3_1; + + ProcessorV1_3_1 = (EFI_REDFISH_PROCESSOR_V1_3_1 *)InterpProp; + DestroyProcessor_V1_3_1_CS (ProcessorV1_3_1->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_3_1/RedfishProcessor_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_3_1/RedfishProcessor_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..d3b6eb24842 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_3_1/RedfishProcessor_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_3_1_Dxe + FILE_GUID = 304aebc1-cae1-40bd-9be0-ee07f0b489f4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_3_2/Processor_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_3_2/Processor_V1_3_2_Dxe.c new file mode 100644 index 00000000000..b8bd276b1c7 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_3_2/Processor_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "3", + "2" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_3_2 *ProcessorV1_3_2; + EFI_REDFISH_PROCESSOR_V1_3_2_CS *ProcessorV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_3_2_To_CS (ResoruceRaw, &ProcessorV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_3_2 = (EFI_REDFISH_PROCESSOR_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_3_2)); + if (ProcessorV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_3_2; + ProcessorV1_3_2->Processor = ProcessorV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_3_2_JSON (*((EFI_REDFISH_PROCESSOR_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_3_2 *ProcessorV1_3_2; + + ProcessorV1_3_2 = (EFI_REDFISH_PROCESSOR_V1_3_2 *)InterpProp; + DestroyProcessor_V1_3_2_CS (ProcessorV1_3_2->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_3_2/RedfishProcessor_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_3_2/RedfishProcessor_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..5602b1ce5ba --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_3_2/RedfishProcessor_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_3_2_Dxe + FILE_GUID = 86a8ab7c-9253-467b-8b4c-54be3b3ad635 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_3_3/Processor_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_3_3/Processor_V1_3_3_Dxe.c new file mode 100644 index 00000000000..6cbe7574bfc --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_3_3/Processor_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "3", + "3" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_3_3 *ProcessorV1_3_3; + EFI_REDFISH_PROCESSOR_V1_3_3_CS *ProcessorV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_3_3_To_CS (ResoruceRaw, &ProcessorV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_3_3 = (EFI_REDFISH_PROCESSOR_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_3_3)); + if (ProcessorV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_3_3; + ProcessorV1_3_3->Processor = ProcessorV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_3_3_JSON (*((EFI_REDFISH_PROCESSOR_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_3_3 *ProcessorV1_3_3; + + ProcessorV1_3_3 = (EFI_REDFISH_PROCESSOR_V1_3_3 *)InterpProp; + DestroyProcessor_V1_3_3_CS (ProcessorV1_3_3->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_3_3/RedfishProcessor_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_3_3/RedfishProcessor_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..e9743ee07aa --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_3_3/RedfishProcessor_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_3_3_Dxe + FILE_GUID = da1f617a-5a13-486c-8e39-5f1129ba173e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_3_4/Processor_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_3_4/Processor_V1_3_4_Dxe.c new file mode 100644 index 00000000000..abf8fe4349b --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_3_4/Processor_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "3", + "4" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_3_4 *ProcessorV1_3_4; + EFI_REDFISH_PROCESSOR_V1_3_4_CS *ProcessorV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_3_4_To_CS (ResoruceRaw, &ProcessorV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_3_4 = (EFI_REDFISH_PROCESSOR_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_3_4)); + if (ProcessorV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_3_4; + ProcessorV1_3_4->Processor = ProcessorV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_3_4_JSON (*((EFI_REDFISH_PROCESSOR_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_3_4 *ProcessorV1_3_4; + + ProcessorV1_3_4 = (EFI_REDFISH_PROCESSOR_V1_3_4 *)InterpProp; + DestroyProcessor_V1_3_4_CS (ProcessorV1_3_4->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_3_4/RedfishProcessor_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_3_4/RedfishProcessor_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..ce418fdb93b --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_3_4/RedfishProcessor_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_3_4_Dxe + FILE_GUID = 21feffcd-c317-4b98-b132-42d62ad231c8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_3_5/Processor_V1_3_5_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_3_5/Processor_V1_3_5_Dxe.c new file mode 100644 index 00000000000..cf9421bfd0a --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_3_5/Processor_V1_3_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_3_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "3", + "5" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_3_5 *ProcessorV1_3_5; + EFI_REDFISH_PROCESSOR_V1_3_5_CS *ProcessorV1_3_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_3_5_To_CS (ResoruceRaw, &ProcessorV1_3_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_3_5 = (EFI_REDFISH_PROCESSOR_V1_3_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_3_5)); + if (ProcessorV1_3_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_3_5; + ProcessorV1_3_5->Processor = ProcessorV1_3_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_3_5_JSON (*((EFI_REDFISH_PROCESSOR_V1_3_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_3_5 *ProcessorV1_3_5; + + ProcessorV1_3_5 = (EFI_REDFISH_PROCESSOR_V1_3_5 *)InterpProp; + DestroyProcessor_V1_3_5_CS (ProcessorV1_3_5->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_3_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_3_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_3_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_3_5/RedfishProcessor_V1_3_5_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_3_5/RedfishProcessor_V1_3_5_Dxe.inf new file mode 100644 index 00000000000..05d7f5f40ff --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_3_5/RedfishProcessor_V1_3_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_3_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_3_5_Dxe + FILE_GUID = 8fdf83ce-b557-4bcc-8950-4f02ee3cd53d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_3_5EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_3_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_3_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_3_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_3_6/Processor_V1_3_6_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_3_6/Processor_V1_3_6_Dxe.c new file mode 100644 index 00000000000..2216ddeccc9 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_3_6/Processor_V1_3_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_3_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "3", + "6" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_3_6 *ProcessorV1_3_6; + EFI_REDFISH_PROCESSOR_V1_3_6_CS *ProcessorV1_3_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_3_6_To_CS (ResoruceRaw, &ProcessorV1_3_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_3_6 = (EFI_REDFISH_PROCESSOR_V1_3_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_3_6)); + if (ProcessorV1_3_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_3_6; + ProcessorV1_3_6->Processor = ProcessorV1_3_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_3_6_JSON (*((EFI_REDFISH_PROCESSOR_V1_3_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_3_6 *ProcessorV1_3_6; + + ProcessorV1_3_6 = (EFI_REDFISH_PROCESSOR_V1_3_6 *)InterpProp; + DestroyProcessor_V1_3_6_CS (ProcessorV1_3_6->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_3_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_3_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_3_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_3_6/RedfishProcessor_V1_3_6_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_3_6/RedfishProcessor_V1_3_6_Dxe.inf new file mode 100644 index 00000000000..d9556636b2e --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_3_6/RedfishProcessor_V1_3_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_3_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_3_6_Dxe + FILE_GUID = b1e22e8c-c718-42e6-b85b-53eef391f892 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_3_6EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_3_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_3_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_3_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_3_7/Processor_V1_3_7_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_3_7/Processor_V1_3_7_Dxe.c new file mode 100644 index 00000000000..359d3cdc350 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_3_7/Processor_V1_3_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_3_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_3_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "3", + "7" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_3_7 *ProcessorV1_3_7; + EFI_REDFISH_PROCESSOR_V1_3_7_CS *ProcessorV1_3_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_3_7_To_CS (ResoruceRaw, &ProcessorV1_3_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_3_7 = (EFI_REDFISH_PROCESSOR_V1_3_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_3_7)); + if (ProcessorV1_3_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_3_7; + ProcessorV1_3_7->Processor = ProcessorV1_3_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_3_7_JSON (*((EFI_REDFISH_PROCESSOR_V1_3_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_3_7 *ProcessorV1_3_7; + + ProcessorV1_3_7 = (EFI_REDFISH_PROCESSOR_V1_3_7 *)InterpProp; + DestroyProcessor_V1_3_7_CS (ProcessorV1_3_7->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_3_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_3_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_3_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_3_7/RedfishProcessor_V1_3_7_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_3_7/RedfishProcessor_V1_3_7_Dxe.inf new file mode 100644 index 00000000000..cbd647b0f08 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_3_7/RedfishProcessor_V1_3_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_3_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_3_7_Dxe + FILE_GUID = ff3fd40e-2c34-42dc-8110-c589323de7f7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_3_7EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_3_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_3_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_3_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_3_8/Processor_V1_3_8_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_3_8/Processor_V1_3_8_Dxe.c new file mode 100644 index 00000000000..bd1b1948016 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_3_8/Processor_V1_3_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_3_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_3_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "3", + "8" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_3_8 *ProcessorV1_3_8; + EFI_REDFISH_PROCESSOR_V1_3_8_CS *ProcessorV1_3_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_3_8_To_CS (ResoruceRaw, &ProcessorV1_3_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_3_8 = (EFI_REDFISH_PROCESSOR_V1_3_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_3_8)); + if (ProcessorV1_3_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_3_8; + ProcessorV1_3_8->Processor = ProcessorV1_3_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_3_8_JSON (*((EFI_REDFISH_PROCESSOR_V1_3_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_3_8 *ProcessorV1_3_8; + + ProcessorV1_3_8 = (EFI_REDFISH_PROCESSOR_V1_3_8 *)InterpProp; + DestroyProcessor_V1_3_8_CS (ProcessorV1_3_8->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_3_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_3_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_3_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_3_8/RedfishProcessor_V1_3_8_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_3_8/RedfishProcessor_V1_3_8_Dxe.inf new file mode 100644 index 00000000000..bce9f03f96e --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_3_8/RedfishProcessor_V1_3_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_3_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_3_8_Dxe + FILE_GUID = f42be8f2-d610-422d-8982-df1fc5d49097 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_3_8EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_3_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_3_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_3_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_4_0/Processor_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_4_0/Processor_V1_4_0_Dxe.c new file mode 100644 index 00000000000..412fb1f13b7 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_4_0/Processor_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "4", + "0" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_4_0 *ProcessorV1_4_0; + EFI_REDFISH_PROCESSOR_V1_4_0_CS *ProcessorV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_4_0_To_CS (ResoruceRaw, &ProcessorV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_4_0 = (EFI_REDFISH_PROCESSOR_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_4_0)); + if (ProcessorV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_4_0; + ProcessorV1_4_0->Processor = ProcessorV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_4_0_JSON (*((EFI_REDFISH_PROCESSOR_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_4_0 *ProcessorV1_4_0; + + ProcessorV1_4_0 = (EFI_REDFISH_PROCESSOR_V1_4_0 *)InterpProp; + DestroyProcessor_V1_4_0_CS (ProcessorV1_4_0->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_4_0/RedfishProcessor_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_4_0/RedfishProcessor_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..088391069c5 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_4_0/RedfishProcessor_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_4_0_Dxe + FILE_GUID = 20b2f7d8-9e45-4039-a30a-1afd655d2f64 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_4_1/Processor_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_4_1/Processor_V1_4_1_Dxe.c new file mode 100644 index 00000000000..6c283359b64 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_4_1/Processor_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "4", + "1" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_4_1 *ProcessorV1_4_1; + EFI_REDFISH_PROCESSOR_V1_4_1_CS *ProcessorV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_4_1_To_CS (ResoruceRaw, &ProcessorV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_4_1 = (EFI_REDFISH_PROCESSOR_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_4_1)); + if (ProcessorV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_4_1; + ProcessorV1_4_1->Processor = ProcessorV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_4_1_JSON (*((EFI_REDFISH_PROCESSOR_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_4_1 *ProcessorV1_4_1; + + ProcessorV1_4_1 = (EFI_REDFISH_PROCESSOR_V1_4_1 *)InterpProp; + DestroyProcessor_V1_4_1_CS (ProcessorV1_4_1->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_4_1/RedfishProcessor_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_4_1/RedfishProcessor_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..1b279936a31 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_4_1/RedfishProcessor_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_4_1_Dxe + FILE_GUID = 5a513f62-0f2d-4692-b4a2-26de1195667c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_4_2/Processor_V1_4_2_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_4_2/Processor_V1_4_2_Dxe.c new file mode 100644 index 00000000000..26572d16d4d --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_4_2/Processor_V1_4_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_4_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "4", + "2" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_4_2 *ProcessorV1_4_2; + EFI_REDFISH_PROCESSOR_V1_4_2_CS *ProcessorV1_4_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_4_2_To_CS (ResoruceRaw, &ProcessorV1_4_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_4_2 = (EFI_REDFISH_PROCESSOR_V1_4_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_4_2)); + if (ProcessorV1_4_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_4_2; + ProcessorV1_4_2->Processor = ProcessorV1_4_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_4_2_JSON (*((EFI_REDFISH_PROCESSOR_V1_4_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_4_2 *ProcessorV1_4_2; + + ProcessorV1_4_2 = (EFI_REDFISH_PROCESSOR_V1_4_2 *)InterpProp; + DestroyProcessor_V1_4_2_CS (ProcessorV1_4_2->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_4_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_4_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_4_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_4_2/RedfishProcessor_V1_4_2_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_4_2/RedfishProcessor_V1_4_2_Dxe.inf new file mode 100644 index 00000000000..4e06a60eac4 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_4_2/RedfishProcessor_V1_4_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_4_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_4_2_Dxe + FILE_GUID = acae06e0-a02b-45b6-b13b-956b11b93a54 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_4_2EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_4_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_4_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_4_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_4_3/Processor_V1_4_3_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_4_3/Processor_V1_4_3_Dxe.c new file mode 100644 index 00000000000..dddbc99ec01 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_4_3/Processor_V1_4_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_4_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "4", + "3" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_4_3 *ProcessorV1_4_3; + EFI_REDFISH_PROCESSOR_V1_4_3_CS *ProcessorV1_4_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_4_3_To_CS (ResoruceRaw, &ProcessorV1_4_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_4_3 = (EFI_REDFISH_PROCESSOR_V1_4_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_4_3)); + if (ProcessorV1_4_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_4_3; + ProcessorV1_4_3->Processor = ProcessorV1_4_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_4_3_JSON (*((EFI_REDFISH_PROCESSOR_V1_4_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_4_3 *ProcessorV1_4_3; + + ProcessorV1_4_3 = (EFI_REDFISH_PROCESSOR_V1_4_3 *)InterpProp; + DestroyProcessor_V1_4_3_CS (ProcessorV1_4_3->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_4_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_4_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_4_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_4_3/RedfishProcessor_V1_4_3_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_4_3/RedfishProcessor_V1_4_3_Dxe.inf new file mode 100644 index 00000000000..b526731e9ef --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_4_3/RedfishProcessor_V1_4_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_4_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_4_3_Dxe + FILE_GUID = 96858e2d-830a-4b9f-8a91-f04b5d6ae5f3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_4_3EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_4_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_4_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_4_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_4_4/Processor_V1_4_4_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_4_4/Processor_V1_4_4_Dxe.c new file mode 100644 index 00000000000..cce6ae36fca --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_4_4/Processor_V1_4_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_4_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "4", + "4" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_4_4 *ProcessorV1_4_4; + EFI_REDFISH_PROCESSOR_V1_4_4_CS *ProcessorV1_4_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_4_4_To_CS (ResoruceRaw, &ProcessorV1_4_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_4_4 = (EFI_REDFISH_PROCESSOR_V1_4_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_4_4)); + if (ProcessorV1_4_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_4_4; + ProcessorV1_4_4->Processor = ProcessorV1_4_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_4_4_JSON (*((EFI_REDFISH_PROCESSOR_V1_4_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_4_4 *ProcessorV1_4_4; + + ProcessorV1_4_4 = (EFI_REDFISH_PROCESSOR_V1_4_4 *)InterpProp; + DestroyProcessor_V1_4_4_CS (ProcessorV1_4_4->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_4_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_4_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_4_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_4_4/RedfishProcessor_V1_4_4_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_4_4/RedfishProcessor_V1_4_4_Dxe.inf new file mode 100644 index 00000000000..5d4fb3a2568 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_4_4/RedfishProcessor_V1_4_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_4_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_4_4_Dxe + FILE_GUID = 7d87b435-484f-4987-8f77-62bd6acfd2e3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_4_4EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_4_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_4_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_4_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_4_5/Processor_V1_4_5_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_4_5/Processor_V1_4_5_Dxe.c new file mode 100644 index 00000000000..5951bf9a776 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_4_5/Processor_V1_4_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_4_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "4", + "5" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_4_5 *ProcessorV1_4_5; + EFI_REDFISH_PROCESSOR_V1_4_5_CS *ProcessorV1_4_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_4_5_To_CS (ResoruceRaw, &ProcessorV1_4_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_4_5 = (EFI_REDFISH_PROCESSOR_V1_4_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_4_5)); + if (ProcessorV1_4_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_4_5; + ProcessorV1_4_5->Processor = ProcessorV1_4_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_4_5_JSON (*((EFI_REDFISH_PROCESSOR_V1_4_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_4_5 *ProcessorV1_4_5; + + ProcessorV1_4_5 = (EFI_REDFISH_PROCESSOR_V1_4_5 *)InterpProp; + DestroyProcessor_V1_4_5_CS (ProcessorV1_4_5->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_4_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_4_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_4_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_4_5/RedfishProcessor_V1_4_5_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_4_5/RedfishProcessor_V1_4_5_Dxe.inf new file mode 100644 index 00000000000..9a69bd79a03 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_4_5/RedfishProcessor_V1_4_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_4_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_4_5_Dxe + FILE_GUID = 4858dd57-f7f3-4fa8-8a05-3a06b9e67ea5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_4_5EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_4_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_4_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_4_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_4_6/Processor_V1_4_6_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_4_6/Processor_V1_4_6_Dxe.c new file mode 100644 index 00000000000..4e6d1281760 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_4_6/Processor_V1_4_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_4_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_4_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "4", + "6" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_4_6 *ProcessorV1_4_6; + EFI_REDFISH_PROCESSOR_V1_4_6_CS *ProcessorV1_4_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_4_6_To_CS (ResoruceRaw, &ProcessorV1_4_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_4_6 = (EFI_REDFISH_PROCESSOR_V1_4_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_4_6)); + if (ProcessorV1_4_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_4_6; + ProcessorV1_4_6->Processor = ProcessorV1_4_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_4_6_JSON (*((EFI_REDFISH_PROCESSOR_V1_4_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_4_6 *ProcessorV1_4_6; + + ProcessorV1_4_6 = (EFI_REDFISH_PROCESSOR_V1_4_6 *)InterpProp; + DestroyProcessor_V1_4_6_CS (ProcessorV1_4_6->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_4_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_4_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_4_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_4_6/RedfishProcessor_V1_4_6_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_4_6/RedfishProcessor_V1_4_6_Dxe.inf new file mode 100644 index 00000000000..6015d665f2e --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_4_6/RedfishProcessor_V1_4_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_4_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_4_6_Dxe + FILE_GUID = f0cdb406-3c9b-490c-93b9-6d3626d3e420 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_4_6EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_4_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_4_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_4_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_4_7/Processor_V1_4_7_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_4_7/Processor_V1_4_7_Dxe.c new file mode 100644 index 00000000000..1bec48018eb --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_4_7/Processor_V1_4_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_4_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_4_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "4", + "7" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_4_7 *ProcessorV1_4_7; + EFI_REDFISH_PROCESSOR_V1_4_7_CS *ProcessorV1_4_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_4_7_To_CS (ResoruceRaw, &ProcessorV1_4_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_4_7 = (EFI_REDFISH_PROCESSOR_V1_4_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_4_7)); + if (ProcessorV1_4_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_4_7; + ProcessorV1_4_7->Processor = ProcessorV1_4_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_4_7_JSON (*((EFI_REDFISH_PROCESSOR_V1_4_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_4_7 *ProcessorV1_4_7; + + ProcessorV1_4_7 = (EFI_REDFISH_PROCESSOR_V1_4_7 *)InterpProp; + DestroyProcessor_V1_4_7_CS (ProcessorV1_4_7->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_4_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_4_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_4_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_4_7/RedfishProcessor_V1_4_7_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_4_7/RedfishProcessor_V1_4_7_Dxe.inf new file mode 100644 index 00000000000..311d410c1fa --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_4_7/RedfishProcessor_V1_4_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_4_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_4_7_Dxe + FILE_GUID = e83aebd4-a66c-4a3f-98a3-cf97cd11a110 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_4_7EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_4_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_4_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_4_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_5_0/Processor_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_5_0/Processor_V1_5_0_Dxe.c new file mode 100644 index 00000000000..2ae066e501a --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_5_0/Processor_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "5", + "0" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_5_0 *ProcessorV1_5_0; + EFI_REDFISH_PROCESSOR_V1_5_0_CS *ProcessorV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_5_0_To_CS (ResoruceRaw, &ProcessorV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_5_0 = (EFI_REDFISH_PROCESSOR_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_5_0)); + if (ProcessorV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_5_0; + ProcessorV1_5_0->Processor = ProcessorV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_5_0_JSON (*((EFI_REDFISH_PROCESSOR_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_5_0 *ProcessorV1_5_0; + + ProcessorV1_5_0 = (EFI_REDFISH_PROCESSOR_V1_5_0 *)InterpProp; + DestroyProcessor_V1_5_0_CS (ProcessorV1_5_0->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_5_0/RedfishProcessor_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_5_0/RedfishProcessor_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..6d4b0ba2e2a --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_5_0/RedfishProcessor_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_5_0_Dxe + FILE_GUID = cf129833-015b-46fc-81cc-286adc667126 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_5_1/Processor_V1_5_1_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_5_1/Processor_V1_5_1_Dxe.c new file mode 100644 index 00000000000..9411a83c202 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_5_1/Processor_V1_5_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_5_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "5", + "1" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_5_1 *ProcessorV1_5_1; + EFI_REDFISH_PROCESSOR_V1_5_1_CS *ProcessorV1_5_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_5_1_To_CS (ResoruceRaw, &ProcessorV1_5_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_5_1 = (EFI_REDFISH_PROCESSOR_V1_5_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_5_1)); + if (ProcessorV1_5_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_5_1; + ProcessorV1_5_1->Processor = ProcessorV1_5_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_5_1_JSON (*((EFI_REDFISH_PROCESSOR_V1_5_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_5_1 *ProcessorV1_5_1; + + ProcessorV1_5_1 = (EFI_REDFISH_PROCESSOR_V1_5_1 *)InterpProp; + DestroyProcessor_V1_5_1_CS (ProcessorV1_5_1->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_5_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_5_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_5_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_5_1/RedfishProcessor_V1_5_1_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_5_1/RedfishProcessor_V1_5_1_Dxe.inf new file mode 100644 index 00000000000..571dda5ee21 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_5_1/RedfishProcessor_V1_5_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_5_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_5_1_Dxe + FILE_GUID = f537b192-963d-458e-8d7f-85150e9aa22a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_5_1EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_5_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_5_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_5_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_5_2/Processor_V1_5_2_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_5_2/Processor_V1_5_2_Dxe.c new file mode 100644 index 00000000000..47cc0640e7c --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_5_2/Processor_V1_5_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_5_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "5", + "2" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_5_2 *ProcessorV1_5_2; + EFI_REDFISH_PROCESSOR_V1_5_2_CS *ProcessorV1_5_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_5_2_To_CS (ResoruceRaw, &ProcessorV1_5_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_5_2 = (EFI_REDFISH_PROCESSOR_V1_5_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_5_2)); + if (ProcessorV1_5_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_5_2; + ProcessorV1_5_2->Processor = ProcessorV1_5_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_5_2_JSON (*((EFI_REDFISH_PROCESSOR_V1_5_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_5_2 *ProcessorV1_5_2; + + ProcessorV1_5_2 = (EFI_REDFISH_PROCESSOR_V1_5_2 *)InterpProp; + DestroyProcessor_V1_5_2_CS (ProcessorV1_5_2->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_5_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_5_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_5_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_5_2/RedfishProcessor_V1_5_2_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_5_2/RedfishProcessor_V1_5_2_Dxe.inf new file mode 100644 index 00000000000..350d9c7a428 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_5_2/RedfishProcessor_V1_5_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_5_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_5_2_Dxe + FILE_GUID = 4e42e2e1-a580-4c18-9b67-b58c8476c704 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_5_2EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_5_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_5_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_5_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_5_3/Processor_V1_5_3_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_5_3/Processor_V1_5_3_Dxe.c new file mode 100644 index 00000000000..b71f32921db --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_5_3/Processor_V1_5_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_5_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "5", + "3" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_5_3 *ProcessorV1_5_3; + EFI_REDFISH_PROCESSOR_V1_5_3_CS *ProcessorV1_5_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_5_3_To_CS (ResoruceRaw, &ProcessorV1_5_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_5_3 = (EFI_REDFISH_PROCESSOR_V1_5_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_5_3)); + if (ProcessorV1_5_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_5_3; + ProcessorV1_5_3->Processor = ProcessorV1_5_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_5_3_JSON (*((EFI_REDFISH_PROCESSOR_V1_5_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_5_3 *ProcessorV1_5_3; + + ProcessorV1_5_3 = (EFI_REDFISH_PROCESSOR_V1_5_3 *)InterpProp; + DestroyProcessor_V1_5_3_CS (ProcessorV1_5_3->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_5_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_5_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_5_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_5_3/RedfishProcessor_V1_5_3_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_5_3/RedfishProcessor_V1_5_3_Dxe.inf new file mode 100644 index 00000000000..29788288688 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_5_3/RedfishProcessor_V1_5_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_5_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_5_3_Dxe + FILE_GUID = f9f64de9-d3fd-4850-845f-e1ec5787340c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_5_3EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_5_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_5_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_5_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_5_4/Processor_V1_5_4_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_5_4/Processor_V1_5_4_Dxe.c new file mode 100644 index 00000000000..7b79b1e3c13 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_5_4/Processor_V1_5_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_5_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "5", + "4" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_5_4 *ProcessorV1_5_4; + EFI_REDFISH_PROCESSOR_V1_5_4_CS *ProcessorV1_5_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_5_4_To_CS (ResoruceRaw, &ProcessorV1_5_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_5_4 = (EFI_REDFISH_PROCESSOR_V1_5_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_5_4)); + if (ProcessorV1_5_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_5_4; + ProcessorV1_5_4->Processor = ProcessorV1_5_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_5_4_JSON (*((EFI_REDFISH_PROCESSOR_V1_5_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_5_4 *ProcessorV1_5_4; + + ProcessorV1_5_4 = (EFI_REDFISH_PROCESSOR_V1_5_4 *)InterpProp; + DestroyProcessor_V1_5_4_CS (ProcessorV1_5_4->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_5_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_5_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_5_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_5_4/RedfishProcessor_V1_5_4_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_5_4/RedfishProcessor_V1_5_4_Dxe.inf new file mode 100644 index 00000000000..e1d0f3df0d7 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_5_4/RedfishProcessor_V1_5_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_5_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_5_4_Dxe + FILE_GUID = 598a0009-d3f6-4f70-b4bf-bc4ba35aa212 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_5_4EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_5_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_5_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_5_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_5_5/Processor_V1_5_5_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_5_5/Processor_V1_5_5_Dxe.c new file mode 100644 index 00000000000..4bb5a1686d8 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_5_5/Processor_V1_5_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_5_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_5_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "5", + "5" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_5_5 *ProcessorV1_5_5; + EFI_REDFISH_PROCESSOR_V1_5_5_CS *ProcessorV1_5_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_5_5_To_CS (ResoruceRaw, &ProcessorV1_5_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_5_5 = (EFI_REDFISH_PROCESSOR_V1_5_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_5_5)); + if (ProcessorV1_5_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_5_5; + ProcessorV1_5_5->Processor = ProcessorV1_5_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_5_5_JSON (*((EFI_REDFISH_PROCESSOR_V1_5_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_5_5 *ProcessorV1_5_5; + + ProcessorV1_5_5 = (EFI_REDFISH_PROCESSOR_V1_5_5 *)InterpProp; + DestroyProcessor_V1_5_5_CS (ProcessorV1_5_5->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_5_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_5_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_5_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_5_5/RedfishProcessor_V1_5_5_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_5_5/RedfishProcessor_V1_5_5_Dxe.inf new file mode 100644 index 00000000000..c205eb7aa0b --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_5_5/RedfishProcessor_V1_5_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_5_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_5_5_Dxe + FILE_GUID = 59a912c4-c195-4bee-936b-b6119fba18b1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_5_5EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_5_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_5_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_5_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_5_6/Processor_V1_5_6_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_5_6/Processor_V1_5_6_Dxe.c new file mode 100644 index 00000000000..630de4fda67 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_5_6/Processor_V1_5_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_5_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_5_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "5", + "6" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_5_6 *ProcessorV1_5_6; + EFI_REDFISH_PROCESSOR_V1_5_6_CS *ProcessorV1_5_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_5_6_To_CS (ResoruceRaw, &ProcessorV1_5_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_5_6 = (EFI_REDFISH_PROCESSOR_V1_5_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_5_6)); + if (ProcessorV1_5_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_5_6; + ProcessorV1_5_6->Processor = ProcessorV1_5_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_5_6_JSON (*((EFI_REDFISH_PROCESSOR_V1_5_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_5_6 *ProcessorV1_5_6; + + ProcessorV1_5_6 = (EFI_REDFISH_PROCESSOR_V1_5_6 *)InterpProp; + DestroyProcessor_V1_5_6_CS (ProcessorV1_5_6->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_5_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_5_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_5_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_5_6/RedfishProcessor_V1_5_6_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_5_6/RedfishProcessor_V1_5_6_Dxe.inf new file mode 100644 index 00000000000..965af65bb75 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_5_6/RedfishProcessor_V1_5_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_5_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_5_6_Dxe + FILE_GUID = f6b71f93-9cf8-4534-ada6-b86d57b7ab3c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_5_6EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_5_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_5_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_5_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_6_0/Processor_V1_6_0_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_6_0/Processor_V1_6_0_Dxe.c new file mode 100644 index 00000000000..ac0f04b5545 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_6_0/Processor_V1_6_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_6_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "6", + "0" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_6_0 *ProcessorV1_6_0; + EFI_REDFISH_PROCESSOR_V1_6_0_CS *ProcessorV1_6_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_6_0_To_CS (ResoruceRaw, &ProcessorV1_6_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_6_0 = (EFI_REDFISH_PROCESSOR_V1_6_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_6_0)); + if (ProcessorV1_6_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_6_0; + ProcessorV1_6_0->Processor = ProcessorV1_6_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_6_0_JSON (*((EFI_REDFISH_PROCESSOR_V1_6_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_6_0 *ProcessorV1_6_0; + + ProcessorV1_6_0 = (EFI_REDFISH_PROCESSOR_V1_6_0 *)InterpProp; + DestroyProcessor_V1_6_0_CS (ProcessorV1_6_0->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_6_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_6_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_6_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_6_0/RedfishProcessor_V1_6_0_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_6_0/RedfishProcessor_V1_6_0_Dxe.inf new file mode 100644 index 00000000000..8843bcb0f3b --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_6_0/RedfishProcessor_V1_6_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_6_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_6_0_Dxe + FILE_GUID = 03e79ac2-f1e4-4c4b-b08b-36881b07a8b4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_6_0EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_6_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_6_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_6_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_6_1/Processor_V1_6_1_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_6_1/Processor_V1_6_1_Dxe.c new file mode 100644 index 00000000000..e9edb360435 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_6_1/Processor_V1_6_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_6_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "6", + "1" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_6_1 *ProcessorV1_6_1; + EFI_REDFISH_PROCESSOR_V1_6_1_CS *ProcessorV1_6_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_6_1_To_CS (ResoruceRaw, &ProcessorV1_6_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_6_1 = (EFI_REDFISH_PROCESSOR_V1_6_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_6_1)); + if (ProcessorV1_6_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_6_1; + ProcessorV1_6_1->Processor = ProcessorV1_6_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_6_1_JSON (*((EFI_REDFISH_PROCESSOR_V1_6_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_6_1 *ProcessorV1_6_1; + + ProcessorV1_6_1 = (EFI_REDFISH_PROCESSOR_V1_6_1 *)InterpProp; + DestroyProcessor_V1_6_1_CS (ProcessorV1_6_1->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_6_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_6_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_6_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_6_1/RedfishProcessor_V1_6_1_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_6_1/RedfishProcessor_V1_6_1_Dxe.inf new file mode 100644 index 00000000000..2ac409d6ddf --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_6_1/RedfishProcessor_V1_6_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_6_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_6_1_Dxe + FILE_GUID = 765851a1-0609-4ce9-b8b4-44800536c549 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_6_1EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_6_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_6_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_6_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_6_2/Processor_V1_6_2_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_6_2/Processor_V1_6_2_Dxe.c new file mode 100644 index 00000000000..76313c94b0c --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_6_2/Processor_V1_6_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_6_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "6", + "2" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_6_2 *ProcessorV1_6_2; + EFI_REDFISH_PROCESSOR_V1_6_2_CS *ProcessorV1_6_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_6_2_To_CS (ResoruceRaw, &ProcessorV1_6_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_6_2 = (EFI_REDFISH_PROCESSOR_V1_6_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_6_2)); + if (ProcessorV1_6_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_6_2; + ProcessorV1_6_2->Processor = ProcessorV1_6_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_6_2_JSON (*((EFI_REDFISH_PROCESSOR_V1_6_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_6_2 *ProcessorV1_6_2; + + ProcessorV1_6_2 = (EFI_REDFISH_PROCESSOR_V1_6_2 *)InterpProp; + DestroyProcessor_V1_6_2_CS (ProcessorV1_6_2->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_6_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_6_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_6_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_6_2/RedfishProcessor_V1_6_2_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_6_2/RedfishProcessor_V1_6_2_Dxe.inf new file mode 100644 index 00000000000..cc9bd927f79 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_6_2/RedfishProcessor_V1_6_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_6_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_6_2_Dxe + FILE_GUID = 25f640c4-5b96-4a73-9a3a-6ed119d9c04f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_6_2EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_6_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_6_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_6_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_6_3/Processor_V1_6_3_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_6_3/Processor_V1_6_3_Dxe.c new file mode 100644 index 00000000000..7393bd12366 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_6_3/Processor_V1_6_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_6_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_6_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "6", + "3" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_6_3 *ProcessorV1_6_3; + EFI_REDFISH_PROCESSOR_V1_6_3_CS *ProcessorV1_6_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_6_3_To_CS (ResoruceRaw, &ProcessorV1_6_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_6_3 = (EFI_REDFISH_PROCESSOR_V1_6_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_6_3)); + if (ProcessorV1_6_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_6_3; + ProcessorV1_6_3->Processor = ProcessorV1_6_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_6_3_JSON (*((EFI_REDFISH_PROCESSOR_V1_6_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_6_3 *ProcessorV1_6_3; + + ProcessorV1_6_3 = (EFI_REDFISH_PROCESSOR_V1_6_3 *)InterpProp; + DestroyProcessor_V1_6_3_CS (ProcessorV1_6_3->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_6_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_6_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_6_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_6_3/RedfishProcessor_V1_6_3_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_6_3/RedfishProcessor_V1_6_3_Dxe.inf new file mode 100644 index 00000000000..3e0dbb88110 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_6_3/RedfishProcessor_V1_6_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_6_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_6_3_Dxe + FILE_GUID = ace53746-d104-465e-8870-ad1ab27ff2c8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_6_3EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_6_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_6_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_6_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_6_4/Processor_V1_6_4_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_6_4/Processor_V1_6_4_Dxe.c new file mode 100644 index 00000000000..58c2f3a5148 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_6_4/Processor_V1_6_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_6_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_6_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "6", + "4" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_6_4 *ProcessorV1_6_4; + EFI_REDFISH_PROCESSOR_V1_6_4_CS *ProcessorV1_6_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_6_4_To_CS (ResoruceRaw, &ProcessorV1_6_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_6_4 = (EFI_REDFISH_PROCESSOR_V1_6_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_6_4)); + if (ProcessorV1_6_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_6_4; + ProcessorV1_6_4->Processor = ProcessorV1_6_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_6_4_JSON (*((EFI_REDFISH_PROCESSOR_V1_6_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_6_4 *ProcessorV1_6_4; + + ProcessorV1_6_4 = (EFI_REDFISH_PROCESSOR_V1_6_4 *)InterpProp; + DestroyProcessor_V1_6_4_CS (ProcessorV1_6_4->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_6_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_6_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_6_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_6_4/RedfishProcessor_V1_6_4_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_6_4/RedfishProcessor_V1_6_4_Dxe.inf new file mode 100644 index 00000000000..be5f2dec98a --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_6_4/RedfishProcessor_V1_6_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_6_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_6_4_Dxe + FILE_GUID = 95e57f5f-0dc0-43dd-a1ed-016e33ccd3f9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_6_4EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_6_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_6_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_6_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_7_0/Processor_V1_7_0_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_7_0/Processor_V1_7_0_Dxe.c new file mode 100644 index 00000000000..efd9aad21dc --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_7_0/Processor_V1_7_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_7_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "7", + "0" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_7_0 *ProcessorV1_7_0; + EFI_REDFISH_PROCESSOR_V1_7_0_CS *ProcessorV1_7_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_7_0_To_CS (ResoruceRaw, &ProcessorV1_7_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_7_0 = (EFI_REDFISH_PROCESSOR_V1_7_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_7_0)); + if (ProcessorV1_7_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_7_0; + ProcessorV1_7_0->Processor = ProcessorV1_7_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_7_0_JSON (*((EFI_REDFISH_PROCESSOR_V1_7_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_7_0 *ProcessorV1_7_0; + + ProcessorV1_7_0 = (EFI_REDFISH_PROCESSOR_V1_7_0 *)InterpProp; + DestroyProcessor_V1_7_0_CS (ProcessorV1_7_0->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_7_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_7_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_7_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_7_0/RedfishProcessor_V1_7_0_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_7_0/RedfishProcessor_V1_7_0_Dxe.inf new file mode 100644 index 00000000000..fca3aa3659c --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_7_0/RedfishProcessor_V1_7_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_7_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_7_0_Dxe + FILE_GUID = b4dfab92-9317-4b87-b7d6-f8128b525933 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_7_0EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_7_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_7_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_7_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_7_1/Processor_V1_7_1_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_7_1/Processor_V1_7_1_Dxe.c new file mode 100644 index 00000000000..5aff363cb20 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_7_1/Processor_V1_7_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_7_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_7_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "7", + "1" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_7_1 *ProcessorV1_7_1; + EFI_REDFISH_PROCESSOR_V1_7_1_CS *ProcessorV1_7_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_7_1_To_CS (ResoruceRaw, &ProcessorV1_7_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_7_1 = (EFI_REDFISH_PROCESSOR_V1_7_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_7_1)); + if (ProcessorV1_7_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_7_1; + ProcessorV1_7_1->Processor = ProcessorV1_7_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_7_1_JSON (*((EFI_REDFISH_PROCESSOR_V1_7_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_7_1 *ProcessorV1_7_1; + + ProcessorV1_7_1 = (EFI_REDFISH_PROCESSOR_V1_7_1 *)InterpProp; + DestroyProcessor_V1_7_1_CS (ProcessorV1_7_1->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_7_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_7_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_7_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_7_1/RedfishProcessor_V1_7_1_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_7_1/RedfishProcessor_V1_7_1_Dxe.inf new file mode 100644 index 00000000000..d6f801db753 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_7_1/RedfishProcessor_V1_7_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_7_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_7_1_Dxe + FILE_GUID = 53faa33c-57a4-4d95-9b5a-7da284efa06c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_7_1EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_7_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_7_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_7_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_7_2/Processor_V1_7_2_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_7_2/Processor_V1_7_2_Dxe.c new file mode 100644 index 00000000000..044062fa98a --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_7_2/Processor_V1_7_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_7_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_7_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "7", + "2" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_7_2 *ProcessorV1_7_2; + EFI_REDFISH_PROCESSOR_V1_7_2_CS *ProcessorV1_7_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_7_2_To_CS (ResoruceRaw, &ProcessorV1_7_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_7_2 = (EFI_REDFISH_PROCESSOR_V1_7_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_7_2)); + if (ProcessorV1_7_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_7_2; + ProcessorV1_7_2->Processor = ProcessorV1_7_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_7_2_JSON (*((EFI_REDFISH_PROCESSOR_V1_7_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_7_2 *ProcessorV1_7_2; + + ProcessorV1_7_2 = (EFI_REDFISH_PROCESSOR_V1_7_2 *)InterpProp; + DestroyProcessor_V1_7_2_CS (ProcessorV1_7_2->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_7_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_7_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_7_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_7_2/RedfishProcessor_V1_7_2_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_7_2/RedfishProcessor_V1_7_2_Dxe.inf new file mode 100644 index 00000000000..18c670c6635 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_7_2/RedfishProcessor_V1_7_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_7_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_7_2_Dxe + FILE_GUID = 6a77535b-83cd-47cd-9287-288ce8dba7c9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_7_2EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_7_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_7_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_7_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_7_3/Processor_V1_7_3_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_7_3/Processor_V1_7_3_Dxe.c new file mode 100644 index 00000000000..42f25cf02f0 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_7_3/Processor_V1_7_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_7_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_7_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "7", + "3" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_7_3 *ProcessorV1_7_3; + EFI_REDFISH_PROCESSOR_V1_7_3_CS *ProcessorV1_7_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_7_3_To_CS (ResoruceRaw, &ProcessorV1_7_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_7_3 = (EFI_REDFISH_PROCESSOR_V1_7_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_7_3)); + if (ProcessorV1_7_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_7_3; + ProcessorV1_7_3->Processor = ProcessorV1_7_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_7_3_JSON (*((EFI_REDFISH_PROCESSOR_V1_7_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_7_3 *ProcessorV1_7_3; + + ProcessorV1_7_3 = (EFI_REDFISH_PROCESSOR_V1_7_3 *)InterpProp; + DestroyProcessor_V1_7_3_CS (ProcessorV1_7_3->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_7_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_7_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_7_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_7_3/RedfishProcessor_V1_7_3_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_7_3/RedfishProcessor_V1_7_3_Dxe.inf new file mode 100644 index 00000000000..60ca21271ef --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_7_3/RedfishProcessor_V1_7_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_7_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_7_3_Dxe + FILE_GUID = c6cb0273-62da-4a01-a5f3-d8acef547c3a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_7_3EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_7_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_7_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_7_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_8_0/Processor_V1_8_0_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_8_0/Processor_V1_8_0_Dxe.c new file mode 100644 index 00000000000..9974508fd1f --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_8_0/Processor_V1_8_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_8_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_8_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "8", + "0" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_8_0 *ProcessorV1_8_0; + EFI_REDFISH_PROCESSOR_V1_8_0_CS *ProcessorV1_8_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_8_0_To_CS (ResoruceRaw, &ProcessorV1_8_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_8_0 = (EFI_REDFISH_PROCESSOR_V1_8_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_8_0)); + if (ProcessorV1_8_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_8_0; + ProcessorV1_8_0->Processor = ProcessorV1_8_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_8_0_JSON (*((EFI_REDFISH_PROCESSOR_V1_8_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_8_0 *ProcessorV1_8_0; + + ProcessorV1_8_0 = (EFI_REDFISH_PROCESSOR_V1_8_0 *)InterpProp; + DestroyProcessor_V1_8_0_CS (ProcessorV1_8_0->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_8_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_8_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_8_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_8_0/RedfishProcessor_V1_8_0_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_8_0/RedfishProcessor_V1_8_0_Dxe.inf new file mode 100644 index 00000000000..f94271e6224 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_8_0/RedfishProcessor_V1_8_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_8_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_8_0_Dxe + FILE_GUID = 5ef70ddd-e0b2-4dfd-81ca-9ee31697a405 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_8_0EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_8_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_8_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_8_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_8_1/Processor_V1_8_1_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_8_1/Processor_V1_8_1_Dxe.c new file mode 100644 index 00000000000..7f6409d961d --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_8_1/Processor_V1_8_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_8_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_8_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "8", + "1" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_8_1 *ProcessorV1_8_1; + EFI_REDFISH_PROCESSOR_V1_8_1_CS *ProcessorV1_8_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_8_1_To_CS (ResoruceRaw, &ProcessorV1_8_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_8_1 = (EFI_REDFISH_PROCESSOR_V1_8_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_8_1)); + if (ProcessorV1_8_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_8_1; + ProcessorV1_8_1->Processor = ProcessorV1_8_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_8_1_JSON (*((EFI_REDFISH_PROCESSOR_V1_8_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_8_1 *ProcessorV1_8_1; + + ProcessorV1_8_1 = (EFI_REDFISH_PROCESSOR_V1_8_1 *)InterpProp; + DestroyProcessor_V1_8_1_CS (ProcessorV1_8_1->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_8_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_8_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_8_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_8_1/RedfishProcessor_V1_8_1_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_8_1/RedfishProcessor_V1_8_1_Dxe.inf new file mode 100644 index 00000000000..edde68d8561 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_8_1/RedfishProcessor_V1_8_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_8_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_8_1_Dxe + FILE_GUID = d351964e-f887-4ef3-b114-e7cf2b4c9dea + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_8_1EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_8_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_8_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_8_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_8_2/Processor_V1_8_2_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_8_2/Processor_V1_8_2_Dxe.c new file mode 100644 index 00000000000..b685bc64ac4 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_8_2/Processor_V1_8_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_8_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_8_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "8", + "2" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_8_2 *ProcessorV1_8_2; + EFI_REDFISH_PROCESSOR_V1_8_2_CS *ProcessorV1_8_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_8_2_To_CS (ResoruceRaw, &ProcessorV1_8_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_8_2 = (EFI_REDFISH_PROCESSOR_V1_8_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_8_2)); + if (ProcessorV1_8_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_8_2; + ProcessorV1_8_2->Processor = ProcessorV1_8_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_8_2_JSON (*((EFI_REDFISH_PROCESSOR_V1_8_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_8_2 *ProcessorV1_8_2; + + ProcessorV1_8_2 = (EFI_REDFISH_PROCESSOR_V1_8_2 *)InterpProp; + DestroyProcessor_V1_8_2_CS (ProcessorV1_8_2->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_8_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_8_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_8_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_8_2/RedfishProcessor_V1_8_2_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_8_2/RedfishProcessor_V1_8_2_Dxe.inf new file mode 100644 index 00000000000..e3d3ea56500 --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_8_2/RedfishProcessor_V1_8_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_8_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_8_2_Dxe + FILE_GUID = 9f9404f1-0492-490f-9551-4909393d568a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_8_2EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_8_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_8_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_8_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_9_0/Processor_V1_9_0_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_9_0/Processor_V1_9_0_Dxe.c new file mode 100644 index 00000000000..bb7e2f7463f --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_9_0/Processor_V1_9_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_9_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_9_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "9", + "0" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_9_0 *ProcessorV1_9_0; + EFI_REDFISH_PROCESSOR_V1_9_0_CS *ProcessorV1_9_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_9_0_To_CS (ResoruceRaw, &ProcessorV1_9_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_9_0 = (EFI_REDFISH_PROCESSOR_V1_9_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_9_0)); + if (ProcessorV1_9_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_9_0; + ProcessorV1_9_0->Processor = ProcessorV1_9_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_9_0_JSON (*((EFI_REDFISH_PROCESSOR_V1_9_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_9_0 *ProcessorV1_9_0; + + ProcessorV1_9_0 = (EFI_REDFISH_PROCESSOR_V1_9_0 *)InterpProp; + DestroyProcessor_V1_9_0_CS (ProcessorV1_9_0->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_9_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_9_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_9_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_9_0/RedfishProcessor_V1_9_0_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_9_0/RedfishProcessor_V1_9_0_Dxe.inf new file mode 100644 index 00000000000..b08ba68f64b --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_9_0/RedfishProcessor_V1_9_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_9_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_9_0_Dxe + FILE_GUID = 85be85d7-49b7-406d-8a6d-426e65bae795 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_9_0EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_9_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_9_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_9_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Processor/v1_9_1/Processor_V1_9_1_Dxe.c b/RedfishClientPkg/Converter/Processor/v1_9_1/Processor_V1_9_1_Dxe.c new file mode 100644 index 00000000000..503221fa1ca --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_9_1/Processor_V1_9_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Processor.v1_9_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Processor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Processor V1_9_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Processor", + "1", + "9", + "1" + }, + "Processor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_9_1 *ProcessorV1_9_1; + EFI_REDFISH_PROCESSOR_V1_9_1_CS *ProcessorV1_9_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Processor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Processor_V1_9_1_To_CS (ResoruceRaw, &ProcessorV1_9_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorV1_9_1 = (EFI_REDFISH_PROCESSOR_V1_9_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSOR_V1_9_1)); + if (ProcessorV1_9_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorV1_9_1; + ProcessorV1_9_1->Processor = ProcessorV1_9_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Processor"), "Processor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Processor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Processor"), "Processor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Processor_V1_9_1_JSON (*((EFI_REDFISH_PROCESSOR_V1_9_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSOR_V1_9_1 *ProcessorV1_9_1; + + ProcessorV1_9_1 = (EFI_REDFISH_PROCESSOR_V1_9_1 *)InterpProp; + DestroyProcessor_V1_9_1_CS (ProcessorV1_9_1->Processor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessor_V1_9_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_9_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorToStructWrapper, + ProcessorToJson, + ProcessorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessor_V1_9_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Processor/v1_9_1/RedfishProcessor_V1_9_1_Dxe.inf b/RedfishClientPkg/Converter/Processor/v1_9_1/RedfishProcessor_V1_9_1_Dxe.inf new file mode 100644 index 00000000000..23472171ace --- /dev/null +++ b/RedfishClientPkg/Converter/Processor/v1_9_1/RedfishProcessor_V1_9_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Processor.v1_9_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessor_V1_9_1_Dxe + FILE_GUID = 891605f1-ba6d-4fd1-9a70-fc42c1dda409 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessor_V1_9_1EntryPoint + UNLOAD_IMAGE = RedfishProcessor_V1_9_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Processor_V1_9_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorV1_9_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ProcessorCollection/ProcessorCollection_Dxe.c b/RedfishClientPkg/Converter/ProcessorCollection/ProcessorCollection_Dxe.c new file mode 100644 index 00000000000..a962d1a8d30 --- /dev/null +++ b/RedfishClientPkg/Converter/ProcessorCollection/ProcessorCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ProcessorCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ProcessorCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support ProcessorCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ProcessorCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "ProcessorCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSORCOLLECTION *ProcessorCollection; + EFI_REDFISH_PROCESSORCOLLECTION_CS *ProcessorCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ProcessorCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ProcessorCollection_To_CS (ResoruceRaw, &ProcessorCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorCollection = (EFI_REDFISH_PROCESSORCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSORCOLLECTION)); + if (ProcessorCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorCollection; + ProcessorCollection->ProcessorCollection = ProcessorCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ProcessorCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ProcessorCollection"), "ProcessorCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ProcessorCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ProcessorCollection"), "ProcessorCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ProcessorCollection_JSON (*((EFI_REDFISH_PROCESSORCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSORCOLLECTION *ProcessorCollection; + + ProcessorCollection = (EFI_REDFISH_PROCESSORCOLLECTION *)InterpProp; + DestroyProcessorCollection_CS (ProcessorCollection->ProcessorCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessorCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessorCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorCollectionToStructWrapper, + ProcessorCollectionToJson, + ProcessorCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessorCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ProcessorCollection/RedfishProcessorCollection_Dxe.inf b/RedfishClientPkg/Converter/ProcessorCollection/RedfishProcessorCollection_Dxe.inf new file mode 100644 index 00000000000..6dc4a7e036f --- /dev/null +++ b/RedfishClientPkg/Converter/ProcessorCollection/RedfishProcessorCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ProcessorCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessorCollection_Dxe + FILE_GUID = ebad9ca2-352e-4daa-acbd-0090ad1b9784 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessorCollectionEntryPoint + UNLOAD_IMAGE = RedfishProcessorCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ProcessorCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_0/ProcessorMetrics_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_0/ProcessorMetrics_V1_0_0_Dxe.c new file mode 100644 index 00000000000..413346c409e --- /dev/null +++ b/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_0/ProcessorMetrics_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ProcessorMetrics.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ProcessorMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support ProcessorMetrics V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ProcessorMetrics", + "1", + "0", + "0" + }, + "ProcessorMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSORMETRICS_V1_0_0 *ProcessorMetricsV1_0_0; + EFI_REDFISH_PROCESSORMETRICS_V1_0_0_CS *ProcessorMetricsV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ProcessorMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ProcessorMetrics_V1_0_0_To_CS (ResoruceRaw, &ProcessorMetricsV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorMetricsV1_0_0 = (EFI_REDFISH_PROCESSORMETRICS_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSORMETRICS_V1_0_0)); + if (ProcessorMetricsV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorMetricsV1_0_0; + ProcessorMetricsV1_0_0->ProcessorMetrics = ProcessorMetricsV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ProcessorMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ProcessorMetrics"), "ProcessorMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ProcessorMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ProcessorMetrics"), "ProcessorMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ProcessorMetrics_V1_0_0_JSON (*((EFI_REDFISH_PROCESSORMETRICS_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSORMETRICS_V1_0_0 *ProcessorMetricsV1_0_0; + + ProcessorMetricsV1_0_0 = (EFI_REDFISH_PROCESSORMETRICS_V1_0_0 *)InterpProp; + DestroyProcessorMetrics_V1_0_0_CS (ProcessorMetricsV1_0_0->ProcessorMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessorMetrics_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessorMetrics_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorMetricsToStructWrapper, + ProcessorMetricsToJson, + ProcessorMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessorMetrics_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_0/RedfishProcessorMetrics_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_0/RedfishProcessorMetrics_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..b1dec38b58c --- /dev/null +++ b/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_0/RedfishProcessorMetrics_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ProcessorMetrics.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessorMetrics_V1_0_0_Dxe + FILE_GUID = c71ada1a-38ec-44af-8d0c-067fa4ddd0fb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessorMetrics_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishProcessorMetrics_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ProcessorMetrics_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorMetricsV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_1/ProcessorMetrics_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_1/ProcessorMetrics_V1_0_1_Dxe.c new file mode 100644 index 00000000000..e3b50a1555f --- /dev/null +++ b/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_1/ProcessorMetrics_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ProcessorMetrics.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ProcessorMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support ProcessorMetrics V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ProcessorMetrics", + "1", + "0", + "1" + }, + "ProcessorMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSORMETRICS_V1_0_1 *ProcessorMetricsV1_0_1; + EFI_REDFISH_PROCESSORMETRICS_V1_0_1_CS *ProcessorMetricsV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ProcessorMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ProcessorMetrics_V1_0_1_To_CS (ResoruceRaw, &ProcessorMetricsV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorMetricsV1_0_1 = (EFI_REDFISH_PROCESSORMETRICS_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSORMETRICS_V1_0_1)); + if (ProcessorMetricsV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorMetricsV1_0_1; + ProcessorMetricsV1_0_1->ProcessorMetrics = ProcessorMetricsV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ProcessorMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ProcessorMetrics"), "ProcessorMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ProcessorMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ProcessorMetrics"), "ProcessorMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ProcessorMetrics_V1_0_1_JSON (*((EFI_REDFISH_PROCESSORMETRICS_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSORMETRICS_V1_0_1 *ProcessorMetricsV1_0_1; + + ProcessorMetricsV1_0_1 = (EFI_REDFISH_PROCESSORMETRICS_V1_0_1 *)InterpProp; + DestroyProcessorMetrics_V1_0_1_CS (ProcessorMetricsV1_0_1->ProcessorMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessorMetrics_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessorMetrics_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorMetricsToStructWrapper, + ProcessorMetricsToJson, + ProcessorMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessorMetrics_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_1/RedfishProcessorMetrics_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_1/RedfishProcessorMetrics_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..6b8ba5a1d49 --- /dev/null +++ b/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_1/RedfishProcessorMetrics_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ProcessorMetrics.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessorMetrics_V1_0_1_Dxe + FILE_GUID = 60d5acbc-1d9f-4ae0-9189-36014be55d15 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessorMetrics_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishProcessorMetrics_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ProcessorMetrics_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorMetricsV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_2/ProcessorMetrics_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_2/ProcessorMetrics_V1_0_2_Dxe.c new file mode 100644 index 00000000000..64b9e3c769f --- /dev/null +++ b/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_2/ProcessorMetrics_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ProcessorMetrics.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ProcessorMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support ProcessorMetrics V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ProcessorMetrics", + "1", + "0", + "2" + }, + "ProcessorMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSORMETRICS_V1_0_2 *ProcessorMetricsV1_0_2; + EFI_REDFISH_PROCESSORMETRICS_V1_0_2_CS *ProcessorMetricsV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ProcessorMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ProcessorMetrics_V1_0_2_To_CS (ResoruceRaw, &ProcessorMetricsV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorMetricsV1_0_2 = (EFI_REDFISH_PROCESSORMETRICS_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSORMETRICS_V1_0_2)); + if (ProcessorMetricsV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorMetricsV1_0_2; + ProcessorMetricsV1_0_2->ProcessorMetrics = ProcessorMetricsV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ProcessorMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ProcessorMetrics"), "ProcessorMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ProcessorMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ProcessorMetrics"), "ProcessorMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ProcessorMetrics_V1_0_2_JSON (*((EFI_REDFISH_PROCESSORMETRICS_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSORMETRICS_V1_0_2 *ProcessorMetricsV1_0_2; + + ProcessorMetricsV1_0_2 = (EFI_REDFISH_PROCESSORMETRICS_V1_0_2 *)InterpProp; + DestroyProcessorMetrics_V1_0_2_CS (ProcessorMetricsV1_0_2->ProcessorMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessorMetrics_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessorMetrics_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorMetricsToStructWrapper, + ProcessorMetricsToJson, + ProcessorMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessorMetrics_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_2/RedfishProcessorMetrics_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_2/RedfishProcessorMetrics_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..e2013e34a2e --- /dev/null +++ b/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_2/RedfishProcessorMetrics_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ProcessorMetrics.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessorMetrics_V1_0_2_Dxe + FILE_GUID = ff368b95-b13e-4c46-8824-6a5364e83640 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessorMetrics_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishProcessorMetrics_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ProcessorMetrics_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorMetricsV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_3/ProcessorMetrics_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_3/ProcessorMetrics_V1_0_3_Dxe.c new file mode 100644 index 00000000000..e6f9dfc84ed --- /dev/null +++ b/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_3/ProcessorMetrics_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ProcessorMetrics.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ProcessorMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support ProcessorMetrics V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ProcessorMetrics", + "1", + "0", + "3" + }, + "ProcessorMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSORMETRICS_V1_0_3 *ProcessorMetricsV1_0_3; + EFI_REDFISH_PROCESSORMETRICS_V1_0_3_CS *ProcessorMetricsV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ProcessorMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ProcessorMetrics_V1_0_3_To_CS (ResoruceRaw, &ProcessorMetricsV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorMetricsV1_0_3 = (EFI_REDFISH_PROCESSORMETRICS_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSORMETRICS_V1_0_3)); + if (ProcessorMetricsV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorMetricsV1_0_3; + ProcessorMetricsV1_0_3->ProcessorMetrics = ProcessorMetricsV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ProcessorMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ProcessorMetrics"), "ProcessorMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ProcessorMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ProcessorMetrics"), "ProcessorMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ProcessorMetrics_V1_0_3_JSON (*((EFI_REDFISH_PROCESSORMETRICS_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSORMETRICS_V1_0_3 *ProcessorMetricsV1_0_3; + + ProcessorMetricsV1_0_3 = (EFI_REDFISH_PROCESSORMETRICS_V1_0_3 *)InterpProp; + DestroyProcessorMetrics_V1_0_3_CS (ProcessorMetricsV1_0_3->ProcessorMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessorMetrics_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessorMetrics_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorMetricsToStructWrapper, + ProcessorMetricsToJson, + ProcessorMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessorMetrics_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_3/RedfishProcessorMetrics_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_3/RedfishProcessorMetrics_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..50fe475ed47 --- /dev/null +++ b/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_3/RedfishProcessorMetrics_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ProcessorMetrics.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessorMetrics_V1_0_3_Dxe + FILE_GUID = 5df24e6f-aee4-4cfe-a6ef-1ca6b8db654f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessorMetrics_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishProcessorMetrics_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ProcessorMetrics_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorMetricsV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_4/ProcessorMetrics_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_4/ProcessorMetrics_V1_0_4_Dxe.c new file mode 100644 index 00000000000..b869cf6d6da --- /dev/null +++ b/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_4/ProcessorMetrics_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ProcessorMetrics.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ProcessorMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support ProcessorMetrics V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ProcessorMetrics", + "1", + "0", + "4" + }, + "ProcessorMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSORMETRICS_V1_0_4 *ProcessorMetricsV1_0_4; + EFI_REDFISH_PROCESSORMETRICS_V1_0_4_CS *ProcessorMetricsV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ProcessorMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ProcessorMetrics_V1_0_4_To_CS (ResoruceRaw, &ProcessorMetricsV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorMetricsV1_0_4 = (EFI_REDFISH_PROCESSORMETRICS_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSORMETRICS_V1_0_4)); + if (ProcessorMetricsV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorMetricsV1_0_4; + ProcessorMetricsV1_0_4->ProcessorMetrics = ProcessorMetricsV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ProcessorMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ProcessorMetrics"), "ProcessorMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ProcessorMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ProcessorMetrics"), "ProcessorMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ProcessorMetrics_V1_0_4_JSON (*((EFI_REDFISH_PROCESSORMETRICS_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSORMETRICS_V1_0_4 *ProcessorMetricsV1_0_4; + + ProcessorMetricsV1_0_4 = (EFI_REDFISH_PROCESSORMETRICS_V1_0_4 *)InterpProp; + DestroyProcessorMetrics_V1_0_4_CS (ProcessorMetricsV1_0_4->ProcessorMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessorMetrics_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessorMetrics_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorMetricsToStructWrapper, + ProcessorMetricsToJson, + ProcessorMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessorMetrics_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_4/RedfishProcessorMetrics_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_4/RedfishProcessorMetrics_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..e2a70a29da8 --- /dev/null +++ b/RedfishClientPkg/Converter/ProcessorMetrics/v1_0_4/RedfishProcessorMetrics_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ProcessorMetrics.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessorMetrics_V1_0_4_Dxe + FILE_GUID = c054e0cf-1584-4d49-ab84-d3192a4c3561 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessorMetrics_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishProcessorMetrics_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ProcessorMetrics_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorMetricsV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ProcessorMetrics/v1_1_0/ProcessorMetrics_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/ProcessorMetrics/v1_1_0/ProcessorMetrics_V1_1_0_Dxe.c new file mode 100644 index 00000000000..020472c32a1 --- /dev/null +++ b/RedfishClientPkg/Converter/ProcessorMetrics/v1_1_0/ProcessorMetrics_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ProcessorMetrics.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ProcessorMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support ProcessorMetrics V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ProcessorMetrics", + "1", + "1", + "0" + }, + "ProcessorMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSORMETRICS_V1_1_0 *ProcessorMetricsV1_1_0; + EFI_REDFISH_PROCESSORMETRICS_V1_1_0_CS *ProcessorMetricsV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ProcessorMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ProcessorMetrics_V1_1_0_To_CS (ResoruceRaw, &ProcessorMetricsV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorMetricsV1_1_0 = (EFI_REDFISH_PROCESSORMETRICS_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSORMETRICS_V1_1_0)); + if (ProcessorMetricsV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorMetricsV1_1_0; + ProcessorMetricsV1_1_0->ProcessorMetrics = ProcessorMetricsV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ProcessorMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ProcessorMetrics"), "ProcessorMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ProcessorMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ProcessorMetrics"), "ProcessorMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ProcessorMetrics_V1_1_0_JSON (*((EFI_REDFISH_PROCESSORMETRICS_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSORMETRICS_V1_1_0 *ProcessorMetricsV1_1_0; + + ProcessorMetricsV1_1_0 = (EFI_REDFISH_PROCESSORMETRICS_V1_1_0 *)InterpProp; + DestroyProcessorMetrics_V1_1_0_CS (ProcessorMetricsV1_1_0->ProcessorMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessorMetrics_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessorMetrics_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorMetricsToStructWrapper, + ProcessorMetricsToJson, + ProcessorMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessorMetrics_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ProcessorMetrics/v1_1_0/RedfishProcessorMetrics_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/ProcessorMetrics/v1_1_0/RedfishProcessorMetrics_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..2f637427e93 --- /dev/null +++ b/RedfishClientPkg/Converter/ProcessorMetrics/v1_1_0/RedfishProcessorMetrics_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ProcessorMetrics.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessorMetrics_V1_1_0_Dxe + FILE_GUID = 7d465c00-2b7a-43a4-8311-cd69fcf02d2a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessorMetrics_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishProcessorMetrics_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ProcessorMetrics_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorMetricsV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ProcessorMetrics/v1_1_1/ProcessorMetrics_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/ProcessorMetrics/v1_1_1/ProcessorMetrics_V1_1_1_Dxe.c new file mode 100644 index 00000000000..2582be2772f --- /dev/null +++ b/RedfishClientPkg/Converter/ProcessorMetrics/v1_1_1/ProcessorMetrics_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ProcessorMetrics.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ProcessorMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support ProcessorMetrics V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ProcessorMetrics", + "1", + "1", + "1" + }, + "ProcessorMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSORMETRICS_V1_1_1 *ProcessorMetricsV1_1_1; + EFI_REDFISH_PROCESSORMETRICS_V1_1_1_CS *ProcessorMetricsV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ProcessorMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ProcessorMetrics_V1_1_1_To_CS (ResoruceRaw, &ProcessorMetricsV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorMetricsV1_1_1 = (EFI_REDFISH_PROCESSORMETRICS_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSORMETRICS_V1_1_1)); + if (ProcessorMetricsV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorMetricsV1_1_1; + ProcessorMetricsV1_1_1->ProcessorMetrics = ProcessorMetricsV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ProcessorMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ProcessorMetrics"), "ProcessorMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ProcessorMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ProcessorMetrics"), "ProcessorMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ProcessorMetrics_V1_1_1_JSON (*((EFI_REDFISH_PROCESSORMETRICS_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSORMETRICS_V1_1_1 *ProcessorMetricsV1_1_1; + + ProcessorMetricsV1_1_1 = (EFI_REDFISH_PROCESSORMETRICS_V1_1_1 *)InterpProp; + DestroyProcessorMetrics_V1_1_1_CS (ProcessorMetricsV1_1_1->ProcessorMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessorMetrics_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessorMetrics_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorMetricsToStructWrapper, + ProcessorMetricsToJson, + ProcessorMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessorMetrics_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ProcessorMetrics/v1_1_1/RedfishProcessorMetrics_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/ProcessorMetrics/v1_1_1/RedfishProcessorMetrics_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..178b319de97 --- /dev/null +++ b/RedfishClientPkg/Converter/ProcessorMetrics/v1_1_1/RedfishProcessorMetrics_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ProcessorMetrics.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessorMetrics_V1_1_1_Dxe + FILE_GUID = af35c162-b6d9-43df-a1c9-57da38049ff2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessorMetrics_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishProcessorMetrics_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ProcessorMetrics_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorMetricsV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ProcessorMetrics/v1_1_2/ProcessorMetrics_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/ProcessorMetrics/v1_1_2/ProcessorMetrics_V1_1_2_Dxe.c new file mode 100644 index 00000000000..db58ee850b2 --- /dev/null +++ b/RedfishClientPkg/Converter/ProcessorMetrics/v1_1_2/ProcessorMetrics_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ProcessorMetrics.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ProcessorMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support ProcessorMetrics V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ProcessorMetrics", + "1", + "1", + "2" + }, + "ProcessorMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSORMETRICS_V1_1_2 *ProcessorMetricsV1_1_2; + EFI_REDFISH_PROCESSORMETRICS_V1_1_2_CS *ProcessorMetricsV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ProcessorMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ProcessorMetrics_V1_1_2_To_CS (ResoruceRaw, &ProcessorMetricsV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorMetricsV1_1_2 = (EFI_REDFISH_PROCESSORMETRICS_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSORMETRICS_V1_1_2)); + if (ProcessorMetricsV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorMetricsV1_1_2; + ProcessorMetricsV1_1_2->ProcessorMetrics = ProcessorMetricsV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ProcessorMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ProcessorMetrics"), "ProcessorMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ProcessorMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ProcessorMetrics"), "ProcessorMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ProcessorMetrics_V1_1_2_JSON (*((EFI_REDFISH_PROCESSORMETRICS_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSORMETRICS_V1_1_2 *ProcessorMetricsV1_1_2; + + ProcessorMetricsV1_1_2 = (EFI_REDFISH_PROCESSORMETRICS_V1_1_2 *)InterpProp; + DestroyProcessorMetrics_V1_1_2_CS (ProcessorMetricsV1_1_2->ProcessorMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessorMetrics_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessorMetrics_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorMetricsToStructWrapper, + ProcessorMetricsToJson, + ProcessorMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessorMetrics_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ProcessorMetrics/v1_1_2/RedfishProcessorMetrics_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/ProcessorMetrics/v1_1_2/RedfishProcessorMetrics_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..336dffd85df --- /dev/null +++ b/RedfishClientPkg/Converter/ProcessorMetrics/v1_1_2/RedfishProcessorMetrics_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ProcessorMetrics.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessorMetrics_V1_1_2_Dxe + FILE_GUID = c32f598a-5524-46d0-802a-8546bacf4286 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessorMetrics_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishProcessorMetrics_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ProcessorMetrics_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorMetricsV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ProcessorMetrics/v1_2_0/ProcessorMetrics_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/ProcessorMetrics/v1_2_0/ProcessorMetrics_V1_2_0_Dxe.c new file mode 100644 index 00000000000..29072ebb34f --- /dev/null +++ b/RedfishClientPkg/Converter/ProcessorMetrics/v1_2_0/ProcessorMetrics_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ProcessorMetrics.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ProcessorMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support ProcessorMetrics V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ProcessorMetrics", + "1", + "2", + "0" + }, + "ProcessorMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_PROCESSORMETRICS_V1_2_0 *ProcessorMetricsV1_2_0; + EFI_REDFISH_PROCESSORMETRICS_V1_2_0_CS *ProcessorMetricsV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ProcessorMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ProcessorMetrics_V1_2_0_To_CS (ResoruceRaw, &ProcessorMetricsV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ProcessorMetricsV1_2_0 = (EFI_REDFISH_PROCESSORMETRICS_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_PROCESSORMETRICS_V1_2_0)); + if (ProcessorMetricsV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ProcessorMetricsV1_2_0; + ProcessorMetricsV1_2_0->ProcessorMetrics = ProcessorMetricsV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ProcessorMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ProcessorMetrics"), "ProcessorMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ProcessorMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ProcessorMetrics"), "ProcessorMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ProcessorMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ProcessorMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ProcessorMetrics_V1_2_0_JSON (*((EFI_REDFISH_PROCESSORMETRICS_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ProcessorMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_PROCESSORMETRICS_V1_2_0 *ProcessorMetricsV1_2_0; + + ProcessorMetricsV1_2_0 = (EFI_REDFISH_PROCESSORMETRICS_V1_2_0 *)InterpProp; + DestroyProcessorMetrics_V1_2_0_CS (ProcessorMetricsV1_2_0->ProcessorMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ProcessorMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ProcessorMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyProcessorMetrics_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishProcessorMetrics_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ProcessorMetricsToStructWrapper, + ProcessorMetricsToJson, + ProcessorMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishProcessorMetrics_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ProcessorMetrics/v1_2_0/RedfishProcessorMetrics_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/ProcessorMetrics/v1_2_0/RedfishProcessorMetrics_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..a592a0c553d --- /dev/null +++ b/RedfishClientPkg/Converter/ProcessorMetrics/v1_2_0/RedfishProcessorMetrics_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ProcessorMetrics.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishProcessorMetrics_V1_2_0_Dxe + FILE_GUID = 3caed8e5-6c51-46c6-8637-f8724213bd60 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishProcessorMetrics_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishProcessorMetrics_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ProcessorMetrics_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ProcessorMetricsV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_0_0/RedfishResourceBlock_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlock/v1_0_0/RedfishResourceBlock_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..f7e31446f75 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_0_0/RedfishResourceBlock_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlock.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlock_V1_0_0_Dxe + FILE_GUID = d4c2252a-143c-478e-b528-231267092ca0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlock_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishResourceBlock_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlock_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_0_0/ResourceBlock_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/ResourceBlock/v1_0_0/ResourceBlock_V1_0_0_Dxe.c new file mode 100644 index 00000000000..60b75262f67 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_0_0/ResourceBlock_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlock.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlock"; +BOOLEAN IsRevisonController = TRUE; + +// Support ResourceBlock V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlock", + "1", + "0", + "0" + }, + "ResourceBlock" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_0_0 *ResourceBlockV1_0_0; + EFI_REDFISH_RESOURCEBLOCK_V1_0_0_CS *ResourceBlockV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlock") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlock_V1_0_0_To_CS (ResoruceRaw, &ResourceBlockV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockV1_0_0 = (EFI_REDFISH_RESOURCEBLOCK_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCK_V1_0_0)); + if (ResourceBlockV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockV1_0_0; + ResourceBlockV1_0_0->ResourceBlock = ResourceBlockV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlock_V1_0_0_JSON (*((EFI_REDFISH_RESOURCEBLOCK_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_0_0 *ResourceBlockV1_0_0; + + ResourceBlockV1_0_0 = (EFI_REDFISH_RESOURCEBLOCK_V1_0_0 *)InterpProp; + DestroyResourceBlock_V1_0_0_CS (ResourceBlockV1_0_0->ResourceBlock); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlock_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockToStructWrapper, + ResourceBlockToJson, + ResourceBlockDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_0_1/RedfishResourceBlock_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlock/v1_0_1/RedfishResourceBlock_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..309947f9595 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_0_1/RedfishResourceBlock_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlock.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlock_V1_0_1_Dxe + FILE_GUID = c50c8453-cc4b-4acf-a1d0-280573f1fa08 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlock_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishResourceBlock_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlock_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_0_1/ResourceBlock_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/ResourceBlock/v1_0_1/ResourceBlock_V1_0_1_Dxe.c new file mode 100644 index 00000000000..85957271161 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_0_1/ResourceBlock_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlock.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlock"; +BOOLEAN IsRevisonController = TRUE; + +// Support ResourceBlock V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlock", + "1", + "0", + "1" + }, + "ResourceBlock" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_0_1 *ResourceBlockV1_0_1; + EFI_REDFISH_RESOURCEBLOCK_V1_0_1_CS *ResourceBlockV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlock") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlock_V1_0_1_To_CS (ResoruceRaw, &ResourceBlockV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockV1_0_1 = (EFI_REDFISH_RESOURCEBLOCK_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCK_V1_0_1)); + if (ResourceBlockV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockV1_0_1; + ResourceBlockV1_0_1->ResourceBlock = ResourceBlockV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlock_V1_0_1_JSON (*((EFI_REDFISH_RESOURCEBLOCK_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_0_1 *ResourceBlockV1_0_1; + + ResourceBlockV1_0_1 = (EFI_REDFISH_RESOURCEBLOCK_V1_0_1 *)InterpProp; + DestroyResourceBlock_V1_0_1_CS (ResourceBlockV1_0_1->ResourceBlock); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlock_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockToStructWrapper, + ResourceBlockToJson, + ResourceBlockDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_0_2/RedfishResourceBlock_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlock/v1_0_2/RedfishResourceBlock_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..7894fd786ad --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_0_2/RedfishResourceBlock_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlock.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlock_V1_0_2_Dxe + FILE_GUID = 406230f6-af43-424d-912a-3d3789bd9e51 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlock_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishResourceBlock_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlock_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_0_2/ResourceBlock_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/ResourceBlock/v1_0_2/ResourceBlock_V1_0_2_Dxe.c new file mode 100644 index 00000000000..eb08bc695f8 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_0_2/ResourceBlock_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlock.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlock"; +BOOLEAN IsRevisonController = TRUE; + +// Support ResourceBlock V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlock", + "1", + "0", + "2" + }, + "ResourceBlock" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_0_2 *ResourceBlockV1_0_2; + EFI_REDFISH_RESOURCEBLOCK_V1_0_2_CS *ResourceBlockV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlock") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlock_V1_0_2_To_CS (ResoruceRaw, &ResourceBlockV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockV1_0_2 = (EFI_REDFISH_RESOURCEBLOCK_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCK_V1_0_2)); + if (ResourceBlockV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockV1_0_2; + ResourceBlockV1_0_2->ResourceBlock = ResourceBlockV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlock_V1_0_2_JSON (*((EFI_REDFISH_RESOURCEBLOCK_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_0_2 *ResourceBlockV1_0_2; + + ResourceBlockV1_0_2 = (EFI_REDFISH_RESOURCEBLOCK_V1_0_2 *)InterpProp; + DestroyResourceBlock_V1_0_2_CS (ResourceBlockV1_0_2->ResourceBlock); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlock_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockToStructWrapper, + ResourceBlockToJson, + ResourceBlockDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_0_3/RedfishResourceBlock_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlock/v1_0_3/RedfishResourceBlock_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..eea7c5f0868 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_0_3/RedfishResourceBlock_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlock.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlock_V1_0_3_Dxe + FILE_GUID = cc6ae82f-f7a4-40f9-85f4-76bf3aa18879 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlock_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishResourceBlock_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlock_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_0_3/ResourceBlock_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/ResourceBlock/v1_0_3/ResourceBlock_V1_0_3_Dxe.c new file mode 100644 index 00000000000..eaa8edf423e --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_0_3/ResourceBlock_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlock.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlock"; +BOOLEAN IsRevisonController = TRUE; + +// Support ResourceBlock V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlock", + "1", + "0", + "3" + }, + "ResourceBlock" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_0_3 *ResourceBlockV1_0_3; + EFI_REDFISH_RESOURCEBLOCK_V1_0_3_CS *ResourceBlockV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlock") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlock_V1_0_3_To_CS (ResoruceRaw, &ResourceBlockV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockV1_0_3 = (EFI_REDFISH_RESOURCEBLOCK_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCK_V1_0_3)); + if (ResourceBlockV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockV1_0_3; + ResourceBlockV1_0_3->ResourceBlock = ResourceBlockV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlock_V1_0_3_JSON (*((EFI_REDFISH_RESOURCEBLOCK_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_0_3 *ResourceBlockV1_0_3; + + ResourceBlockV1_0_3 = (EFI_REDFISH_RESOURCEBLOCK_V1_0_3 *)InterpProp; + DestroyResourceBlock_V1_0_3_CS (ResourceBlockV1_0_3->ResourceBlock); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlock_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockToStructWrapper, + ResourceBlockToJson, + ResourceBlockDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_0_4/RedfishResourceBlock_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlock/v1_0_4/RedfishResourceBlock_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..2588636b872 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_0_4/RedfishResourceBlock_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlock.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlock_V1_0_4_Dxe + FILE_GUID = 354e225b-1034-48d0-adeb-7a477f9e3707 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlock_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishResourceBlock_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlock_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_0_4/ResourceBlock_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/ResourceBlock/v1_0_4/ResourceBlock_V1_0_4_Dxe.c new file mode 100644 index 00000000000..f5bb2bc55f9 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_0_4/ResourceBlock_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlock.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlock"; +BOOLEAN IsRevisonController = TRUE; + +// Support ResourceBlock V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlock", + "1", + "0", + "4" + }, + "ResourceBlock" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_0_4 *ResourceBlockV1_0_4; + EFI_REDFISH_RESOURCEBLOCK_V1_0_4_CS *ResourceBlockV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlock") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlock_V1_0_4_To_CS (ResoruceRaw, &ResourceBlockV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockV1_0_4 = (EFI_REDFISH_RESOURCEBLOCK_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCK_V1_0_4)); + if (ResourceBlockV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockV1_0_4; + ResourceBlockV1_0_4->ResourceBlock = ResourceBlockV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlock_V1_0_4_JSON (*((EFI_REDFISH_RESOURCEBLOCK_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_0_4 *ResourceBlockV1_0_4; + + ResourceBlockV1_0_4 = (EFI_REDFISH_RESOURCEBLOCK_V1_0_4 *)InterpProp; + DestroyResourceBlock_V1_0_4_CS (ResourceBlockV1_0_4->ResourceBlock); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlock_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockToStructWrapper, + ResourceBlockToJson, + ResourceBlockDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_0_5/RedfishResourceBlock_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlock/v1_0_5/RedfishResourceBlock_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..c14180e430c --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_0_5/RedfishResourceBlock_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlock.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlock_V1_0_5_Dxe + FILE_GUID = 2ad5571a-24d1-4c61-bf06-42197e370108 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlock_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishResourceBlock_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlock_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_0_5/ResourceBlock_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/ResourceBlock/v1_0_5/ResourceBlock_V1_0_5_Dxe.c new file mode 100644 index 00000000000..aaba09ebc92 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_0_5/ResourceBlock_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlock.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlock"; +BOOLEAN IsRevisonController = TRUE; + +// Support ResourceBlock V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlock", + "1", + "0", + "5" + }, + "ResourceBlock" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_0_5 *ResourceBlockV1_0_5; + EFI_REDFISH_RESOURCEBLOCK_V1_0_5_CS *ResourceBlockV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlock") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlock_V1_0_5_To_CS (ResoruceRaw, &ResourceBlockV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockV1_0_5 = (EFI_REDFISH_RESOURCEBLOCK_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCK_V1_0_5)); + if (ResourceBlockV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockV1_0_5; + ResourceBlockV1_0_5->ResourceBlock = ResourceBlockV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlock_V1_0_5_JSON (*((EFI_REDFISH_RESOURCEBLOCK_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_0_5 *ResourceBlockV1_0_5; + + ResourceBlockV1_0_5 = (EFI_REDFISH_RESOURCEBLOCK_V1_0_5 *)InterpProp; + DestroyResourceBlock_V1_0_5_CS (ResourceBlockV1_0_5->ResourceBlock); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlock_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockToStructWrapper, + ResourceBlockToJson, + ResourceBlockDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_0_6/RedfishResourceBlock_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlock/v1_0_6/RedfishResourceBlock_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..662dc7a20a7 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_0_6/RedfishResourceBlock_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlock.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlock_V1_0_6_Dxe + FILE_GUID = 3cb16891-837a-428b-bcb3-5d380e0bf004 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlock_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishResourceBlock_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlock_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_0_6/ResourceBlock_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/ResourceBlock/v1_0_6/ResourceBlock_V1_0_6_Dxe.c new file mode 100644 index 00000000000..02700d7dd03 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_0_6/ResourceBlock_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlock.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlock"; +BOOLEAN IsRevisonController = TRUE; + +// Support ResourceBlock V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlock", + "1", + "0", + "6" + }, + "ResourceBlock" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_0_6 *ResourceBlockV1_0_6; + EFI_REDFISH_RESOURCEBLOCK_V1_0_6_CS *ResourceBlockV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlock") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlock_V1_0_6_To_CS (ResoruceRaw, &ResourceBlockV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockV1_0_6 = (EFI_REDFISH_RESOURCEBLOCK_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCK_V1_0_6)); + if (ResourceBlockV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockV1_0_6; + ResourceBlockV1_0_6->ResourceBlock = ResourceBlockV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlock_V1_0_6_JSON (*((EFI_REDFISH_RESOURCEBLOCK_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_0_6 *ResourceBlockV1_0_6; + + ResourceBlockV1_0_6 = (EFI_REDFISH_RESOURCEBLOCK_V1_0_6 *)InterpProp; + DestroyResourceBlock_V1_0_6_CS (ResourceBlockV1_0_6->ResourceBlock); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlock_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockToStructWrapper, + ResourceBlockToJson, + ResourceBlockDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_1_0/RedfishResourceBlock_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlock/v1_1_0/RedfishResourceBlock_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..76537f1cc8b --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_1_0/RedfishResourceBlock_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlock.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlock_V1_1_0_Dxe + FILE_GUID = 71cb584f-7f7e-4a52-a574-f402c71c2bbd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlock_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishResourceBlock_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlock_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_1_0/ResourceBlock_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/ResourceBlock/v1_1_0/ResourceBlock_V1_1_0_Dxe.c new file mode 100644 index 00000000000..5d8719494f7 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_1_0/ResourceBlock_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlock.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlock"; +BOOLEAN IsRevisonController = TRUE; + +// Support ResourceBlock V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlock", + "1", + "1", + "0" + }, + "ResourceBlock" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_1_0 *ResourceBlockV1_1_0; + EFI_REDFISH_RESOURCEBLOCK_V1_1_0_CS *ResourceBlockV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlock") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlock_V1_1_0_To_CS (ResoruceRaw, &ResourceBlockV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockV1_1_0 = (EFI_REDFISH_RESOURCEBLOCK_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCK_V1_1_0)); + if (ResourceBlockV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockV1_1_0; + ResourceBlockV1_1_0->ResourceBlock = ResourceBlockV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlock_V1_1_0_JSON (*((EFI_REDFISH_RESOURCEBLOCK_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_1_0 *ResourceBlockV1_1_0; + + ResourceBlockV1_1_0 = (EFI_REDFISH_RESOURCEBLOCK_V1_1_0 *)InterpProp; + DestroyResourceBlock_V1_1_0_CS (ResourceBlockV1_1_0->ResourceBlock); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlock_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockToStructWrapper, + ResourceBlockToJson, + ResourceBlockDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_1_1/RedfishResourceBlock_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlock/v1_1_1/RedfishResourceBlock_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..8b17f3b141d --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_1_1/RedfishResourceBlock_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlock.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlock_V1_1_1_Dxe + FILE_GUID = d11b1a78-44df-4af3-8964-70c0518ede1e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlock_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishResourceBlock_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlock_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_1_1/ResourceBlock_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/ResourceBlock/v1_1_1/ResourceBlock_V1_1_1_Dxe.c new file mode 100644 index 00000000000..3bc7d54f059 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_1_1/ResourceBlock_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlock.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlock"; +BOOLEAN IsRevisonController = TRUE; + +// Support ResourceBlock V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlock", + "1", + "1", + "1" + }, + "ResourceBlock" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_1_1 *ResourceBlockV1_1_1; + EFI_REDFISH_RESOURCEBLOCK_V1_1_1_CS *ResourceBlockV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlock") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlock_V1_1_1_To_CS (ResoruceRaw, &ResourceBlockV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockV1_1_1 = (EFI_REDFISH_RESOURCEBLOCK_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCK_V1_1_1)); + if (ResourceBlockV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockV1_1_1; + ResourceBlockV1_1_1->ResourceBlock = ResourceBlockV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlock_V1_1_1_JSON (*((EFI_REDFISH_RESOURCEBLOCK_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_1_1 *ResourceBlockV1_1_1; + + ResourceBlockV1_1_1 = (EFI_REDFISH_RESOURCEBLOCK_V1_1_1 *)InterpProp; + DestroyResourceBlock_V1_1_1_CS (ResourceBlockV1_1_1->ResourceBlock); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlock_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockToStructWrapper, + ResourceBlockToJson, + ResourceBlockDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_1_2/RedfishResourceBlock_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlock/v1_1_2/RedfishResourceBlock_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..aa770cf6664 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_1_2/RedfishResourceBlock_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlock.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlock_V1_1_2_Dxe + FILE_GUID = cd0c72d4-295d-44f9-9a4d-d31bed4d7c57 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlock_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishResourceBlock_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlock_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_1_2/ResourceBlock_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/ResourceBlock/v1_1_2/ResourceBlock_V1_1_2_Dxe.c new file mode 100644 index 00000000000..a3a53918df6 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_1_2/ResourceBlock_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlock.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlock"; +BOOLEAN IsRevisonController = TRUE; + +// Support ResourceBlock V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlock", + "1", + "1", + "2" + }, + "ResourceBlock" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_1_2 *ResourceBlockV1_1_2; + EFI_REDFISH_RESOURCEBLOCK_V1_1_2_CS *ResourceBlockV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlock") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlock_V1_1_2_To_CS (ResoruceRaw, &ResourceBlockV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockV1_1_2 = (EFI_REDFISH_RESOURCEBLOCK_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCK_V1_1_2)); + if (ResourceBlockV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockV1_1_2; + ResourceBlockV1_1_2->ResourceBlock = ResourceBlockV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlock_V1_1_2_JSON (*((EFI_REDFISH_RESOURCEBLOCK_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_1_2 *ResourceBlockV1_1_2; + + ResourceBlockV1_1_2 = (EFI_REDFISH_RESOURCEBLOCK_V1_1_2 *)InterpProp; + DestroyResourceBlock_V1_1_2_CS (ResourceBlockV1_1_2->ResourceBlock); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlock_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockToStructWrapper, + ResourceBlockToJson, + ResourceBlockDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_1_3/RedfishResourceBlock_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlock/v1_1_3/RedfishResourceBlock_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..b191badc092 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_1_3/RedfishResourceBlock_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlock.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlock_V1_1_3_Dxe + FILE_GUID = cf551c93-1f50-4230-b540-e1bf78159f43 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlock_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishResourceBlock_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlock_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_1_3/ResourceBlock_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/ResourceBlock/v1_1_3/ResourceBlock_V1_1_3_Dxe.c new file mode 100644 index 00000000000..5db7e547ca6 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_1_3/ResourceBlock_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlock.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlock"; +BOOLEAN IsRevisonController = TRUE; + +// Support ResourceBlock V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlock", + "1", + "1", + "3" + }, + "ResourceBlock" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_1_3 *ResourceBlockV1_1_3; + EFI_REDFISH_RESOURCEBLOCK_V1_1_3_CS *ResourceBlockV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlock") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlock_V1_1_3_To_CS (ResoruceRaw, &ResourceBlockV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockV1_1_3 = (EFI_REDFISH_RESOURCEBLOCK_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCK_V1_1_3)); + if (ResourceBlockV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockV1_1_3; + ResourceBlockV1_1_3->ResourceBlock = ResourceBlockV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlock_V1_1_3_JSON (*((EFI_REDFISH_RESOURCEBLOCK_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_1_3 *ResourceBlockV1_1_3; + + ResourceBlockV1_1_3 = (EFI_REDFISH_RESOURCEBLOCK_V1_1_3 *)InterpProp; + DestroyResourceBlock_V1_1_3_CS (ResourceBlockV1_1_3->ResourceBlock); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlock_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockToStructWrapper, + ResourceBlockToJson, + ResourceBlockDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_1_4/RedfishResourceBlock_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlock/v1_1_4/RedfishResourceBlock_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..668524d354b --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_1_4/RedfishResourceBlock_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlock.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlock_V1_1_4_Dxe + FILE_GUID = 71503510-7d42-4209-9e0b-337cf9996aca + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlock_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishResourceBlock_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlock_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_1_4/ResourceBlock_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/ResourceBlock/v1_1_4/ResourceBlock_V1_1_4_Dxe.c new file mode 100644 index 00000000000..e1991f2eb9d --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_1_4/ResourceBlock_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlock.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlock"; +BOOLEAN IsRevisonController = TRUE; + +// Support ResourceBlock V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlock", + "1", + "1", + "4" + }, + "ResourceBlock" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_1_4 *ResourceBlockV1_1_4; + EFI_REDFISH_RESOURCEBLOCK_V1_1_4_CS *ResourceBlockV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlock") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlock_V1_1_4_To_CS (ResoruceRaw, &ResourceBlockV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockV1_1_4 = (EFI_REDFISH_RESOURCEBLOCK_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCK_V1_1_4)); + if (ResourceBlockV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockV1_1_4; + ResourceBlockV1_1_4->ResourceBlock = ResourceBlockV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlock_V1_1_4_JSON (*((EFI_REDFISH_RESOURCEBLOCK_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_1_4 *ResourceBlockV1_1_4; + + ResourceBlockV1_1_4 = (EFI_REDFISH_RESOURCEBLOCK_V1_1_4 *)InterpProp; + DestroyResourceBlock_V1_1_4_CS (ResourceBlockV1_1_4->ResourceBlock); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlock_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockToStructWrapper, + ResourceBlockToJson, + ResourceBlockDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_1_5/RedfishResourceBlock_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlock/v1_1_5/RedfishResourceBlock_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..99ab409cacb --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_1_5/RedfishResourceBlock_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlock.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlock_V1_1_5_Dxe + FILE_GUID = 4762ba31-9aee-4d8b-a370-bc80788267b7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlock_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishResourceBlock_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlock_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_1_5/ResourceBlock_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/ResourceBlock/v1_1_5/ResourceBlock_V1_1_5_Dxe.c new file mode 100644 index 00000000000..49f2b0e9cc4 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_1_5/ResourceBlock_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlock.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlock"; +BOOLEAN IsRevisonController = TRUE; + +// Support ResourceBlock V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlock", + "1", + "1", + "5" + }, + "ResourceBlock" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_1_5 *ResourceBlockV1_1_5; + EFI_REDFISH_RESOURCEBLOCK_V1_1_5_CS *ResourceBlockV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlock") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlock_V1_1_5_To_CS (ResoruceRaw, &ResourceBlockV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockV1_1_5 = (EFI_REDFISH_RESOURCEBLOCK_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCK_V1_1_5)); + if (ResourceBlockV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockV1_1_5; + ResourceBlockV1_1_5->ResourceBlock = ResourceBlockV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlock_V1_1_5_JSON (*((EFI_REDFISH_RESOURCEBLOCK_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_1_5 *ResourceBlockV1_1_5; + + ResourceBlockV1_1_5 = (EFI_REDFISH_RESOURCEBLOCK_V1_1_5 *)InterpProp; + DestroyResourceBlock_V1_1_5_CS (ResourceBlockV1_1_5->ResourceBlock); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlock_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockToStructWrapper, + ResourceBlockToJson, + ResourceBlockDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_1_6/RedfishResourceBlock_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlock/v1_1_6/RedfishResourceBlock_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..a186a8df438 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_1_6/RedfishResourceBlock_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlock.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlock_V1_1_6_Dxe + FILE_GUID = 72702282-1332-4720-9eda-17553563300a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlock_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishResourceBlock_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlock_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_1_6/ResourceBlock_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/ResourceBlock/v1_1_6/ResourceBlock_V1_1_6_Dxe.c new file mode 100644 index 00000000000..8766637f2fe --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_1_6/ResourceBlock_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlock.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlock"; +BOOLEAN IsRevisonController = TRUE; + +// Support ResourceBlock V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlock", + "1", + "1", + "6" + }, + "ResourceBlock" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_1_6 *ResourceBlockV1_1_6; + EFI_REDFISH_RESOURCEBLOCK_V1_1_6_CS *ResourceBlockV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlock") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlock_V1_1_6_To_CS (ResoruceRaw, &ResourceBlockV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockV1_1_6 = (EFI_REDFISH_RESOURCEBLOCK_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCK_V1_1_6)); + if (ResourceBlockV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockV1_1_6; + ResourceBlockV1_1_6->ResourceBlock = ResourceBlockV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlock_V1_1_6_JSON (*((EFI_REDFISH_RESOURCEBLOCK_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_1_6 *ResourceBlockV1_1_6; + + ResourceBlockV1_1_6 = (EFI_REDFISH_RESOURCEBLOCK_V1_1_6 *)InterpProp; + DestroyResourceBlock_V1_1_6_CS (ResourceBlockV1_1_6->ResourceBlock); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlock_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockToStructWrapper, + ResourceBlockToJson, + ResourceBlockDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_2_0/RedfishResourceBlock_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlock/v1_2_0/RedfishResourceBlock_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..90daf499351 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_2_0/RedfishResourceBlock_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlock.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlock_V1_2_0_Dxe + FILE_GUID = f89fd02c-81c2-4ff9-824e-94fef7df3359 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlock_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishResourceBlock_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlock_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_2_0/ResourceBlock_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/ResourceBlock/v1_2_0/ResourceBlock_V1_2_0_Dxe.c new file mode 100644 index 00000000000..47bced95583 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_2_0/ResourceBlock_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlock.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlock"; +BOOLEAN IsRevisonController = TRUE; + +// Support ResourceBlock V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlock", + "1", + "2", + "0" + }, + "ResourceBlock" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_2_0 *ResourceBlockV1_2_0; + EFI_REDFISH_RESOURCEBLOCK_V1_2_0_CS *ResourceBlockV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlock") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlock_V1_2_0_To_CS (ResoruceRaw, &ResourceBlockV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockV1_2_0 = (EFI_REDFISH_RESOURCEBLOCK_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCK_V1_2_0)); + if (ResourceBlockV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockV1_2_0; + ResourceBlockV1_2_0->ResourceBlock = ResourceBlockV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlock_V1_2_0_JSON (*((EFI_REDFISH_RESOURCEBLOCK_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_2_0 *ResourceBlockV1_2_0; + + ResourceBlockV1_2_0 = (EFI_REDFISH_RESOURCEBLOCK_V1_2_0 *)InterpProp; + DestroyResourceBlock_V1_2_0_CS (ResourceBlockV1_2_0->ResourceBlock); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlock_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockToStructWrapper, + ResourceBlockToJson, + ResourceBlockDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_2_1/RedfishResourceBlock_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlock/v1_2_1/RedfishResourceBlock_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..0ba3c3d8634 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_2_1/RedfishResourceBlock_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlock.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlock_V1_2_1_Dxe + FILE_GUID = 6596e21d-3836-4721-a340-885695f04e62 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlock_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishResourceBlock_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlock_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_2_1/ResourceBlock_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/ResourceBlock/v1_2_1/ResourceBlock_V1_2_1_Dxe.c new file mode 100644 index 00000000000..f2009e4ff56 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_2_1/ResourceBlock_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlock.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlock"; +BOOLEAN IsRevisonController = TRUE; + +// Support ResourceBlock V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlock", + "1", + "2", + "1" + }, + "ResourceBlock" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_2_1 *ResourceBlockV1_2_1; + EFI_REDFISH_RESOURCEBLOCK_V1_2_1_CS *ResourceBlockV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlock") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlock_V1_2_1_To_CS (ResoruceRaw, &ResourceBlockV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockV1_2_1 = (EFI_REDFISH_RESOURCEBLOCK_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCK_V1_2_1)); + if (ResourceBlockV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockV1_2_1; + ResourceBlockV1_2_1->ResourceBlock = ResourceBlockV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlock_V1_2_1_JSON (*((EFI_REDFISH_RESOURCEBLOCK_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_2_1 *ResourceBlockV1_2_1; + + ResourceBlockV1_2_1 = (EFI_REDFISH_RESOURCEBLOCK_V1_2_1 *)InterpProp; + DestroyResourceBlock_V1_2_1_CS (ResourceBlockV1_2_1->ResourceBlock); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlock_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockToStructWrapper, + ResourceBlockToJson, + ResourceBlockDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_2_2/RedfishResourceBlock_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlock/v1_2_2/RedfishResourceBlock_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..b6d77ce1cdc --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_2_2/RedfishResourceBlock_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlock.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlock_V1_2_2_Dxe + FILE_GUID = cee2f709-b745-4e2b-949e-70a46fd8d6b7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlock_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishResourceBlock_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlock_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_2_2/ResourceBlock_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/ResourceBlock/v1_2_2/ResourceBlock_V1_2_2_Dxe.c new file mode 100644 index 00000000000..de70944b864 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_2_2/ResourceBlock_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlock.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlock"; +BOOLEAN IsRevisonController = TRUE; + +// Support ResourceBlock V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlock", + "1", + "2", + "2" + }, + "ResourceBlock" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_2_2 *ResourceBlockV1_2_2; + EFI_REDFISH_RESOURCEBLOCK_V1_2_2_CS *ResourceBlockV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlock") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlock_V1_2_2_To_CS (ResoruceRaw, &ResourceBlockV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockV1_2_2 = (EFI_REDFISH_RESOURCEBLOCK_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCK_V1_2_2)); + if (ResourceBlockV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockV1_2_2; + ResourceBlockV1_2_2->ResourceBlock = ResourceBlockV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlock_V1_2_2_JSON (*((EFI_REDFISH_RESOURCEBLOCK_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_2_2 *ResourceBlockV1_2_2; + + ResourceBlockV1_2_2 = (EFI_REDFISH_RESOURCEBLOCK_V1_2_2 *)InterpProp; + DestroyResourceBlock_V1_2_2_CS (ResourceBlockV1_2_2->ResourceBlock); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlock_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockToStructWrapper, + ResourceBlockToJson, + ResourceBlockDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_2_3/RedfishResourceBlock_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlock/v1_2_3/RedfishResourceBlock_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..54a02aa78d1 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_2_3/RedfishResourceBlock_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlock.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlock_V1_2_3_Dxe + FILE_GUID = 3f6f3718-f3a7-4449-a707-f5762ac72285 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlock_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishResourceBlock_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlock_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_2_3/ResourceBlock_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/ResourceBlock/v1_2_3/ResourceBlock_V1_2_3_Dxe.c new file mode 100644 index 00000000000..88e0feab72d --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_2_3/ResourceBlock_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlock.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlock"; +BOOLEAN IsRevisonController = TRUE; + +// Support ResourceBlock V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlock", + "1", + "2", + "3" + }, + "ResourceBlock" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_2_3 *ResourceBlockV1_2_3; + EFI_REDFISH_RESOURCEBLOCK_V1_2_3_CS *ResourceBlockV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlock") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlock_V1_2_3_To_CS (ResoruceRaw, &ResourceBlockV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockV1_2_3 = (EFI_REDFISH_RESOURCEBLOCK_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCK_V1_2_3)); + if (ResourceBlockV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockV1_2_3; + ResourceBlockV1_2_3->ResourceBlock = ResourceBlockV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlock_V1_2_3_JSON (*((EFI_REDFISH_RESOURCEBLOCK_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_2_3 *ResourceBlockV1_2_3; + + ResourceBlockV1_2_3 = (EFI_REDFISH_RESOURCEBLOCK_V1_2_3 *)InterpProp; + DestroyResourceBlock_V1_2_3_CS (ResourceBlockV1_2_3->ResourceBlock); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlock_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockToStructWrapper, + ResourceBlockToJson, + ResourceBlockDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_2_4/RedfishResourceBlock_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlock/v1_2_4/RedfishResourceBlock_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..cb51679ce55 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_2_4/RedfishResourceBlock_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlock.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlock_V1_2_4_Dxe + FILE_GUID = 20be392e-1937-4b23-8bb6-9c40155cdd6e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlock_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishResourceBlock_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlock_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_2_4/ResourceBlock_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/ResourceBlock/v1_2_4/ResourceBlock_V1_2_4_Dxe.c new file mode 100644 index 00000000000..49b63c11ed4 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_2_4/ResourceBlock_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlock.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlock"; +BOOLEAN IsRevisonController = TRUE; + +// Support ResourceBlock V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlock", + "1", + "2", + "4" + }, + "ResourceBlock" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_2_4 *ResourceBlockV1_2_4; + EFI_REDFISH_RESOURCEBLOCK_V1_2_4_CS *ResourceBlockV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlock") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlock_V1_2_4_To_CS (ResoruceRaw, &ResourceBlockV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockV1_2_4 = (EFI_REDFISH_RESOURCEBLOCK_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCK_V1_2_4)); + if (ResourceBlockV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockV1_2_4; + ResourceBlockV1_2_4->ResourceBlock = ResourceBlockV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlock_V1_2_4_JSON (*((EFI_REDFISH_RESOURCEBLOCK_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_2_4 *ResourceBlockV1_2_4; + + ResourceBlockV1_2_4 = (EFI_REDFISH_RESOURCEBLOCK_V1_2_4 *)InterpProp; + DestroyResourceBlock_V1_2_4_CS (ResourceBlockV1_2_4->ResourceBlock); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlock_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockToStructWrapper, + ResourceBlockToJson, + ResourceBlockDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_2_5/RedfishResourceBlock_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlock/v1_2_5/RedfishResourceBlock_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..2d01cdf2173 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_2_5/RedfishResourceBlock_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlock.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlock_V1_2_5_Dxe + FILE_GUID = 46bc4a8d-5746-4878-b866-98aba69bd20c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlock_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishResourceBlock_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlock_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_2_5/ResourceBlock_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/ResourceBlock/v1_2_5/ResourceBlock_V1_2_5_Dxe.c new file mode 100644 index 00000000000..c0554253b6e --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_2_5/ResourceBlock_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlock.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlock"; +BOOLEAN IsRevisonController = TRUE; + +// Support ResourceBlock V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlock", + "1", + "2", + "5" + }, + "ResourceBlock" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_2_5 *ResourceBlockV1_2_5; + EFI_REDFISH_RESOURCEBLOCK_V1_2_5_CS *ResourceBlockV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlock") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlock_V1_2_5_To_CS (ResoruceRaw, &ResourceBlockV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockV1_2_5 = (EFI_REDFISH_RESOURCEBLOCK_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCK_V1_2_5)); + if (ResourceBlockV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockV1_2_5; + ResourceBlockV1_2_5->ResourceBlock = ResourceBlockV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlock_V1_2_5_JSON (*((EFI_REDFISH_RESOURCEBLOCK_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_2_5 *ResourceBlockV1_2_5; + + ResourceBlockV1_2_5 = (EFI_REDFISH_RESOURCEBLOCK_V1_2_5 *)InterpProp; + DestroyResourceBlock_V1_2_5_CS (ResourceBlockV1_2_5->ResourceBlock); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlock_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockToStructWrapper, + ResourceBlockToJson, + ResourceBlockDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_3_0/RedfishResourceBlock_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlock/v1_3_0/RedfishResourceBlock_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..2a9ee8346d8 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_3_0/RedfishResourceBlock_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlock.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlock_V1_3_0_Dxe + FILE_GUID = 6e236b28-3932-47d3-8ff8-6d18d563cded + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlock_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishResourceBlock_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlock_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_3_0/ResourceBlock_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/ResourceBlock/v1_3_0/ResourceBlock_V1_3_0_Dxe.c new file mode 100644 index 00000000000..089296f4248 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_3_0/ResourceBlock_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlock.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlock"; +BOOLEAN IsRevisonController = TRUE; + +// Support ResourceBlock V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlock", + "1", + "3", + "0" + }, + "ResourceBlock" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_3_0 *ResourceBlockV1_3_0; + EFI_REDFISH_RESOURCEBLOCK_V1_3_0_CS *ResourceBlockV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlock") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlock_V1_3_0_To_CS (ResoruceRaw, &ResourceBlockV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockV1_3_0 = (EFI_REDFISH_RESOURCEBLOCK_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCK_V1_3_0)); + if (ResourceBlockV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockV1_3_0; + ResourceBlockV1_3_0->ResourceBlock = ResourceBlockV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlock_V1_3_0_JSON (*((EFI_REDFISH_RESOURCEBLOCK_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_3_0 *ResourceBlockV1_3_0; + + ResourceBlockV1_3_0 = (EFI_REDFISH_RESOURCEBLOCK_V1_3_0 *)InterpProp; + DestroyResourceBlock_V1_3_0_CS (ResourceBlockV1_3_0->ResourceBlock); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlock_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockToStructWrapper, + ResourceBlockToJson, + ResourceBlockDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_3_1/RedfishResourceBlock_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlock/v1_3_1/RedfishResourceBlock_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..3419d77a65c --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_3_1/RedfishResourceBlock_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlock.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlock_V1_3_1_Dxe + FILE_GUID = 9820ece6-0d14-43d8-b10f-a1093aa7a2e3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlock_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishResourceBlock_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlock_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_3_1/ResourceBlock_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/ResourceBlock/v1_3_1/ResourceBlock_V1_3_1_Dxe.c new file mode 100644 index 00000000000..23150fc14ff --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_3_1/ResourceBlock_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlock.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlock"; +BOOLEAN IsRevisonController = TRUE; + +// Support ResourceBlock V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlock", + "1", + "3", + "1" + }, + "ResourceBlock" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_3_1 *ResourceBlockV1_3_1; + EFI_REDFISH_RESOURCEBLOCK_V1_3_1_CS *ResourceBlockV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlock") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlock_V1_3_1_To_CS (ResoruceRaw, &ResourceBlockV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockV1_3_1 = (EFI_REDFISH_RESOURCEBLOCK_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCK_V1_3_1)); + if (ResourceBlockV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockV1_3_1; + ResourceBlockV1_3_1->ResourceBlock = ResourceBlockV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlock_V1_3_1_JSON (*((EFI_REDFISH_RESOURCEBLOCK_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_3_1 *ResourceBlockV1_3_1; + + ResourceBlockV1_3_1 = (EFI_REDFISH_RESOURCEBLOCK_V1_3_1 *)InterpProp; + DestroyResourceBlock_V1_3_1_CS (ResourceBlockV1_3_1->ResourceBlock); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlock_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockToStructWrapper, + ResourceBlockToJson, + ResourceBlockDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_3_2/RedfishResourceBlock_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlock/v1_3_2/RedfishResourceBlock_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..b7eafd98a41 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_3_2/RedfishResourceBlock_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlock.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlock_V1_3_2_Dxe + FILE_GUID = 392d786f-bf09-4695-b84f-c07aa324883a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlock_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishResourceBlock_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlock_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_3_2/ResourceBlock_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/ResourceBlock/v1_3_2/ResourceBlock_V1_3_2_Dxe.c new file mode 100644 index 00000000000..3172bd905f1 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_3_2/ResourceBlock_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlock.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlock"; +BOOLEAN IsRevisonController = TRUE; + +// Support ResourceBlock V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlock", + "1", + "3", + "2" + }, + "ResourceBlock" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_3_2 *ResourceBlockV1_3_2; + EFI_REDFISH_RESOURCEBLOCK_V1_3_2_CS *ResourceBlockV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlock") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlock_V1_3_2_To_CS (ResoruceRaw, &ResourceBlockV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockV1_3_2 = (EFI_REDFISH_RESOURCEBLOCK_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCK_V1_3_2)); + if (ResourceBlockV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockV1_3_2; + ResourceBlockV1_3_2->ResourceBlock = ResourceBlockV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlock_V1_3_2_JSON (*((EFI_REDFISH_RESOURCEBLOCK_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_3_2 *ResourceBlockV1_3_2; + + ResourceBlockV1_3_2 = (EFI_REDFISH_RESOURCEBLOCK_V1_3_2 *)InterpProp; + DestroyResourceBlock_V1_3_2_CS (ResourceBlockV1_3_2->ResourceBlock); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlock_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockToStructWrapper, + ResourceBlockToJson, + ResourceBlockDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_3_3/RedfishResourceBlock_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlock/v1_3_3/RedfishResourceBlock_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..4cf7961f685 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_3_3/RedfishResourceBlock_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlock.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlock_V1_3_3_Dxe + FILE_GUID = 001450ab-9f60-43f6-8719-4d0de8903403 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlock_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishResourceBlock_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlock_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_3_3/ResourceBlock_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/ResourceBlock/v1_3_3/ResourceBlock_V1_3_3_Dxe.c new file mode 100644 index 00000000000..f663c15c4f9 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_3_3/ResourceBlock_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlock.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlock"; +BOOLEAN IsRevisonController = TRUE; + +// Support ResourceBlock V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlock", + "1", + "3", + "3" + }, + "ResourceBlock" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_3_3 *ResourceBlockV1_3_3; + EFI_REDFISH_RESOURCEBLOCK_V1_3_3_CS *ResourceBlockV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlock") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlock_V1_3_3_To_CS (ResoruceRaw, &ResourceBlockV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockV1_3_3 = (EFI_REDFISH_RESOURCEBLOCK_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCK_V1_3_3)); + if (ResourceBlockV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockV1_3_3; + ResourceBlockV1_3_3->ResourceBlock = ResourceBlockV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlock_V1_3_3_JSON (*((EFI_REDFISH_RESOURCEBLOCK_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_3_3 *ResourceBlockV1_3_3; + + ResourceBlockV1_3_3 = (EFI_REDFISH_RESOURCEBLOCK_V1_3_3 *)InterpProp; + DestroyResourceBlock_V1_3_3_CS (ResourceBlockV1_3_3->ResourceBlock); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlock_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockToStructWrapper, + ResourceBlockToJson, + ResourceBlockDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_3_4/RedfishResourceBlock_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlock/v1_3_4/RedfishResourceBlock_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..4977562ed1e --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_3_4/RedfishResourceBlock_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlock.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlock_V1_3_4_Dxe + FILE_GUID = 381cbe2b-982c-4656-850e-9a66a28467a5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlock_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishResourceBlock_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlock_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlock/v1_3_4/ResourceBlock_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/ResourceBlock/v1_3_4/ResourceBlock_V1_3_4_Dxe.c new file mode 100644 index 00000000000..80ac30b2ec7 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlock/v1_3_4/ResourceBlock_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlock.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlock"; +BOOLEAN IsRevisonController = TRUE; + +// Support ResourceBlock V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlock", + "1", + "3", + "4" + }, + "ResourceBlock" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_3_4 *ResourceBlockV1_3_4; + EFI_REDFISH_RESOURCEBLOCK_V1_3_4_CS *ResourceBlockV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlock") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlock_V1_3_4_To_CS (ResoruceRaw, &ResourceBlockV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockV1_3_4 = (EFI_REDFISH_RESOURCEBLOCK_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCK_V1_3_4)); + if (ResourceBlockV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockV1_3_4; + ResourceBlockV1_3_4->ResourceBlock = ResourceBlockV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlock")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlock"), "ResourceBlock"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlock_V1_3_4_JSON (*((EFI_REDFISH_RESOURCEBLOCK_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCK_V1_3_4 *ResourceBlockV1_3_4; + + ResourceBlockV1_3_4 = (EFI_REDFISH_RESOURCEBLOCK_V1_3_4 *)InterpProp; + DestroyResourceBlock_V1_3_4_CS (ResourceBlockV1_3_4->ResourceBlock); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlock_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockToStructWrapper, + ResourceBlockToJson, + ResourceBlockDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlock_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ResourceBlockCollection/RedfishResourceBlockCollection_Dxe.inf b/RedfishClientPkg/Converter/ResourceBlockCollection/RedfishResourceBlockCollection_Dxe.inf new file mode 100644 index 00000000000..bb757dd41dc --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlockCollection/RedfishResourceBlockCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ResourceBlockCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishResourceBlockCollection_Dxe + FILE_GUID = 2dee0bb5-365f-4031-af6a-34c1275f345c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishResourceBlockCollectionEntryPoint + UNLOAD_IMAGE = RedfishResourceBlockCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ResourceBlockCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ResourceBlockCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ResourceBlockCollection/ResourceBlockCollection_Dxe.c b/RedfishClientPkg/Converter/ResourceBlockCollection/ResourceBlockCollection_Dxe.c new file mode 100644 index 00000000000..18f5ef62ae8 --- /dev/null +++ b/RedfishClientPkg/Converter/ResourceBlockCollection/ResourceBlockCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ResourceBlockCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ResourceBlockCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support ResourceBlockCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ResourceBlockCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "ResourceBlockCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCKCOLLECTION *ResourceBlockCollection; + EFI_REDFISH_RESOURCEBLOCKCOLLECTION_CS *ResourceBlockCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ResourceBlockCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ResourceBlockCollection_To_CS (ResoruceRaw, &ResourceBlockCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + ResourceBlockCollection = (EFI_REDFISH_RESOURCEBLOCKCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_RESOURCEBLOCKCOLLECTION)); + if (ResourceBlockCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ResourceBlockCollection; + ResourceBlockCollection->ResourceBlockCollection = ResourceBlockCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlockCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ResourceBlockCollection"), "ResourceBlockCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ResourceBlockCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ResourceBlockCollection"), "ResourceBlockCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ResourceBlockCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ResourceBlockCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ResourceBlockCollection_JSON (*((EFI_REDFISH_RESOURCEBLOCKCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ResourceBlockCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_RESOURCEBLOCKCOLLECTION *ResourceBlockCollection; + + ResourceBlockCollection = (EFI_REDFISH_RESOURCEBLOCKCOLLECTION *)InterpProp; + DestroyResourceBlockCollection_CS (ResourceBlockCollection->ResourceBlockCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ResourceBlockCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ResourceBlockCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyResourceBlockCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlockCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ResourceBlockCollectionToStructWrapper, + ResourceBlockCollectionToJson, + ResourceBlockCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishResourceBlockCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Role/v1_0_0/RedfishRole_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Role/v1_0_0/RedfishRole_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..17c784ebce7 --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_0_0/RedfishRole_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Role.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRole_V1_0_0_Dxe + FILE_GUID = 218b9495-4c1d-4bb1-8ea4-886e436b5a3a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRole_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishRole_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Role_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RoleV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Role/v1_0_0/Role_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Role/v1_0_0/Role_V1_0_0_Dxe.c new file mode 100644 index 00000000000..61d9947bf65 --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_0_0/Role_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Role.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Role"; +BOOLEAN IsRevisonController = TRUE; + +// Support Role V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Role", + "1", + "0", + "0" + }, + "Role" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROLE_V1_0_0 *RoleV1_0_0; + EFI_REDFISH_ROLE_V1_0_0_CS *RoleV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Role") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Role_V1_0_0_To_CS (ResoruceRaw, &RoleV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + RoleV1_0_0 = (EFI_REDFISH_ROLE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROLE_V1_0_0)); + if (RoleV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RoleV1_0_0; + RoleV1_0_0->Role = RoleV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Role"), "Role"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Role"), "Role"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RoleToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RoleToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Role_V1_0_0_JSON (*((EFI_REDFISH_ROLE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RoleToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROLE_V1_0_0 *RoleV1_0_0; + + RoleV1_0_0 = (EFI_REDFISH_ROLE_V1_0_0 *)InterpProp; + DestroyRole_V1_0_0_CS (RoleV1_0_0->Role); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RoleFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRole_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RoleToStructWrapper, + RoleToJson, + RoleDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Role/v1_0_2/RedfishRole_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Role/v1_0_2/RedfishRole_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..4ad7c31cb63 --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_0_2/RedfishRole_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Role.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRole_V1_0_2_Dxe + FILE_GUID = 4ce98102-fba1-4355-8da0-afa64fd7a40d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRole_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishRole_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Role_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RoleV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Role/v1_0_2/Role_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Role/v1_0_2/Role_V1_0_2_Dxe.c new file mode 100644 index 00000000000..5051a2c7f77 --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_0_2/Role_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Role.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Role"; +BOOLEAN IsRevisonController = TRUE; + +// Support Role V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Role", + "1", + "0", + "2" + }, + "Role" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROLE_V1_0_2 *RoleV1_0_2; + EFI_REDFISH_ROLE_V1_0_2_CS *RoleV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Role") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Role_V1_0_2_To_CS (ResoruceRaw, &RoleV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + RoleV1_0_2 = (EFI_REDFISH_ROLE_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROLE_V1_0_2)); + if (RoleV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RoleV1_0_2; + RoleV1_0_2->Role = RoleV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Role"), "Role"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Role"), "Role"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RoleToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RoleToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Role_V1_0_2_JSON (*((EFI_REDFISH_ROLE_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RoleToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROLE_V1_0_2 *RoleV1_0_2; + + RoleV1_0_2 = (EFI_REDFISH_ROLE_V1_0_2 *)InterpProp; + DestroyRole_V1_0_2_CS (RoleV1_0_2->Role); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RoleFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRole_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RoleToStructWrapper, + RoleToJson, + RoleDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Role/v1_0_3/RedfishRole_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/Role/v1_0_3/RedfishRole_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..b58db2a8312 --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_0_3/RedfishRole_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Role.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRole_V1_0_3_Dxe + FILE_GUID = 2c887b97-d748-4a11-99f9-9e3ab09f12c2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRole_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishRole_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Role_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RoleV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Role/v1_0_3/Role_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/Role/v1_0_3/Role_V1_0_3_Dxe.c new file mode 100644 index 00000000000..dca7875f877 --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_0_3/Role_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Role.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Role"; +BOOLEAN IsRevisonController = TRUE; + +// Support Role V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Role", + "1", + "0", + "3" + }, + "Role" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROLE_V1_0_3 *RoleV1_0_3; + EFI_REDFISH_ROLE_V1_0_3_CS *RoleV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Role") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Role_V1_0_3_To_CS (ResoruceRaw, &RoleV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + RoleV1_0_3 = (EFI_REDFISH_ROLE_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROLE_V1_0_3)); + if (RoleV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RoleV1_0_3; + RoleV1_0_3->Role = RoleV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Role"), "Role"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Role"), "Role"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RoleToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RoleToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Role_V1_0_3_JSON (*((EFI_REDFISH_ROLE_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RoleToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROLE_V1_0_3 *RoleV1_0_3; + + RoleV1_0_3 = (EFI_REDFISH_ROLE_V1_0_3 *)InterpProp; + DestroyRole_V1_0_3_CS (RoleV1_0_3->Role); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RoleFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRole_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RoleToStructWrapper, + RoleToJson, + RoleDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Role/v1_0_4/RedfishRole_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/Role/v1_0_4/RedfishRole_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..bff2aa3c87b --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_0_4/RedfishRole_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Role.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRole_V1_0_4_Dxe + FILE_GUID = f31f2629-c938-48d7-abd0-a10b962dad5e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRole_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishRole_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Role_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RoleV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Role/v1_0_4/Role_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/Role/v1_0_4/Role_V1_0_4_Dxe.c new file mode 100644 index 00000000000..f76facb9970 --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_0_4/Role_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Role.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Role"; +BOOLEAN IsRevisonController = TRUE; + +// Support Role V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Role", + "1", + "0", + "4" + }, + "Role" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROLE_V1_0_4 *RoleV1_0_4; + EFI_REDFISH_ROLE_V1_0_4_CS *RoleV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Role") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Role_V1_0_4_To_CS (ResoruceRaw, &RoleV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + RoleV1_0_4 = (EFI_REDFISH_ROLE_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROLE_V1_0_4)); + if (RoleV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RoleV1_0_4; + RoleV1_0_4->Role = RoleV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Role"), "Role"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Role"), "Role"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RoleToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RoleToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Role_V1_0_4_JSON (*((EFI_REDFISH_ROLE_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RoleToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROLE_V1_0_4 *RoleV1_0_4; + + RoleV1_0_4 = (EFI_REDFISH_ROLE_V1_0_4 *)InterpProp; + DestroyRole_V1_0_4_CS (RoleV1_0_4->Role); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RoleFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRole_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RoleToStructWrapper, + RoleToJson, + RoleDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Role/v1_0_5/RedfishRole_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/Role/v1_0_5/RedfishRole_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..214cc432ba6 --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_0_5/RedfishRole_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Role.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRole_V1_0_5_Dxe + FILE_GUID = a3c18a4e-8819-43a9-a22f-aede4e1a8ec3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRole_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishRole_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Role_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RoleV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Role/v1_0_5/Role_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/Role/v1_0_5/Role_V1_0_5_Dxe.c new file mode 100644 index 00000000000..049a9ccb87b --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_0_5/Role_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Role.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Role"; +BOOLEAN IsRevisonController = TRUE; + +// Support Role V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Role", + "1", + "0", + "5" + }, + "Role" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROLE_V1_0_5 *RoleV1_0_5; + EFI_REDFISH_ROLE_V1_0_5_CS *RoleV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Role") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Role_V1_0_5_To_CS (ResoruceRaw, &RoleV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + RoleV1_0_5 = (EFI_REDFISH_ROLE_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROLE_V1_0_5)); + if (RoleV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RoleV1_0_5; + RoleV1_0_5->Role = RoleV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Role"), "Role"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Role"), "Role"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RoleToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RoleToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Role_V1_0_5_JSON (*((EFI_REDFISH_ROLE_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RoleToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROLE_V1_0_5 *RoleV1_0_5; + + RoleV1_0_5 = (EFI_REDFISH_ROLE_V1_0_5 *)InterpProp; + DestroyRole_V1_0_5_CS (RoleV1_0_5->Role); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RoleFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRole_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RoleToStructWrapper, + RoleToJson, + RoleDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Role/v1_0_6/RedfishRole_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/Role/v1_0_6/RedfishRole_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..ea074cd500e --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_0_6/RedfishRole_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Role.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRole_V1_0_6_Dxe + FILE_GUID = 6a203917-df00-4fbd-b733-bb8fcabb68ab + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRole_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishRole_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Role_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RoleV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Role/v1_0_6/Role_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/Role/v1_0_6/Role_V1_0_6_Dxe.c new file mode 100644 index 00000000000..bb4bea08725 --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_0_6/Role_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Role.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Role"; +BOOLEAN IsRevisonController = TRUE; + +// Support Role V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Role", + "1", + "0", + "6" + }, + "Role" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROLE_V1_0_6 *RoleV1_0_6; + EFI_REDFISH_ROLE_V1_0_6_CS *RoleV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Role") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Role_V1_0_6_To_CS (ResoruceRaw, &RoleV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + RoleV1_0_6 = (EFI_REDFISH_ROLE_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROLE_V1_0_6)); + if (RoleV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RoleV1_0_6; + RoleV1_0_6->Role = RoleV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Role"), "Role"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Role"), "Role"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RoleToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RoleToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Role_V1_0_6_JSON (*((EFI_REDFISH_ROLE_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RoleToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROLE_V1_0_6 *RoleV1_0_6; + + RoleV1_0_6 = (EFI_REDFISH_ROLE_V1_0_6 *)InterpProp; + DestroyRole_V1_0_6_CS (RoleV1_0_6->Role); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RoleFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRole_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RoleToStructWrapper, + RoleToJson, + RoleDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Role/v1_0_7/RedfishRole_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/Role/v1_0_7/RedfishRole_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..8f7c5b1872b --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_0_7/RedfishRole_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Role.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRole_V1_0_7_Dxe + FILE_GUID = 8982d062-1130-498f-b3c4-2abf23dcc74a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRole_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishRole_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Role_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RoleV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Role/v1_0_7/Role_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/Role/v1_0_7/Role_V1_0_7_Dxe.c new file mode 100644 index 00000000000..845d1bcf356 --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_0_7/Role_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Role.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Role"; +BOOLEAN IsRevisonController = TRUE; + +// Support Role V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Role", + "1", + "0", + "7" + }, + "Role" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROLE_V1_0_7 *RoleV1_0_7; + EFI_REDFISH_ROLE_V1_0_7_CS *RoleV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Role") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Role_V1_0_7_To_CS (ResoruceRaw, &RoleV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + RoleV1_0_7 = (EFI_REDFISH_ROLE_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROLE_V1_0_7)); + if (RoleV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RoleV1_0_7; + RoleV1_0_7->Role = RoleV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Role"), "Role"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Role"), "Role"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RoleToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RoleToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Role_V1_0_7_JSON (*((EFI_REDFISH_ROLE_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RoleToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROLE_V1_0_7 *RoleV1_0_7; + + RoleV1_0_7 = (EFI_REDFISH_ROLE_V1_0_7 *)InterpProp; + DestroyRole_V1_0_7_CS (RoleV1_0_7->Role); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RoleFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRole_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RoleToStructWrapper, + RoleToJson, + RoleDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Role/v1_1_0/RedfishRole_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/Role/v1_1_0/RedfishRole_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..217d52f3665 --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_1_0/RedfishRole_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Role.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRole_V1_1_0_Dxe + FILE_GUID = feb70b38-0e7c-454f-a1f9-1337f0d42289 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRole_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishRole_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Role_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RoleV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Role/v1_1_0/Role_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/Role/v1_1_0/Role_V1_1_0_Dxe.c new file mode 100644 index 00000000000..70ba9e9c4b9 --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_1_0/Role_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Role.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Role"; +BOOLEAN IsRevisonController = TRUE; + +// Support Role V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Role", + "1", + "1", + "0" + }, + "Role" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROLE_V1_1_0 *RoleV1_1_0; + EFI_REDFISH_ROLE_V1_1_0_CS *RoleV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Role") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Role_V1_1_0_To_CS (ResoruceRaw, &RoleV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + RoleV1_1_0 = (EFI_REDFISH_ROLE_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROLE_V1_1_0)); + if (RoleV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RoleV1_1_0; + RoleV1_1_0->Role = RoleV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Role"), "Role"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Role"), "Role"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RoleToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RoleToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Role_V1_1_0_JSON (*((EFI_REDFISH_ROLE_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RoleToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROLE_V1_1_0 *RoleV1_1_0; + + RoleV1_1_0 = (EFI_REDFISH_ROLE_V1_1_0 *)InterpProp; + DestroyRole_V1_1_0_CS (RoleV1_1_0->Role); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RoleFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRole_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RoleToStructWrapper, + RoleToJson, + RoleDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Role/v1_1_1/RedfishRole_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/Role/v1_1_1/RedfishRole_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..7c8e8e13e68 --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_1_1/RedfishRole_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Role.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRole_V1_1_1_Dxe + FILE_GUID = c48174b1-1e0c-4185-a5b7-62305dcc0fbc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRole_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishRole_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Role_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RoleV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Role/v1_1_1/Role_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/Role/v1_1_1/Role_V1_1_1_Dxe.c new file mode 100644 index 00000000000..71fdd5b988b --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_1_1/Role_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Role.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Role"; +BOOLEAN IsRevisonController = TRUE; + +// Support Role V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Role", + "1", + "1", + "1" + }, + "Role" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROLE_V1_1_1 *RoleV1_1_1; + EFI_REDFISH_ROLE_V1_1_1_CS *RoleV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Role") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Role_V1_1_1_To_CS (ResoruceRaw, &RoleV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + RoleV1_1_1 = (EFI_REDFISH_ROLE_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROLE_V1_1_1)); + if (RoleV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RoleV1_1_1; + RoleV1_1_1->Role = RoleV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Role"), "Role"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Role"), "Role"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RoleToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RoleToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Role_V1_1_1_JSON (*((EFI_REDFISH_ROLE_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RoleToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROLE_V1_1_1 *RoleV1_1_1; + + RoleV1_1_1 = (EFI_REDFISH_ROLE_V1_1_1 *)InterpProp; + DestroyRole_V1_1_1_CS (RoleV1_1_1->Role); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RoleFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRole_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RoleToStructWrapper, + RoleToJson, + RoleDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Role/v1_1_2/RedfishRole_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/Role/v1_1_2/RedfishRole_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..4ea1ddf03fc --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_1_2/RedfishRole_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Role.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRole_V1_1_2_Dxe + FILE_GUID = fdc16f75-fec4-4269-97ab-f0a5db2d03ec + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRole_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishRole_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Role_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RoleV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Role/v1_1_2/Role_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/Role/v1_1_2/Role_V1_1_2_Dxe.c new file mode 100644 index 00000000000..13a43dabfd2 --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_1_2/Role_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Role.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Role"; +BOOLEAN IsRevisonController = TRUE; + +// Support Role V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Role", + "1", + "1", + "2" + }, + "Role" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROLE_V1_1_2 *RoleV1_1_2; + EFI_REDFISH_ROLE_V1_1_2_CS *RoleV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Role") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Role_V1_1_2_To_CS (ResoruceRaw, &RoleV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + RoleV1_1_2 = (EFI_REDFISH_ROLE_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROLE_V1_1_2)); + if (RoleV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RoleV1_1_2; + RoleV1_1_2->Role = RoleV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Role"), "Role"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Role"), "Role"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RoleToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RoleToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Role_V1_1_2_JSON (*((EFI_REDFISH_ROLE_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RoleToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROLE_V1_1_2 *RoleV1_1_2; + + RoleV1_1_2 = (EFI_REDFISH_ROLE_V1_1_2 *)InterpProp; + DestroyRole_V1_1_2_CS (RoleV1_1_2->Role); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RoleFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRole_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RoleToStructWrapper, + RoleToJson, + RoleDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Role/v1_1_3/RedfishRole_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/Role/v1_1_3/RedfishRole_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..326aa55333a --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_1_3/RedfishRole_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Role.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRole_V1_1_3_Dxe + FILE_GUID = 1ae5f25b-5830-463d-a63a-73aab60dc9b7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRole_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishRole_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Role_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RoleV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Role/v1_1_3/Role_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/Role/v1_1_3/Role_V1_1_3_Dxe.c new file mode 100644 index 00000000000..59573d9d39d --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_1_3/Role_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Role.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Role"; +BOOLEAN IsRevisonController = TRUE; + +// Support Role V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Role", + "1", + "1", + "3" + }, + "Role" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROLE_V1_1_3 *RoleV1_1_3; + EFI_REDFISH_ROLE_V1_1_3_CS *RoleV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Role") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Role_V1_1_3_To_CS (ResoruceRaw, &RoleV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + RoleV1_1_3 = (EFI_REDFISH_ROLE_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROLE_V1_1_3)); + if (RoleV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RoleV1_1_3; + RoleV1_1_3->Role = RoleV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Role"), "Role"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Role"), "Role"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RoleToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RoleToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Role_V1_1_3_JSON (*((EFI_REDFISH_ROLE_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RoleToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROLE_V1_1_3 *RoleV1_1_3; + + RoleV1_1_3 = (EFI_REDFISH_ROLE_V1_1_3 *)InterpProp; + DestroyRole_V1_1_3_CS (RoleV1_1_3->Role); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RoleFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRole_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RoleToStructWrapper, + RoleToJson, + RoleDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Role/v1_1_4/RedfishRole_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/Role/v1_1_4/RedfishRole_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..0c6e62eef4d --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_1_4/RedfishRole_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Role.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRole_V1_1_4_Dxe + FILE_GUID = f8316cec-27f7-44d3-a30f-18e3f9fc7fa0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRole_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishRole_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Role_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RoleV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Role/v1_1_4/Role_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/Role/v1_1_4/Role_V1_1_4_Dxe.c new file mode 100644 index 00000000000..97aaaefb0f4 --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_1_4/Role_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Role.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Role"; +BOOLEAN IsRevisonController = TRUE; + +// Support Role V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Role", + "1", + "1", + "4" + }, + "Role" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROLE_V1_1_4 *RoleV1_1_4; + EFI_REDFISH_ROLE_V1_1_4_CS *RoleV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Role") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Role_V1_1_4_To_CS (ResoruceRaw, &RoleV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + RoleV1_1_4 = (EFI_REDFISH_ROLE_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROLE_V1_1_4)); + if (RoleV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RoleV1_1_4; + RoleV1_1_4->Role = RoleV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Role"), "Role"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Role"), "Role"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RoleToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RoleToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Role_V1_1_4_JSON (*((EFI_REDFISH_ROLE_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RoleToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROLE_V1_1_4 *RoleV1_1_4; + + RoleV1_1_4 = (EFI_REDFISH_ROLE_V1_1_4 *)InterpProp; + DestroyRole_V1_1_4_CS (RoleV1_1_4->Role); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RoleFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRole_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RoleToStructWrapper, + RoleToJson, + RoleDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Role/v1_1_5/RedfishRole_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/Role/v1_1_5/RedfishRole_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..861a1a8edf3 --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_1_5/RedfishRole_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Role.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRole_V1_1_5_Dxe + FILE_GUID = d2d71cdb-3514-4782-8425-daafa144641e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRole_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishRole_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Role_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RoleV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Role/v1_1_5/Role_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/Role/v1_1_5/Role_V1_1_5_Dxe.c new file mode 100644 index 00000000000..b4be185e605 --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_1_5/Role_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Role.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Role"; +BOOLEAN IsRevisonController = TRUE; + +// Support Role V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Role", + "1", + "1", + "5" + }, + "Role" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROLE_V1_1_5 *RoleV1_1_5; + EFI_REDFISH_ROLE_V1_1_5_CS *RoleV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Role") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Role_V1_1_5_To_CS (ResoruceRaw, &RoleV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + RoleV1_1_5 = (EFI_REDFISH_ROLE_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROLE_V1_1_5)); + if (RoleV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RoleV1_1_5; + RoleV1_1_5->Role = RoleV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Role"), "Role"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Role"), "Role"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RoleToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RoleToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Role_V1_1_5_JSON (*((EFI_REDFISH_ROLE_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RoleToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROLE_V1_1_5 *RoleV1_1_5; + + RoleV1_1_5 = (EFI_REDFISH_ROLE_V1_1_5 *)InterpProp; + DestroyRole_V1_1_5_CS (RoleV1_1_5->Role); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RoleFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRole_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RoleToStructWrapper, + RoleToJson, + RoleDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Role/v1_2_0/RedfishRole_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/Role/v1_2_0/RedfishRole_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..6f03c677d88 --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_2_0/RedfishRole_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Role.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRole_V1_2_0_Dxe + FILE_GUID = 7e41f3a7-8333-4825-ad0f-a87d6fdff4ac + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRole_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishRole_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Role_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RoleV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Role/v1_2_0/Role_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/Role/v1_2_0/Role_V1_2_0_Dxe.c new file mode 100644 index 00000000000..3cec9f937b3 --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_2_0/Role_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Role.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Role"; +BOOLEAN IsRevisonController = TRUE; + +// Support Role V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Role", + "1", + "2", + "0" + }, + "Role" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROLE_V1_2_0 *RoleV1_2_0; + EFI_REDFISH_ROLE_V1_2_0_CS *RoleV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Role") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Role_V1_2_0_To_CS (ResoruceRaw, &RoleV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + RoleV1_2_0 = (EFI_REDFISH_ROLE_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROLE_V1_2_0)); + if (RoleV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RoleV1_2_0; + RoleV1_2_0->Role = RoleV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Role"), "Role"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Role"), "Role"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RoleToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RoleToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Role_V1_2_0_JSON (*((EFI_REDFISH_ROLE_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RoleToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROLE_V1_2_0 *RoleV1_2_0; + + RoleV1_2_0 = (EFI_REDFISH_ROLE_V1_2_0 *)InterpProp; + DestroyRole_V1_2_0_CS (RoleV1_2_0->Role); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RoleFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRole_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RoleToStructWrapper, + RoleToJson, + RoleDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Role/v1_2_1/RedfishRole_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/Role/v1_2_1/RedfishRole_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..49cc1a37f16 --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_2_1/RedfishRole_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Role.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRole_V1_2_1_Dxe + FILE_GUID = e7d771d8-4287-4536-b2b3-f7e5d4959dbd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRole_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishRole_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Role_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RoleV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Role/v1_2_1/Role_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/Role/v1_2_1/Role_V1_2_1_Dxe.c new file mode 100644 index 00000000000..febb530b0fb --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_2_1/Role_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Role.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Role"; +BOOLEAN IsRevisonController = TRUE; + +// Support Role V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Role", + "1", + "2", + "1" + }, + "Role" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROLE_V1_2_1 *RoleV1_2_1; + EFI_REDFISH_ROLE_V1_2_1_CS *RoleV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Role") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Role_V1_2_1_To_CS (ResoruceRaw, &RoleV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + RoleV1_2_1 = (EFI_REDFISH_ROLE_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROLE_V1_2_1)); + if (RoleV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RoleV1_2_1; + RoleV1_2_1->Role = RoleV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Role"), "Role"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Role"), "Role"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RoleToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RoleToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Role_V1_2_1_JSON (*((EFI_REDFISH_ROLE_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RoleToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROLE_V1_2_1 *RoleV1_2_1; + + RoleV1_2_1 = (EFI_REDFISH_ROLE_V1_2_1 *)InterpProp; + DestroyRole_V1_2_1_CS (RoleV1_2_1->Role); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RoleFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRole_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RoleToStructWrapper, + RoleToJson, + RoleDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Role/v1_2_2/RedfishRole_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/Role/v1_2_2/RedfishRole_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..1e532895acc --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_2_2/RedfishRole_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Role.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRole_V1_2_2_Dxe + FILE_GUID = 620d72b0-da16-4daf-b36d-5a3fbea3bacc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRole_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishRole_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Role_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RoleV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Role/v1_2_2/Role_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/Role/v1_2_2/Role_V1_2_2_Dxe.c new file mode 100644 index 00000000000..bca06ea76b9 --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_2_2/Role_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Role.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Role"; +BOOLEAN IsRevisonController = TRUE; + +// Support Role V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Role", + "1", + "2", + "2" + }, + "Role" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROLE_V1_2_2 *RoleV1_2_2; + EFI_REDFISH_ROLE_V1_2_2_CS *RoleV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Role") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Role_V1_2_2_To_CS (ResoruceRaw, &RoleV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + RoleV1_2_2 = (EFI_REDFISH_ROLE_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROLE_V1_2_2)); + if (RoleV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RoleV1_2_2; + RoleV1_2_2->Role = RoleV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Role"), "Role"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Role"), "Role"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RoleToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RoleToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Role_V1_2_2_JSON (*((EFI_REDFISH_ROLE_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RoleToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROLE_V1_2_2 *RoleV1_2_2; + + RoleV1_2_2 = (EFI_REDFISH_ROLE_V1_2_2 *)InterpProp; + DestroyRole_V1_2_2_CS (RoleV1_2_2->Role); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RoleFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRole_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RoleToStructWrapper, + RoleToJson, + RoleDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Role/v1_2_3/RedfishRole_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/Role/v1_2_3/RedfishRole_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..883ba51fb5e --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_2_3/RedfishRole_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Role.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRole_V1_2_3_Dxe + FILE_GUID = 75d648ba-9b3e-46a0-b5d8-72d291eb9621 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRole_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishRole_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Role_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RoleV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Role/v1_2_3/Role_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/Role/v1_2_3/Role_V1_2_3_Dxe.c new file mode 100644 index 00000000000..e547e9e86c9 --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_2_3/Role_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Role.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Role"; +BOOLEAN IsRevisonController = TRUE; + +// Support Role V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Role", + "1", + "2", + "3" + }, + "Role" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROLE_V1_2_3 *RoleV1_2_3; + EFI_REDFISH_ROLE_V1_2_3_CS *RoleV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Role") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Role_V1_2_3_To_CS (ResoruceRaw, &RoleV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + RoleV1_2_3 = (EFI_REDFISH_ROLE_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROLE_V1_2_3)); + if (RoleV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RoleV1_2_3; + RoleV1_2_3->Role = RoleV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Role"), "Role"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Role"), "Role"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RoleToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RoleToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Role_V1_2_3_JSON (*((EFI_REDFISH_ROLE_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RoleToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROLE_V1_2_3 *RoleV1_2_3; + + RoleV1_2_3 = (EFI_REDFISH_ROLE_V1_2_3 *)InterpProp; + DestroyRole_V1_2_3_CS (RoleV1_2_3->Role); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RoleFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRole_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RoleToStructWrapper, + RoleToJson, + RoleDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Role/v1_2_4/RedfishRole_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/Role/v1_2_4/RedfishRole_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..ccdec46d1c7 --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_2_4/RedfishRole_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Role.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRole_V1_2_4_Dxe + FILE_GUID = dfaad3fa-5459-4b9f-8adc-17b2985c2ec9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRole_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishRole_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Role_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RoleV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Role/v1_2_4/Role_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/Role/v1_2_4/Role_V1_2_4_Dxe.c new file mode 100644 index 00000000000..a93c4a3248f --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_2_4/Role_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Role.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Role"; +BOOLEAN IsRevisonController = TRUE; + +// Support Role V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Role", + "1", + "2", + "4" + }, + "Role" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROLE_V1_2_4 *RoleV1_2_4; + EFI_REDFISH_ROLE_V1_2_4_CS *RoleV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Role") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Role_V1_2_4_To_CS (ResoruceRaw, &RoleV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + RoleV1_2_4 = (EFI_REDFISH_ROLE_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROLE_V1_2_4)); + if (RoleV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RoleV1_2_4; + RoleV1_2_4->Role = RoleV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Role"), "Role"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Role"), "Role"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RoleToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RoleToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Role_V1_2_4_JSON (*((EFI_REDFISH_ROLE_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RoleToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROLE_V1_2_4 *RoleV1_2_4; + + RoleV1_2_4 = (EFI_REDFISH_ROLE_V1_2_4 *)InterpProp; + DestroyRole_V1_2_4_CS (RoleV1_2_4->Role); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RoleFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRole_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RoleToStructWrapper, + RoleToJson, + RoleDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Role/v1_2_5/RedfishRole_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/Role/v1_2_5/RedfishRole_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..0621e4cfd9a --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_2_5/RedfishRole_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Role.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRole_V1_2_5_Dxe + FILE_GUID = 0e88698a-f505-4bd0-af73-df031eab68f2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRole_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishRole_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Role_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RoleV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Role/v1_2_5/Role_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/Role/v1_2_5/Role_V1_2_5_Dxe.c new file mode 100644 index 00000000000..b4710788f01 --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_2_5/Role_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Role.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Role"; +BOOLEAN IsRevisonController = TRUE; + +// Support Role V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Role", + "1", + "2", + "5" + }, + "Role" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROLE_V1_2_5 *RoleV1_2_5; + EFI_REDFISH_ROLE_V1_2_5_CS *RoleV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Role") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Role_V1_2_5_To_CS (ResoruceRaw, &RoleV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + RoleV1_2_5 = (EFI_REDFISH_ROLE_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROLE_V1_2_5)); + if (RoleV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RoleV1_2_5; + RoleV1_2_5->Role = RoleV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Role"), "Role"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Role"), "Role"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RoleToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RoleToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Role_V1_2_5_JSON (*((EFI_REDFISH_ROLE_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RoleToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROLE_V1_2_5 *RoleV1_2_5; + + RoleV1_2_5 = (EFI_REDFISH_ROLE_V1_2_5 *)InterpProp; + DestroyRole_V1_2_5_CS (RoleV1_2_5->Role); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RoleFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRole_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RoleToStructWrapper, + RoleToJson, + RoleDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Role/v1_3_0/RedfishRole_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/Role/v1_3_0/RedfishRole_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..747d44a34f2 --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_3_0/RedfishRole_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Role.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRole_V1_3_0_Dxe + FILE_GUID = 8db72c15-4303-4265-810e-114bafe23f35 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRole_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishRole_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Role_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RoleV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Role/v1_3_0/Role_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/Role/v1_3_0/Role_V1_3_0_Dxe.c new file mode 100644 index 00000000000..c70cbee413b --- /dev/null +++ b/RedfishClientPkg/Converter/Role/v1_3_0/Role_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Role.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Role"; +BOOLEAN IsRevisonController = TRUE; + +// Support Role V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Role", + "1", + "3", + "0" + }, + "Role" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROLE_V1_3_0 *RoleV1_3_0; + EFI_REDFISH_ROLE_V1_3_0_CS *RoleV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Role") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Role_V1_3_0_To_CS (ResoruceRaw, &RoleV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + RoleV1_3_0 = (EFI_REDFISH_ROLE_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROLE_V1_3_0)); + if (RoleV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RoleV1_3_0; + RoleV1_3_0->Role = RoleV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Role"), "Role"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Role")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Role"), "Role"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RoleToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RoleToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Role_V1_3_0_JSON (*((EFI_REDFISH_ROLE_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RoleToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROLE_V1_3_0 *RoleV1_3_0; + + RoleV1_3_0 = (EFI_REDFISH_ROLE_V1_3_0 *)InterpProp; + DestroyRole_V1_3_0_CS (RoleV1_3_0->Role); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RoleFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRole_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RoleToStructWrapper, + RoleToJson, + RoleDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRole_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/RoleCollection/RedfishRoleCollection_Dxe.inf b/RedfishClientPkg/Converter/RoleCollection/RedfishRoleCollection_Dxe.inf new file mode 100644 index 00000000000..3d0d667fd49 --- /dev/null +++ b/RedfishClientPkg/Converter/RoleCollection/RedfishRoleCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of RoleCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRoleCollection_Dxe + FILE_GUID = 9d5b83a5-b214-4bae-9c0e-481c29d74f88 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRoleCollectionEntryPoint + UNLOAD_IMAGE = RedfishRoleCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + RoleCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RoleCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/RoleCollection/RoleCollection_Dxe.c b/RedfishClientPkg/Converter/RoleCollection/RoleCollection_Dxe.c new file mode 100644 index 00000000000..4c4adab4c98 --- /dev/null +++ b/RedfishClientPkg/Converter/RoleCollection/RoleCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - RoleCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#RoleCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support RoleCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "RoleCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "RoleCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROLECOLLECTION *RoleCollection; + EFI_REDFISH_ROLECOLLECTION_CS *RoleCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "RoleCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_RoleCollection_To_CS (ResoruceRaw, &RoleCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + RoleCollection = (EFI_REDFISH_ROLECOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROLECOLLECTION)); + if (RoleCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RoleCollection; + RoleCollection->RoleCollection = RoleCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("RoleCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("RoleCollection"), "RoleCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("RoleCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("RoleCollection"), "RoleCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RoleCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RoleCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_RoleCollection_JSON (*((EFI_REDFISH_ROLECOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RoleCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROLECOLLECTION *RoleCollection; + + RoleCollection = (EFI_REDFISH_ROLECOLLECTION *)InterpProp; + DestroyRoleCollection_CS (RoleCollection->RoleCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RoleCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RoleCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRoleCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRoleCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RoleCollectionToStructWrapper, + RoleCollectionToJson, + RoleCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRoleCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/RouteEntry/v1_0_0/RedfishRouteEntry_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/RouteEntry/v1_0_0/RedfishRouteEntry_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..09b0d00658e --- /dev/null +++ b/RedfishClientPkg/Converter/RouteEntry/v1_0_0/RedfishRouteEntry_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of RouteEntry.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRouteEntry_V1_0_0_Dxe + FILE_GUID = eecae926-7662-4fee-9463-6fa7538dde50 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRouteEntry_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishRouteEntry_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + RouteEntry_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RouteEntryV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/RouteEntry/v1_0_0/RouteEntry_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/RouteEntry/v1_0_0/RouteEntry_V1_0_0_Dxe.c new file mode 100644 index 00000000000..fc3e55af05c --- /dev/null +++ b/RedfishClientPkg/Converter/RouteEntry/v1_0_0/RouteEntry_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - RouteEntry.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#RouteEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support RouteEntry V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "RouteEntry", + "1", + "0", + "0" + }, + "RouteEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROUTEENTRY_V1_0_0 *RouteEntryV1_0_0; + EFI_REDFISH_ROUTEENTRY_V1_0_0_CS *RouteEntryV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "RouteEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_RouteEntry_V1_0_0_To_CS (ResoruceRaw, &RouteEntryV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + RouteEntryV1_0_0 = (EFI_REDFISH_ROUTEENTRY_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROUTEENTRY_V1_0_0)); + if (RouteEntryV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RouteEntryV1_0_0; + RouteEntryV1_0_0->RouteEntry = RouteEntryV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("RouteEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("RouteEntry"), "RouteEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("RouteEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("RouteEntry"), "RouteEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RouteEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RouteEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_RouteEntry_V1_0_0_JSON (*((EFI_REDFISH_ROUTEENTRY_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RouteEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROUTEENTRY_V1_0_0 *RouteEntryV1_0_0; + + RouteEntryV1_0_0 = (EFI_REDFISH_ROUTEENTRY_V1_0_0 *)InterpProp; + DestroyRouteEntry_V1_0_0_CS (RouteEntryV1_0_0->RouteEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RouteEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRouteEntry_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRouteEntry_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RouteEntryToStructWrapper, + RouteEntryToJson, + RouteEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRouteEntry_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/RouteEntry/v1_0_1/RedfishRouteEntry_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/RouteEntry/v1_0_1/RedfishRouteEntry_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..500fc09d20f --- /dev/null +++ b/RedfishClientPkg/Converter/RouteEntry/v1_0_1/RedfishRouteEntry_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of RouteEntry.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRouteEntry_V1_0_1_Dxe + FILE_GUID = c0bc3fed-a988-4c08-9446-5e1360801d08 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRouteEntry_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishRouteEntry_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + RouteEntry_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RouteEntryV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/RouteEntry/v1_0_1/RouteEntry_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/RouteEntry/v1_0_1/RouteEntry_V1_0_1_Dxe.c new file mode 100644 index 00000000000..0ff41bd6d2c --- /dev/null +++ b/RedfishClientPkg/Converter/RouteEntry/v1_0_1/RouteEntry_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - RouteEntry.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#RouteEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support RouteEntry V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "RouteEntry", + "1", + "0", + "1" + }, + "RouteEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROUTEENTRY_V1_0_1 *RouteEntryV1_0_1; + EFI_REDFISH_ROUTEENTRY_V1_0_1_CS *RouteEntryV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "RouteEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_RouteEntry_V1_0_1_To_CS (ResoruceRaw, &RouteEntryV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + RouteEntryV1_0_1 = (EFI_REDFISH_ROUTEENTRY_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROUTEENTRY_V1_0_1)); + if (RouteEntryV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RouteEntryV1_0_1; + RouteEntryV1_0_1->RouteEntry = RouteEntryV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("RouteEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("RouteEntry"), "RouteEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("RouteEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("RouteEntry"), "RouteEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RouteEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RouteEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_RouteEntry_V1_0_1_JSON (*((EFI_REDFISH_ROUTEENTRY_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RouteEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROUTEENTRY_V1_0_1 *RouteEntryV1_0_1; + + RouteEntryV1_0_1 = (EFI_REDFISH_ROUTEENTRY_V1_0_1 *)InterpProp; + DestroyRouteEntry_V1_0_1_CS (RouteEntryV1_0_1->RouteEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RouteEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRouteEntry_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRouteEntry_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RouteEntryToStructWrapper, + RouteEntryToJson, + RouteEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRouteEntry_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/RouteEntryCollection/RedfishRouteEntryCollection_Dxe.inf b/RedfishClientPkg/Converter/RouteEntryCollection/RedfishRouteEntryCollection_Dxe.inf new file mode 100644 index 00000000000..6b6782e5328 --- /dev/null +++ b/RedfishClientPkg/Converter/RouteEntryCollection/RedfishRouteEntryCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of RouteEntryCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRouteEntryCollection_Dxe + FILE_GUID = 28a6441e-e575-4d59-9686-7982c2639383 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRouteEntryCollectionEntryPoint + UNLOAD_IMAGE = RedfishRouteEntryCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + RouteEntryCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RouteEntryCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/RouteEntryCollection/RouteEntryCollection_Dxe.c b/RedfishClientPkg/Converter/RouteEntryCollection/RouteEntryCollection_Dxe.c new file mode 100644 index 00000000000..0fa5dfb2d11 --- /dev/null +++ b/RedfishClientPkg/Converter/RouteEntryCollection/RouteEntryCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - RouteEntryCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#RouteEntryCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support RouteEntryCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "RouteEntryCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "RouteEntryCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteEntryCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROUTEENTRYCOLLECTION *RouteEntryCollection; + EFI_REDFISH_ROUTEENTRYCOLLECTION_CS *RouteEntryCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "RouteEntryCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_RouteEntryCollection_To_CS (ResoruceRaw, &RouteEntryCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + RouteEntryCollection = (EFI_REDFISH_ROUTEENTRYCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROUTEENTRYCOLLECTION)); + if (RouteEntryCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RouteEntryCollection; + RouteEntryCollection->RouteEntryCollection = RouteEntryCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("RouteEntryCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("RouteEntryCollection"), "RouteEntryCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("RouteEntryCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("RouteEntryCollection"), "RouteEntryCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RouteEntryCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteEntryCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RouteEntryCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteEntryCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_RouteEntryCollection_JSON (*((EFI_REDFISH_ROUTEENTRYCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RouteEntryCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteEntryCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROUTEENTRYCOLLECTION *RouteEntryCollection; + + RouteEntryCollection = (EFI_REDFISH_ROUTEENTRYCOLLECTION *)InterpProp; + DestroyRouteEntryCollection_CS (RouteEntryCollection->RouteEntryCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RouteEntryCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteEntryCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRouteEntryCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRouteEntryCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RouteEntryCollectionToStructWrapper, + RouteEntryCollectionToJson, + RouteEntryCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRouteEntryCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/RouteSetEntry/v1_0_0/RedfishRouteSetEntry_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/RouteSetEntry/v1_0_0/RedfishRouteSetEntry_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..730f5123db4 --- /dev/null +++ b/RedfishClientPkg/Converter/RouteSetEntry/v1_0_0/RedfishRouteSetEntry_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of RouteSetEntry.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRouteSetEntry_V1_0_0_Dxe + FILE_GUID = 6a005c5e-be9c-455a-8970-2ed6379df173 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRouteSetEntry_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishRouteSetEntry_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + RouteSetEntry_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RouteSetEntryV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/RouteSetEntry/v1_0_0/RouteSetEntry_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/RouteSetEntry/v1_0_0/RouteSetEntry_V1_0_0_Dxe.c new file mode 100644 index 00000000000..47d4bcfd083 --- /dev/null +++ b/RedfishClientPkg/Converter/RouteSetEntry/v1_0_0/RouteSetEntry_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - RouteSetEntry.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#RouteSetEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support RouteSetEntry V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "RouteSetEntry", + "1", + "0", + "0" + }, + "RouteSetEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteSetEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROUTESETENTRY_V1_0_0 *RouteSetEntryV1_0_0; + EFI_REDFISH_ROUTESETENTRY_V1_0_0_CS *RouteSetEntryV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "RouteSetEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_RouteSetEntry_V1_0_0_To_CS (ResoruceRaw, &RouteSetEntryV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + RouteSetEntryV1_0_0 = (EFI_REDFISH_ROUTESETENTRY_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROUTESETENTRY_V1_0_0)); + if (RouteSetEntryV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RouteSetEntryV1_0_0; + RouteSetEntryV1_0_0->RouteSetEntry = RouteSetEntryV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("RouteSetEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("RouteSetEntry"), "RouteSetEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("RouteSetEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("RouteSetEntry"), "RouteSetEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RouteSetEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteSetEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RouteSetEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteSetEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_RouteSetEntry_V1_0_0_JSON (*((EFI_REDFISH_ROUTESETENTRY_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RouteSetEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteSetEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROUTESETENTRY_V1_0_0 *RouteSetEntryV1_0_0; + + RouteSetEntryV1_0_0 = (EFI_REDFISH_ROUTESETENTRY_V1_0_0 *)InterpProp; + DestroyRouteSetEntry_V1_0_0_CS (RouteSetEntryV1_0_0->RouteSetEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RouteSetEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteSetEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRouteSetEntry_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRouteSetEntry_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RouteSetEntryToStructWrapper, + RouteSetEntryToJson, + RouteSetEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRouteSetEntry_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/RouteSetEntry/v1_0_1/RedfishRouteSetEntry_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/RouteSetEntry/v1_0_1/RedfishRouteSetEntry_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..652149f3f3e --- /dev/null +++ b/RedfishClientPkg/Converter/RouteSetEntry/v1_0_1/RedfishRouteSetEntry_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of RouteSetEntry.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRouteSetEntry_V1_0_1_Dxe + FILE_GUID = b2d9d213-6076-40ef-b0bf-d0bf679909b3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRouteSetEntry_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishRouteSetEntry_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + RouteSetEntry_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RouteSetEntryV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/RouteSetEntry/v1_0_1/RouteSetEntry_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/RouteSetEntry/v1_0_1/RouteSetEntry_V1_0_1_Dxe.c new file mode 100644 index 00000000000..654acb0c79e --- /dev/null +++ b/RedfishClientPkg/Converter/RouteSetEntry/v1_0_1/RouteSetEntry_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - RouteSetEntry.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#RouteSetEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support RouteSetEntry V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "RouteSetEntry", + "1", + "0", + "1" + }, + "RouteSetEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteSetEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROUTESETENTRY_V1_0_1 *RouteSetEntryV1_0_1; + EFI_REDFISH_ROUTESETENTRY_V1_0_1_CS *RouteSetEntryV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "RouteSetEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_RouteSetEntry_V1_0_1_To_CS (ResoruceRaw, &RouteSetEntryV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + RouteSetEntryV1_0_1 = (EFI_REDFISH_ROUTESETENTRY_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROUTESETENTRY_V1_0_1)); + if (RouteSetEntryV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RouteSetEntryV1_0_1; + RouteSetEntryV1_0_1->RouteSetEntry = RouteSetEntryV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("RouteSetEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("RouteSetEntry"), "RouteSetEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("RouteSetEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("RouteSetEntry"), "RouteSetEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RouteSetEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteSetEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RouteSetEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteSetEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_RouteSetEntry_V1_0_1_JSON (*((EFI_REDFISH_ROUTESETENTRY_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RouteSetEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteSetEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROUTESETENTRY_V1_0_1 *RouteSetEntryV1_0_1; + + RouteSetEntryV1_0_1 = (EFI_REDFISH_ROUTESETENTRY_V1_0_1 *)InterpProp; + DestroyRouteSetEntry_V1_0_1_CS (RouteSetEntryV1_0_1->RouteSetEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RouteSetEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteSetEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRouteSetEntry_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRouteSetEntry_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RouteSetEntryToStructWrapper, + RouteSetEntryToJson, + RouteSetEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRouteSetEntry_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/RouteSetEntryCollection/RedfishRouteSetEntryCollection_Dxe.inf b/RedfishClientPkg/Converter/RouteSetEntryCollection/RedfishRouteSetEntryCollection_Dxe.inf new file mode 100644 index 00000000000..071ca2b4848 --- /dev/null +++ b/RedfishClientPkg/Converter/RouteSetEntryCollection/RedfishRouteSetEntryCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of RouteSetEntryCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishRouteSetEntryCollection_Dxe + FILE_GUID = b8ab0eea-e545-414a-b53e-404b2989b379 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishRouteSetEntryCollectionEntryPoint + UNLOAD_IMAGE = RedfishRouteSetEntryCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + RouteSetEntryCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + RouteSetEntryCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/RouteSetEntryCollection/RouteSetEntryCollection_Dxe.c b/RedfishClientPkg/Converter/RouteSetEntryCollection/RouteSetEntryCollection_Dxe.c new file mode 100644 index 00000000000..72900592d37 --- /dev/null +++ b/RedfishClientPkg/Converter/RouteSetEntryCollection/RouteSetEntryCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - RouteSetEntryCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#RouteSetEntryCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support RouteSetEntryCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "RouteSetEntryCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "RouteSetEntryCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteSetEntryCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ROUTESETENTRYCOLLECTION *RouteSetEntryCollection; + EFI_REDFISH_ROUTESETENTRYCOLLECTION_CS *RouteSetEntryCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "RouteSetEntryCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_RouteSetEntryCollection_To_CS (ResoruceRaw, &RouteSetEntryCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + RouteSetEntryCollection = (EFI_REDFISH_ROUTESETENTRYCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ROUTESETENTRYCOLLECTION)); + if (RouteSetEntryCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)RouteSetEntryCollection; + RouteSetEntryCollection->RouteSetEntryCollection = RouteSetEntryCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("RouteSetEntryCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("RouteSetEntryCollection"), "RouteSetEntryCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("RouteSetEntryCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("RouteSetEntryCollection"), "RouteSetEntryCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of RouteSetEntryCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteSetEntryCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return RouteSetEntryCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteSetEntryCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_RouteSetEntryCollection_JSON (*((EFI_REDFISH_ROUTESETENTRYCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in RouteSetEntryCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteSetEntryCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ROUTESETENTRYCOLLECTION *RouteSetEntryCollection; + + RouteSetEntryCollection = (EFI_REDFISH_ROUTESETENTRYCOLLECTION *)InterpProp; + DestroyRouteSetEntryCollection_CS (RouteSetEntryCollection->RouteSetEntryCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from RouteSetEntryCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +RouteSetEntryCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyRouteSetEntryCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishRouteSetEntryCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + RouteSetEntryCollectionToStructWrapper, + RouteSetEntryCollectionToJson, + RouteSetEntryCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishRouteSetEntryCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SecureBoot/v1_0_0/RedfishSecureBoot_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/SecureBoot/v1_0_0/RedfishSecureBoot_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..5e3b75c841b --- /dev/null +++ b/RedfishClientPkg/Converter/SecureBoot/v1_0_0/RedfishSecureBoot_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SecureBoot.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSecureBoot_V1_0_0_Dxe + FILE_GUID = a281675c-9a79-4fdc-99b1-131eceda28a6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSecureBoot_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishSecureBoot_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SecureBoot_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SecureBootV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SecureBoot/v1_0_0/SecureBoot_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/SecureBoot/v1_0_0/SecureBoot_V1_0_0_Dxe.c new file mode 100644 index 00000000000..612b1118b01 --- /dev/null +++ b/RedfishClientPkg/Converter/SecureBoot/v1_0_0/SecureBoot_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SecureBoot.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SecureBoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support SecureBoot V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SecureBoot", + "1", + "0", + "0" + }, + "SecureBoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SECUREBOOT_V1_0_0 *SecureBootV1_0_0; + EFI_REDFISH_SECUREBOOT_V1_0_0_CS *SecureBootV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SecureBoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SecureBoot_V1_0_0_To_CS (ResoruceRaw, &SecureBootV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SecureBootV1_0_0 = (EFI_REDFISH_SECUREBOOT_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SECUREBOOT_V1_0_0)); + if (SecureBootV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SecureBootV1_0_0; + SecureBootV1_0_0->SecureBoot = SecureBootV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SecureBoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SecureBoot"), "SecureBoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SecureBoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SecureBoot"), "SecureBoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SecureBootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SecureBootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SecureBoot_V1_0_0_JSON (*((EFI_REDFISH_SECUREBOOT_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SecureBootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SECUREBOOT_V1_0_0 *SecureBootV1_0_0; + + SecureBootV1_0_0 = (EFI_REDFISH_SECUREBOOT_V1_0_0 *)InterpProp; + DestroySecureBoot_V1_0_0_CS (SecureBootV1_0_0->SecureBoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SecureBootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySecureBoot_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSecureBoot_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SecureBootToStructWrapper, + SecureBootToJson, + SecureBootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSecureBoot_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SecureBoot/v1_0_1/RedfishSecureBoot_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/SecureBoot/v1_0_1/RedfishSecureBoot_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..6ca245ac1d2 --- /dev/null +++ b/RedfishClientPkg/Converter/SecureBoot/v1_0_1/RedfishSecureBoot_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SecureBoot.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSecureBoot_V1_0_1_Dxe + FILE_GUID = de129526-adcb-44c0-beb3-4ca0a9aac5f5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSecureBoot_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishSecureBoot_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SecureBoot_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SecureBootV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SecureBoot/v1_0_1/SecureBoot_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/SecureBoot/v1_0_1/SecureBoot_V1_0_1_Dxe.c new file mode 100644 index 00000000000..a5f4b1e962d --- /dev/null +++ b/RedfishClientPkg/Converter/SecureBoot/v1_0_1/SecureBoot_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SecureBoot.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SecureBoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support SecureBoot V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SecureBoot", + "1", + "0", + "1" + }, + "SecureBoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SECUREBOOT_V1_0_1 *SecureBootV1_0_1; + EFI_REDFISH_SECUREBOOT_V1_0_1_CS *SecureBootV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SecureBoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SecureBoot_V1_0_1_To_CS (ResoruceRaw, &SecureBootV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SecureBootV1_0_1 = (EFI_REDFISH_SECUREBOOT_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SECUREBOOT_V1_0_1)); + if (SecureBootV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SecureBootV1_0_1; + SecureBootV1_0_1->SecureBoot = SecureBootV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SecureBoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SecureBoot"), "SecureBoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SecureBoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SecureBoot"), "SecureBoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SecureBootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SecureBootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SecureBoot_V1_0_1_JSON (*((EFI_REDFISH_SECUREBOOT_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SecureBootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SECUREBOOT_V1_0_1 *SecureBootV1_0_1; + + SecureBootV1_0_1 = (EFI_REDFISH_SECUREBOOT_V1_0_1 *)InterpProp; + DestroySecureBoot_V1_0_1_CS (SecureBootV1_0_1->SecureBoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SecureBootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySecureBoot_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSecureBoot_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SecureBootToStructWrapper, + SecureBootToJson, + SecureBootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSecureBoot_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SecureBoot/v1_0_2/RedfishSecureBoot_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/SecureBoot/v1_0_2/RedfishSecureBoot_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..0b2dd1ec466 --- /dev/null +++ b/RedfishClientPkg/Converter/SecureBoot/v1_0_2/RedfishSecureBoot_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SecureBoot.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSecureBoot_V1_0_2_Dxe + FILE_GUID = a84c3b66-6507-4a78-8585-bb5a1cf73a89 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSecureBoot_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishSecureBoot_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SecureBoot_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SecureBootV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SecureBoot/v1_0_2/SecureBoot_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/SecureBoot/v1_0_2/SecureBoot_V1_0_2_Dxe.c new file mode 100644 index 00000000000..ed97f22887d --- /dev/null +++ b/RedfishClientPkg/Converter/SecureBoot/v1_0_2/SecureBoot_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SecureBoot.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SecureBoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support SecureBoot V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SecureBoot", + "1", + "0", + "2" + }, + "SecureBoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SECUREBOOT_V1_0_2 *SecureBootV1_0_2; + EFI_REDFISH_SECUREBOOT_V1_0_2_CS *SecureBootV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SecureBoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SecureBoot_V1_0_2_To_CS (ResoruceRaw, &SecureBootV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SecureBootV1_0_2 = (EFI_REDFISH_SECUREBOOT_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SECUREBOOT_V1_0_2)); + if (SecureBootV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SecureBootV1_0_2; + SecureBootV1_0_2->SecureBoot = SecureBootV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SecureBoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SecureBoot"), "SecureBoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SecureBoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SecureBoot"), "SecureBoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SecureBootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SecureBootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SecureBoot_V1_0_2_JSON (*((EFI_REDFISH_SECUREBOOT_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SecureBootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SECUREBOOT_V1_0_2 *SecureBootV1_0_2; + + SecureBootV1_0_2 = (EFI_REDFISH_SECUREBOOT_V1_0_2 *)InterpProp; + DestroySecureBoot_V1_0_2_CS (SecureBootV1_0_2->SecureBoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SecureBootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySecureBoot_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSecureBoot_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SecureBootToStructWrapper, + SecureBootToJson, + SecureBootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSecureBoot_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SecureBoot/v1_0_3/RedfishSecureBoot_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/SecureBoot/v1_0_3/RedfishSecureBoot_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..f6271ebe94f --- /dev/null +++ b/RedfishClientPkg/Converter/SecureBoot/v1_0_3/RedfishSecureBoot_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SecureBoot.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSecureBoot_V1_0_3_Dxe + FILE_GUID = 1379b02c-bf64-4c2f-a5db-1fe0c0cedca6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSecureBoot_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishSecureBoot_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SecureBoot_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SecureBootV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SecureBoot/v1_0_3/SecureBoot_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/SecureBoot/v1_0_3/SecureBoot_V1_0_3_Dxe.c new file mode 100644 index 00000000000..c6c6d15e952 --- /dev/null +++ b/RedfishClientPkg/Converter/SecureBoot/v1_0_3/SecureBoot_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SecureBoot.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SecureBoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support SecureBoot V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SecureBoot", + "1", + "0", + "3" + }, + "SecureBoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SECUREBOOT_V1_0_3 *SecureBootV1_0_3; + EFI_REDFISH_SECUREBOOT_V1_0_3_CS *SecureBootV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SecureBoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SecureBoot_V1_0_3_To_CS (ResoruceRaw, &SecureBootV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SecureBootV1_0_3 = (EFI_REDFISH_SECUREBOOT_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SECUREBOOT_V1_0_3)); + if (SecureBootV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SecureBootV1_0_3; + SecureBootV1_0_3->SecureBoot = SecureBootV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SecureBoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SecureBoot"), "SecureBoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SecureBoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SecureBoot"), "SecureBoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SecureBootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SecureBootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SecureBoot_V1_0_3_JSON (*((EFI_REDFISH_SECUREBOOT_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SecureBootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SECUREBOOT_V1_0_3 *SecureBootV1_0_3; + + SecureBootV1_0_3 = (EFI_REDFISH_SECUREBOOT_V1_0_3 *)InterpProp; + DestroySecureBoot_V1_0_3_CS (SecureBootV1_0_3->SecureBoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SecureBootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySecureBoot_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSecureBoot_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SecureBootToStructWrapper, + SecureBootToJson, + SecureBootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSecureBoot_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SecureBoot/v1_0_4/RedfishSecureBoot_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/SecureBoot/v1_0_4/RedfishSecureBoot_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..e21b9d5b4ef --- /dev/null +++ b/RedfishClientPkg/Converter/SecureBoot/v1_0_4/RedfishSecureBoot_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SecureBoot.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSecureBoot_V1_0_4_Dxe + FILE_GUID = 13a15a7a-d254-4cc7-ba57-8c4ce5d3a5b2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSecureBoot_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishSecureBoot_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SecureBoot_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SecureBootV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SecureBoot/v1_0_4/SecureBoot_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/SecureBoot/v1_0_4/SecureBoot_V1_0_4_Dxe.c new file mode 100644 index 00000000000..5cf1cdbd50b --- /dev/null +++ b/RedfishClientPkg/Converter/SecureBoot/v1_0_4/SecureBoot_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SecureBoot.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SecureBoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support SecureBoot V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SecureBoot", + "1", + "0", + "4" + }, + "SecureBoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SECUREBOOT_V1_0_4 *SecureBootV1_0_4; + EFI_REDFISH_SECUREBOOT_V1_0_4_CS *SecureBootV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SecureBoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SecureBoot_V1_0_4_To_CS (ResoruceRaw, &SecureBootV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SecureBootV1_0_4 = (EFI_REDFISH_SECUREBOOT_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SECUREBOOT_V1_0_4)); + if (SecureBootV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SecureBootV1_0_4; + SecureBootV1_0_4->SecureBoot = SecureBootV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SecureBoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SecureBoot"), "SecureBoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SecureBoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SecureBoot"), "SecureBoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SecureBootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SecureBootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SecureBoot_V1_0_4_JSON (*((EFI_REDFISH_SECUREBOOT_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SecureBootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SECUREBOOT_V1_0_4 *SecureBootV1_0_4; + + SecureBootV1_0_4 = (EFI_REDFISH_SECUREBOOT_V1_0_4 *)InterpProp; + DestroySecureBoot_V1_0_4_CS (SecureBootV1_0_4->SecureBoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SecureBootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySecureBoot_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSecureBoot_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SecureBootToStructWrapper, + SecureBootToJson, + SecureBootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSecureBoot_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SecureBoot/v1_0_5/RedfishSecureBoot_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/SecureBoot/v1_0_5/RedfishSecureBoot_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..d875b2b4d9b --- /dev/null +++ b/RedfishClientPkg/Converter/SecureBoot/v1_0_5/RedfishSecureBoot_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SecureBoot.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSecureBoot_V1_0_5_Dxe + FILE_GUID = d61a0317-0a6e-4b54-801f-7aeb85c511ee + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSecureBoot_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishSecureBoot_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SecureBoot_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SecureBootV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SecureBoot/v1_0_5/SecureBoot_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/SecureBoot/v1_0_5/SecureBoot_V1_0_5_Dxe.c new file mode 100644 index 00000000000..81a78976fbd --- /dev/null +++ b/RedfishClientPkg/Converter/SecureBoot/v1_0_5/SecureBoot_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SecureBoot.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SecureBoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support SecureBoot V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SecureBoot", + "1", + "0", + "5" + }, + "SecureBoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SECUREBOOT_V1_0_5 *SecureBootV1_0_5; + EFI_REDFISH_SECUREBOOT_V1_0_5_CS *SecureBootV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SecureBoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SecureBoot_V1_0_5_To_CS (ResoruceRaw, &SecureBootV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SecureBootV1_0_5 = (EFI_REDFISH_SECUREBOOT_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SECUREBOOT_V1_0_5)); + if (SecureBootV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SecureBootV1_0_5; + SecureBootV1_0_5->SecureBoot = SecureBootV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SecureBoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SecureBoot"), "SecureBoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SecureBoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SecureBoot"), "SecureBoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SecureBootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SecureBootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SecureBoot_V1_0_5_JSON (*((EFI_REDFISH_SECUREBOOT_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SecureBootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SECUREBOOT_V1_0_5 *SecureBootV1_0_5; + + SecureBootV1_0_5 = (EFI_REDFISH_SECUREBOOT_V1_0_5 *)InterpProp; + DestroySecureBoot_V1_0_5_CS (SecureBootV1_0_5->SecureBoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SecureBootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySecureBoot_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSecureBoot_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SecureBootToStructWrapper, + SecureBootToJson, + SecureBootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSecureBoot_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SecureBoot/v1_0_6/RedfishSecureBoot_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/SecureBoot/v1_0_6/RedfishSecureBoot_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..020b49ddd07 --- /dev/null +++ b/RedfishClientPkg/Converter/SecureBoot/v1_0_6/RedfishSecureBoot_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SecureBoot.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSecureBoot_V1_0_6_Dxe + FILE_GUID = b15bc8a1-6d4b-4f09-a512-ce16467b4e85 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSecureBoot_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishSecureBoot_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SecureBoot_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SecureBootV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SecureBoot/v1_0_6/SecureBoot_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/SecureBoot/v1_0_6/SecureBoot_V1_0_6_Dxe.c new file mode 100644 index 00000000000..4f30cd1bc74 --- /dev/null +++ b/RedfishClientPkg/Converter/SecureBoot/v1_0_6/SecureBoot_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SecureBoot.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SecureBoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support SecureBoot V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SecureBoot", + "1", + "0", + "6" + }, + "SecureBoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SECUREBOOT_V1_0_6 *SecureBootV1_0_6; + EFI_REDFISH_SECUREBOOT_V1_0_6_CS *SecureBootV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SecureBoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SecureBoot_V1_0_6_To_CS (ResoruceRaw, &SecureBootV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SecureBootV1_0_6 = (EFI_REDFISH_SECUREBOOT_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SECUREBOOT_V1_0_6)); + if (SecureBootV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SecureBootV1_0_6; + SecureBootV1_0_6->SecureBoot = SecureBootV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SecureBoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SecureBoot"), "SecureBoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SecureBoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SecureBoot"), "SecureBoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SecureBootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SecureBootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SecureBoot_V1_0_6_JSON (*((EFI_REDFISH_SECUREBOOT_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SecureBootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SECUREBOOT_V1_0_6 *SecureBootV1_0_6; + + SecureBootV1_0_6 = (EFI_REDFISH_SECUREBOOT_V1_0_6 *)InterpProp; + DestroySecureBoot_V1_0_6_CS (SecureBootV1_0_6->SecureBoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SecureBootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySecureBoot_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSecureBoot_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SecureBootToStructWrapper, + SecureBootToJson, + SecureBootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSecureBoot_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SecureBoot/v1_0_7/RedfishSecureBoot_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/SecureBoot/v1_0_7/RedfishSecureBoot_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..55fa3720694 --- /dev/null +++ b/RedfishClientPkg/Converter/SecureBoot/v1_0_7/RedfishSecureBoot_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SecureBoot.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSecureBoot_V1_0_7_Dxe + FILE_GUID = ae231899-608b-4870-97b3-ac6e84e70039 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSecureBoot_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishSecureBoot_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SecureBoot_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SecureBootV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SecureBoot/v1_0_7/SecureBoot_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/SecureBoot/v1_0_7/SecureBoot_V1_0_7_Dxe.c new file mode 100644 index 00000000000..ddb273538b0 --- /dev/null +++ b/RedfishClientPkg/Converter/SecureBoot/v1_0_7/SecureBoot_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SecureBoot.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SecureBoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support SecureBoot V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SecureBoot", + "1", + "0", + "7" + }, + "SecureBoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SECUREBOOT_V1_0_7 *SecureBootV1_0_7; + EFI_REDFISH_SECUREBOOT_V1_0_7_CS *SecureBootV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SecureBoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SecureBoot_V1_0_7_To_CS (ResoruceRaw, &SecureBootV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SecureBootV1_0_7 = (EFI_REDFISH_SECUREBOOT_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SECUREBOOT_V1_0_7)); + if (SecureBootV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SecureBootV1_0_7; + SecureBootV1_0_7->SecureBoot = SecureBootV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SecureBoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SecureBoot"), "SecureBoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SecureBoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SecureBoot"), "SecureBoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SecureBootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SecureBootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SecureBoot_V1_0_7_JSON (*((EFI_REDFISH_SECUREBOOT_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SecureBootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SECUREBOOT_V1_0_7 *SecureBootV1_0_7; + + SecureBootV1_0_7 = (EFI_REDFISH_SECUREBOOT_V1_0_7 *)InterpProp; + DestroySecureBoot_V1_0_7_CS (SecureBootV1_0_7->SecureBoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SecureBootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySecureBoot_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSecureBoot_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SecureBootToStructWrapper, + SecureBootToJson, + SecureBootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSecureBoot_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SecureBoot/v1_1_0/RedfishSecureBoot_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/SecureBoot/v1_1_0/RedfishSecureBoot_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..e86c6cd045c --- /dev/null +++ b/RedfishClientPkg/Converter/SecureBoot/v1_1_0/RedfishSecureBoot_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SecureBoot.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSecureBoot_V1_1_0_Dxe + FILE_GUID = 8828c968-bd18-4fb6-aee9-844bf925a198 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSecureBoot_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishSecureBoot_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SecureBoot_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SecureBootV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SecureBoot/v1_1_0/SecureBoot_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/SecureBoot/v1_1_0/SecureBoot_V1_1_0_Dxe.c new file mode 100644 index 00000000000..848ff407345 --- /dev/null +++ b/RedfishClientPkg/Converter/SecureBoot/v1_1_0/SecureBoot_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SecureBoot.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SecureBoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support SecureBoot V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SecureBoot", + "1", + "1", + "0" + }, + "SecureBoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SECUREBOOT_V1_1_0 *SecureBootV1_1_0; + EFI_REDFISH_SECUREBOOT_V1_1_0_CS *SecureBootV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SecureBoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SecureBoot_V1_1_0_To_CS (ResoruceRaw, &SecureBootV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SecureBootV1_1_0 = (EFI_REDFISH_SECUREBOOT_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SECUREBOOT_V1_1_0)); + if (SecureBootV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SecureBootV1_1_0; + SecureBootV1_1_0->SecureBoot = SecureBootV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SecureBoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SecureBoot"), "SecureBoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SecureBoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SecureBoot"), "SecureBoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SecureBootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SecureBootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SecureBoot_V1_1_0_JSON (*((EFI_REDFISH_SECUREBOOT_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SecureBootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SECUREBOOT_V1_1_0 *SecureBootV1_1_0; + + SecureBootV1_1_0 = (EFI_REDFISH_SECUREBOOT_V1_1_0 *)InterpProp; + DestroySecureBoot_V1_1_0_CS (SecureBootV1_1_0->SecureBoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SecureBootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySecureBoot_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSecureBoot_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SecureBootToStructWrapper, + SecureBootToJson, + SecureBootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSecureBoot_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SecureBootDatabase/v1_0_0/RedfishSecureBootDatabase_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/SecureBootDatabase/v1_0_0/RedfishSecureBootDatabase_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..f840297891b --- /dev/null +++ b/RedfishClientPkg/Converter/SecureBootDatabase/v1_0_0/RedfishSecureBootDatabase_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SecureBootDatabase.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSecureBootDatabase_V1_0_0_Dxe + FILE_GUID = f7a5692f-e411-4c63-bde2-bd9a78ac2441 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSecureBootDatabase_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishSecureBootDatabase_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SecureBootDatabase_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SecureBootDatabaseV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SecureBootDatabase/v1_0_0/SecureBootDatabase_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/SecureBootDatabase/v1_0_0/SecureBootDatabase_V1_0_0_Dxe.c new file mode 100644 index 00000000000..77a0cbe331c --- /dev/null +++ b/RedfishClientPkg/Converter/SecureBootDatabase/v1_0_0/SecureBootDatabase_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SecureBootDatabase.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SecureBootDatabase"; +BOOLEAN IsRevisonController = TRUE; + +// Support SecureBootDatabase V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SecureBootDatabase", + "1", + "0", + "0" + }, + "SecureBootDatabase" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDatabaseToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SECUREBOOTDATABASE_V1_0_0 *SecureBootDatabaseV1_0_0; + EFI_REDFISH_SECUREBOOTDATABASE_V1_0_0_CS *SecureBootDatabaseV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SecureBootDatabase") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SecureBootDatabase_V1_0_0_To_CS (ResoruceRaw, &SecureBootDatabaseV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SecureBootDatabaseV1_0_0 = (EFI_REDFISH_SECUREBOOTDATABASE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SECUREBOOTDATABASE_V1_0_0)); + if (SecureBootDatabaseV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SecureBootDatabaseV1_0_0; + SecureBootDatabaseV1_0_0->SecureBootDatabase = SecureBootDatabaseV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SecureBootDatabase")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SecureBootDatabase"), "SecureBootDatabase"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SecureBootDatabase")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SecureBootDatabase"), "SecureBootDatabase"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SecureBootDatabaseToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDatabaseToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SecureBootDatabaseToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDatabaseToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SecureBootDatabase_V1_0_0_JSON (*((EFI_REDFISH_SECUREBOOTDATABASE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SecureBootDatabaseToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDatabaseDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SECUREBOOTDATABASE_V1_0_0 *SecureBootDatabaseV1_0_0; + + SecureBootDatabaseV1_0_0 = (EFI_REDFISH_SECUREBOOTDATABASE_V1_0_0 *)InterpProp; + DestroySecureBootDatabase_V1_0_0_CS (SecureBootDatabaseV1_0_0->SecureBootDatabase); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SecureBootDatabaseFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDatabaseDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySecureBootDatabase_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSecureBootDatabase_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SecureBootDatabaseToStructWrapper, + SecureBootDatabaseToJson, + SecureBootDatabaseDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSecureBootDatabase_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SecureBootDatabaseCollection/RedfishSecureBootDatabaseCollection_Dxe.inf b/RedfishClientPkg/Converter/SecureBootDatabaseCollection/RedfishSecureBootDatabaseCollection_Dxe.inf new file mode 100644 index 00000000000..ccbb2f3b040 --- /dev/null +++ b/RedfishClientPkg/Converter/SecureBootDatabaseCollection/RedfishSecureBootDatabaseCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SecureBootDatabaseCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSecureBootDatabaseCollection_Dxe + FILE_GUID = d15763d0-2ee1-42aa-a5c1-76810c15ea31 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSecureBootDatabaseCollectionEntryPoint + UNLOAD_IMAGE = RedfishSecureBootDatabaseCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SecureBootDatabaseCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SecureBootDatabaseCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SecureBootDatabaseCollection/SecureBootDatabaseCollection_Dxe.c b/RedfishClientPkg/Converter/SecureBootDatabaseCollection/SecureBootDatabaseCollection_Dxe.c new file mode 100644 index 00000000000..bff29824663 --- /dev/null +++ b/RedfishClientPkg/Converter/SecureBootDatabaseCollection/SecureBootDatabaseCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SecureBootDatabaseCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SecureBootDatabaseCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support SecureBootDatabaseCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SecureBootDatabaseCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "SecureBootDatabaseCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDatabaseCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SECUREBOOTDATABASECOLLECTION *SecureBootDatabaseCollection; + EFI_REDFISH_SECUREBOOTDATABASECOLLECTION_CS *SecureBootDatabaseCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SecureBootDatabaseCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SecureBootDatabaseCollection_To_CS (ResoruceRaw, &SecureBootDatabaseCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + SecureBootDatabaseCollection = (EFI_REDFISH_SECUREBOOTDATABASECOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SECUREBOOTDATABASECOLLECTION)); + if (SecureBootDatabaseCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SecureBootDatabaseCollection; + SecureBootDatabaseCollection->SecureBootDatabaseCollection = SecureBootDatabaseCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SecureBootDatabaseCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SecureBootDatabaseCollection"), "SecureBootDatabaseCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SecureBootDatabaseCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SecureBootDatabaseCollection"), "SecureBootDatabaseCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SecureBootDatabaseCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDatabaseCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SecureBootDatabaseCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDatabaseCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SecureBootDatabaseCollection_JSON (*((EFI_REDFISH_SECUREBOOTDATABASECOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SecureBootDatabaseCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDatabaseCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SECUREBOOTDATABASECOLLECTION *SecureBootDatabaseCollection; + + SecureBootDatabaseCollection = (EFI_REDFISH_SECUREBOOTDATABASECOLLECTION *)InterpProp; + DestroySecureBootDatabaseCollection_CS (SecureBootDatabaseCollection->SecureBootDatabaseCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SecureBootDatabaseCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SecureBootDatabaseCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySecureBootDatabaseCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSecureBootDatabaseCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SecureBootDatabaseCollectionToStructWrapper, + SecureBootDatabaseCollectionToJson, + SecureBootDatabaseCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSecureBootDatabaseCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Sensor/v1_0_0/RedfishSensor_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Sensor/v1_0_0/RedfishSensor_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..d31d9fbe356 --- /dev/null +++ b/RedfishClientPkg/Converter/Sensor/v1_0_0/RedfishSensor_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Sensor.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSensor_V1_0_0_Dxe + FILE_GUID = 543f3305-4cd3-4502-9a24-133ee8cd56cc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSensor_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishSensor_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Sensor_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SensorV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Sensor/v1_0_0/Sensor_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Sensor/v1_0_0/Sensor_V1_0_0_Dxe.c new file mode 100644 index 00000000000..49b5e058863 --- /dev/null +++ b/RedfishClientPkg/Converter/Sensor/v1_0_0/Sensor_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Sensor.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Sensor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Sensor V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Sensor", + "1", + "0", + "0" + }, + "Sensor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SENSOR_V1_0_0 *SensorV1_0_0; + EFI_REDFISH_SENSOR_V1_0_0_CS *SensorV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Sensor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Sensor_V1_0_0_To_CS (ResoruceRaw, &SensorV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SensorV1_0_0 = (EFI_REDFISH_SENSOR_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SENSOR_V1_0_0)); + if (SensorV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SensorV1_0_0; + SensorV1_0_0->Sensor = SensorV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Sensor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Sensor"), "Sensor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Sensor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Sensor"), "Sensor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SensorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SensorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Sensor_V1_0_0_JSON (*((EFI_REDFISH_SENSOR_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SensorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SENSOR_V1_0_0 *SensorV1_0_0; + + SensorV1_0_0 = (EFI_REDFISH_SENSOR_V1_0_0 *)InterpProp; + DestroySensor_V1_0_0_CS (SensorV1_0_0->Sensor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SensorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySensor_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSensor_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SensorToStructWrapper, + SensorToJson, + SensorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSensor_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Sensor/v1_0_1/RedfishSensor_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/Sensor/v1_0_1/RedfishSensor_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..6637d58c79a --- /dev/null +++ b/RedfishClientPkg/Converter/Sensor/v1_0_1/RedfishSensor_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Sensor.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSensor_V1_0_1_Dxe + FILE_GUID = 20f97b8f-4b51-4cf0-bed8-679a1e7e8fcc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSensor_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishSensor_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Sensor_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SensorV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Sensor/v1_0_1/Sensor_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/Sensor/v1_0_1/Sensor_V1_0_1_Dxe.c new file mode 100644 index 00000000000..625e251853c --- /dev/null +++ b/RedfishClientPkg/Converter/Sensor/v1_0_1/Sensor_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Sensor.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Sensor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Sensor V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Sensor", + "1", + "0", + "1" + }, + "Sensor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SENSOR_V1_0_1 *SensorV1_0_1; + EFI_REDFISH_SENSOR_V1_0_1_CS *SensorV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Sensor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Sensor_V1_0_1_To_CS (ResoruceRaw, &SensorV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SensorV1_0_1 = (EFI_REDFISH_SENSOR_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SENSOR_V1_0_1)); + if (SensorV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SensorV1_0_1; + SensorV1_0_1->Sensor = SensorV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Sensor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Sensor"), "Sensor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Sensor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Sensor"), "Sensor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SensorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SensorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Sensor_V1_0_1_JSON (*((EFI_REDFISH_SENSOR_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SensorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SENSOR_V1_0_1 *SensorV1_0_1; + + SensorV1_0_1 = (EFI_REDFISH_SENSOR_V1_0_1 *)InterpProp; + DestroySensor_V1_0_1_CS (SensorV1_0_1->Sensor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SensorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySensor_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSensor_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SensorToStructWrapper, + SensorToJson, + SensorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSensor_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Sensor/v1_0_2/RedfishSensor_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Sensor/v1_0_2/RedfishSensor_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..ddd38e16b96 --- /dev/null +++ b/RedfishClientPkg/Converter/Sensor/v1_0_2/RedfishSensor_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Sensor.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSensor_V1_0_2_Dxe + FILE_GUID = 8fd13035-732c-41f8-9e9d-381803b6f36f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSensor_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishSensor_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Sensor_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SensorV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Sensor/v1_0_2/Sensor_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Sensor/v1_0_2/Sensor_V1_0_2_Dxe.c new file mode 100644 index 00000000000..04b6130ad22 --- /dev/null +++ b/RedfishClientPkg/Converter/Sensor/v1_0_2/Sensor_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Sensor.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Sensor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Sensor V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Sensor", + "1", + "0", + "2" + }, + "Sensor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SENSOR_V1_0_2 *SensorV1_0_2; + EFI_REDFISH_SENSOR_V1_0_2_CS *SensorV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Sensor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Sensor_V1_0_2_To_CS (ResoruceRaw, &SensorV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SensorV1_0_2 = (EFI_REDFISH_SENSOR_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SENSOR_V1_0_2)); + if (SensorV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SensorV1_0_2; + SensorV1_0_2->Sensor = SensorV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Sensor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Sensor"), "Sensor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Sensor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Sensor"), "Sensor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SensorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SensorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Sensor_V1_0_2_JSON (*((EFI_REDFISH_SENSOR_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SensorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SENSOR_V1_0_2 *SensorV1_0_2; + + SensorV1_0_2 = (EFI_REDFISH_SENSOR_V1_0_2 *)InterpProp; + DestroySensor_V1_0_2_CS (SensorV1_0_2->Sensor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SensorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySensor_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSensor_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SensorToStructWrapper, + SensorToJson, + SensorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSensor_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Sensor/v1_0_3/RedfishSensor_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/Sensor/v1_0_3/RedfishSensor_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..cc7664bb9be --- /dev/null +++ b/RedfishClientPkg/Converter/Sensor/v1_0_3/RedfishSensor_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Sensor.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSensor_V1_0_3_Dxe + FILE_GUID = 5566be02-f261-4912-a957-6b78043768fd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSensor_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishSensor_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Sensor_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SensorV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Sensor/v1_0_3/Sensor_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/Sensor/v1_0_3/Sensor_V1_0_3_Dxe.c new file mode 100644 index 00000000000..cab3469e798 --- /dev/null +++ b/RedfishClientPkg/Converter/Sensor/v1_0_3/Sensor_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Sensor.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Sensor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Sensor V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Sensor", + "1", + "0", + "3" + }, + "Sensor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SENSOR_V1_0_3 *SensorV1_0_3; + EFI_REDFISH_SENSOR_V1_0_3_CS *SensorV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Sensor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Sensor_V1_0_3_To_CS (ResoruceRaw, &SensorV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SensorV1_0_3 = (EFI_REDFISH_SENSOR_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SENSOR_V1_0_3)); + if (SensorV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SensorV1_0_3; + SensorV1_0_3->Sensor = SensorV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Sensor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Sensor"), "Sensor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Sensor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Sensor"), "Sensor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SensorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SensorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Sensor_V1_0_3_JSON (*((EFI_REDFISH_SENSOR_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SensorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SENSOR_V1_0_3 *SensorV1_0_3; + + SensorV1_0_3 = (EFI_REDFISH_SENSOR_V1_0_3 *)InterpProp; + DestroySensor_V1_0_3_CS (SensorV1_0_3->Sensor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SensorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySensor_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSensor_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SensorToStructWrapper, + SensorToJson, + SensorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSensor_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Sensor/v1_0_4/RedfishSensor_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/Sensor/v1_0_4/RedfishSensor_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..b69921121cd --- /dev/null +++ b/RedfishClientPkg/Converter/Sensor/v1_0_4/RedfishSensor_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Sensor.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSensor_V1_0_4_Dxe + FILE_GUID = caef8bb9-8692-49fd-b399-a69536c9eb6d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSensor_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishSensor_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Sensor_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SensorV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Sensor/v1_0_4/Sensor_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/Sensor/v1_0_4/Sensor_V1_0_4_Dxe.c new file mode 100644 index 00000000000..f0a256fe0cb --- /dev/null +++ b/RedfishClientPkg/Converter/Sensor/v1_0_4/Sensor_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Sensor.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Sensor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Sensor V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Sensor", + "1", + "0", + "4" + }, + "Sensor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SENSOR_V1_0_4 *SensorV1_0_4; + EFI_REDFISH_SENSOR_V1_0_4_CS *SensorV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Sensor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Sensor_V1_0_4_To_CS (ResoruceRaw, &SensorV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SensorV1_0_4 = (EFI_REDFISH_SENSOR_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SENSOR_V1_0_4)); + if (SensorV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SensorV1_0_4; + SensorV1_0_4->Sensor = SensorV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Sensor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Sensor"), "Sensor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Sensor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Sensor"), "Sensor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SensorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SensorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Sensor_V1_0_4_JSON (*((EFI_REDFISH_SENSOR_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SensorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SENSOR_V1_0_4 *SensorV1_0_4; + + SensorV1_0_4 = (EFI_REDFISH_SENSOR_V1_0_4 *)InterpProp; + DestroySensor_V1_0_4_CS (SensorV1_0_4->Sensor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SensorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySensor_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSensor_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SensorToStructWrapper, + SensorToJson, + SensorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSensor_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Sensor/v1_0_5/RedfishSensor_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/Sensor/v1_0_5/RedfishSensor_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..60f6433c57c --- /dev/null +++ b/RedfishClientPkg/Converter/Sensor/v1_0_5/RedfishSensor_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Sensor.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSensor_V1_0_5_Dxe + FILE_GUID = 7fd215e9-2815-4201-9fd3-f45ce25370dc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSensor_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishSensor_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Sensor_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SensorV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Sensor/v1_0_5/Sensor_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/Sensor/v1_0_5/Sensor_V1_0_5_Dxe.c new file mode 100644 index 00000000000..a79c8da3547 --- /dev/null +++ b/RedfishClientPkg/Converter/Sensor/v1_0_5/Sensor_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Sensor.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Sensor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Sensor V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Sensor", + "1", + "0", + "5" + }, + "Sensor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SENSOR_V1_0_5 *SensorV1_0_5; + EFI_REDFISH_SENSOR_V1_0_5_CS *SensorV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Sensor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Sensor_V1_0_5_To_CS (ResoruceRaw, &SensorV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SensorV1_0_5 = (EFI_REDFISH_SENSOR_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SENSOR_V1_0_5)); + if (SensorV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SensorV1_0_5; + SensorV1_0_5->Sensor = SensorV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Sensor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Sensor"), "Sensor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Sensor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Sensor"), "Sensor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SensorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SensorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Sensor_V1_0_5_JSON (*((EFI_REDFISH_SENSOR_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SensorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SENSOR_V1_0_5 *SensorV1_0_5; + + SensorV1_0_5 = (EFI_REDFISH_SENSOR_V1_0_5 *)InterpProp; + DestroySensor_V1_0_5_CS (SensorV1_0_5->Sensor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SensorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySensor_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSensor_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SensorToStructWrapper, + SensorToJson, + SensorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSensor_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Sensor/v1_0_6/RedfishSensor_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/Sensor/v1_0_6/RedfishSensor_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..7bb3d732c30 --- /dev/null +++ b/RedfishClientPkg/Converter/Sensor/v1_0_6/RedfishSensor_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Sensor.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSensor_V1_0_6_Dxe + FILE_GUID = 41024802-128f-461e-ac85-865613fa6c55 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSensor_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishSensor_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Sensor_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SensorV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Sensor/v1_0_6/Sensor_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/Sensor/v1_0_6/Sensor_V1_0_6_Dxe.c new file mode 100644 index 00000000000..c8deeb83499 --- /dev/null +++ b/RedfishClientPkg/Converter/Sensor/v1_0_6/Sensor_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Sensor.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Sensor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Sensor V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Sensor", + "1", + "0", + "6" + }, + "Sensor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SENSOR_V1_0_6 *SensorV1_0_6; + EFI_REDFISH_SENSOR_V1_0_6_CS *SensorV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Sensor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Sensor_V1_0_6_To_CS (ResoruceRaw, &SensorV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SensorV1_0_6 = (EFI_REDFISH_SENSOR_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SENSOR_V1_0_6)); + if (SensorV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SensorV1_0_6; + SensorV1_0_6->Sensor = SensorV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Sensor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Sensor"), "Sensor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Sensor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Sensor"), "Sensor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SensorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SensorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Sensor_V1_0_6_JSON (*((EFI_REDFISH_SENSOR_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SensorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SENSOR_V1_0_6 *SensorV1_0_6; + + SensorV1_0_6 = (EFI_REDFISH_SENSOR_V1_0_6 *)InterpProp; + DestroySensor_V1_0_6_CS (SensorV1_0_6->Sensor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SensorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySensor_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSensor_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SensorToStructWrapper, + SensorToJson, + SensorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSensor_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Sensor/v1_1_0/RedfishSensor_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/Sensor/v1_1_0/RedfishSensor_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..67a084b4e03 --- /dev/null +++ b/RedfishClientPkg/Converter/Sensor/v1_1_0/RedfishSensor_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Sensor.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSensor_V1_1_0_Dxe + FILE_GUID = f454851a-dee5-4938-8e0d-3ee0754ade30 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSensor_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishSensor_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Sensor_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SensorV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Sensor/v1_1_0/Sensor_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/Sensor/v1_1_0/Sensor_V1_1_0_Dxe.c new file mode 100644 index 00000000000..28d82dfc05f --- /dev/null +++ b/RedfishClientPkg/Converter/Sensor/v1_1_0/Sensor_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Sensor.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Sensor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Sensor V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Sensor", + "1", + "1", + "0" + }, + "Sensor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SENSOR_V1_1_0 *SensorV1_1_0; + EFI_REDFISH_SENSOR_V1_1_0_CS *SensorV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Sensor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Sensor_V1_1_0_To_CS (ResoruceRaw, &SensorV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SensorV1_1_0 = (EFI_REDFISH_SENSOR_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SENSOR_V1_1_0)); + if (SensorV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SensorV1_1_0; + SensorV1_1_0->Sensor = SensorV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Sensor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Sensor"), "Sensor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Sensor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Sensor"), "Sensor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SensorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SensorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Sensor_V1_1_0_JSON (*((EFI_REDFISH_SENSOR_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SensorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SENSOR_V1_1_0 *SensorV1_1_0; + + SensorV1_1_0 = (EFI_REDFISH_SENSOR_V1_1_0 *)InterpProp; + DestroySensor_V1_1_0_CS (SensorV1_1_0->Sensor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SensorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySensor_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSensor_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SensorToStructWrapper, + SensorToJson, + SensorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSensor_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Sensor/v1_1_1/RedfishSensor_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/Sensor/v1_1_1/RedfishSensor_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..334cbe4d5bf --- /dev/null +++ b/RedfishClientPkg/Converter/Sensor/v1_1_1/RedfishSensor_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Sensor.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSensor_V1_1_1_Dxe + FILE_GUID = 58ae4ba2-8847-49c0-b32e-fa9d01e116b3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSensor_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishSensor_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Sensor_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SensorV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Sensor/v1_1_1/Sensor_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/Sensor/v1_1_1/Sensor_V1_1_1_Dxe.c new file mode 100644 index 00000000000..a7875739e46 --- /dev/null +++ b/RedfishClientPkg/Converter/Sensor/v1_1_1/Sensor_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Sensor.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Sensor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Sensor V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Sensor", + "1", + "1", + "1" + }, + "Sensor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SENSOR_V1_1_1 *SensorV1_1_1; + EFI_REDFISH_SENSOR_V1_1_1_CS *SensorV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Sensor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Sensor_V1_1_1_To_CS (ResoruceRaw, &SensorV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SensorV1_1_1 = (EFI_REDFISH_SENSOR_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SENSOR_V1_1_1)); + if (SensorV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SensorV1_1_1; + SensorV1_1_1->Sensor = SensorV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Sensor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Sensor"), "Sensor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Sensor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Sensor"), "Sensor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SensorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SensorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Sensor_V1_1_1_JSON (*((EFI_REDFISH_SENSOR_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SensorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SENSOR_V1_1_1 *SensorV1_1_1; + + SensorV1_1_1 = (EFI_REDFISH_SENSOR_V1_1_1 *)InterpProp; + DestroySensor_V1_1_1_CS (SensorV1_1_1->Sensor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SensorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySensor_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSensor_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SensorToStructWrapper, + SensorToJson, + SensorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSensor_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Sensor/v1_1_2/RedfishSensor_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/Sensor/v1_1_2/RedfishSensor_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..db289ee993f --- /dev/null +++ b/RedfishClientPkg/Converter/Sensor/v1_1_2/RedfishSensor_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Sensor.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSensor_V1_1_2_Dxe + FILE_GUID = 71c235e1-b901-4c48-a7ce-0f9365715527 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSensor_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishSensor_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Sensor_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SensorV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Sensor/v1_1_2/Sensor_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/Sensor/v1_1_2/Sensor_V1_1_2_Dxe.c new file mode 100644 index 00000000000..4924e67c636 --- /dev/null +++ b/RedfishClientPkg/Converter/Sensor/v1_1_2/Sensor_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Sensor.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Sensor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Sensor V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Sensor", + "1", + "1", + "2" + }, + "Sensor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SENSOR_V1_1_2 *SensorV1_1_2; + EFI_REDFISH_SENSOR_V1_1_2_CS *SensorV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Sensor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Sensor_V1_1_2_To_CS (ResoruceRaw, &SensorV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SensorV1_1_2 = (EFI_REDFISH_SENSOR_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SENSOR_V1_1_2)); + if (SensorV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SensorV1_1_2; + SensorV1_1_2->Sensor = SensorV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Sensor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Sensor"), "Sensor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Sensor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Sensor"), "Sensor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SensorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SensorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Sensor_V1_1_2_JSON (*((EFI_REDFISH_SENSOR_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SensorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SENSOR_V1_1_2 *SensorV1_1_2; + + SensorV1_1_2 = (EFI_REDFISH_SENSOR_V1_1_2 *)InterpProp; + DestroySensor_V1_1_2_CS (SensorV1_1_2->Sensor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SensorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySensor_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSensor_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SensorToStructWrapper, + SensorToJson, + SensorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSensor_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Sensor/v1_2_0/RedfishSensor_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/Sensor/v1_2_0/RedfishSensor_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..ea29615f372 --- /dev/null +++ b/RedfishClientPkg/Converter/Sensor/v1_2_0/RedfishSensor_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Sensor.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSensor_V1_2_0_Dxe + FILE_GUID = 805f9cc2-7c9b-4168-b47f-7687aaa708a2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSensor_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishSensor_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Sensor_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SensorV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Sensor/v1_2_0/Sensor_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/Sensor/v1_2_0/Sensor_V1_2_0_Dxe.c new file mode 100644 index 00000000000..92a819a5112 --- /dev/null +++ b/RedfishClientPkg/Converter/Sensor/v1_2_0/Sensor_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Sensor.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Sensor"; +BOOLEAN IsRevisonController = TRUE; + +// Support Sensor V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Sensor", + "1", + "2", + "0" + }, + "Sensor" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SENSOR_V1_2_0 *SensorV1_2_0; + EFI_REDFISH_SENSOR_V1_2_0_CS *SensorV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Sensor") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Sensor_V1_2_0_To_CS (ResoruceRaw, &SensorV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SensorV1_2_0 = (EFI_REDFISH_SENSOR_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SENSOR_V1_2_0)); + if (SensorV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SensorV1_2_0; + SensorV1_2_0->Sensor = SensorV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Sensor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Sensor"), "Sensor"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Sensor")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Sensor"), "Sensor"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SensorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SensorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Sensor_V1_2_0_JSON (*((EFI_REDFISH_SENSOR_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SensorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SENSOR_V1_2_0 *SensorV1_2_0; + + SensorV1_2_0 = (EFI_REDFISH_SENSOR_V1_2_0 *)InterpProp; + DestroySensor_V1_2_0_CS (SensorV1_2_0->Sensor); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SensorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySensor_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSensor_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SensorToStructWrapper, + SensorToJson, + SensorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSensor_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SensorCollection/RedfishSensorCollection_Dxe.inf b/RedfishClientPkg/Converter/SensorCollection/RedfishSensorCollection_Dxe.inf new file mode 100644 index 00000000000..0050a8a95be --- /dev/null +++ b/RedfishClientPkg/Converter/SensorCollection/RedfishSensorCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SensorCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSensorCollection_Dxe + FILE_GUID = 2530eb20-5574-4081-8e1e-1953299b36b1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSensorCollectionEntryPoint + UNLOAD_IMAGE = RedfishSensorCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SensorCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SensorCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SensorCollection/SensorCollection_Dxe.c b/RedfishClientPkg/Converter/SensorCollection/SensorCollection_Dxe.c new file mode 100644 index 00000000000..c4f5eacd15c --- /dev/null +++ b/RedfishClientPkg/Converter/SensorCollection/SensorCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SensorCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SensorCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support SensorCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SensorCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "SensorCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SENSORCOLLECTION *SensorCollection; + EFI_REDFISH_SENSORCOLLECTION_CS *SensorCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SensorCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SensorCollection_To_CS (ResoruceRaw, &SensorCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + SensorCollection = (EFI_REDFISH_SENSORCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SENSORCOLLECTION)); + if (SensorCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SensorCollection; + SensorCollection->SensorCollection = SensorCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SensorCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SensorCollection"), "SensorCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SensorCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SensorCollection"), "SensorCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SensorCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SensorCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SensorCollection_JSON (*((EFI_REDFISH_SENSORCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SensorCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SENSORCOLLECTION *SensorCollection; + + SensorCollection = (EFI_REDFISH_SENSORCOLLECTION *)InterpProp; + DestroySensorCollection_CS (SensorCollection->SensorCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SensorCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SensorCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySensorCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSensorCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SensorCollectionToStructWrapper, + SensorCollectionToJson, + SensorCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSensorCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_0_0/RedfishSerialInterface_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/SerialInterface/v1_0_0/RedfishSerialInterface_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..c9aab546e4e --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_0_0/RedfishSerialInterface_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SerialInterface.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSerialInterface_V1_0_0_Dxe + FILE_GUID = a02095d8-b130-400f-bf22-b8c29a70189d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSerialInterface_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishSerialInterface_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SerialInterface_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SerialInterfaceV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_0_0/SerialInterface_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/SerialInterface/v1_0_0/SerialInterface_V1_0_0_Dxe.c new file mode 100644 index 00000000000..908041f3592 --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_0_0/SerialInterface_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SerialInterface.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SerialInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support SerialInterface V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SerialInterface", + "1", + "0", + "0" + }, + "SerialInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_0_0 *SerialInterfaceV1_0_0; + EFI_REDFISH_SERIALINTERFACE_V1_0_0_CS *SerialInterfaceV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SerialInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SerialInterface_V1_0_0_To_CS (ResoruceRaw, &SerialInterfaceV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SerialInterfaceV1_0_0 = (EFI_REDFISH_SERIALINTERFACE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERIALINTERFACE_V1_0_0)); + if (SerialInterfaceV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SerialInterfaceV1_0_0; + SerialInterfaceV1_0_0->SerialInterface = SerialInterfaceV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SerialInterface"), "SerialInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SerialInterface"), "SerialInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SerialInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SerialInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SerialInterface_V1_0_0_JSON (*((EFI_REDFISH_SERIALINTERFACE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SerialInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_0_0 *SerialInterfaceV1_0_0; + + SerialInterfaceV1_0_0 = (EFI_REDFISH_SERIALINTERFACE_V1_0_0 *)InterpProp; + DestroySerialInterface_V1_0_0_CS (SerialInterfaceV1_0_0->SerialInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SerialInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySerialInterface_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SerialInterfaceToStructWrapper, + SerialInterfaceToJson, + SerialInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_0_10/RedfishSerialInterface_V1_0_10_Dxe.inf b/RedfishClientPkg/Converter/SerialInterface/v1_0_10/RedfishSerialInterface_V1_0_10_Dxe.inf new file mode 100644 index 00000000000..a4e15394242 --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_0_10/RedfishSerialInterface_V1_0_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SerialInterface.v1_0_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSerialInterface_V1_0_10_Dxe + FILE_GUID = 401d2c91-a056-499f-b905-e0b1bfcc609f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSerialInterface_V1_0_10EntryPoint + UNLOAD_IMAGE = RedfishSerialInterface_V1_0_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SerialInterface_V1_0_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SerialInterfaceV1_0_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_0_10/SerialInterface_V1_0_10_Dxe.c b/RedfishClientPkg/Converter/SerialInterface/v1_0_10/SerialInterface_V1_0_10_Dxe.c new file mode 100644 index 00000000000..2b38d92e306 --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_0_10/SerialInterface_V1_0_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SerialInterface.v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SerialInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support SerialInterface V1_0_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SerialInterface", + "1", + "0", + "10" + }, + "SerialInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_0_10 *SerialInterfaceV1_0_10; + EFI_REDFISH_SERIALINTERFACE_V1_0_10_CS *SerialInterfaceV1_0_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SerialInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SerialInterface_V1_0_10_To_CS (ResoruceRaw, &SerialInterfaceV1_0_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SerialInterfaceV1_0_10 = (EFI_REDFISH_SERIALINTERFACE_V1_0_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERIALINTERFACE_V1_0_10)); + if (SerialInterfaceV1_0_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SerialInterfaceV1_0_10; + SerialInterfaceV1_0_10->SerialInterface = SerialInterfaceV1_0_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SerialInterface"), "SerialInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SerialInterface"), "SerialInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SerialInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SerialInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SerialInterface_V1_0_10_JSON (*((EFI_REDFISH_SERIALINTERFACE_V1_0_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SerialInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_0_10 *SerialInterfaceV1_0_10; + + SerialInterfaceV1_0_10 = (EFI_REDFISH_SERIALINTERFACE_V1_0_10 *)InterpProp; + DestroySerialInterface_V1_0_10_CS (SerialInterfaceV1_0_10->SerialInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SerialInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySerialInterface_V1_0_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_0_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SerialInterfaceToStructWrapper, + SerialInterfaceToJson, + SerialInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_0_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_0_2/RedfishSerialInterface_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/SerialInterface/v1_0_2/RedfishSerialInterface_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..516d370ff70 --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_0_2/RedfishSerialInterface_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SerialInterface.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSerialInterface_V1_0_2_Dxe + FILE_GUID = e6d0ad91-1ca8-46b3-83a9-f6fe0369ace5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSerialInterface_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishSerialInterface_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SerialInterface_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SerialInterfaceV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_0_2/SerialInterface_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/SerialInterface/v1_0_2/SerialInterface_V1_0_2_Dxe.c new file mode 100644 index 00000000000..89fec9bc5bc --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_0_2/SerialInterface_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SerialInterface.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SerialInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support SerialInterface V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SerialInterface", + "1", + "0", + "2" + }, + "SerialInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_0_2 *SerialInterfaceV1_0_2; + EFI_REDFISH_SERIALINTERFACE_V1_0_2_CS *SerialInterfaceV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SerialInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SerialInterface_V1_0_2_To_CS (ResoruceRaw, &SerialInterfaceV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SerialInterfaceV1_0_2 = (EFI_REDFISH_SERIALINTERFACE_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERIALINTERFACE_V1_0_2)); + if (SerialInterfaceV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SerialInterfaceV1_0_2; + SerialInterfaceV1_0_2->SerialInterface = SerialInterfaceV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SerialInterface"), "SerialInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SerialInterface"), "SerialInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SerialInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SerialInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SerialInterface_V1_0_2_JSON (*((EFI_REDFISH_SERIALINTERFACE_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SerialInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_0_2 *SerialInterfaceV1_0_2; + + SerialInterfaceV1_0_2 = (EFI_REDFISH_SERIALINTERFACE_V1_0_2 *)InterpProp; + DestroySerialInterface_V1_0_2_CS (SerialInterfaceV1_0_2->SerialInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SerialInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySerialInterface_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SerialInterfaceToStructWrapper, + SerialInterfaceToJson, + SerialInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_0_3/RedfishSerialInterface_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/SerialInterface/v1_0_3/RedfishSerialInterface_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..d36a199321e --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_0_3/RedfishSerialInterface_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SerialInterface.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSerialInterface_V1_0_3_Dxe + FILE_GUID = 87a4b9a5-594b-4df9-ad56-ceec98b80c9d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSerialInterface_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishSerialInterface_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SerialInterface_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SerialInterfaceV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_0_3/SerialInterface_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/SerialInterface/v1_0_3/SerialInterface_V1_0_3_Dxe.c new file mode 100644 index 00000000000..84c638a23f8 --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_0_3/SerialInterface_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SerialInterface.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SerialInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support SerialInterface V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SerialInterface", + "1", + "0", + "3" + }, + "SerialInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_0_3 *SerialInterfaceV1_0_3; + EFI_REDFISH_SERIALINTERFACE_V1_0_3_CS *SerialInterfaceV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SerialInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SerialInterface_V1_0_3_To_CS (ResoruceRaw, &SerialInterfaceV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SerialInterfaceV1_0_3 = (EFI_REDFISH_SERIALINTERFACE_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERIALINTERFACE_V1_0_3)); + if (SerialInterfaceV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SerialInterfaceV1_0_3; + SerialInterfaceV1_0_3->SerialInterface = SerialInterfaceV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SerialInterface"), "SerialInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SerialInterface"), "SerialInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SerialInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SerialInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SerialInterface_V1_0_3_JSON (*((EFI_REDFISH_SERIALINTERFACE_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SerialInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_0_3 *SerialInterfaceV1_0_3; + + SerialInterfaceV1_0_3 = (EFI_REDFISH_SERIALINTERFACE_V1_0_3 *)InterpProp; + DestroySerialInterface_V1_0_3_CS (SerialInterfaceV1_0_3->SerialInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SerialInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySerialInterface_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SerialInterfaceToStructWrapper, + SerialInterfaceToJson, + SerialInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_0_4/RedfishSerialInterface_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/SerialInterface/v1_0_4/RedfishSerialInterface_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..25e5eae131a --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_0_4/RedfishSerialInterface_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SerialInterface.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSerialInterface_V1_0_4_Dxe + FILE_GUID = 92115332-73ca-4f24-b023-4bf7127b0755 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSerialInterface_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishSerialInterface_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SerialInterface_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SerialInterfaceV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_0_4/SerialInterface_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/SerialInterface/v1_0_4/SerialInterface_V1_0_4_Dxe.c new file mode 100644 index 00000000000..2d41cdb3bdb --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_0_4/SerialInterface_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SerialInterface.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SerialInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support SerialInterface V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SerialInterface", + "1", + "0", + "4" + }, + "SerialInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_0_4 *SerialInterfaceV1_0_4; + EFI_REDFISH_SERIALINTERFACE_V1_0_4_CS *SerialInterfaceV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SerialInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SerialInterface_V1_0_4_To_CS (ResoruceRaw, &SerialInterfaceV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SerialInterfaceV1_0_4 = (EFI_REDFISH_SERIALINTERFACE_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERIALINTERFACE_V1_0_4)); + if (SerialInterfaceV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SerialInterfaceV1_0_4; + SerialInterfaceV1_0_4->SerialInterface = SerialInterfaceV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SerialInterface"), "SerialInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SerialInterface"), "SerialInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SerialInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SerialInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SerialInterface_V1_0_4_JSON (*((EFI_REDFISH_SERIALINTERFACE_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SerialInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_0_4 *SerialInterfaceV1_0_4; + + SerialInterfaceV1_0_4 = (EFI_REDFISH_SERIALINTERFACE_V1_0_4 *)InterpProp; + DestroySerialInterface_V1_0_4_CS (SerialInterfaceV1_0_4->SerialInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SerialInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySerialInterface_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SerialInterfaceToStructWrapper, + SerialInterfaceToJson, + SerialInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_0_5/RedfishSerialInterface_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/SerialInterface/v1_0_5/RedfishSerialInterface_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..f7f65fb43a0 --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_0_5/RedfishSerialInterface_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SerialInterface.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSerialInterface_V1_0_5_Dxe + FILE_GUID = 4f9550ab-4345-4552-9b36-a0e60cb538bf + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSerialInterface_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishSerialInterface_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SerialInterface_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SerialInterfaceV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_0_5/SerialInterface_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/SerialInterface/v1_0_5/SerialInterface_V1_0_5_Dxe.c new file mode 100644 index 00000000000..989234e0077 --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_0_5/SerialInterface_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SerialInterface.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SerialInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support SerialInterface V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SerialInterface", + "1", + "0", + "5" + }, + "SerialInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_0_5 *SerialInterfaceV1_0_5; + EFI_REDFISH_SERIALINTERFACE_V1_0_5_CS *SerialInterfaceV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SerialInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SerialInterface_V1_0_5_To_CS (ResoruceRaw, &SerialInterfaceV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SerialInterfaceV1_0_5 = (EFI_REDFISH_SERIALINTERFACE_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERIALINTERFACE_V1_0_5)); + if (SerialInterfaceV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SerialInterfaceV1_0_5; + SerialInterfaceV1_0_5->SerialInterface = SerialInterfaceV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SerialInterface"), "SerialInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SerialInterface"), "SerialInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SerialInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SerialInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SerialInterface_V1_0_5_JSON (*((EFI_REDFISH_SERIALINTERFACE_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SerialInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_0_5 *SerialInterfaceV1_0_5; + + SerialInterfaceV1_0_5 = (EFI_REDFISH_SERIALINTERFACE_V1_0_5 *)InterpProp; + DestroySerialInterface_V1_0_5_CS (SerialInterfaceV1_0_5->SerialInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SerialInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySerialInterface_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SerialInterfaceToStructWrapper, + SerialInterfaceToJson, + SerialInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_0_6/RedfishSerialInterface_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/SerialInterface/v1_0_6/RedfishSerialInterface_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..5cdd199ffa6 --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_0_6/RedfishSerialInterface_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SerialInterface.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSerialInterface_V1_0_6_Dxe + FILE_GUID = e5403481-49a1-49b7-9ee5-2937d10e5752 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSerialInterface_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishSerialInterface_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SerialInterface_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SerialInterfaceV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_0_6/SerialInterface_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/SerialInterface/v1_0_6/SerialInterface_V1_0_6_Dxe.c new file mode 100644 index 00000000000..4d64c710b77 --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_0_6/SerialInterface_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SerialInterface.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SerialInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support SerialInterface V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SerialInterface", + "1", + "0", + "6" + }, + "SerialInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_0_6 *SerialInterfaceV1_0_6; + EFI_REDFISH_SERIALINTERFACE_V1_0_6_CS *SerialInterfaceV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SerialInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SerialInterface_V1_0_6_To_CS (ResoruceRaw, &SerialInterfaceV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SerialInterfaceV1_0_6 = (EFI_REDFISH_SERIALINTERFACE_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERIALINTERFACE_V1_0_6)); + if (SerialInterfaceV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SerialInterfaceV1_0_6; + SerialInterfaceV1_0_6->SerialInterface = SerialInterfaceV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SerialInterface"), "SerialInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SerialInterface"), "SerialInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SerialInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SerialInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SerialInterface_V1_0_6_JSON (*((EFI_REDFISH_SERIALINTERFACE_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SerialInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_0_6 *SerialInterfaceV1_0_6; + + SerialInterfaceV1_0_6 = (EFI_REDFISH_SERIALINTERFACE_V1_0_6 *)InterpProp; + DestroySerialInterface_V1_0_6_CS (SerialInterfaceV1_0_6->SerialInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SerialInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySerialInterface_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SerialInterfaceToStructWrapper, + SerialInterfaceToJson, + SerialInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_0_7/RedfishSerialInterface_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/SerialInterface/v1_0_7/RedfishSerialInterface_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..bce4e3db88d --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_0_7/RedfishSerialInterface_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SerialInterface.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSerialInterface_V1_0_7_Dxe + FILE_GUID = 1e0c7c22-8203-4487-bef3-ec7885e0f0ad + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSerialInterface_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishSerialInterface_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SerialInterface_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SerialInterfaceV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_0_7/SerialInterface_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/SerialInterface/v1_0_7/SerialInterface_V1_0_7_Dxe.c new file mode 100644 index 00000000000..df72db6a0b1 --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_0_7/SerialInterface_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SerialInterface.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SerialInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support SerialInterface V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SerialInterface", + "1", + "0", + "7" + }, + "SerialInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_0_7 *SerialInterfaceV1_0_7; + EFI_REDFISH_SERIALINTERFACE_V1_0_7_CS *SerialInterfaceV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SerialInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SerialInterface_V1_0_7_To_CS (ResoruceRaw, &SerialInterfaceV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SerialInterfaceV1_0_7 = (EFI_REDFISH_SERIALINTERFACE_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERIALINTERFACE_V1_0_7)); + if (SerialInterfaceV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SerialInterfaceV1_0_7; + SerialInterfaceV1_0_7->SerialInterface = SerialInterfaceV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SerialInterface"), "SerialInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SerialInterface"), "SerialInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SerialInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SerialInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SerialInterface_V1_0_7_JSON (*((EFI_REDFISH_SERIALINTERFACE_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SerialInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_0_7 *SerialInterfaceV1_0_7; + + SerialInterfaceV1_0_7 = (EFI_REDFISH_SERIALINTERFACE_V1_0_7 *)InterpProp; + DestroySerialInterface_V1_0_7_CS (SerialInterfaceV1_0_7->SerialInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SerialInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySerialInterface_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SerialInterfaceToStructWrapper, + SerialInterfaceToJson, + SerialInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_0_8/RedfishSerialInterface_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/SerialInterface/v1_0_8/RedfishSerialInterface_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..de2dee5b2b8 --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_0_8/RedfishSerialInterface_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SerialInterface.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSerialInterface_V1_0_8_Dxe + FILE_GUID = 3a2cff61-1da9-4084-962f-254b976a65bd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSerialInterface_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishSerialInterface_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SerialInterface_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SerialInterfaceV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_0_8/SerialInterface_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/SerialInterface/v1_0_8/SerialInterface_V1_0_8_Dxe.c new file mode 100644 index 00000000000..a670c26688a --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_0_8/SerialInterface_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SerialInterface.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SerialInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support SerialInterface V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SerialInterface", + "1", + "0", + "8" + }, + "SerialInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_0_8 *SerialInterfaceV1_0_8; + EFI_REDFISH_SERIALINTERFACE_V1_0_8_CS *SerialInterfaceV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SerialInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SerialInterface_V1_0_8_To_CS (ResoruceRaw, &SerialInterfaceV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SerialInterfaceV1_0_8 = (EFI_REDFISH_SERIALINTERFACE_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERIALINTERFACE_V1_0_8)); + if (SerialInterfaceV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SerialInterfaceV1_0_8; + SerialInterfaceV1_0_8->SerialInterface = SerialInterfaceV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SerialInterface"), "SerialInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SerialInterface"), "SerialInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SerialInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SerialInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SerialInterface_V1_0_8_JSON (*((EFI_REDFISH_SERIALINTERFACE_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SerialInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_0_8 *SerialInterfaceV1_0_8; + + SerialInterfaceV1_0_8 = (EFI_REDFISH_SERIALINTERFACE_V1_0_8 *)InterpProp; + DestroySerialInterface_V1_0_8_CS (SerialInterfaceV1_0_8->SerialInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SerialInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySerialInterface_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SerialInterfaceToStructWrapper, + SerialInterfaceToJson, + SerialInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_0_9/RedfishSerialInterface_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/SerialInterface/v1_0_9/RedfishSerialInterface_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..8addc007c64 --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_0_9/RedfishSerialInterface_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SerialInterface.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSerialInterface_V1_0_9_Dxe + FILE_GUID = ab4535a4-3072-446a-85f9-71d33f4459b1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSerialInterface_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishSerialInterface_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SerialInterface_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SerialInterfaceV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_0_9/SerialInterface_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/SerialInterface/v1_0_9/SerialInterface_V1_0_9_Dxe.c new file mode 100644 index 00000000000..c8d631baa46 --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_0_9/SerialInterface_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SerialInterface.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SerialInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support SerialInterface V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SerialInterface", + "1", + "0", + "9" + }, + "SerialInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_0_9 *SerialInterfaceV1_0_9; + EFI_REDFISH_SERIALINTERFACE_V1_0_9_CS *SerialInterfaceV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SerialInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SerialInterface_V1_0_9_To_CS (ResoruceRaw, &SerialInterfaceV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SerialInterfaceV1_0_9 = (EFI_REDFISH_SERIALINTERFACE_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERIALINTERFACE_V1_0_9)); + if (SerialInterfaceV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SerialInterfaceV1_0_9; + SerialInterfaceV1_0_9->SerialInterface = SerialInterfaceV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SerialInterface"), "SerialInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SerialInterface"), "SerialInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SerialInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SerialInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SerialInterface_V1_0_9_JSON (*((EFI_REDFISH_SERIALINTERFACE_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SerialInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_0_9 *SerialInterfaceV1_0_9; + + SerialInterfaceV1_0_9 = (EFI_REDFISH_SERIALINTERFACE_V1_0_9 *)InterpProp; + DestroySerialInterface_V1_0_9_CS (SerialInterfaceV1_0_9->SerialInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SerialInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySerialInterface_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SerialInterfaceToStructWrapper, + SerialInterfaceToJson, + SerialInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_1_0/RedfishSerialInterface_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/SerialInterface/v1_1_0/RedfishSerialInterface_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..d99d8d22026 --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_1_0/RedfishSerialInterface_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SerialInterface.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSerialInterface_V1_1_0_Dxe + FILE_GUID = ea658dfb-8d9e-4782-bc9c-a516244c0b61 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSerialInterface_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishSerialInterface_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SerialInterface_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SerialInterfaceV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_1_0/SerialInterface_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/SerialInterface/v1_1_0/SerialInterface_V1_1_0_Dxe.c new file mode 100644 index 00000000000..02981c1283c --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_1_0/SerialInterface_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SerialInterface.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SerialInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support SerialInterface V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SerialInterface", + "1", + "1", + "0" + }, + "SerialInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_1_0 *SerialInterfaceV1_1_0; + EFI_REDFISH_SERIALINTERFACE_V1_1_0_CS *SerialInterfaceV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SerialInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SerialInterface_V1_1_0_To_CS (ResoruceRaw, &SerialInterfaceV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SerialInterfaceV1_1_0 = (EFI_REDFISH_SERIALINTERFACE_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERIALINTERFACE_V1_1_0)); + if (SerialInterfaceV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SerialInterfaceV1_1_0; + SerialInterfaceV1_1_0->SerialInterface = SerialInterfaceV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SerialInterface"), "SerialInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SerialInterface"), "SerialInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SerialInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SerialInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SerialInterface_V1_1_0_JSON (*((EFI_REDFISH_SERIALINTERFACE_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SerialInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_1_0 *SerialInterfaceV1_1_0; + + SerialInterfaceV1_1_0 = (EFI_REDFISH_SERIALINTERFACE_V1_1_0 *)InterpProp; + DestroySerialInterface_V1_1_0_CS (SerialInterfaceV1_1_0->SerialInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SerialInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySerialInterface_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SerialInterfaceToStructWrapper, + SerialInterfaceToJson, + SerialInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_1_1/RedfishSerialInterface_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/SerialInterface/v1_1_1/RedfishSerialInterface_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..8b84beaa39f --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_1_1/RedfishSerialInterface_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SerialInterface.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSerialInterface_V1_1_1_Dxe + FILE_GUID = eb42d787-9a71-449f-89e2-a038266e2c7e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSerialInterface_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishSerialInterface_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SerialInterface_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SerialInterfaceV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_1_1/SerialInterface_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/SerialInterface/v1_1_1/SerialInterface_V1_1_1_Dxe.c new file mode 100644 index 00000000000..d03221e378b --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_1_1/SerialInterface_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SerialInterface.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SerialInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support SerialInterface V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SerialInterface", + "1", + "1", + "1" + }, + "SerialInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_1_1 *SerialInterfaceV1_1_1; + EFI_REDFISH_SERIALINTERFACE_V1_1_1_CS *SerialInterfaceV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SerialInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SerialInterface_V1_1_1_To_CS (ResoruceRaw, &SerialInterfaceV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SerialInterfaceV1_1_1 = (EFI_REDFISH_SERIALINTERFACE_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERIALINTERFACE_V1_1_1)); + if (SerialInterfaceV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SerialInterfaceV1_1_1; + SerialInterfaceV1_1_1->SerialInterface = SerialInterfaceV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SerialInterface"), "SerialInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SerialInterface"), "SerialInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SerialInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SerialInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SerialInterface_V1_1_1_JSON (*((EFI_REDFISH_SERIALINTERFACE_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SerialInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_1_1 *SerialInterfaceV1_1_1; + + SerialInterfaceV1_1_1 = (EFI_REDFISH_SERIALINTERFACE_V1_1_1 *)InterpProp; + DestroySerialInterface_V1_1_1_CS (SerialInterfaceV1_1_1->SerialInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SerialInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySerialInterface_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SerialInterfaceToStructWrapper, + SerialInterfaceToJson, + SerialInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_1_2/RedfishSerialInterface_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/SerialInterface/v1_1_2/RedfishSerialInterface_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..88990fea991 --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_1_2/RedfishSerialInterface_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SerialInterface.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSerialInterface_V1_1_2_Dxe + FILE_GUID = e6473f37-33fd-446b-9f81-b118d051c727 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSerialInterface_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishSerialInterface_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SerialInterface_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SerialInterfaceV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_1_2/SerialInterface_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/SerialInterface/v1_1_2/SerialInterface_V1_1_2_Dxe.c new file mode 100644 index 00000000000..73f38dca94f --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_1_2/SerialInterface_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SerialInterface.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SerialInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support SerialInterface V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SerialInterface", + "1", + "1", + "2" + }, + "SerialInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_1_2 *SerialInterfaceV1_1_2; + EFI_REDFISH_SERIALINTERFACE_V1_1_2_CS *SerialInterfaceV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SerialInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SerialInterface_V1_1_2_To_CS (ResoruceRaw, &SerialInterfaceV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SerialInterfaceV1_1_2 = (EFI_REDFISH_SERIALINTERFACE_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERIALINTERFACE_V1_1_2)); + if (SerialInterfaceV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SerialInterfaceV1_1_2; + SerialInterfaceV1_1_2->SerialInterface = SerialInterfaceV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SerialInterface"), "SerialInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SerialInterface"), "SerialInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SerialInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SerialInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SerialInterface_V1_1_2_JSON (*((EFI_REDFISH_SERIALINTERFACE_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SerialInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_1_2 *SerialInterfaceV1_1_2; + + SerialInterfaceV1_1_2 = (EFI_REDFISH_SERIALINTERFACE_V1_1_2 *)InterpProp; + DestroySerialInterface_V1_1_2_CS (SerialInterfaceV1_1_2->SerialInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SerialInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySerialInterface_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SerialInterfaceToStructWrapper, + SerialInterfaceToJson, + SerialInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_1_3/RedfishSerialInterface_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/SerialInterface/v1_1_3/RedfishSerialInterface_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..87debee8098 --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_1_3/RedfishSerialInterface_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SerialInterface.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSerialInterface_V1_1_3_Dxe + FILE_GUID = d1a96968-794e-4cfa-a91c-d65ec80bc378 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSerialInterface_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishSerialInterface_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SerialInterface_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SerialInterfaceV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_1_3/SerialInterface_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/SerialInterface/v1_1_3/SerialInterface_V1_1_3_Dxe.c new file mode 100644 index 00000000000..4a90881b6c0 --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_1_3/SerialInterface_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SerialInterface.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SerialInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support SerialInterface V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SerialInterface", + "1", + "1", + "3" + }, + "SerialInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_1_3 *SerialInterfaceV1_1_3; + EFI_REDFISH_SERIALINTERFACE_V1_1_3_CS *SerialInterfaceV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SerialInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SerialInterface_V1_1_3_To_CS (ResoruceRaw, &SerialInterfaceV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SerialInterfaceV1_1_3 = (EFI_REDFISH_SERIALINTERFACE_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERIALINTERFACE_V1_1_3)); + if (SerialInterfaceV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SerialInterfaceV1_1_3; + SerialInterfaceV1_1_3->SerialInterface = SerialInterfaceV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SerialInterface"), "SerialInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SerialInterface"), "SerialInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SerialInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SerialInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SerialInterface_V1_1_3_JSON (*((EFI_REDFISH_SERIALINTERFACE_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SerialInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_1_3 *SerialInterfaceV1_1_3; + + SerialInterfaceV1_1_3 = (EFI_REDFISH_SERIALINTERFACE_V1_1_3 *)InterpProp; + DestroySerialInterface_V1_1_3_CS (SerialInterfaceV1_1_3->SerialInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SerialInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySerialInterface_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SerialInterfaceToStructWrapper, + SerialInterfaceToJson, + SerialInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_1_4/RedfishSerialInterface_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/SerialInterface/v1_1_4/RedfishSerialInterface_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..7bd323c9083 --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_1_4/RedfishSerialInterface_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SerialInterface.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSerialInterface_V1_1_4_Dxe + FILE_GUID = a78db99b-6d2c-490d-b76b-de9780541aee + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSerialInterface_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishSerialInterface_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SerialInterface_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SerialInterfaceV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_1_4/SerialInterface_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/SerialInterface/v1_1_4/SerialInterface_V1_1_4_Dxe.c new file mode 100644 index 00000000000..34ba3dc72fd --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_1_4/SerialInterface_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SerialInterface.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SerialInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support SerialInterface V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SerialInterface", + "1", + "1", + "4" + }, + "SerialInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_1_4 *SerialInterfaceV1_1_4; + EFI_REDFISH_SERIALINTERFACE_V1_1_4_CS *SerialInterfaceV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SerialInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SerialInterface_V1_1_4_To_CS (ResoruceRaw, &SerialInterfaceV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SerialInterfaceV1_1_4 = (EFI_REDFISH_SERIALINTERFACE_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERIALINTERFACE_V1_1_4)); + if (SerialInterfaceV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SerialInterfaceV1_1_4; + SerialInterfaceV1_1_4->SerialInterface = SerialInterfaceV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SerialInterface"), "SerialInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SerialInterface"), "SerialInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SerialInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SerialInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SerialInterface_V1_1_4_JSON (*((EFI_REDFISH_SERIALINTERFACE_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SerialInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_1_4 *SerialInterfaceV1_1_4; + + SerialInterfaceV1_1_4 = (EFI_REDFISH_SERIALINTERFACE_V1_1_4 *)InterpProp; + DestroySerialInterface_V1_1_4_CS (SerialInterfaceV1_1_4->SerialInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SerialInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySerialInterface_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SerialInterfaceToStructWrapper, + SerialInterfaceToJson, + SerialInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_1_5/RedfishSerialInterface_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/SerialInterface/v1_1_5/RedfishSerialInterface_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..c8dc3c1a819 --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_1_5/RedfishSerialInterface_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SerialInterface.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSerialInterface_V1_1_5_Dxe + FILE_GUID = 5367ee2b-0475-4bfe-9265-fe696361d999 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSerialInterface_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishSerialInterface_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SerialInterface_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SerialInterfaceV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_1_5/SerialInterface_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/SerialInterface/v1_1_5/SerialInterface_V1_1_5_Dxe.c new file mode 100644 index 00000000000..9cfb5113bc4 --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_1_5/SerialInterface_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SerialInterface.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SerialInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support SerialInterface V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SerialInterface", + "1", + "1", + "5" + }, + "SerialInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_1_5 *SerialInterfaceV1_1_5; + EFI_REDFISH_SERIALINTERFACE_V1_1_5_CS *SerialInterfaceV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SerialInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SerialInterface_V1_1_5_To_CS (ResoruceRaw, &SerialInterfaceV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SerialInterfaceV1_1_5 = (EFI_REDFISH_SERIALINTERFACE_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERIALINTERFACE_V1_1_5)); + if (SerialInterfaceV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SerialInterfaceV1_1_5; + SerialInterfaceV1_1_5->SerialInterface = SerialInterfaceV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SerialInterface"), "SerialInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SerialInterface"), "SerialInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SerialInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SerialInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SerialInterface_V1_1_5_JSON (*((EFI_REDFISH_SERIALINTERFACE_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SerialInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_1_5 *SerialInterfaceV1_1_5; + + SerialInterfaceV1_1_5 = (EFI_REDFISH_SERIALINTERFACE_V1_1_5 *)InterpProp; + DestroySerialInterface_V1_1_5_CS (SerialInterfaceV1_1_5->SerialInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SerialInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySerialInterface_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SerialInterfaceToStructWrapper, + SerialInterfaceToJson, + SerialInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_1_6/RedfishSerialInterface_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/SerialInterface/v1_1_6/RedfishSerialInterface_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..fb8b01a8401 --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_1_6/RedfishSerialInterface_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SerialInterface.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSerialInterface_V1_1_6_Dxe + FILE_GUID = 57f8324d-ef3c-455d-b042-15313431e687 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSerialInterface_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishSerialInterface_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SerialInterface_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SerialInterfaceV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_1_6/SerialInterface_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/SerialInterface/v1_1_6/SerialInterface_V1_1_6_Dxe.c new file mode 100644 index 00000000000..0f866927d2e --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_1_6/SerialInterface_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SerialInterface.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SerialInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support SerialInterface V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SerialInterface", + "1", + "1", + "6" + }, + "SerialInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_1_6 *SerialInterfaceV1_1_6; + EFI_REDFISH_SERIALINTERFACE_V1_1_6_CS *SerialInterfaceV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SerialInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SerialInterface_V1_1_6_To_CS (ResoruceRaw, &SerialInterfaceV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SerialInterfaceV1_1_6 = (EFI_REDFISH_SERIALINTERFACE_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERIALINTERFACE_V1_1_6)); + if (SerialInterfaceV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SerialInterfaceV1_1_6; + SerialInterfaceV1_1_6->SerialInterface = SerialInterfaceV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SerialInterface"), "SerialInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SerialInterface"), "SerialInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SerialInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SerialInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SerialInterface_V1_1_6_JSON (*((EFI_REDFISH_SERIALINTERFACE_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SerialInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_1_6 *SerialInterfaceV1_1_6; + + SerialInterfaceV1_1_6 = (EFI_REDFISH_SERIALINTERFACE_V1_1_6 *)InterpProp; + DestroySerialInterface_V1_1_6_CS (SerialInterfaceV1_1_6->SerialInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SerialInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySerialInterface_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SerialInterfaceToStructWrapper, + SerialInterfaceToJson, + SerialInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_1_7/RedfishSerialInterface_V1_1_7_Dxe.inf b/RedfishClientPkg/Converter/SerialInterface/v1_1_7/RedfishSerialInterface_V1_1_7_Dxe.inf new file mode 100644 index 00000000000..72f93419fe3 --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_1_7/RedfishSerialInterface_V1_1_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SerialInterface.v1_1_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSerialInterface_V1_1_7_Dxe + FILE_GUID = 3a23af07-6aed-472d-8480-343dacf7c864 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSerialInterface_V1_1_7EntryPoint + UNLOAD_IMAGE = RedfishSerialInterface_V1_1_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SerialInterface_V1_1_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SerialInterfaceV1_1_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SerialInterface/v1_1_7/SerialInterface_V1_1_7_Dxe.c b/RedfishClientPkg/Converter/SerialInterface/v1_1_7/SerialInterface_V1_1_7_Dxe.c new file mode 100644 index 00000000000..4ee2a4c7227 --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterface/v1_1_7/SerialInterface_V1_1_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SerialInterface.v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SerialInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support SerialInterface V1_1_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SerialInterface", + "1", + "1", + "7" + }, + "SerialInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_1_7 *SerialInterfaceV1_1_7; + EFI_REDFISH_SERIALINTERFACE_V1_1_7_CS *SerialInterfaceV1_1_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SerialInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SerialInterface_V1_1_7_To_CS (ResoruceRaw, &SerialInterfaceV1_1_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SerialInterfaceV1_1_7 = (EFI_REDFISH_SERIALINTERFACE_V1_1_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERIALINTERFACE_V1_1_7)); + if (SerialInterfaceV1_1_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SerialInterfaceV1_1_7; + SerialInterfaceV1_1_7->SerialInterface = SerialInterfaceV1_1_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SerialInterface"), "SerialInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SerialInterface"), "SerialInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SerialInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SerialInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SerialInterface_V1_1_7_JSON (*((EFI_REDFISH_SERIALINTERFACE_V1_1_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SerialInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACE_V1_1_7 *SerialInterfaceV1_1_7; + + SerialInterfaceV1_1_7 = (EFI_REDFISH_SERIALINTERFACE_V1_1_7 *)InterpProp; + DestroySerialInterface_V1_1_7_CS (SerialInterfaceV1_1_7->SerialInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SerialInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySerialInterface_V1_1_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_1_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SerialInterfaceToStructWrapper, + SerialInterfaceToJson, + SerialInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterface_V1_1_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SerialInterfaceCollection/RedfishSerialInterfaceCollection_Dxe.inf b/RedfishClientPkg/Converter/SerialInterfaceCollection/RedfishSerialInterfaceCollection_Dxe.inf new file mode 100644 index 00000000000..5abebb53a1b --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterfaceCollection/RedfishSerialInterfaceCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SerialInterfaceCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSerialInterfaceCollection_Dxe + FILE_GUID = c14ea07d-1788-4b60-a6ab-8433ad650136 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSerialInterfaceCollectionEntryPoint + UNLOAD_IMAGE = RedfishSerialInterfaceCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SerialInterfaceCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SerialInterfaceCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SerialInterfaceCollection/SerialInterfaceCollection_Dxe.c b/RedfishClientPkg/Converter/SerialInterfaceCollection/SerialInterfaceCollection_Dxe.c new file mode 100644 index 00000000000..283ff83a4e4 --- /dev/null +++ b/RedfishClientPkg/Converter/SerialInterfaceCollection/SerialInterfaceCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SerialInterfaceCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SerialInterfaceCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support SerialInterfaceCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SerialInterfaceCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "SerialInterfaceCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACECOLLECTION *SerialInterfaceCollection; + EFI_REDFISH_SERIALINTERFACECOLLECTION_CS *SerialInterfaceCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SerialInterfaceCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SerialInterfaceCollection_To_CS (ResoruceRaw, &SerialInterfaceCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + SerialInterfaceCollection = (EFI_REDFISH_SERIALINTERFACECOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERIALINTERFACECOLLECTION)); + if (SerialInterfaceCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SerialInterfaceCollection; + SerialInterfaceCollection->SerialInterfaceCollection = SerialInterfaceCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterfaceCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SerialInterfaceCollection"), "SerialInterfaceCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SerialInterfaceCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SerialInterfaceCollection"), "SerialInterfaceCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SerialInterfaceCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SerialInterfaceCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SerialInterfaceCollection_JSON (*((EFI_REDFISH_SERIALINTERFACECOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SerialInterfaceCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERIALINTERFACECOLLECTION *SerialInterfaceCollection; + + SerialInterfaceCollection = (EFI_REDFISH_SERIALINTERFACECOLLECTION *)InterpProp; + DestroySerialInterfaceCollection_CS (SerialInterfaceCollection->SerialInterfaceCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SerialInterfaceCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SerialInterfaceCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySerialInterfaceCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterfaceCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SerialInterfaceCollectionToStructWrapper, + SerialInterfaceCollectionToJson, + SerialInterfaceCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSerialInterfaceCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_0_0/RedfishServiceRoot_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_0_0/RedfishServiceRoot_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..23bf5617106 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_0_0/RedfishServiceRoot_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_0_0_Dxe + FILE_GUID = 2097b7af-a86b-4e85-b43e-87f0edc3726e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_0_0/ServiceRoot_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_0_0/ServiceRoot_V1_0_0_Dxe.c new file mode 100644 index 00000000000..f77d502b8f5 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_0_0/ServiceRoot_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "0", + "0" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_0_0 *ServiceRootV1_0_0; + EFI_REDFISH_SERVICEROOT_V1_0_0_CS *ServiceRootV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_0_0_To_CS (ResoruceRaw, &ServiceRootV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_0_0 = (EFI_REDFISH_SERVICEROOT_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_0_0)); + if (ServiceRootV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_0_0; + ServiceRootV1_0_0->ServiceRoot = ServiceRootV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_0_0_JSON (*((EFI_REDFISH_SERVICEROOT_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_0_0 *ServiceRootV1_0_0; + + ServiceRootV1_0_0 = (EFI_REDFISH_SERVICEROOT_V1_0_0 *)InterpProp; + DestroyServiceRoot_V1_0_0_CS (ServiceRootV1_0_0->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_0_2/RedfishServiceRoot_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_0_2/RedfishServiceRoot_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..dbb712125d2 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_0_2/RedfishServiceRoot_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_0_2_Dxe + FILE_GUID = b9edfc5f-1d8f-4c62-ad1e-36db801538ab + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_0_2/ServiceRoot_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_0_2/ServiceRoot_V1_0_2_Dxe.c new file mode 100644 index 00000000000..c47d41878d6 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_0_2/ServiceRoot_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "0", + "2" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_0_2 *ServiceRootV1_0_2; + EFI_REDFISH_SERVICEROOT_V1_0_2_CS *ServiceRootV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_0_2_To_CS (ResoruceRaw, &ServiceRootV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_0_2 = (EFI_REDFISH_SERVICEROOT_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_0_2)); + if (ServiceRootV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_0_2; + ServiceRootV1_0_2->ServiceRoot = ServiceRootV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_0_2_JSON (*((EFI_REDFISH_SERVICEROOT_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_0_2 *ServiceRootV1_0_2; + + ServiceRootV1_0_2 = (EFI_REDFISH_SERVICEROOT_V1_0_2 *)InterpProp; + DestroyServiceRoot_V1_0_2_CS (ServiceRootV1_0_2->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_0_3/RedfishServiceRoot_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_0_3/RedfishServiceRoot_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..945fcc05742 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_0_3/RedfishServiceRoot_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_0_3_Dxe + FILE_GUID = 3868d65d-d5e4-46b5-8226-2318ff0740bb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_0_3/ServiceRoot_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_0_3/ServiceRoot_V1_0_3_Dxe.c new file mode 100644 index 00000000000..add0c4a7f8d --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_0_3/ServiceRoot_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "0", + "3" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_0_3 *ServiceRootV1_0_3; + EFI_REDFISH_SERVICEROOT_V1_0_3_CS *ServiceRootV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_0_3_To_CS (ResoruceRaw, &ServiceRootV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_0_3 = (EFI_REDFISH_SERVICEROOT_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_0_3)); + if (ServiceRootV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_0_3; + ServiceRootV1_0_3->ServiceRoot = ServiceRootV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_0_3_JSON (*((EFI_REDFISH_SERVICEROOT_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_0_3 *ServiceRootV1_0_3; + + ServiceRootV1_0_3 = (EFI_REDFISH_SERVICEROOT_V1_0_3 *)InterpProp; + DestroyServiceRoot_V1_0_3_CS (ServiceRootV1_0_3->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_0_4/RedfishServiceRoot_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_0_4/RedfishServiceRoot_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..f72add5def0 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_0_4/RedfishServiceRoot_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_0_4_Dxe + FILE_GUID = 73654c0d-b398-4182-b4bb-addd53536bc6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_0_4/ServiceRoot_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_0_4/ServiceRoot_V1_0_4_Dxe.c new file mode 100644 index 00000000000..f2b153b319d --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_0_4/ServiceRoot_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "0", + "4" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_0_4 *ServiceRootV1_0_4; + EFI_REDFISH_SERVICEROOT_V1_0_4_CS *ServiceRootV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_0_4_To_CS (ResoruceRaw, &ServiceRootV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_0_4 = (EFI_REDFISH_SERVICEROOT_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_0_4)); + if (ServiceRootV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_0_4; + ServiceRootV1_0_4->ServiceRoot = ServiceRootV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_0_4_JSON (*((EFI_REDFISH_SERVICEROOT_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_0_4 *ServiceRootV1_0_4; + + ServiceRootV1_0_4 = (EFI_REDFISH_SERVICEROOT_V1_0_4 *)InterpProp; + DestroyServiceRoot_V1_0_4_CS (ServiceRootV1_0_4->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_0_5/RedfishServiceRoot_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_0_5/RedfishServiceRoot_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..bbc9c3533b9 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_0_5/RedfishServiceRoot_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_0_5_Dxe + FILE_GUID = e9fb1ab5-1fdd-4550-a7cf-4f6946d5cbc8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_0_5/ServiceRoot_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_0_5/ServiceRoot_V1_0_5_Dxe.c new file mode 100644 index 00000000000..eac79de5945 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_0_5/ServiceRoot_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "0", + "5" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_0_5 *ServiceRootV1_0_5; + EFI_REDFISH_SERVICEROOT_V1_0_5_CS *ServiceRootV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_0_5_To_CS (ResoruceRaw, &ServiceRootV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_0_5 = (EFI_REDFISH_SERVICEROOT_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_0_5)); + if (ServiceRootV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_0_5; + ServiceRootV1_0_5->ServiceRoot = ServiceRootV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_0_5_JSON (*((EFI_REDFISH_SERVICEROOT_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_0_5 *ServiceRootV1_0_5; + + ServiceRootV1_0_5 = (EFI_REDFISH_SERVICEROOT_V1_0_5 *)InterpProp; + DestroyServiceRoot_V1_0_5_CS (ServiceRootV1_0_5->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_0_6/RedfishServiceRoot_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_0_6/RedfishServiceRoot_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..a2611e3bb44 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_0_6/RedfishServiceRoot_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_0_6_Dxe + FILE_GUID = 6dcc95da-59d6-45f0-81a1-1ad85e5fc25f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_0_6/ServiceRoot_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_0_6/ServiceRoot_V1_0_6_Dxe.c new file mode 100644 index 00000000000..a52a1344bcc --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_0_6/ServiceRoot_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "0", + "6" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_0_6 *ServiceRootV1_0_6; + EFI_REDFISH_SERVICEROOT_V1_0_6_CS *ServiceRootV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_0_6_To_CS (ResoruceRaw, &ServiceRootV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_0_6 = (EFI_REDFISH_SERVICEROOT_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_0_6)); + if (ServiceRootV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_0_6; + ServiceRootV1_0_6->ServiceRoot = ServiceRootV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_0_6_JSON (*((EFI_REDFISH_SERVICEROOT_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_0_6 *ServiceRootV1_0_6; + + ServiceRootV1_0_6 = (EFI_REDFISH_SERVICEROOT_V1_0_6 *)InterpProp; + DestroyServiceRoot_V1_0_6_CS (ServiceRootV1_0_6->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_0_7/RedfishServiceRoot_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_0_7/RedfishServiceRoot_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..414f9231f18 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_0_7/RedfishServiceRoot_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_0_7_Dxe + FILE_GUID = 61f9617f-5524-4404-b388-beff9077cdaf + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_0_7/ServiceRoot_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_0_7/ServiceRoot_V1_0_7_Dxe.c new file mode 100644 index 00000000000..deaf2500b56 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_0_7/ServiceRoot_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "0", + "7" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_0_7 *ServiceRootV1_0_7; + EFI_REDFISH_SERVICEROOT_V1_0_7_CS *ServiceRootV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_0_7_To_CS (ResoruceRaw, &ServiceRootV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_0_7 = (EFI_REDFISH_SERVICEROOT_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_0_7)); + if (ServiceRootV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_0_7; + ServiceRootV1_0_7->ServiceRoot = ServiceRootV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_0_7_JSON (*((EFI_REDFISH_SERVICEROOT_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_0_7 *ServiceRootV1_0_7; + + ServiceRootV1_0_7 = (EFI_REDFISH_SERVICEROOT_V1_0_7 *)InterpProp; + DestroyServiceRoot_V1_0_7_CS (ServiceRootV1_0_7->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_0_8/RedfishServiceRoot_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_0_8/RedfishServiceRoot_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..5697cd83219 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_0_8/RedfishServiceRoot_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_0_8_Dxe + FILE_GUID = 4ea546a7-393e-406f-a8bf-d25af19bbe83 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_0_8/ServiceRoot_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_0_8/ServiceRoot_V1_0_8_Dxe.c new file mode 100644 index 00000000000..2ec939505c9 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_0_8/ServiceRoot_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "0", + "8" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_0_8 *ServiceRootV1_0_8; + EFI_REDFISH_SERVICEROOT_V1_0_8_CS *ServiceRootV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_0_8_To_CS (ResoruceRaw, &ServiceRootV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_0_8 = (EFI_REDFISH_SERVICEROOT_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_0_8)); + if (ServiceRootV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_0_8; + ServiceRootV1_0_8->ServiceRoot = ServiceRootV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_0_8_JSON (*((EFI_REDFISH_SERVICEROOT_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_0_8 *ServiceRootV1_0_8; + + ServiceRootV1_0_8 = (EFI_REDFISH_SERVICEROOT_V1_0_8 *)InterpProp; + DestroyServiceRoot_V1_0_8_CS (ServiceRootV1_0_8->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_0_9/RedfishServiceRoot_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_0_9/RedfishServiceRoot_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..11046726523 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_0_9/RedfishServiceRoot_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_0_9_Dxe + FILE_GUID = e4cb1ae7-e5d8-4f59-9c6a-5dc8b0e41adc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_0_9/ServiceRoot_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_0_9/ServiceRoot_V1_0_9_Dxe.c new file mode 100644 index 00000000000..125092a74c0 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_0_9/ServiceRoot_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "0", + "9" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_0_9 *ServiceRootV1_0_9; + EFI_REDFISH_SERVICEROOT_V1_0_9_CS *ServiceRootV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_0_9_To_CS (ResoruceRaw, &ServiceRootV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_0_9 = (EFI_REDFISH_SERVICEROOT_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_0_9)); + if (ServiceRootV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_0_9; + ServiceRootV1_0_9->ServiceRoot = ServiceRootV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_0_9_JSON (*((EFI_REDFISH_SERVICEROOT_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_0_9 *ServiceRootV1_0_9; + + ServiceRootV1_0_9 = (EFI_REDFISH_SERVICEROOT_V1_0_9 *)InterpProp; + DestroyServiceRoot_V1_0_9_CS (ServiceRootV1_0_9->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_1_0/RedfishServiceRoot_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_1_0/RedfishServiceRoot_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..d309386a11c --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_1_0/RedfishServiceRoot_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_1_0_Dxe + FILE_GUID = c3f4bbdb-dd04-4e28-8f33-2454062c6eba + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_1_0/ServiceRoot_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_1_0/ServiceRoot_V1_1_0_Dxe.c new file mode 100644 index 00000000000..fc33fd84c91 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_1_0/ServiceRoot_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "1", + "0" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_1_0 *ServiceRootV1_1_0; + EFI_REDFISH_SERVICEROOT_V1_1_0_CS *ServiceRootV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_1_0_To_CS (ResoruceRaw, &ServiceRootV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_1_0 = (EFI_REDFISH_SERVICEROOT_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_1_0)); + if (ServiceRootV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_1_0; + ServiceRootV1_1_0->ServiceRoot = ServiceRootV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_1_0_JSON (*((EFI_REDFISH_SERVICEROOT_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_1_0 *ServiceRootV1_1_0; + + ServiceRootV1_1_0 = (EFI_REDFISH_SERVICEROOT_V1_1_0 *)InterpProp; + DestroyServiceRoot_V1_1_0_CS (ServiceRootV1_1_0->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_1_1/RedfishServiceRoot_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_1_1/RedfishServiceRoot_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..e6ff770c200 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_1_1/RedfishServiceRoot_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_1_1_Dxe + FILE_GUID = dab75057-abd7-4763-bc50-139c2953375a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_1_1/ServiceRoot_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_1_1/ServiceRoot_V1_1_1_Dxe.c new file mode 100644 index 00000000000..ad52927f7c1 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_1_1/ServiceRoot_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "1", + "1" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_1_1 *ServiceRootV1_1_1; + EFI_REDFISH_SERVICEROOT_V1_1_1_CS *ServiceRootV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_1_1_To_CS (ResoruceRaw, &ServiceRootV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_1_1 = (EFI_REDFISH_SERVICEROOT_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_1_1)); + if (ServiceRootV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_1_1; + ServiceRootV1_1_1->ServiceRoot = ServiceRootV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_1_1_JSON (*((EFI_REDFISH_SERVICEROOT_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_1_1 *ServiceRootV1_1_1; + + ServiceRootV1_1_1 = (EFI_REDFISH_SERVICEROOT_V1_1_1 *)InterpProp; + DestroyServiceRoot_V1_1_1_CS (ServiceRootV1_1_1->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_1_2/RedfishServiceRoot_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_1_2/RedfishServiceRoot_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..15367244a2c --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_1_2/RedfishServiceRoot_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_1_2_Dxe + FILE_GUID = e7f3c9b5-3d49-462a-b3b5-de03d0337ef9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_1_2/ServiceRoot_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_1_2/ServiceRoot_V1_1_2_Dxe.c new file mode 100644 index 00000000000..259b57520df --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_1_2/ServiceRoot_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "1", + "2" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_1_2 *ServiceRootV1_1_2; + EFI_REDFISH_SERVICEROOT_V1_1_2_CS *ServiceRootV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_1_2_To_CS (ResoruceRaw, &ServiceRootV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_1_2 = (EFI_REDFISH_SERVICEROOT_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_1_2)); + if (ServiceRootV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_1_2; + ServiceRootV1_1_2->ServiceRoot = ServiceRootV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_1_2_JSON (*((EFI_REDFISH_SERVICEROOT_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_1_2 *ServiceRootV1_1_2; + + ServiceRootV1_1_2 = (EFI_REDFISH_SERVICEROOT_V1_1_2 *)InterpProp; + DestroyServiceRoot_V1_1_2_CS (ServiceRootV1_1_2->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_1_3/RedfishServiceRoot_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_1_3/RedfishServiceRoot_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..4f2694de54c --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_1_3/RedfishServiceRoot_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_1_3_Dxe + FILE_GUID = 7e004801-81b7-486c-bfc9-ecedbb315b63 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_1_3/ServiceRoot_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_1_3/ServiceRoot_V1_1_3_Dxe.c new file mode 100644 index 00000000000..6065ca15b77 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_1_3/ServiceRoot_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "1", + "3" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_1_3 *ServiceRootV1_1_3; + EFI_REDFISH_SERVICEROOT_V1_1_3_CS *ServiceRootV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_1_3_To_CS (ResoruceRaw, &ServiceRootV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_1_3 = (EFI_REDFISH_SERVICEROOT_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_1_3)); + if (ServiceRootV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_1_3; + ServiceRootV1_1_3->ServiceRoot = ServiceRootV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_1_3_JSON (*((EFI_REDFISH_SERVICEROOT_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_1_3 *ServiceRootV1_1_3; + + ServiceRootV1_1_3 = (EFI_REDFISH_SERVICEROOT_V1_1_3 *)InterpProp; + DestroyServiceRoot_V1_1_3_CS (ServiceRootV1_1_3->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_1_4/RedfishServiceRoot_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_1_4/RedfishServiceRoot_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..cb3cfc000e2 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_1_4/RedfishServiceRoot_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_1_4_Dxe + FILE_GUID = ad4ff91d-6755-411f-8957-bdd151f0dd33 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_1_4/ServiceRoot_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_1_4/ServiceRoot_V1_1_4_Dxe.c new file mode 100644 index 00000000000..5017d648bb4 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_1_4/ServiceRoot_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "1", + "4" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_1_4 *ServiceRootV1_1_4; + EFI_REDFISH_SERVICEROOT_V1_1_4_CS *ServiceRootV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_1_4_To_CS (ResoruceRaw, &ServiceRootV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_1_4 = (EFI_REDFISH_SERVICEROOT_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_1_4)); + if (ServiceRootV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_1_4; + ServiceRootV1_1_4->ServiceRoot = ServiceRootV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_1_4_JSON (*((EFI_REDFISH_SERVICEROOT_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_1_4 *ServiceRootV1_1_4; + + ServiceRootV1_1_4 = (EFI_REDFISH_SERVICEROOT_V1_1_4 *)InterpProp; + DestroyServiceRoot_V1_1_4_CS (ServiceRootV1_1_4->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_1_5/RedfishServiceRoot_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_1_5/RedfishServiceRoot_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..f9ac5729df5 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_1_5/RedfishServiceRoot_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_1_5_Dxe + FILE_GUID = f5a75525-8edd-42d6-b1db-1b10cd91ced0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_1_5/ServiceRoot_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_1_5/ServiceRoot_V1_1_5_Dxe.c new file mode 100644 index 00000000000..a15b7306d84 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_1_5/ServiceRoot_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "1", + "5" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_1_5 *ServiceRootV1_1_5; + EFI_REDFISH_SERVICEROOT_V1_1_5_CS *ServiceRootV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_1_5_To_CS (ResoruceRaw, &ServiceRootV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_1_5 = (EFI_REDFISH_SERVICEROOT_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_1_5)); + if (ServiceRootV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_1_5; + ServiceRootV1_1_5->ServiceRoot = ServiceRootV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_1_5_JSON (*((EFI_REDFISH_SERVICEROOT_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_1_5 *ServiceRootV1_1_5; + + ServiceRootV1_1_5 = (EFI_REDFISH_SERVICEROOT_V1_1_5 *)InterpProp; + DestroyServiceRoot_V1_1_5_CS (ServiceRootV1_1_5->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_1_6/RedfishServiceRoot_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_1_6/RedfishServiceRoot_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..d33dc5a2da1 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_1_6/RedfishServiceRoot_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_1_6_Dxe + FILE_GUID = f4f16e43-3009-4f5e-999e-17cdbcbf3207 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_1_6/ServiceRoot_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_1_6/ServiceRoot_V1_1_6_Dxe.c new file mode 100644 index 00000000000..55073f1a75a --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_1_6/ServiceRoot_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "1", + "6" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_1_6 *ServiceRootV1_1_6; + EFI_REDFISH_SERVICEROOT_V1_1_6_CS *ServiceRootV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_1_6_To_CS (ResoruceRaw, &ServiceRootV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_1_6 = (EFI_REDFISH_SERVICEROOT_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_1_6)); + if (ServiceRootV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_1_6; + ServiceRootV1_1_6->ServiceRoot = ServiceRootV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_1_6_JSON (*((EFI_REDFISH_SERVICEROOT_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_1_6 *ServiceRootV1_1_6; + + ServiceRootV1_1_6 = (EFI_REDFISH_SERVICEROOT_V1_1_6 *)InterpProp; + DestroyServiceRoot_V1_1_6_CS (ServiceRootV1_1_6->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_2_0/RedfishServiceRoot_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_2_0/RedfishServiceRoot_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..691642b2e40 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_2_0/RedfishServiceRoot_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_2_0_Dxe + FILE_GUID = 4683485f-3a75-42aa-ab63-a85b0ffb261f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_2_0/ServiceRoot_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_2_0/ServiceRoot_V1_2_0_Dxe.c new file mode 100644 index 00000000000..a5ac66b554d --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_2_0/ServiceRoot_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "2", + "0" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_2_0 *ServiceRootV1_2_0; + EFI_REDFISH_SERVICEROOT_V1_2_0_CS *ServiceRootV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_2_0_To_CS (ResoruceRaw, &ServiceRootV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_2_0 = (EFI_REDFISH_SERVICEROOT_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_2_0)); + if (ServiceRootV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_2_0; + ServiceRootV1_2_0->ServiceRoot = ServiceRootV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_2_0_JSON (*((EFI_REDFISH_SERVICEROOT_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_2_0 *ServiceRootV1_2_0; + + ServiceRootV1_2_0 = (EFI_REDFISH_SERVICEROOT_V1_2_0 *)InterpProp; + DestroyServiceRoot_V1_2_0_CS (ServiceRootV1_2_0->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_2_1/RedfishServiceRoot_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_2_1/RedfishServiceRoot_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..496d6c7931d --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_2_1/RedfishServiceRoot_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_2_1_Dxe + FILE_GUID = bc931062-6ea8-43d0-95a3-33c80713deac + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_2_1/ServiceRoot_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_2_1/ServiceRoot_V1_2_1_Dxe.c new file mode 100644 index 00000000000..fcefcd87431 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_2_1/ServiceRoot_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "2", + "1" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_2_1 *ServiceRootV1_2_1; + EFI_REDFISH_SERVICEROOT_V1_2_1_CS *ServiceRootV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_2_1_To_CS (ResoruceRaw, &ServiceRootV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_2_1 = (EFI_REDFISH_SERVICEROOT_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_2_1)); + if (ServiceRootV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_2_1; + ServiceRootV1_2_1->ServiceRoot = ServiceRootV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_2_1_JSON (*((EFI_REDFISH_SERVICEROOT_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_2_1 *ServiceRootV1_2_1; + + ServiceRootV1_2_1 = (EFI_REDFISH_SERVICEROOT_V1_2_1 *)InterpProp; + DestroyServiceRoot_V1_2_1_CS (ServiceRootV1_2_1->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_2_2/RedfishServiceRoot_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_2_2/RedfishServiceRoot_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..957c6a47e58 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_2_2/RedfishServiceRoot_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_2_2_Dxe + FILE_GUID = 4729fbeb-303f-401c-b58b-ee75bd8971d6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_2_2/ServiceRoot_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_2_2/ServiceRoot_V1_2_2_Dxe.c new file mode 100644 index 00000000000..0d925a07d79 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_2_2/ServiceRoot_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "2", + "2" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_2_2 *ServiceRootV1_2_2; + EFI_REDFISH_SERVICEROOT_V1_2_2_CS *ServiceRootV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_2_2_To_CS (ResoruceRaw, &ServiceRootV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_2_2 = (EFI_REDFISH_SERVICEROOT_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_2_2)); + if (ServiceRootV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_2_2; + ServiceRootV1_2_2->ServiceRoot = ServiceRootV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_2_2_JSON (*((EFI_REDFISH_SERVICEROOT_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_2_2 *ServiceRootV1_2_2; + + ServiceRootV1_2_2 = (EFI_REDFISH_SERVICEROOT_V1_2_2 *)InterpProp; + DestroyServiceRoot_V1_2_2_CS (ServiceRootV1_2_2->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_2_3/RedfishServiceRoot_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_2_3/RedfishServiceRoot_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..a232c66bff0 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_2_3/RedfishServiceRoot_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_2_3_Dxe + FILE_GUID = 7b0ea320-0657-419e-bfab-86463661f0b7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_2_3/ServiceRoot_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_2_3/ServiceRoot_V1_2_3_Dxe.c new file mode 100644 index 00000000000..84bfa883fd5 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_2_3/ServiceRoot_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "2", + "3" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_2_3 *ServiceRootV1_2_3; + EFI_REDFISH_SERVICEROOT_V1_2_3_CS *ServiceRootV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_2_3_To_CS (ResoruceRaw, &ServiceRootV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_2_3 = (EFI_REDFISH_SERVICEROOT_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_2_3)); + if (ServiceRootV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_2_3; + ServiceRootV1_2_3->ServiceRoot = ServiceRootV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_2_3_JSON (*((EFI_REDFISH_SERVICEROOT_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_2_3 *ServiceRootV1_2_3; + + ServiceRootV1_2_3 = (EFI_REDFISH_SERVICEROOT_V1_2_3 *)InterpProp; + DestroyServiceRoot_V1_2_3_CS (ServiceRootV1_2_3->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_2_4/RedfishServiceRoot_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_2_4/RedfishServiceRoot_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..5495bbf429d --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_2_4/RedfishServiceRoot_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_2_4_Dxe + FILE_GUID = 4861ae13-6859-4235-8262-9f0159ce041e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_2_4/ServiceRoot_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_2_4/ServiceRoot_V1_2_4_Dxe.c new file mode 100644 index 00000000000..46a0f205bcc --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_2_4/ServiceRoot_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "2", + "4" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_2_4 *ServiceRootV1_2_4; + EFI_REDFISH_SERVICEROOT_V1_2_4_CS *ServiceRootV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_2_4_To_CS (ResoruceRaw, &ServiceRootV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_2_4 = (EFI_REDFISH_SERVICEROOT_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_2_4)); + if (ServiceRootV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_2_4; + ServiceRootV1_2_4->ServiceRoot = ServiceRootV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_2_4_JSON (*((EFI_REDFISH_SERVICEROOT_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_2_4 *ServiceRootV1_2_4; + + ServiceRootV1_2_4 = (EFI_REDFISH_SERVICEROOT_V1_2_4 *)InterpProp; + DestroyServiceRoot_V1_2_4_CS (ServiceRootV1_2_4->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_3_0/RedfishServiceRoot_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_3_0/RedfishServiceRoot_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..4ab8fc46c12 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_3_0/RedfishServiceRoot_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_3_0_Dxe + FILE_GUID = 30befa13-0cca-45fc-8757-72b69caa99d7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_3_0/ServiceRoot_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_3_0/ServiceRoot_V1_3_0_Dxe.c new file mode 100644 index 00000000000..56a4d4af375 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_3_0/ServiceRoot_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "3", + "0" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_3_0 *ServiceRootV1_3_0; + EFI_REDFISH_SERVICEROOT_V1_3_0_CS *ServiceRootV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_3_0_To_CS (ResoruceRaw, &ServiceRootV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_3_0 = (EFI_REDFISH_SERVICEROOT_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_3_0)); + if (ServiceRootV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_3_0; + ServiceRootV1_3_0->ServiceRoot = ServiceRootV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_3_0_JSON (*((EFI_REDFISH_SERVICEROOT_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_3_0 *ServiceRootV1_3_0; + + ServiceRootV1_3_0 = (EFI_REDFISH_SERVICEROOT_V1_3_0 *)InterpProp; + DestroyServiceRoot_V1_3_0_CS (ServiceRootV1_3_0->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_3_1/RedfishServiceRoot_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_3_1/RedfishServiceRoot_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..a44ea928fb2 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_3_1/RedfishServiceRoot_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_3_1_Dxe + FILE_GUID = 08c67c68-087e-478f-b2e2-f96b6df426ed + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_3_1/ServiceRoot_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_3_1/ServiceRoot_V1_3_1_Dxe.c new file mode 100644 index 00000000000..9231202aea5 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_3_1/ServiceRoot_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "3", + "1" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_3_1 *ServiceRootV1_3_1; + EFI_REDFISH_SERVICEROOT_V1_3_1_CS *ServiceRootV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_3_1_To_CS (ResoruceRaw, &ServiceRootV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_3_1 = (EFI_REDFISH_SERVICEROOT_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_3_1)); + if (ServiceRootV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_3_1; + ServiceRootV1_3_1->ServiceRoot = ServiceRootV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_3_1_JSON (*((EFI_REDFISH_SERVICEROOT_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_3_1 *ServiceRootV1_3_1; + + ServiceRootV1_3_1 = (EFI_REDFISH_SERVICEROOT_V1_3_1 *)InterpProp; + DestroyServiceRoot_V1_3_1_CS (ServiceRootV1_3_1->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_3_2/RedfishServiceRoot_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_3_2/RedfishServiceRoot_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..c90b08308b6 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_3_2/RedfishServiceRoot_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_3_2_Dxe + FILE_GUID = 40c4f07d-02d1-4c85-b476-264e2e1c8f53 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_3_2/ServiceRoot_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_3_2/ServiceRoot_V1_3_2_Dxe.c new file mode 100644 index 00000000000..04608f97679 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_3_2/ServiceRoot_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "3", + "2" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_3_2 *ServiceRootV1_3_2; + EFI_REDFISH_SERVICEROOT_V1_3_2_CS *ServiceRootV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_3_2_To_CS (ResoruceRaw, &ServiceRootV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_3_2 = (EFI_REDFISH_SERVICEROOT_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_3_2)); + if (ServiceRootV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_3_2; + ServiceRootV1_3_2->ServiceRoot = ServiceRootV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_3_2_JSON (*((EFI_REDFISH_SERVICEROOT_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_3_2 *ServiceRootV1_3_2; + + ServiceRootV1_3_2 = (EFI_REDFISH_SERVICEROOT_V1_3_2 *)InterpProp; + DestroyServiceRoot_V1_3_2_CS (ServiceRootV1_3_2->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_3_3/RedfishServiceRoot_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_3_3/RedfishServiceRoot_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..85060f0af53 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_3_3/RedfishServiceRoot_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_3_3_Dxe + FILE_GUID = 8fb9c1b4-5117-4004-95be-32fb86e33142 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_3_3/ServiceRoot_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_3_3/ServiceRoot_V1_3_3_Dxe.c new file mode 100644 index 00000000000..b1b6bb51065 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_3_3/ServiceRoot_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "3", + "3" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_3_3 *ServiceRootV1_3_3; + EFI_REDFISH_SERVICEROOT_V1_3_3_CS *ServiceRootV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_3_3_To_CS (ResoruceRaw, &ServiceRootV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_3_3 = (EFI_REDFISH_SERVICEROOT_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_3_3)); + if (ServiceRootV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_3_3; + ServiceRootV1_3_3->ServiceRoot = ServiceRootV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_3_3_JSON (*((EFI_REDFISH_SERVICEROOT_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_3_3 *ServiceRootV1_3_3; + + ServiceRootV1_3_3 = (EFI_REDFISH_SERVICEROOT_V1_3_3 *)InterpProp; + DestroyServiceRoot_V1_3_3_CS (ServiceRootV1_3_3->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_3_4/RedfishServiceRoot_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_3_4/RedfishServiceRoot_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..1c200ab9f8b --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_3_4/RedfishServiceRoot_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_3_4_Dxe + FILE_GUID = e404465e-5943-404e-b938-f2f7c10d7cfe + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_3_4/ServiceRoot_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_3_4/ServiceRoot_V1_3_4_Dxe.c new file mode 100644 index 00000000000..d21a6389917 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_3_4/ServiceRoot_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "3", + "4" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_3_4 *ServiceRootV1_3_4; + EFI_REDFISH_SERVICEROOT_V1_3_4_CS *ServiceRootV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_3_4_To_CS (ResoruceRaw, &ServiceRootV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_3_4 = (EFI_REDFISH_SERVICEROOT_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_3_4)); + if (ServiceRootV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_3_4; + ServiceRootV1_3_4->ServiceRoot = ServiceRootV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_3_4_JSON (*((EFI_REDFISH_SERVICEROOT_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_3_4 *ServiceRootV1_3_4; + + ServiceRootV1_3_4 = (EFI_REDFISH_SERVICEROOT_V1_3_4 *)InterpProp; + DestroyServiceRoot_V1_3_4_CS (ServiceRootV1_3_4->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_3_5/RedfishServiceRoot_V1_3_5_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_3_5/RedfishServiceRoot_V1_3_5_Dxe.inf new file mode 100644 index 00000000000..5ad0456ae96 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_3_5/RedfishServiceRoot_V1_3_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_3_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_3_5_Dxe + FILE_GUID = b7991dba-6c25-4a55-bc18-17cba56a07ca + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_3_5EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_3_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_3_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_3_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_3_5/ServiceRoot_V1_3_5_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_3_5/ServiceRoot_V1_3_5_Dxe.c new file mode 100644 index 00000000000..eb905fbe3b6 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_3_5/ServiceRoot_V1_3_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_3_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "3", + "5" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_3_5 *ServiceRootV1_3_5; + EFI_REDFISH_SERVICEROOT_V1_3_5_CS *ServiceRootV1_3_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_3_5_To_CS (ResoruceRaw, &ServiceRootV1_3_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_3_5 = (EFI_REDFISH_SERVICEROOT_V1_3_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_3_5)); + if (ServiceRootV1_3_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_3_5; + ServiceRootV1_3_5->ServiceRoot = ServiceRootV1_3_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_3_5_JSON (*((EFI_REDFISH_SERVICEROOT_V1_3_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_3_5 *ServiceRootV1_3_5; + + ServiceRootV1_3_5 = (EFI_REDFISH_SERVICEROOT_V1_3_5 *)InterpProp; + DestroyServiceRoot_V1_3_5_CS (ServiceRootV1_3_5->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_3_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_3_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_3_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_4_0/RedfishServiceRoot_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_4_0/RedfishServiceRoot_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..16a78ff4c15 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_4_0/RedfishServiceRoot_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_4_0_Dxe + FILE_GUID = 7ceaeadc-6e3f-49fa-8b62-23c14424d440 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_4_0/ServiceRoot_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_4_0/ServiceRoot_V1_4_0_Dxe.c new file mode 100644 index 00000000000..9b15a702ba5 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_4_0/ServiceRoot_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "4", + "0" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_4_0 *ServiceRootV1_4_0; + EFI_REDFISH_SERVICEROOT_V1_4_0_CS *ServiceRootV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_4_0_To_CS (ResoruceRaw, &ServiceRootV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_4_0 = (EFI_REDFISH_SERVICEROOT_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_4_0)); + if (ServiceRootV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_4_0; + ServiceRootV1_4_0->ServiceRoot = ServiceRootV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_4_0_JSON (*((EFI_REDFISH_SERVICEROOT_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_4_0 *ServiceRootV1_4_0; + + ServiceRootV1_4_0 = (EFI_REDFISH_SERVICEROOT_V1_4_0 *)InterpProp; + DestroyServiceRoot_V1_4_0_CS (ServiceRootV1_4_0->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_4_1/RedfishServiceRoot_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_4_1/RedfishServiceRoot_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..7ae9f0d76cb --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_4_1/RedfishServiceRoot_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_4_1_Dxe + FILE_GUID = ce009dcd-2b71-4663-8329-4bf5e2e5da18 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_4_1/ServiceRoot_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_4_1/ServiceRoot_V1_4_1_Dxe.c new file mode 100644 index 00000000000..d614359dfc9 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_4_1/ServiceRoot_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "4", + "1" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_4_1 *ServiceRootV1_4_1; + EFI_REDFISH_SERVICEROOT_V1_4_1_CS *ServiceRootV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_4_1_To_CS (ResoruceRaw, &ServiceRootV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_4_1 = (EFI_REDFISH_SERVICEROOT_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_4_1)); + if (ServiceRootV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_4_1; + ServiceRootV1_4_1->ServiceRoot = ServiceRootV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_4_1_JSON (*((EFI_REDFISH_SERVICEROOT_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_4_1 *ServiceRootV1_4_1; + + ServiceRootV1_4_1 = (EFI_REDFISH_SERVICEROOT_V1_4_1 *)InterpProp; + DestroyServiceRoot_V1_4_1_CS (ServiceRootV1_4_1->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_4_2/RedfishServiceRoot_V1_4_2_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_4_2/RedfishServiceRoot_V1_4_2_Dxe.inf new file mode 100644 index 00000000000..0328c152c03 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_4_2/RedfishServiceRoot_V1_4_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_4_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_4_2_Dxe + FILE_GUID = 57e8f49d-77c0-4229-940e-2ca613ea8484 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_4_2EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_4_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_4_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_4_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_4_2/ServiceRoot_V1_4_2_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_4_2/ServiceRoot_V1_4_2_Dxe.c new file mode 100644 index 00000000000..6cb218da5cc --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_4_2/ServiceRoot_V1_4_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_4_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "4", + "2" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_4_2 *ServiceRootV1_4_2; + EFI_REDFISH_SERVICEROOT_V1_4_2_CS *ServiceRootV1_4_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_4_2_To_CS (ResoruceRaw, &ServiceRootV1_4_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_4_2 = (EFI_REDFISH_SERVICEROOT_V1_4_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_4_2)); + if (ServiceRootV1_4_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_4_2; + ServiceRootV1_4_2->ServiceRoot = ServiceRootV1_4_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_4_2_JSON (*((EFI_REDFISH_SERVICEROOT_V1_4_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_4_2 *ServiceRootV1_4_2; + + ServiceRootV1_4_2 = (EFI_REDFISH_SERVICEROOT_V1_4_2 *)InterpProp; + DestroyServiceRoot_V1_4_2_CS (ServiceRootV1_4_2->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_4_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_4_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_4_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_4_3/RedfishServiceRoot_V1_4_3_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_4_3/RedfishServiceRoot_V1_4_3_Dxe.inf new file mode 100644 index 00000000000..d31e98eb635 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_4_3/RedfishServiceRoot_V1_4_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_4_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_4_3_Dxe + FILE_GUID = c200358c-15c9-44b7-a441-9071fc235ae7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_4_3EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_4_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_4_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_4_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_4_3/ServiceRoot_V1_4_3_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_4_3/ServiceRoot_V1_4_3_Dxe.c new file mode 100644 index 00000000000..a7a64d60d54 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_4_3/ServiceRoot_V1_4_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_4_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "4", + "3" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_4_3 *ServiceRootV1_4_3; + EFI_REDFISH_SERVICEROOT_V1_4_3_CS *ServiceRootV1_4_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_4_3_To_CS (ResoruceRaw, &ServiceRootV1_4_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_4_3 = (EFI_REDFISH_SERVICEROOT_V1_4_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_4_3)); + if (ServiceRootV1_4_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_4_3; + ServiceRootV1_4_3->ServiceRoot = ServiceRootV1_4_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_4_3_JSON (*((EFI_REDFISH_SERVICEROOT_V1_4_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_4_3 *ServiceRootV1_4_3; + + ServiceRootV1_4_3 = (EFI_REDFISH_SERVICEROOT_V1_4_3 *)InterpProp; + DestroyServiceRoot_V1_4_3_CS (ServiceRootV1_4_3->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_4_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_4_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_4_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_5_0/RedfishServiceRoot_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_5_0/RedfishServiceRoot_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..e88c2478589 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_5_0/RedfishServiceRoot_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_5_0_Dxe + FILE_GUID = eb3c14fb-8b49-4908-a35b-3a54c38f1af3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_5_0/ServiceRoot_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_5_0/ServiceRoot_V1_5_0_Dxe.c new file mode 100644 index 00000000000..42887f46faa --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_5_0/ServiceRoot_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "5", + "0" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_5_0 *ServiceRootV1_5_0; + EFI_REDFISH_SERVICEROOT_V1_5_0_CS *ServiceRootV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_5_0_To_CS (ResoruceRaw, &ServiceRootV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_5_0 = (EFI_REDFISH_SERVICEROOT_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_5_0)); + if (ServiceRootV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_5_0; + ServiceRootV1_5_0->ServiceRoot = ServiceRootV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_5_0_JSON (*((EFI_REDFISH_SERVICEROOT_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_5_0 *ServiceRootV1_5_0; + + ServiceRootV1_5_0 = (EFI_REDFISH_SERVICEROOT_V1_5_0 *)InterpProp; + DestroyServiceRoot_V1_5_0_CS (ServiceRootV1_5_0->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_5_1/RedfishServiceRoot_V1_5_1_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_5_1/RedfishServiceRoot_V1_5_1_Dxe.inf new file mode 100644 index 00000000000..dde4d88f250 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_5_1/RedfishServiceRoot_V1_5_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_5_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_5_1_Dxe + FILE_GUID = 080baaae-303e-4874-8486-4a81441f98b0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_5_1EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_5_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_5_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_5_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_5_1/ServiceRoot_V1_5_1_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_5_1/ServiceRoot_V1_5_1_Dxe.c new file mode 100644 index 00000000000..5f67d371baf --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_5_1/ServiceRoot_V1_5_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_5_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "5", + "1" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_5_1 *ServiceRootV1_5_1; + EFI_REDFISH_SERVICEROOT_V1_5_1_CS *ServiceRootV1_5_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_5_1_To_CS (ResoruceRaw, &ServiceRootV1_5_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_5_1 = (EFI_REDFISH_SERVICEROOT_V1_5_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_5_1)); + if (ServiceRootV1_5_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_5_1; + ServiceRootV1_5_1->ServiceRoot = ServiceRootV1_5_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_5_1_JSON (*((EFI_REDFISH_SERVICEROOT_V1_5_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_5_1 *ServiceRootV1_5_1; + + ServiceRootV1_5_1 = (EFI_REDFISH_SERVICEROOT_V1_5_1 *)InterpProp; + DestroyServiceRoot_V1_5_1_CS (ServiceRootV1_5_1->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_5_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_5_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_5_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_5_2/RedfishServiceRoot_V1_5_2_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_5_2/RedfishServiceRoot_V1_5_2_Dxe.inf new file mode 100644 index 00000000000..b2d0523a165 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_5_2/RedfishServiceRoot_V1_5_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_5_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_5_2_Dxe + FILE_GUID = 959cb391-455c-403a-be00-41c7d1c1d4db + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_5_2EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_5_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_5_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_5_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_5_2/ServiceRoot_V1_5_2_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_5_2/ServiceRoot_V1_5_2_Dxe.c new file mode 100644 index 00000000000..b644de69dbf --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_5_2/ServiceRoot_V1_5_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_5_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "5", + "2" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_5_2 *ServiceRootV1_5_2; + EFI_REDFISH_SERVICEROOT_V1_5_2_CS *ServiceRootV1_5_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_5_2_To_CS (ResoruceRaw, &ServiceRootV1_5_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_5_2 = (EFI_REDFISH_SERVICEROOT_V1_5_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_5_2)); + if (ServiceRootV1_5_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_5_2; + ServiceRootV1_5_2->ServiceRoot = ServiceRootV1_5_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_5_2_JSON (*((EFI_REDFISH_SERVICEROOT_V1_5_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_5_2 *ServiceRootV1_5_2; + + ServiceRootV1_5_2 = (EFI_REDFISH_SERVICEROOT_V1_5_2 *)InterpProp; + DestroyServiceRoot_V1_5_2_CS (ServiceRootV1_5_2->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_5_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_5_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_5_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_6_0/RedfishServiceRoot_V1_6_0_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_6_0/RedfishServiceRoot_V1_6_0_Dxe.inf new file mode 100644 index 00000000000..16072b4f242 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_6_0/RedfishServiceRoot_V1_6_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_6_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_6_0_Dxe + FILE_GUID = 41b88006-323b-48d5-9ea7-2906a7f831a4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_6_0EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_6_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_6_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_6_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_6_0/ServiceRoot_V1_6_0_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_6_0/ServiceRoot_V1_6_0_Dxe.c new file mode 100644 index 00000000000..ed0904d070c --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_6_0/ServiceRoot_V1_6_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_6_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "6", + "0" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_6_0 *ServiceRootV1_6_0; + EFI_REDFISH_SERVICEROOT_V1_6_0_CS *ServiceRootV1_6_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_6_0_To_CS (ResoruceRaw, &ServiceRootV1_6_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_6_0 = (EFI_REDFISH_SERVICEROOT_V1_6_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_6_0)); + if (ServiceRootV1_6_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_6_0; + ServiceRootV1_6_0->ServiceRoot = ServiceRootV1_6_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_6_0_JSON (*((EFI_REDFISH_SERVICEROOT_V1_6_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_6_0 *ServiceRootV1_6_0; + + ServiceRootV1_6_0 = (EFI_REDFISH_SERVICEROOT_V1_6_0 *)InterpProp; + DestroyServiceRoot_V1_6_0_CS (ServiceRootV1_6_0->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_6_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_6_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_6_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_7_0/RedfishServiceRoot_V1_7_0_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_7_0/RedfishServiceRoot_V1_7_0_Dxe.inf new file mode 100644 index 00000000000..b862ed2290f --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_7_0/RedfishServiceRoot_V1_7_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_7_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_7_0_Dxe + FILE_GUID = baa0b4d8-6e13-4c3f-94c5-012c6fe30f60 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_7_0EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_7_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_7_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_7_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_7_0/ServiceRoot_V1_7_0_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_7_0/ServiceRoot_V1_7_0_Dxe.c new file mode 100644 index 00000000000..a0ce49797ce --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_7_0/ServiceRoot_V1_7_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_7_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "7", + "0" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_7_0 *ServiceRootV1_7_0; + EFI_REDFISH_SERVICEROOT_V1_7_0_CS *ServiceRootV1_7_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_7_0_To_CS (ResoruceRaw, &ServiceRootV1_7_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_7_0 = (EFI_REDFISH_SERVICEROOT_V1_7_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_7_0)); + if (ServiceRootV1_7_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_7_0; + ServiceRootV1_7_0->ServiceRoot = ServiceRootV1_7_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_7_0_JSON (*((EFI_REDFISH_SERVICEROOT_V1_7_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_7_0 *ServiceRootV1_7_0; + + ServiceRootV1_7_0 = (EFI_REDFISH_SERVICEROOT_V1_7_0 *)InterpProp; + DestroyServiceRoot_V1_7_0_CS (ServiceRootV1_7_0->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_7_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_7_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_7_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_8_0/RedfishServiceRoot_V1_8_0_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_8_0/RedfishServiceRoot_V1_8_0_Dxe.inf new file mode 100644 index 00000000000..e7cad093c4d --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_8_0/RedfishServiceRoot_V1_8_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_8_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_8_0_Dxe + FILE_GUID = 3b849a5a-fc3b-4a9c-9c1c-afb001d0f59b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_8_0EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_8_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_8_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_8_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_8_0/ServiceRoot_V1_8_0_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_8_0/ServiceRoot_V1_8_0_Dxe.c new file mode 100644 index 00000000000..56b9fa0d85b --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_8_0/ServiceRoot_V1_8_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_8_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_8_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "8", + "0" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_8_0 *ServiceRootV1_8_0; + EFI_REDFISH_SERVICEROOT_V1_8_0_CS *ServiceRootV1_8_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_8_0_To_CS (ResoruceRaw, &ServiceRootV1_8_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_8_0 = (EFI_REDFISH_SERVICEROOT_V1_8_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_8_0)); + if (ServiceRootV1_8_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_8_0; + ServiceRootV1_8_0->ServiceRoot = ServiceRootV1_8_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_8_0_JSON (*((EFI_REDFISH_SERVICEROOT_V1_8_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_8_0 *ServiceRootV1_8_0; + + ServiceRootV1_8_0 = (EFI_REDFISH_SERVICEROOT_V1_8_0 *)InterpProp; + DestroyServiceRoot_V1_8_0_CS (ServiceRootV1_8_0->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_8_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_8_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_8_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_9_0/RedfishServiceRoot_V1_9_0_Dxe.inf b/RedfishClientPkg/Converter/ServiceRoot/v1_9_0/RedfishServiceRoot_V1_9_0_Dxe.inf new file mode 100644 index 00000000000..2fa13e6f305 --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_9_0/RedfishServiceRoot_V1_9_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ServiceRoot.v1_9_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishServiceRoot_V1_9_0_Dxe + FILE_GUID = 87a2e3d2-3a97-4873-bd4d-92506bd61968 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishServiceRoot_V1_9_0EntryPoint + UNLOAD_IMAGE = RedfishServiceRoot_V1_9_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ServiceRoot_V1_9_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ServiceRootV1_9_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ServiceRoot/v1_9_0/ServiceRoot_V1_9_0_Dxe.c b/RedfishClientPkg/Converter/ServiceRoot/v1_9_0/ServiceRoot_V1_9_0_Dxe.c new file mode 100644 index 00000000000..08575dd360e --- /dev/null +++ b/RedfishClientPkg/Converter/ServiceRoot/v1_9_0/ServiceRoot_V1_9_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ServiceRoot.v1_9_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ServiceRoot"; +BOOLEAN IsRevisonController = TRUE; + +// Support ServiceRoot V1_9_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ServiceRoot", + "1", + "9", + "0" + }, + "ServiceRoot" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_9_0 *ServiceRootV1_9_0; + EFI_REDFISH_SERVICEROOT_V1_9_0_CS *ServiceRootV1_9_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ServiceRoot") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ServiceRoot_V1_9_0_To_CS (ResoruceRaw, &ServiceRootV1_9_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ServiceRootV1_9_0 = (EFI_REDFISH_SERVICEROOT_V1_9_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SERVICEROOT_V1_9_0)); + if (ServiceRootV1_9_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ServiceRootV1_9_0; + ServiceRootV1_9_0->ServiceRoot = ServiceRootV1_9_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ServiceRoot")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ServiceRoot"), "ServiceRoot"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ServiceRootToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ServiceRootToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ServiceRoot_V1_9_0_JSON (*((EFI_REDFISH_SERVICEROOT_V1_9_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ServiceRootToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SERVICEROOT_V1_9_0 *ServiceRootV1_9_0; + + ServiceRootV1_9_0 = (EFI_REDFISH_SERVICEROOT_V1_9_0 *)InterpProp; + DestroyServiceRoot_V1_9_0_CS (ServiceRootV1_9_0->ServiceRoot); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ServiceRootFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ServiceRootDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyServiceRoot_V1_9_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_9_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ServiceRootToStructWrapper, + ServiceRootToJson, + ServiceRootDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishServiceRoot_V1_9_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Session/v1_0_0/RedfishSession_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Session/v1_0_0/RedfishSession_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..664f790b648 --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_0_0/RedfishSession_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Session.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSession_V1_0_0_Dxe + FILE_GUID = e291d210-ea50-4e8a-958a-3a75283b171b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSession_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishSession_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Session_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Session/v1_0_0/Session_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Session/v1_0_0/Session_V1_0_0_Dxe.c new file mode 100644 index 00000000000..ada5dae653a --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_0_0/Session_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Session.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Session"; +BOOLEAN IsRevisonController = TRUE; + +// Support Session V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Session", + "1", + "0", + "0" + }, + "Session" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSION_V1_0_0 *SessionV1_0_0; + EFI_REDFISH_SESSION_V1_0_0_CS *SessionV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Session") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Session_V1_0_0_To_CS (ResoruceRaw, &SessionV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionV1_0_0 = (EFI_REDFISH_SESSION_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSION_V1_0_0)); + if (SessionV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionV1_0_0; + SessionV1_0_0->Session = SessionV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Session"), "Session"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Session"), "Session"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Session_V1_0_0_JSON (*((EFI_REDFISH_SESSION_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSION_V1_0_0 *SessionV1_0_0; + + SessionV1_0_0 = (EFI_REDFISH_SESSION_V1_0_0 *)InterpProp; + DestroySession_V1_0_0_CS (SessionV1_0_0->Session); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySession_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionToStructWrapper, + SessionToJson, + SessionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Session/v1_0_2/RedfishSession_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Session/v1_0_2/RedfishSession_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..460454f4b63 --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_0_2/RedfishSession_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Session.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSession_V1_0_2_Dxe + FILE_GUID = 88d3d632-eb0c-4944-951a-fd147a3fdf5d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSession_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishSession_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Session_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Session/v1_0_2/Session_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Session/v1_0_2/Session_V1_0_2_Dxe.c new file mode 100644 index 00000000000..84df7815520 --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_0_2/Session_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Session.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Session"; +BOOLEAN IsRevisonController = TRUE; + +// Support Session V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Session", + "1", + "0", + "2" + }, + "Session" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSION_V1_0_2 *SessionV1_0_2; + EFI_REDFISH_SESSION_V1_0_2_CS *SessionV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Session") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Session_V1_0_2_To_CS (ResoruceRaw, &SessionV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionV1_0_2 = (EFI_REDFISH_SESSION_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSION_V1_0_2)); + if (SessionV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionV1_0_2; + SessionV1_0_2->Session = SessionV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Session"), "Session"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Session"), "Session"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Session_V1_0_2_JSON (*((EFI_REDFISH_SESSION_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSION_V1_0_2 *SessionV1_0_2; + + SessionV1_0_2 = (EFI_REDFISH_SESSION_V1_0_2 *)InterpProp; + DestroySession_V1_0_2_CS (SessionV1_0_2->Session); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySession_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionToStructWrapper, + SessionToJson, + SessionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Session/v1_0_3/RedfishSession_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/Session/v1_0_3/RedfishSession_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..0fbffada723 --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_0_3/RedfishSession_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Session.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSession_V1_0_3_Dxe + FILE_GUID = d60d3e58-e7d9-48c2-9d5b-adaa39a5b69c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSession_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishSession_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Session_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Session/v1_0_3/Session_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/Session/v1_0_3/Session_V1_0_3_Dxe.c new file mode 100644 index 00000000000..921e2f8f16e --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_0_3/Session_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Session.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Session"; +BOOLEAN IsRevisonController = TRUE; + +// Support Session V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Session", + "1", + "0", + "3" + }, + "Session" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSION_V1_0_3 *SessionV1_0_3; + EFI_REDFISH_SESSION_V1_0_3_CS *SessionV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Session") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Session_V1_0_3_To_CS (ResoruceRaw, &SessionV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionV1_0_3 = (EFI_REDFISH_SESSION_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSION_V1_0_3)); + if (SessionV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionV1_0_3; + SessionV1_0_3->Session = SessionV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Session"), "Session"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Session"), "Session"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Session_V1_0_3_JSON (*((EFI_REDFISH_SESSION_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSION_V1_0_3 *SessionV1_0_3; + + SessionV1_0_3 = (EFI_REDFISH_SESSION_V1_0_3 *)InterpProp; + DestroySession_V1_0_3_CS (SessionV1_0_3->Session); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySession_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionToStructWrapper, + SessionToJson, + SessionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Session/v1_0_4/RedfishSession_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/Session/v1_0_4/RedfishSession_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..c8b3f80114e --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_0_4/RedfishSession_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Session.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSession_V1_0_4_Dxe + FILE_GUID = bfa92863-8893-405d-99c6-66bb43558bf4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSession_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishSession_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Session_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Session/v1_0_4/Session_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/Session/v1_0_4/Session_V1_0_4_Dxe.c new file mode 100644 index 00000000000..81af6d86fdc --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_0_4/Session_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Session.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Session"; +BOOLEAN IsRevisonController = TRUE; + +// Support Session V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Session", + "1", + "0", + "4" + }, + "Session" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSION_V1_0_4 *SessionV1_0_4; + EFI_REDFISH_SESSION_V1_0_4_CS *SessionV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Session") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Session_V1_0_4_To_CS (ResoruceRaw, &SessionV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionV1_0_4 = (EFI_REDFISH_SESSION_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSION_V1_0_4)); + if (SessionV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionV1_0_4; + SessionV1_0_4->Session = SessionV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Session"), "Session"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Session"), "Session"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Session_V1_0_4_JSON (*((EFI_REDFISH_SESSION_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSION_V1_0_4 *SessionV1_0_4; + + SessionV1_0_4 = (EFI_REDFISH_SESSION_V1_0_4 *)InterpProp; + DestroySession_V1_0_4_CS (SessionV1_0_4->Session); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySession_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionToStructWrapper, + SessionToJson, + SessionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Session/v1_0_5/RedfishSession_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/Session/v1_0_5/RedfishSession_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..35570033d0c --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_0_5/RedfishSession_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Session.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSession_V1_0_5_Dxe + FILE_GUID = 238a2b2f-84b7-4a90-bdf9-d07ccb951053 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSession_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishSession_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Session_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Session/v1_0_5/Session_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/Session/v1_0_5/Session_V1_0_5_Dxe.c new file mode 100644 index 00000000000..4f6db3cfb09 --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_0_5/Session_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Session.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Session"; +BOOLEAN IsRevisonController = TRUE; + +// Support Session V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Session", + "1", + "0", + "5" + }, + "Session" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSION_V1_0_5 *SessionV1_0_5; + EFI_REDFISH_SESSION_V1_0_5_CS *SessionV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Session") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Session_V1_0_5_To_CS (ResoruceRaw, &SessionV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionV1_0_5 = (EFI_REDFISH_SESSION_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSION_V1_0_5)); + if (SessionV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionV1_0_5; + SessionV1_0_5->Session = SessionV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Session"), "Session"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Session"), "Session"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Session_V1_0_5_JSON (*((EFI_REDFISH_SESSION_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSION_V1_0_5 *SessionV1_0_5; + + SessionV1_0_5 = (EFI_REDFISH_SESSION_V1_0_5 *)InterpProp; + DestroySession_V1_0_5_CS (SessionV1_0_5->Session); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySession_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionToStructWrapper, + SessionToJson, + SessionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Session/v1_0_6/RedfishSession_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/Session/v1_0_6/RedfishSession_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..2c802782f38 --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_0_6/RedfishSession_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Session.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSession_V1_0_6_Dxe + FILE_GUID = 3677ae05-e945-4bfa-aa97-3b288904b23a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSession_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishSession_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Session_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Session/v1_0_6/Session_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/Session/v1_0_6/Session_V1_0_6_Dxe.c new file mode 100644 index 00000000000..0dcf7513834 --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_0_6/Session_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Session.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Session"; +BOOLEAN IsRevisonController = TRUE; + +// Support Session V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Session", + "1", + "0", + "6" + }, + "Session" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSION_V1_0_6 *SessionV1_0_6; + EFI_REDFISH_SESSION_V1_0_6_CS *SessionV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Session") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Session_V1_0_6_To_CS (ResoruceRaw, &SessionV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionV1_0_6 = (EFI_REDFISH_SESSION_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSION_V1_0_6)); + if (SessionV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionV1_0_6; + SessionV1_0_6->Session = SessionV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Session"), "Session"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Session"), "Session"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Session_V1_0_6_JSON (*((EFI_REDFISH_SESSION_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSION_V1_0_6 *SessionV1_0_6; + + SessionV1_0_6 = (EFI_REDFISH_SESSION_V1_0_6 *)InterpProp; + DestroySession_V1_0_6_CS (SessionV1_0_6->Session); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySession_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionToStructWrapper, + SessionToJson, + SessionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Session/v1_1_0/RedfishSession_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/Session/v1_1_0/RedfishSession_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..93c980debdc --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_1_0/RedfishSession_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Session.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSession_V1_1_0_Dxe + FILE_GUID = e2298153-5fbf-417a-91d6-31179592afa4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSession_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishSession_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Session_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Session/v1_1_0/Session_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/Session/v1_1_0/Session_V1_1_0_Dxe.c new file mode 100644 index 00000000000..8ff4b848450 --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_1_0/Session_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Session.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Session"; +BOOLEAN IsRevisonController = TRUE; + +// Support Session V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Session", + "1", + "1", + "0" + }, + "Session" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSION_V1_1_0 *SessionV1_1_0; + EFI_REDFISH_SESSION_V1_1_0_CS *SessionV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Session") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Session_V1_1_0_To_CS (ResoruceRaw, &SessionV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionV1_1_0 = (EFI_REDFISH_SESSION_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSION_V1_1_0)); + if (SessionV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionV1_1_0; + SessionV1_1_0->Session = SessionV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Session"), "Session"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Session"), "Session"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Session_V1_1_0_JSON (*((EFI_REDFISH_SESSION_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSION_V1_1_0 *SessionV1_1_0; + + SessionV1_1_0 = (EFI_REDFISH_SESSION_V1_1_0 *)InterpProp; + DestroySession_V1_1_0_CS (SessionV1_1_0->Session); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySession_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionToStructWrapper, + SessionToJson, + SessionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Session/v1_1_1/RedfishSession_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/Session/v1_1_1/RedfishSession_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..a799c059e3c --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_1_1/RedfishSession_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Session.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSession_V1_1_1_Dxe + FILE_GUID = 80fe28db-6c95-4778-87f5-bbb41498ce49 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSession_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishSession_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Session_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Session/v1_1_1/Session_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/Session/v1_1_1/Session_V1_1_1_Dxe.c new file mode 100644 index 00000000000..0799ce750c3 --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_1_1/Session_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Session.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Session"; +BOOLEAN IsRevisonController = TRUE; + +// Support Session V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Session", + "1", + "1", + "1" + }, + "Session" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSION_V1_1_1 *SessionV1_1_1; + EFI_REDFISH_SESSION_V1_1_1_CS *SessionV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Session") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Session_V1_1_1_To_CS (ResoruceRaw, &SessionV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionV1_1_1 = (EFI_REDFISH_SESSION_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSION_V1_1_1)); + if (SessionV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionV1_1_1; + SessionV1_1_1->Session = SessionV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Session"), "Session"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Session"), "Session"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Session_V1_1_1_JSON (*((EFI_REDFISH_SESSION_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSION_V1_1_1 *SessionV1_1_1; + + SessionV1_1_1 = (EFI_REDFISH_SESSION_V1_1_1 *)InterpProp; + DestroySession_V1_1_1_CS (SessionV1_1_1->Session); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySession_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionToStructWrapper, + SessionToJson, + SessionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Session/v1_1_2/RedfishSession_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/Session/v1_1_2/RedfishSession_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..ad4cfb48f60 --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_1_2/RedfishSession_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Session.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSession_V1_1_2_Dxe + FILE_GUID = f32da89a-5233-42bc-8de1-be91b3eda254 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSession_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishSession_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Session_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Session/v1_1_2/Session_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/Session/v1_1_2/Session_V1_1_2_Dxe.c new file mode 100644 index 00000000000..c9e6070e0fc --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_1_2/Session_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Session.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Session"; +BOOLEAN IsRevisonController = TRUE; + +// Support Session V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Session", + "1", + "1", + "2" + }, + "Session" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSION_V1_1_2 *SessionV1_1_2; + EFI_REDFISH_SESSION_V1_1_2_CS *SessionV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Session") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Session_V1_1_2_To_CS (ResoruceRaw, &SessionV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionV1_1_2 = (EFI_REDFISH_SESSION_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSION_V1_1_2)); + if (SessionV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionV1_1_2; + SessionV1_1_2->Session = SessionV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Session"), "Session"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Session"), "Session"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Session_V1_1_2_JSON (*((EFI_REDFISH_SESSION_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSION_V1_1_2 *SessionV1_1_2; + + SessionV1_1_2 = (EFI_REDFISH_SESSION_V1_1_2 *)InterpProp; + DestroySession_V1_1_2_CS (SessionV1_1_2->Session); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySession_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionToStructWrapper, + SessionToJson, + SessionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Session/v1_1_3/RedfishSession_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/Session/v1_1_3/RedfishSession_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..1e57916264c --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_1_3/RedfishSession_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Session.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSession_V1_1_3_Dxe + FILE_GUID = c27e9bf4-2210-404e-92fa-a55262f952e4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSession_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishSession_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Session_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Session/v1_1_3/Session_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/Session/v1_1_3/Session_V1_1_3_Dxe.c new file mode 100644 index 00000000000..ff7b910b2ca --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_1_3/Session_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Session.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Session"; +BOOLEAN IsRevisonController = TRUE; + +// Support Session V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Session", + "1", + "1", + "3" + }, + "Session" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSION_V1_1_3 *SessionV1_1_3; + EFI_REDFISH_SESSION_V1_1_3_CS *SessionV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Session") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Session_V1_1_3_To_CS (ResoruceRaw, &SessionV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionV1_1_3 = (EFI_REDFISH_SESSION_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSION_V1_1_3)); + if (SessionV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionV1_1_3; + SessionV1_1_3->Session = SessionV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Session"), "Session"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Session"), "Session"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Session_V1_1_3_JSON (*((EFI_REDFISH_SESSION_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSION_V1_1_3 *SessionV1_1_3; + + SessionV1_1_3 = (EFI_REDFISH_SESSION_V1_1_3 *)InterpProp; + DestroySession_V1_1_3_CS (SessionV1_1_3->Session); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySession_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionToStructWrapper, + SessionToJson, + SessionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Session/v1_2_0/RedfishSession_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/Session/v1_2_0/RedfishSession_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..96ca2eb507c --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_2_0/RedfishSession_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Session.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSession_V1_2_0_Dxe + FILE_GUID = 1deb6c22-b8f2-4b9e-a6b6-4c61225f39f4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSession_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishSession_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Session_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Session/v1_2_0/Session_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/Session/v1_2_0/Session_V1_2_0_Dxe.c new file mode 100644 index 00000000000..5a642365662 --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_2_0/Session_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Session.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Session"; +BOOLEAN IsRevisonController = TRUE; + +// Support Session V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Session", + "1", + "2", + "0" + }, + "Session" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSION_V1_2_0 *SessionV1_2_0; + EFI_REDFISH_SESSION_V1_2_0_CS *SessionV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Session") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Session_V1_2_0_To_CS (ResoruceRaw, &SessionV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionV1_2_0 = (EFI_REDFISH_SESSION_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSION_V1_2_0)); + if (SessionV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionV1_2_0; + SessionV1_2_0->Session = SessionV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Session"), "Session"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Session"), "Session"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Session_V1_2_0_JSON (*((EFI_REDFISH_SESSION_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSION_V1_2_0 *SessionV1_2_0; + + SessionV1_2_0 = (EFI_REDFISH_SESSION_V1_2_0 *)InterpProp; + DestroySession_V1_2_0_CS (SessionV1_2_0->Session); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySession_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionToStructWrapper, + SessionToJson, + SessionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Session/v1_2_1/RedfishSession_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/Session/v1_2_1/RedfishSession_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..46302eb190d --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_2_1/RedfishSession_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Session.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSession_V1_2_1_Dxe + FILE_GUID = fb2a6ca9-af2b-4d77-a5ae-a136f5fae7e7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSession_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishSession_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Session_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Session/v1_2_1/Session_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/Session/v1_2_1/Session_V1_2_1_Dxe.c new file mode 100644 index 00000000000..824da798d3a --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_2_1/Session_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Session.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Session"; +BOOLEAN IsRevisonController = TRUE; + +// Support Session V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Session", + "1", + "2", + "1" + }, + "Session" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSION_V1_2_1 *SessionV1_2_1; + EFI_REDFISH_SESSION_V1_2_1_CS *SessionV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Session") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Session_V1_2_1_To_CS (ResoruceRaw, &SessionV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionV1_2_1 = (EFI_REDFISH_SESSION_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSION_V1_2_1)); + if (SessionV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionV1_2_1; + SessionV1_2_1->Session = SessionV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Session"), "Session"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Session"), "Session"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Session_V1_2_1_JSON (*((EFI_REDFISH_SESSION_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSION_V1_2_1 *SessionV1_2_1; + + SessionV1_2_1 = (EFI_REDFISH_SESSION_V1_2_1 *)InterpProp; + DestroySession_V1_2_1_CS (SessionV1_2_1->Session); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySession_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionToStructWrapper, + SessionToJson, + SessionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Session/v1_3_0/RedfishSession_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/Session/v1_3_0/RedfishSession_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..d5c114b873d --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_3_0/RedfishSession_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Session.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSession_V1_3_0_Dxe + FILE_GUID = 1c533e78-9ae7-4cb7-93d4-dd6b3cda903e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSession_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishSession_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Session_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Session/v1_3_0/Session_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/Session/v1_3_0/Session_V1_3_0_Dxe.c new file mode 100644 index 00000000000..f6ca5a5a552 --- /dev/null +++ b/RedfishClientPkg/Converter/Session/v1_3_0/Session_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Session.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Session"; +BOOLEAN IsRevisonController = TRUE; + +// Support Session V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Session", + "1", + "3", + "0" + }, + "Session" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSION_V1_3_0 *SessionV1_3_0; + EFI_REDFISH_SESSION_V1_3_0_CS *SessionV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Session") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Session_V1_3_0_To_CS (ResoruceRaw, &SessionV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionV1_3_0 = (EFI_REDFISH_SESSION_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSION_V1_3_0)); + if (SessionV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionV1_3_0; + SessionV1_3_0->Session = SessionV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Session"), "Session"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Session")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Session"), "Session"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Session_V1_3_0_JSON (*((EFI_REDFISH_SESSION_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSION_V1_3_0 *SessionV1_3_0; + + SessionV1_3_0 = (EFI_REDFISH_SESSION_V1_3_0 *)InterpProp; + DestroySession_V1_3_0_CS (SessionV1_3_0->Session); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySession_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionToStructWrapper, + SessionToJson, + SessionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSession_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SessionCollection/RedfishSessionCollection_Dxe.inf b/RedfishClientPkg/Converter/SessionCollection/RedfishSessionCollection_Dxe.inf new file mode 100644 index 00000000000..c773a02696b --- /dev/null +++ b/RedfishClientPkg/Converter/SessionCollection/RedfishSessionCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SessionCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSessionCollection_Dxe + FILE_GUID = 60bbf061-9705-4349-92e9-d3c26516817d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSessionCollectionEntryPoint + UNLOAD_IMAGE = RedfishSessionCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SessionCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SessionCollection/SessionCollection_Dxe.c b/RedfishClientPkg/Converter/SessionCollection/SessionCollection_Dxe.c new file mode 100644 index 00000000000..7690a40f1be --- /dev/null +++ b/RedfishClientPkg/Converter/SessionCollection/SessionCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SessionCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SessionCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support SessionCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SessionCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "SessionCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSIONCOLLECTION *SessionCollection; + EFI_REDFISH_SESSIONCOLLECTION_CS *SessionCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SessionCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SessionCollection_To_CS (ResoruceRaw, &SessionCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionCollection = (EFI_REDFISH_SESSIONCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSIONCOLLECTION)); + if (SessionCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionCollection; + SessionCollection->SessionCollection = SessionCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SessionCollection"), "SessionCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SessionCollection"), "SessionCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SessionCollection_JSON (*((EFI_REDFISH_SESSIONCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSIONCOLLECTION *SessionCollection; + + SessionCollection = (EFI_REDFISH_SESSIONCOLLECTION *)InterpProp; + DestroySessionCollection_CS (SessionCollection->SessionCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySessionCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSessionCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionCollectionToStructWrapper, + SessionCollectionToJson, + SessionCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSessionCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SessionService/v1_0_0/RedfishSessionService_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/SessionService/v1_0_0/RedfishSessionService_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..6deb2ad5c9b --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_0_0/RedfishSessionService_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SessionService.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSessionService_V1_0_0_Dxe + FILE_GUID = 41c54a8f-d9e9-4844-9370-ee115d5b1d46 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSessionService_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishSessionService_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SessionService_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionServiceV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SessionService/v1_0_0/SessionService_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/SessionService/v1_0_0/SessionService_V1_0_0_Dxe.c new file mode 100644 index 00000000000..93eb1657000 --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_0_0/SessionService_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SessionService.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SessionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support SessionService V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SessionService", + "1", + "0", + "0" + }, + "SessionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_0_0 *SessionServiceV1_0_0; + EFI_REDFISH_SESSIONSERVICE_V1_0_0_CS *SessionServiceV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SessionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SessionService_V1_0_0_To_CS (ResoruceRaw, &SessionServiceV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionServiceV1_0_0 = (EFI_REDFISH_SESSIONSERVICE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSIONSERVICE_V1_0_0)); + if (SessionServiceV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionServiceV1_0_0; + SessionServiceV1_0_0->SessionService = SessionServiceV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SessionService"), "SessionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SessionService"), "SessionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SessionService_V1_0_0_JSON (*((EFI_REDFISH_SESSIONSERVICE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_0_0 *SessionServiceV1_0_0; + + SessionServiceV1_0_0 = (EFI_REDFISH_SESSIONSERVICE_V1_0_0 *)InterpProp; + DestroySessionService_V1_0_0_CS (SessionServiceV1_0_0->SessionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySessionService_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionServiceToStructWrapper, + SessionServiceToJson, + SessionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SessionService/v1_0_2/RedfishSessionService_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/SessionService/v1_0_2/RedfishSessionService_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..c873020ac91 --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_0_2/RedfishSessionService_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SessionService.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSessionService_V1_0_2_Dxe + FILE_GUID = 3be1761e-bff7-4b1f-9ba9-1458352c9989 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSessionService_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishSessionService_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SessionService_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionServiceV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SessionService/v1_0_2/SessionService_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/SessionService/v1_0_2/SessionService_V1_0_2_Dxe.c new file mode 100644 index 00000000000..b7a8a7eafb9 --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_0_2/SessionService_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SessionService.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SessionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support SessionService V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SessionService", + "1", + "0", + "2" + }, + "SessionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_0_2 *SessionServiceV1_0_2; + EFI_REDFISH_SESSIONSERVICE_V1_0_2_CS *SessionServiceV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SessionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SessionService_V1_0_2_To_CS (ResoruceRaw, &SessionServiceV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionServiceV1_0_2 = (EFI_REDFISH_SESSIONSERVICE_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSIONSERVICE_V1_0_2)); + if (SessionServiceV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionServiceV1_0_2; + SessionServiceV1_0_2->SessionService = SessionServiceV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SessionService"), "SessionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SessionService"), "SessionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SessionService_V1_0_2_JSON (*((EFI_REDFISH_SESSIONSERVICE_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_0_2 *SessionServiceV1_0_2; + + SessionServiceV1_0_2 = (EFI_REDFISH_SESSIONSERVICE_V1_0_2 *)InterpProp; + DestroySessionService_V1_0_2_CS (SessionServiceV1_0_2->SessionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySessionService_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionServiceToStructWrapper, + SessionServiceToJson, + SessionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SessionService/v1_0_3/RedfishSessionService_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/SessionService/v1_0_3/RedfishSessionService_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..09788bb49ee --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_0_3/RedfishSessionService_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SessionService.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSessionService_V1_0_3_Dxe + FILE_GUID = 7c8c8e36-01b8-4df8-9732-1953eb14707e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSessionService_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishSessionService_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SessionService_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionServiceV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SessionService/v1_0_3/SessionService_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/SessionService/v1_0_3/SessionService_V1_0_3_Dxe.c new file mode 100644 index 00000000000..08d9133013d --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_0_3/SessionService_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SessionService.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SessionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support SessionService V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SessionService", + "1", + "0", + "3" + }, + "SessionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_0_3 *SessionServiceV1_0_3; + EFI_REDFISH_SESSIONSERVICE_V1_0_3_CS *SessionServiceV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SessionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SessionService_V1_0_3_To_CS (ResoruceRaw, &SessionServiceV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionServiceV1_0_3 = (EFI_REDFISH_SESSIONSERVICE_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSIONSERVICE_V1_0_3)); + if (SessionServiceV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionServiceV1_0_3; + SessionServiceV1_0_3->SessionService = SessionServiceV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SessionService"), "SessionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SessionService"), "SessionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SessionService_V1_0_3_JSON (*((EFI_REDFISH_SESSIONSERVICE_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_0_3 *SessionServiceV1_0_3; + + SessionServiceV1_0_3 = (EFI_REDFISH_SESSIONSERVICE_V1_0_3 *)InterpProp; + DestroySessionService_V1_0_3_CS (SessionServiceV1_0_3->SessionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySessionService_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionServiceToStructWrapper, + SessionServiceToJson, + SessionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SessionService/v1_0_4/RedfishSessionService_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/SessionService/v1_0_4/RedfishSessionService_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..895cd04d6cf --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_0_4/RedfishSessionService_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SessionService.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSessionService_V1_0_4_Dxe + FILE_GUID = 87d0a18d-98a7-4a75-b871-65d8f9c7f04c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSessionService_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishSessionService_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SessionService_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionServiceV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SessionService/v1_0_4/SessionService_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/SessionService/v1_0_4/SessionService_V1_0_4_Dxe.c new file mode 100644 index 00000000000..86ab26ef0d0 --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_0_4/SessionService_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SessionService.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SessionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support SessionService V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SessionService", + "1", + "0", + "4" + }, + "SessionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_0_4 *SessionServiceV1_0_4; + EFI_REDFISH_SESSIONSERVICE_V1_0_4_CS *SessionServiceV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SessionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SessionService_V1_0_4_To_CS (ResoruceRaw, &SessionServiceV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionServiceV1_0_4 = (EFI_REDFISH_SESSIONSERVICE_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSIONSERVICE_V1_0_4)); + if (SessionServiceV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionServiceV1_0_4; + SessionServiceV1_0_4->SessionService = SessionServiceV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SessionService"), "SessionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SessionService"), "SessionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SessionService_V1_0_4_JSON (*((EFI_REDFISH_SESSIONSERVICE_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_0_4 *SessionServiceV1_0_4; + + SessionServiceV1_0_4 = (EFI_REDFISH_SESSIONSERVICE_V1_0_4 *)InterpProp; + DestroySessionService_V1_0_4_CS (SessionServiceV1_0_4->SessionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySessionService_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionServiceToStructWrapper, + SessionServiceToJson, + SessionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SessionService/v1_0_5/RedfishSessionService_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/SessionService/v1_0_5/RedfishSessionService_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..d167b4458d8 --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_0_5/RedfishSessionService_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SessionService.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSessionService_V1_0_5_Dxe + FILE_GUID = fe5a5e9f-bb1d-4c2d-915f-df2d36a78c48 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSessionService_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishSessionService_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SessionService_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionServiceV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SessionService/v1_0_5/SessionService_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/SessionService/v1_0_5/SessionService_V1_0_5_Dxe.c new file mode 100644 index 00000000000..6ee5aed0cb8 --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_0_5/SessionService_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SessionService.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SessionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support SessionService V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SessionService", + "1", + "0", + "5" + }, + "SessionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_0_5 *SessionServiceV1_0_5; + EFI_REDFISH_SESSIONSERVICE_V1_0_5_CS *SessionServiceV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SessionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SessionService_V1_0_5_To_CS (ResoruceRaw, &SessionServiceV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionServiceV1_0_5 = (EFI_REDFISH_SESSIONSERVICE_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSIONSERVICE_V1_0_5)); + if (SessionServiceV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionServiceV1_0_5; + SessionServiceV1_0_5->SessionService = SessionServiceV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SessionService"), "SessionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SessionService"), "SessionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SessionService_V1_0_5_JSON (*((EFI_REDFISH_SESSIONSERVICE_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_0_5 *SessionServiceV1_0_5; + + SessionServiceV1_0_5 = (EFI_REDFISH_SESSIONSERVICE_V1_0_5 *)InterpProp; + DestroySessionService_V1_0_5_CS (SessionServiceV1_0_5->SessionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySessionService_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionServiceToStructWrapper, + SessionServiceToJson, + SessionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SessionService/v1_0_6/RedfishSessionService_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/SessionService/v1_0_6/RedfishSessionService_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..45dde0474f6 --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_0_6/RedfishSessionService_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SessionService.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSessionService_V1_0_6_Dxe + FILE_GUID = c4f4bdaa-7b02-4e63-ad44-4a4a955a3a70 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSessionService_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishSessionService_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SessionService_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionServiceV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SessionService/v1_0_6/SessionService_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/SessionService/v1_0_6/SessionService_V1_0_6_Dxe.c new file mode 100644 index 00000000000..c8b48c33b07 --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_0_6/SessionService_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SessionService.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SessionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support SessionService V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SessionService", + "1", + "0", + "6" + }, + "SessionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_0_6 *SessionServiceV1_0_6; + EFI_REDFISH_SESSIONSERVICE_V1_0_6_CS *SessionServiceV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SessionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SessionService_V1_0_6_To_CS (ResoruceRaw, &SessionServiceV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionServiceV1_0_6 = (EFI_REDFISH_SESSIONSERVICE_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSIONSERVICE_V1_0_6)); + if (SessionServiceV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionServiceV1_0_6; + SessionServiceV1_0_6->SessionService = SessionServiceV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SessionService"), "SessionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SessionService"), "SessionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SessionService_V1_0_6_JSON (*((EFI_REDFISH_SESSIONSERVICE_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_0_6 *SessionServiceV1_0_6; + + SessionServiceV1_0_6 = (EFI_REDFISH_SESSIONSERVICE_V1_0_6 *)InterpProp; + DestroySessionService_V1_0_6_CS (SessionServiceV1_0_6->SessionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySessionService_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionServiceToStructWrapper, + SessionServiceToJson, + SessionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SessionService/v1_0_7/RedfishSessionService_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/SessionService/v1_0_7/RedfishSessionService_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..d153c66f104 --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_0_7/RedfishSessionService_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SessionService.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSessionService_V1_0_7_Dxe + FILE_GUID = 40c8d9d5-ff29-432f-9e32-55184ac06fb9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSessionService_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishSessionService_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SessionService_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionServiceV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SessionService/v1_0_7/SessionService_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/SessionService/v1_0_7/SessionService_V1_0_7_Dxe.c new file mode 100644 index 00000000000..934ff21a898 --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_0_7/SessionService_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SessionService.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SessionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support SessionService V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SessionService", + "1", + "0", + "7" + }, + "SessionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_0_7 *SessionServiceV1_0_7; + EFI_REDFISH_SESSIONSERVICE_V1_0_7_CS *SessionServiceV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SessionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SessionService_V1_0_7_To_CS (ResoruceRaw, &SessionServiceV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionServiceV1_0_7 = (EFI_REDFISH_SESSIONSERVICE_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSIONSERVICE_V1_0_7)); + if (SessionServiceV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionServiceV1_0_7; + SessionServiceV1_0_7->SessionService = SessionServiceV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SessionService"), "SessionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SessionService"), "SessionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SessionService_V1_0_7_JSON (*((EFI_REDFISH_SESSIONSERVICE_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_0_7 *SessionServiceV1_0_7; + + SessionServiceV1_0_7 = (EFI_REDFISH_SESSIONSERVICE_V1_0_7 *)InterpProp; + DestroySessionService_V1_0_7_CS (SessionServiceV1_0_7->SessionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySessionService_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionServiceToStructWrapper, + SessionServiceToJson, + SessionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SessionService/v1_0_8/RedfishSessionService_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/SessionService/v1_0_8/RedfishSessionService_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..47ef261712e --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_0_8/RedfishSessionService_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SessionService.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSessionService_V1_0_8_Dxe + FILE_GUID = 82668839-736d-4c5d-bf59-bc958a13be1b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSessionService_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishSessionService_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SessionService_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionServiceV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SessionService/v1_0_8/SessionService_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/SessionService/v1_0_8/SessionService_V1_0_8_Dxe.c new file mode 100644 index 00000000000..77473c33f70 --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_0_8/SessionService_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SessionService.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SessionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support SessionService V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SessionService", + "1", + "0", + "8" + }, + "SessionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_0_8 *SessionServiceV1_0_8; + EFI_REDFISH_SESSIONSERVICE_V1_0_8_CS *SessionServiceV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SessionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SessionService_V1_0_8_To_CS (ResoruceRaw, &SessionServiceV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionServiceV1_0_8 = (EFI_REDFISH_SESSIONSERVICE_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSIONSERVICE_V1_0_8)); + if (SessionServiceV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionServiceV1_0_8; + SessionServiceV1_0_8->SessionService = SessionServiceV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SessionService"), "SessionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SessionService"), "SessionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SessionService_V1_0_8_JSON (*((EFI_REDFISH_SESSIONSERVICE_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_0_8 *SessionServiceV1_0_8; + + SessionServiceV1_0_8 = (EFI_REDFISH_SESSIONSERVICE_V1_0_8 *)InterpProp; + DestroySessionService_V1_0_8_CS (SessionServiceV1_0_8->SessionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySessionService_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionServiceToStructWrapper, + SessionServiceToJson, + SessionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SessionService/v1_0_9/RedfishSessionService_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/SessionService/v1_0_9/RedfishSessionService_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..fdbf724df7f --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_0_9/RedfishSessionService_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SessionService.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSessionService_V1_0_9_Dxe + FILE_GUID = 36af4877-ceb2-4aea-984a-9fe0db0fafbb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSessionService_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishSessionService_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SessionService_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionServiceV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SessionService/v1_0_9/SessionService_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/SessionService/v1_0_9/SessionService_V1_0_9_Dxe.c new file mode 100644 index 00000000000..2203974bab8 --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_0_9/SessionService_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SessionService.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SessionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support SessionService V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SessionService", + "1", + "0", + "9" + }, + "SessionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_0_9 *SessionServiceV1_0_9; + EFI_REDFISH_SESSIONSERVICE_V1_0_9_CS *SessionServiceV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SessionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SessionService_V1_0_9_To_CS (ResoruceRaw, &SessionServiceV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionServiceV1_0_9 = (EFI_REDFISH_SESSIONSERVICE_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSIONSERVICE_V1_0_9)); + if (SessionServiceV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionServiceV1_0_9; + SessionServiceV1_0_9->SessionService = SessionServiceV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SessionService"), "SessionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SessionService"), "SessionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SessionService_V1_0_9_JSON (*((EFI_REDFISH_SESSIONSERVICE_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_0_9 *SessionServiceV1_0_9; + + SessionServiceV1_0_9 = (EFI_REDFISH_SESSIONSERVICE_V1_0_9 *)InterpProp; + DestroySessionService_V1_0_9_CS (SessionServiceV1_0_9->SessionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySessionService_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionServiceToStructWrapper, + SessionServiceToJson, + SessionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SessionService/v1_1_0/RedfishSessionService_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/SessionService/v1_1_0/RedfishSessionService_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..5ffcdf9cb39 --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_1_0/RedfishSessionService_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SessionService.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSessionService_V1_1_0_Dxe + FILE_GUID = 6c6b89cb-ecc6-4d8c-974c-7e733082335c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSessionService_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishSessionService_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SessionService_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionServiceV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SessionService/v1_1_0/SessionService_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/SessionService/v1_1_0/SessionService_V1_1_0_Dxe.c new file mode 100644 index 00000000000..d832c744eb1 --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_1_0/SessionService_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SessionService.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SessionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support SessionService V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SessionService", + "1", + "1", + "0" + }, + "SessionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_1_0 *SessionServiceV1_1_0; + EFI_REDFISH_SESSIONSERVICE_V1_1_0_CS *SessionServiceV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SessionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SessionService_V1_1_0_To_CS (ResoruceRaw, &SessionServiceV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionServiceV1_1_0 = (EFI_REDFISH_SESSIONSERVICE_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSIONSERVICE_V1_1_0)); + if (SessionServiceV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionServiceV1_1_0; + SessionServiceV1_1_0->SessionService = SessionServiceV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SessionService"), "SessionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SessionService"), "SessionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SessionService_V1_1_0_JSON (*((EFI_REDFISH_SESSIONSERVICE_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_1_0 *SessionServiceV1_1_0; + + SessionServiceV1_1_0 = (EFI_REDFISH_SESSIONSERVICE_V1_1_0 *)InterpProp; + DestroySessionService_V1_1_0_CS (SessionServiceV1_1_0->SessionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySessionService_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionServiceToStructWrapper, + SessionServiceToJson, + SessionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SessionService/v1_1_1/RedfishSessionService_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/SessionService/v1_1_1/RedfishSessionService_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..d49c10f8b96 --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_1_1/RedfishSessionService_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SessionService.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSessionService_V1_1_1_Dxe + FILE_GUID = 22a46325-0614-4b94-be67-6b4a8dcda4ac + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSessionService_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishSessionService_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SessionService_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionServiceV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SessionService/v1_1_1/SessionService_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/SessionService/v1_1_1/SessionService_V1_1_1_Dxe.c new file mode 100644 index 00000000000..8ba1e190d5b --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_1_1/SessionService_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SessionService.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SessionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support SessionService V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SessionService", + "1", + "1", + "1" + }, + "SessionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_1_1 *SessionServiceV1_1_1; + EFI_REDFISH_SESSIONSERVICE_V1_1_1_CS *SessionServiceV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SessionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SessionService_V1_1_1_To_CS (ResoruceRaw, &SessionServiceV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionServiceV1_1_1 = (EFI_REDFISH_SESSIONSERVICE_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSIONSERVICE_V1_1_1)); + if (SessionServiceV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionServiceV1_1_1; + SessionServiceV1_1_1->SessionService = SessionServiceV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SessionService"), "SessionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SessionService"), "SessionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SessionService_V1_1_1_JSON (*((EFI_REDFISH_SESSIONSERVICE_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_1_1 *SessionServiceV1_1_1; + + SessionServiceV1_1_1 = (EFI_REDFISH_SESSIONSERVICE_V1_1_1 *)InterpProp; + DestroySessionService_V1_1_1_CS (SessionServiceV1_1_1->SessionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySessionService_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionServiceToStructWrapper, + SessionServiceToJson, + SessionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SessionService/v1_1_2/RedfishSessionService_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/SessionService/v1_1_2/RedfishSessionService_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..88a253c18ad --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_1_2/RedfishSessionService_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SessionService.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSessionService_V1_1_2_Dxe + FILE_GUID = a8e8a4e2-c82e-4bf8-9eed-7ca85261603f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSessionService_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishSessionService_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SessionService_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionServiceV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SessionService/v1_1_2/SessionService_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/SessionService/v1_1_2/SessionService_V1_1_2_Dxe.c new file mode 100644 index 00000000000..9c76d1c03b8 --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_1_2/SessionService_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SessionService.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SessionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support SessionService V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SessionService", + "1", + "1", + "2" + }, + "SessionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_1_2 *SessionServiceV1_1_2; + EFI_REDFISH_SESSIONSERVICE_V1_1_2_CS *SessionServiceV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SessionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SessionService_V1_1_2_To_CS (ResoruceRaw, &SessionServiceV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionServiceV1_1_2 = (EFI_REDFISH_SESSIONSERVICE_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSIONSERVICE_V1_1_2)); + if (SessionServiceV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionServiceV1_1_2; + SessionServiceV1_1_2->SessionService = SessionServiceV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SessionService"), "SessionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SessionService"), "SessionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SessionService_V1_1_2_JSON (*((EFI_REDFISH_SESSIONSERVICE_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_1_2 *SessionServiceV1_1_2; + + SessionServiceV1_1_2 = (EFI_REDFISH_SESSIONSERVICE_V1_1_2 *)InterpProp; + DestroySessionService_V1_1_2_CS (SessionServiceV1_1_2->SessionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySessionService_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionServiceToStructWrapper, + SessionServiceToJson, + SessionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SessionService/v1_1_3/RedfishSessionService_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/SessionService/v1_1_3/RedfishSessionService_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..7a08c8c8497 --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_1_3/RedfishSessionService_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SessionService.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSessionService_V1_1_3_Dxe + FILE_GUID = 70b86846-2ace-4ef2-af2e-9e7be45a64cf + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSessionService_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishSessionService_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SessionService_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionServiceV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SessionService/v1_1_3/SessionService_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/SessionService/v1_1_3/SessionService_V1_1_3_Dxe.c new file mode 100644 index 00000000000..8c789d67c8f --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_1_3/SessionService_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SessionService.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SessionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support SessionService V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SessionService", + "1", + "1", + "3" + }, + "SessionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_1_3 *SessionServiceV1_1_3; + EFI_REDFISH_SESSIONSERVICE_V1_1_3_CS *SessionServiceV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SessionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SessionService_V1_1_3_To_CS (ResoruceRaw, &SessionServiceV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionServiceV1_1_3 = (EFI_REDFISH_SESSIONSERVICE_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSIONSERVICE_V1_1_3)); + if (SessionServiceV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionServiceV1_1_3; + SessionServiceV1_1_3->SessionService = SessionServiceV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SessionService"), "SessionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SessionService"), "SessionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SessionService_V1_1_3_JSON (*((EFI_REDFISH_SESSIONSERVICE_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_1_3 *SessionServiceV1_1_3; + + SessionServiceV1_1_3 = (EFI_REDFISH_SESSIONSERVICE_V1_1_3 *)InterpProp; + DestroySessionService_V1_1_3_CS (SessionServiceV1_1_3->SessionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySessionService_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionServiceToStructWrapper, + SessionServiceToJson, + SessionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SessionService/v1_1_4/RedfishSessionService_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/SessionService/v1_1_4/RedfishSessionService_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..1295daee984 --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_1_4/RedfishSessionService_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SessionService.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSessionService_V1_1_4_Dxe + FILE_GUID = 2bb60538-698b-49c9-b004-dc457b1b6773 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSessionService_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishSessionService_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SessionService_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionServiceV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SessionService/v1_1_4/SessionService_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/SessionService/v1_1_4/SessionService_V1_1_4_Dxe.c new file mode 100644 index 00000000000..76a55a8035a --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_1_4/SessionService_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SessionService.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SessionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support SessionService V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SessionService", + "1", + "1", + "4" + }, + "SessionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_1_4 *SessionServiceV1_1_4; + EFI_REDFISH_SESSIONSERVICE_V1_1_4_CS *SessionServiceV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SessionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SessionService_V1_1_4_To_CS (ResoruceRaw, &SessionServiceV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionServiceV1_1_4 = (EFI_REDFISH_SESSIONSERVICE_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSIONSERVICE_V1_1_4)); + if (SessionServiceV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionServiceV1_1_4; + SessionServiceV1_1_4->SessionService = SessionServiceV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SessionService"), "SessionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SessionService"), "SessionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SessionService_V1_1_4_JSON (*((EFI_REDFISH_SESSIONSERVICE_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_1_4 *SessionServiceV1_1_4; + + SessionServiceV1_1_4 = (EFI_REDFISH_SESSIONSERVICE_V1_1_4 *)InterpProp; + DestroySessionService_V1_1_4_CS (SessionServiceV1_1_4->SessionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySessionService_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionServiceToStructWrapper, + SessionServiceToJson, + SessionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SessionService/v1_1_5/RedfishSessionService_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/SessionService/v1_1_5/RedfishSessionService_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..394d07423bd --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_1_5/RedfishSessionService_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SessionService.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSessionService_V1_1_5_Dxe + FILE_GUID = 1cade054-bfea-4eac-b869-97b36926ecb3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSessionService_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishSessionService_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SessionService_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionServiceV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SessionService/v1_1_5/SessionService_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/SessionService/v1_1_5/SessionService_V1_1_5_Dxe.c new file mode 100644 index 00000000000..57e77818458 --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_1_5/SessionService_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SessionService.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SessionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support SessionService V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SessionService", + "1", + "1", + "5" + }, + "SessionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_1_5 *SessionServiceV1_1_5; + EFI_REDFISH_SESSIONSERVICE_V1_1_5_CS *SessionServiceV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SessionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SessionService_V1_1_5_To_CS (ResoruceRaw, &SessionServiceV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionServiceV1_1_5 = (EFI_REDFISH_SESSIONSERVICE_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSIONSERVICE_V1_1_5)); + if (SessionServiceV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionServiceV1_1_5; + SessionServiceV1_1_5->SessionService = SessionServiceV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SessionService"), "SessionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SessionService"), "SessionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SessionService_V1_1_5_JSON (*((EFI_REDFISH_SESSIONSERVICE_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_1_5 *SessionServiceV1_1_5; + + SessionServiceV1_1_5 = (EFI_REDFISH_SESSIONSERVICE_V1_1_5 *)InterpProp; + DestroySessionService_V1_1_5_CS (SessionServiceV1_1_5->SessionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySessionService_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionServiceToStructWrapper, + SessionServiceToJson, + SessionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SessionService/v1_1_6/RedfishSessionService_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/SessionService/v1_1_6/RedfishSessionService_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..176713dcc27 --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_1_6/RedfishSessionService_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SessionService.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSessionService_V1_1_6_Dxe + FILE_GUID = 0ce25f1a-0d78-4531-b783-85af4873e32f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSessionService_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishSessionService_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SessionService_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionServiceV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SessionService/v1_1_6/SessionService_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/SessionService/v1_1_6/SessionService_V1_1_6_Dxe.c new file mode 100644 index 00000000000..d2cbfea77df --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_1_6/SessionService_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SessionService.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SessionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support SessionService V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SessionService", + "1", + "1", + "6" + }, + "SessionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_1_6 *SessionServiceV1_1_6; + EFI_REDFISH_SESSIONSERVICE_V1_1_6_CS *SessionServiceV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SessionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SessionService_V1_1_6_To_CS (ResoruceRaw, &SessionServiceV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionServiceV1_1_6 = (EFI_REDFISH_SESSIONSERVICE_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSIONSERVICE_V1_1_6)); + if (SessionServiceV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionServiceV1_1_6; + SessionServiceV1_1_6->SessionService = SessionServiceV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SessionService"), "SessionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SessionService"), "SessionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SessionService_V1_1_6_JSON (*((EFI_REDFISH_SESSIONSERVICE_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_1_6 *SessionServiceV1_1_6; + + SessionServiceV1_1_6 = (EFI_REDFISH_SESSIONSERVICE_V1_1_6 *)InterpProp; + DestroySessionService_V1_1_6_CS (SessionServiceV1_1_6->SessionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySessionService_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionServiceToStructWrapper, + SessionServiceToJson, + SessionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SessionService/v1_1_7/RedfishSessionService_V1_1_7_Dxe.inf b/RedfishClientPkg/Converter/SessionService/v1_1_7/RedfishSessionService_V1_1_7_Dxe.inf new file mode 100644 index 00000000000..4ce082259c0 --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_1_7/RedfishSessionService_V1_1_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SessionService.v1_1_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSessionService_V1_1_7_Dxe + FILE_GUID = abb17d1a-7f5b-4fa6-b8ba-919f64804623 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSessionService_V1_1_7EntryPoint + UNLOAD_IMAGE = RedfishSessionService_V1_1_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SessionService_V1_1_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionServiceV1_1_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SessionService/v1_1_7/SessionService_V1_1_7_Dxe.c b/RedfishClientPkg/Converter/SessionService/v1_1_7/SessionService_V1_1_7_Dxe.c new file mode 100644 index 00000000000..c7435836335 --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_1_7/SessionService_V1_1_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SessionService.v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SessionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support SessionService V1_1_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SessionService", + "1", + "1", + "7" + }, + "SessionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_1_7 *SessionServiceV1_1_7; + EFI_REDFISH_SESSIONSERVICE_V1_1_7_CS *SessionServiceV1_1_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SessionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SessionService_V1_1_7_To_CS (ResoruceRaw, &SessionServiceV1_1_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionServiceV1_1_7 = (EFI_REDFISH_SESSIONSERVICE_V1_1_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSIONSERVICE_V1_1_7)); + if (SessionServiceV1_1_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionServiceV1_1_7; + SessionServiceV1_1_7->SessionService = SessionServiceV1_1_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SessionService"), "SessionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SessionService"), "SessionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SessionService_V1_1_7_JSON (*((EFI_REDFISH_SESSIONSERVICE_V1_1_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_1_7 *SessionServiceV1_1_7; + + SessionServiceV1_1_7 = (EFI_REDFISH_SESSIONSERVICE_V1_1_7 *)InterpProp; + DestroySessionService_V1_1_7_CS (SessionServiceV1_1_7->SessionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySessionService_V1_1_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_1_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionServiceToStructWrapper, + SessionServiceToJson, + SessionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_1_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SessionService/v1_1_8/RedfishSessionService_V1_1_8_Dxe.inf b/RedfishClientPkg/Converter/SessionService/v1_1_8/RedfishSessionService_V1_1_8_Dxe.inf new file mode 100644 index 00000000000..086a1ebd7db --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_1_8/RedfishSessionService_V1_1_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SessionService.v1_1_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSessionService_V1_1_8_Dxe + FILE_GUID = b11cce4c-331e-43c6-a3d2-0ae774e8594e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSessionService_V1_1_8EntryPoint + UNLOAD_IMAGE = RedfishSessionService_V1_1_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SessionService_V1_1_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SessionServiceV1_1_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SessionService/v1_1_8/SessionService_V1_1_8_Dxe.c b/RedfishClientPkg/Converter/SessionService/v1_1_8/SessionService_V1_1_8_Dxe.c new file mode 100644 index 00000000000..0def9e2f25d --- /dev/null +++ b/RedfishClientPkg/Converter/SessionService/v1_1_8/SessionService_V1_1_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SessionService.v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SessionService"; +BOOLEAN IsRevisonController = TRUE; + +// Support SessionService V1_1_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SessionService", + "1", + "1", + "8" + }, + "SessionService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_1_8 *SessionServiceV1_1_8; + EFI_REDFISH_SESSIONSERVICE_V1_1_8_CS *SessionServiceV1_1_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SessionService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SessionService_V1_1_8_To_CS (ResoruceRaw, &SessionServiceV1_1_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SessionServiceV1_1_8 = (EFI_REDFISH_SESSIONSERVICE_V1_1_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SESSIONSERVICE_V1_1_8)); + if (SessionServiceV1_1_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SessionServiceV1_1_8; + SessionServiceV1_1_8->SessionService = SessionServiceV1_1_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SessionService"), "SessionService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SessionService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SessionService"), "SessionService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SessionServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SessionServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SessionService_V1_1_8_JSON (*((EFI_REDFISH_SESSIONSERVICE_V1_1_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SessionServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SESSIONSERVICE_V1_1_8 *SessionServiceV1_1_8; + + SessionServiceV1_1_8 = (EFI_REDFISH_SESSIONSERVICE_V1_1_8 *)InterpProp; + DestroySessionService_V1_1_8_CS (SessionServiceV1_1_8->SessionService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SessionServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SessionServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySessionService_V1_1_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_1_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SessionServiceToStructWrapper, + SessionServiceToJson, + SessionServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSessionService_V1_1_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Signature/v1_0_0/RedfishSignature_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Signature/v1_0_0/RedfishSignature_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..8299521b439 --- /dev/null +++ b/RedfishClientPkg/Converter/Signature/v1_0_0/RedfishSignature_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Signature.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSignature_V1_0_0_Dxe + FILE_GUID = d71c304a-9fd1-4614-ada7-ad9a31634b29 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSignature_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishSignature_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Signature_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SignatureV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Signature/v1_0_0/Signature_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Signature/v1_0_0/Signature_V1_0_0_Dxe.c new file mode 100644 index 00000000000..aa7a9d08e81 --- /dev/null +++ b/RedfishClientPkg/Converter/Signature/v1_0_0/Signature_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Signature.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Signature"; +BOOLEAN IsRevisonController = TRUE; + +// Support Signature V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Signature", + "1", + "0", + "0" + }, + "Signature" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SignatureToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIGNATURE_V1_0_0 *SignatureV1_0_0; + EFI_REDFISH_SIGNATURE_V1_0_0_CS *SignatureV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Signature") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Signature_V1_0_0_To_CS (ResoruceRaw, &SignatureV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SignatureV1_0_0 = (EFI_REDFISH_SIGNATURE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIGNATURE_V1_0_0)); + if (SignatureV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SignatureV1_0_0; + SignatureV1_0_0->Signature = SignatureV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Signature")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Signature"), "Signature"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Signature")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Signature"), "Signature"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SignatureToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SignatureToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SignatureToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SignatureToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Signature_V1_0_0_JSON (*((EFI_REDFISH_SIGNATURE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SignatureToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SignatureDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIGNATURE_V1_0_0 *SignatureV1_0_0; + + SignatureV1_0_0 = (EFI_REDFISH_SIGNATURE_V1_0_0 *)InterpProp; + DestroySignature_V1_0_0_CS (SignatureV1_0_0->Signature); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SignatureFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SignatureDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySignature_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSignature_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SignatureToStructWrapper, + SignatureToJson, + SignatureDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSignature_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Signature/v1_0_1/RedfishSignature_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/Signature/v1_0_1/RedfishSignature_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..b18d6827aba --- /dev/null +++ b/RedfishClientPkg/Converter/Signature/v1_0_1/RedfishSignature_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Signature.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSignature_V1_0_1_Dxe + FILE_GUID = c554ef74-ec33-4fd3-b342-62ef67a8ad24 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSignature_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishSignature_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Signature_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SignatureV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Signature/v1_0_1/Signature_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/Signature/v1_0_1/Signature_V1_0_1_Dxe.c new file mode 100644 index 00000000000..2c579c8fc50 --- /dev/null +++ b/RedfishClientPkg/Converter/Signature/v1_0_1/Signature_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Signature.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Signature"; +BOOLEAN IsRevisonController = TRUE; + +// Support Signature V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Signature", + "1", + "0", + "1" + }, + "Signature" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SignatureToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIGNATURE_V1_0_1 *SignatureV1_0_1; + EFI_REDFISH_SIGNATURE_V1_0_1_CS *SignatureV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Signature") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Signature_V1_0_1_To_CS (ResoruceRaw, &SignatureV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SignatureV1_0_1 = (EFI_REDFISH_SIGNATURE_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIGNATURE_V1_0_1)); + if (SignatureV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SignatureV1_0_1; + SignatureV1_0_1->Signature = SignatureV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Signature")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Signature"), "Signature"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Signature")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Signature"), "Signature"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SignatureToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SignatureToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SignatureToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SignatureToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Signature_V1_0_1_JSON (*((EFI_REDFISH_SIGNATURE_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SignatureToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SignatureDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIGNATURE_V1_0_1 *SignatureV1_0_1; + + SignatureV1_0_1 = (EFI_REDFISH_SIGNATURE_V1_0_1 *)InterpProp; + DestroySignature_V1_0_1_CS (SignatureV1_0_1->Signature); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SignatureFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SignatureDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySignature_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSignature_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SignatureToStructWrapper, + SignatureToJson, + SignatureDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSignature_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Signature/v1_0_2/RedfishSignature_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Signature/v1_0_2/RedfishSignature_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..6804b93de88 --- /dev/null +++ b/RedfishClientPkg/Converter/Signature/v1_0_2/RedfishSignature_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Signature.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSignature_V1_0_2_Dxe + FILE_GUID = d8046a27-9ace-47bb-99f2-105f04700ad6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSignature_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishSignature_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Signature_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SignatureV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Signature/v1_0_2/Signature_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Signature/v1_0_2/Signature_V1_0_2_Dxe.c new file mode 100644 index 00000000000..9f593ed800c --- /dev/null +++ b/RedfishClientPkg/Converter/Signature/v1_0_2/Signature_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Signature.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Signature"; +BOOLEAN IsRevisonController = TRUE; + +// Support Signature V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Signature", + "1", + "0", + "2" + }, + "Signature" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SignatureToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIGNATURE_V1_0_2 *SignatureV1_0_2; + EFI_REDFISH_SIGNATURE_V1_0_2_CS *SignatureV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Signature") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Signature_V1_0_2_To_CS (ResoruceRaw, &SignatureV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SignatureV1_0_2 = (EFI_REDFISH_SIGNATURE_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIGNATURE_V1_0_2)); + if (SignatureV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SignatureV1_0_2; + SignatureV1_0_2->Signature = SignatureV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Signature")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Signature"), "Signature"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Signature")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Signature"), "Signature"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SignatureToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SignatureToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SignatureToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SignatureToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Signature_V1_0_2_JSON (*((EFI_REDFISH_SIGNATURE_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SignatureToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SignatureDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIGNATURE_V1_0_2 *SignatureV1_0_2; + + SignatureV1_0_2 = (EFI_REDFISH_SIGNATURE_V1_0_2 *)InterpProp; + DestroySignature_V1_0_2_CS (SignatureV1_0_2->Signature); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SignatureFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SignatureDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySignature_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSignature_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SignatureToStructWrapper, + SignatureToJson, + SignatureDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSignature_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SignatureCollection/RedfishSignatureCollection_Dxe.inf b/RedfishClientPkg/Converter/SignatureCollection/RedfishSignatureCollection_Dxe.inf new file mode 100644 index 00000000000..ebda499bdcb --- /dev/null +++ b/RedfishClientPkg/Converter/SignatureCollection/RedfishSignatureCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SignatureCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSignatureCollection_Dxe + FILE_GUID = 0d5f1383-ad47-4cee-a722-4f8deb1d3ceb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSignatureCollectionEntryPoint + UNLOAD_IMAGE = RedfishSignatureCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SignatureCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SignatureCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SignatureCollection/SignatureCollection_Dxe.c b/RedfishClientPkg/Converter/SignatureCollection/SignatureCollection_Dxe.c new file mode 100644 index 00000000000..c2411595da6 --- /dev/null +++ b/RedfishClientPkg/Converter/SignatureCollection/SignatureCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SignatureCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SignatureCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support SignatureCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SignatureCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "SignatureCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SignatureCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIGNATURECOLLECTION *SignatureCollection; + EFI_REDFISH_SIGNATURECOLLECTION_CS *SignatureCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SignatureCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SignatureCollection_To_CS (ResoruceRaw, &SignatureCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + SignatureCollection = (EFI_REDFISH_SIGNATURECOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIGNATURECOLLECTION)); + if (SignatureCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SignatureCollection; + SignatureCollection->SignatureCollection = SignatureCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SignatureCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SignatureCollection"), "SignatureCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SignatureCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SignatureCollection"), "SignatureCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SignatureCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SignatureCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SignatureCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SignatureCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SignatureCollection_JSON (*((EFI_REDFISH_SIGNATURECOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SignatureCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SignatureCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIGNATURECOLLECTION *SignatureCollection; + + SignatureCollection = (EFI_REDFISH_SIGNATURECOLLECTION *)InterpProp; + DestroySignatureCollection_CS (SignatureCollection->SignatureCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SignatureCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SignatureCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySignatureCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSignatureCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SignatureCollectionToStructWrapper, + SignatureCollectionToJson, + SignatureCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSignatureCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_0_0/RedfishSimpleStorage_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/SimpleStorage/v1_0_0/RedfishSimpleStorage_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..299a4782498 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_0_0/RedfishSimpleStorage_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SimpleStorage.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSimpleStorage_V1_0_0_Dxe + FILE_GUID = 86ab04de-1c9f-4a6c-8919-00a32cd5db34 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSimpleStorage_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishSimpleStorage_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SimpleStorage_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SimpleStorageV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_0_0/SimpleStorage_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/SimpleStorage/v1_0_0/SimpleStorage_V1_0_0_Dxe.c new file mode 100644 index 00000000000..74d6c25649e --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_0_0/SimpleStorage_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SimpleStorage.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SimpleStorage"; +BOOLEAN IsRevisonController = TRUE; + +// Support SimpleStorage V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SimpleStorage", + "1", + "0", + "0" + }, + "SimpleStorage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_0_0 *SimpleStorageV1_0_0; + EFI_REDFISH_SIMPLESTORAGE_V1_0_0_CS *SimpleStorageV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SimpleStorage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SimpleStorage_V1_0_0_To_CS (ResoruceRaw, &SimpleStorageV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SimpleStorageV1_0_0 = (EFI_REDFISH_SIMPLESTORAGE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIMPLESTORAGE_V1_0_0)); + if (SimpleStorageV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SimpleStorageV1_0_0; + SimpleStorageV1_0_0->SimpleStorage = SimpleStorageV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SimpleStorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SimpleStorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SimpleStorage_V1_0_0_JSON (*((EFI_REDFISH_SIMPLESTORAGE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SimpleStorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_0_0 *SimpleStorageV1_0_0; + + SimpleStorageV1_0_0 = (EFI_REDFISH_SIMPLESTORAGE_V1_0_0 *)InterpProp; + DestroySimpleStorage_V1_0_0_CS (SimpleStorageV1_0_0->SimpleStorage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SimpleStorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySimpleStorage_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SimpleStorageToStructWrapper, + SimpleStorageToJson, + SimpleStorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_0_2/RedfishSimpleStorage_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/SimpleStorage/v1_0_2/RedfishSimpleStorage_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..10d18b60d27 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_0_2/RedfishSimpleStorage_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SimpleStorage.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSimpleStorage_V1_0_2_Dxe + FILE_GUID = f7110353-df8e-4432-83d0-4aca5e144489 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSimpleStorage_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishSimpleStorage_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SimpleStorage_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SimpleStorageV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_0_2/SimpleStorage_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/SimpleStorage/v1_0_2/SimpleStorage_V1_0_2_Dxe.c new file mode 100644 index 00000000000..83bdb7d53a3 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_0_2/SimpleStorage_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SimpleStorage.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SimpleStorage"; +BOOLEAN IsRevisonController = TRUE; + +// Support SimpleStorage V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SimpleStorage", + "1", + "0", + "2" + }, + "SimpleStorage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_0_2 *SimpleStorageV1_0_2; + EFI_REDFISH_SIMPLESTORAGE_V1_0_2_CS *SimpleStorageV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SimpleStorage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SimpleStorage_V1_0_2_To_CS (ResoruceRaw, &SimpleStorageV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SimpleStorageV1_0_2 = (EFI_REDFISH_SIMPLESTORAGE_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIMPLESTORAGE_V1_0_2)); + if (SimpleStorageV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SimpleStorageV1_0_2; + SimpleStorageV1_0_2->SimpleStorage = SimpleStorageV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SimpleStorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SimpleStorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SimpleStorage_V1_0_2_JSON (*((EFI_REDFISH_SIMPLESTORAGE_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SimpleStorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_0_2 *SimpleStorageV1_0_2; + + SimpleStorageV1_0_2 = (EFI_REDFISH_SIMPLESTORAGE_V1_0_2 *)InterpProp; + DestroySimpleStorage_V1_0_2_CS (SimpleStorageV1_0_2->SimpleStorage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SimpleStorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySimpleStorage_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SimpleStorageToStructWrapper, + SimpleStorageToJson, + SimpleStorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_0_3/RedfishSimpleStorage_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/SimpleStorage/v1_0_3/RedfishSimpleStorage_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..53c10ccea50 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_0_3/RedfishSimpleStorage_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SimpleStorage.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSimpleStorage_V1_0_3_Dxe + FILE_GUID = a9a5cdff-ca51-4c58-95ae-3f42dac4230a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSimpleStorage_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishSimpleStorage_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SimpleStorage_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SimpleStorageV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_0_3/SimpleStorage_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/SimpleStorage/v1_0_3/SimpleStorage_V1_0_3_Dxe.c new file mode 100644 index 00000000000..951996b7d6d --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_0_3/SimpleStorage_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SimpleStorage.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SimpleStorage"; +BOOLEAN IsRevisonController = TRUE; + +// Support SimpleStorage V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SimpleStorage", + "1", + "0", + "3" + }, + "SimpleStorage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_0_3 *SimpleStorageV1_0_3; + EFI_REDFISH_SIMPLESTORAGE_V1_0_3_CS *SimpleStorageV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SimpleStorage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SimpleStorage_V1_0_3_To_CS (ResoruceRaw, &SimpleStorageV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SimpleStorageV1_0_3 = (EFI_REDFISH_SIMPLESTORAGE_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIMPLESTORAGE_V1_0_3)); + if (SimpleStorageV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SimpleStorageV1_0_3; + SimpleStorageV1_0_3->SimpleStorage = SimpleStorageV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SimpleStorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SimpleStorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SimpleStorage_V1_0_3_JSON (*((EFI_REDFISH_SIMPLESTORAGE_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SimpleStorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_0_3 *SimpleStorageV1_0_3; + + SimpleStorageV1_0_3 = (EFI_REDFISH_SIMPLESTORAGE_V1_0_3 *)InterpProp; + DestroySimpleStorage_V1_0_3_CS (SimpleStorageV1_0_3->SimpleStorage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SimpleStorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySimpleStorage_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SimpleStorageToStructWrapper, + SimpleStorageToJson, + SimpleStorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_0_4/RedfishSimpleStorage_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/SimpleStorage/v1_0_4/RedfishSimpleStorage_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..5dfef11d32f --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_0_4/RedfishSimpleStorage_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SimpleStorage.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSimpleStorage_V1_0_4_Dxe + FILE_GUID = a9a409f1-0725-4f38-85c7-7fb61b391a5b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSimpleStorage_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishSimpleStorage_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SimpleStorage_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SimpleStorageV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_0_4/SimpleStorage_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/SimpleStorage/v1_0_4/SimpleStorage_V1_0_4_Dxe.c new file mode 100644 index 00000000000..3373858496e --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_0_4/SimpleStorage_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SimpleStorage.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SimpleStorage"; +BOOLEAN IsRevisonController = TRUE; + +// Support SimpleStorage V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SimpleStorage", + "1", + "0", + "4" + }, + "SimpleStorage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_0_4 *SimpleStorageV1_0_4; + EFI_REDFISH_SIMPLESTORAGE_V1_0_4_CS *SimpleStorageV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SimpleStorage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SimpleStorage_V1_0_4_To_CS (ResoruceRaw, &SimpleStorageV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SimpleStorageV1_0_4 = (EFI_REDFISH_SIMPLESTORAGE_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIMPLESTORAGE_V1_0_4)); + if (SimpleStorageV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SimpleStorageV1_0_4; + SimpleStorageV1_0_4->SimpleStorage = SimpleStorageV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SimpleStorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SimpleStorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SimpleStorage_V1_0_4_JSON (*((EFI_REDFISH_SIMPLESTORAGE_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SimpleStorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_0_4 *SimpleStorageV1_0_4; + + SimpleStorageV1_0_4 = (EFI_REDFISH_SIMPLESTORAGE_V1_0_4 *)InterpProp; + DestroySimpleStorage_V1_0_4_CS (SimpleStorageV1_0_4->SimpleStorage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SimpleStorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySimpleStorage_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SimpleStorageToStructWrapper, + SimpleStorageToJson, + SimpleStorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_0_5/RedfishSimpleStorage_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/SimpleStorage/v1_0_5/RedfishSimpleStorage_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..c9bb2c01b7b --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_0_5/RedfishSimpleStorage_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SimpleStorage.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSimpleStorage_V1_0_5_Dxe + FILE_GUID = 33f6e16e-5266-4940-b970-b23e37045206 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSimpleStorage_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishSimpleStorage_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SimpleStorage_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SimpleStorageV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_0_5/SimpleStorage_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/SimpleStorage/v1_0_5/SimpleStorage_V1_0_5_Dxe.c new file mode 100644 index 00000000000..f33b185daa6 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_0_5/SimpleStorage_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SimpleStorage.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SimpleStorage"; +BOOLEAN IsRevisonController = TRUE; + +// Support SimpleStorage V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SimpleStorage", + "1", + "0", + "5" + }, + "SimpleStorage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_0_5 *SimpleStorageV1_0_5; + EFI_REDFISH_SIMPLESTORAGE_V1_0_5_CS *SimpleStorageV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SimpleStorage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SimpleStorage_V1_0_5_To_CS (ResoruceRaw, &SimpleStorageV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SimpleStorageV1_0_5 = (EFI_REDFISH_SIMPLESTORAGE_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIMPLESTORAGE_V1_0_5)); + if (SimpleStorageV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SimpleStorageV1_0_5; + SimpleStorageV1_0_5->SimpleStorage = SimpleStorageV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SimpleStorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SimpleStorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SimpleStorage_V1_0_5_JSON (*((EFI_REDFISH_SIMPLESTORAGE_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SimpleStorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_0_5 *SimpleStorageV1_0_5; + + SimpleStorageV1_0_5 = (EFI_REDFISH_SIMPLESTORAGE_V1_0_5 *)InterpProp; + DestroySimpleStorage_V1_0_5_CS (SimpleStorageV1_0_5->SimpleStorage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SimpleStorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySimpleStorage_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SimpleStorageToStructWrapper, + SimpleStorageToJson, + SimpleStorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_0_6/RedfishSimpleStorage_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/SimpleStorage/v1_0_6/RedfishSimpleStorage_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..7688b82d3ba --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_0_6/RedfishSimpleStorage_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SimpleStorage.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSimpleStorage_V1_0_6_Dxe + FILE_GUID = 0146321c-8a84-408f-8f53-dc10db9a4a8c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSimpleStorage_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishSimpleStorage_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SimpleStorage_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SimpleStorageV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_0_6/SimpleStorage_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/SimpleStorage/v1_0_6/SimpleStorage_V1_0_6_Dxe.c new file mode 100644 index 00000000000..f4d41f3b223 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_0_6/SimpleStorage_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SimpleStorage.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SimpleStorage"; +BOOLEAN IsRevisonController = TRUE; + +// Support SimpleStorage V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SimpleStorage", + "1", + "0", + "6" + }, + "SimpleStorage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_0_6 *SimpleStorageV1_0_6; + EFI_REDFISH_SIMPLESTORAGE_V1_0_6_CS *SimpleStorageV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SimpleStorage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SimpleStorage_V1_0_6_To_CS (ResoruceRaw, &SimpleStorageV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SimpleStorageV1_0_6 = (EFI_REDFISH_SIMPLESTORAGE_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIMPLESTORAGE_V1_0_6)); + if (SimpleStorageV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SimpleStorageV1_0_6; + SimpleStorageV1_0_6->SimpleStorage = SimpleStorageV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SimpleStorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SimpleStorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SimpleStorage_V1_0_6_JSON (*((EFI_REDFISH_SIMPLESTORAGE_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SimpleStorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_0_6 *SimpleStorageV1_0_6; + + SimpleStorageV1_0_6 = (EFI_REDFISH_SIMPLESTORAGE_V1_0_6 *)InterpProp; + DestroySimpleStorage_V1_0_6_CS (SimpleStorageV1_0_6->SimpleStorage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SimpleStorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySimpleStorage_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SimpleStorageToStructWrapper, + SimpleStorageToJson, + SimpleStorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_0_7/RedfishSimpleStorage_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/SimpleStorage/v1_0_7/RedfishSimpleStorage_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..f41d0194404 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_0_7/RedfishSimpleStorage_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SimpleStorage.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSimpleStorage_V1_0_7_Dxe + FILE_GUID = 9a9c0287-f22f-4edb-a8da-4e3a0c29dcce + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSimpleStorage_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishSimpleStorage_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SimpleStorage_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SimpleStorageV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_0_7/SimpleStorage_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/SimpleStorage/v1_0_7/SimpleStorage_V1_0_7_Dxe.c new file mode 100644 index 00000000000..5aecf00b033 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_0_7/SimpleStorage_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SimpleStorage.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SimpleStorage"; +BOOLEAN IsRevisonController = TRUE; + +// Support SimpleStorage V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SimpleStorage", + "1", + "0", + "7" + }, + "SimpleStorage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_0_7 *SimpleStorageV1_0_7; + EFI_REDFISH_SIMPLESTORAGE_V1_0_7_CS *SimpleStorageV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SimpleStorage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SimpleStorage_V1_0_7_To_CS (ResoruceRaw, &SimpleStorageV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SimpleStorageV1_0_7 = (EFI_REDFISH_SIMPLESTORAGE_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIMPLESTORAGE_V1_0_7)); + if (SimpleStorageV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SimpleStorageV1_0_7; + SimpleStorageV1_0_7->SimpleStorage = SimpleStorageV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SimpleStorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SimpleStorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SimpleStorage_V1_0_7_JSON (*((EFI_REDFISH_SIMPLESTORAGE_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SimpleStorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_0_7 *SimpleStorageV1_0_7; + + SimpleStorageV1_0_7 = (EFI_REDFISH_SIMPLESTORAGE_V1_0_7 *)InterpProp; + DestroySimpleStorage_V1_0_7_CS (SimpleStorageV1_0_7->SimpleStorage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SimpleStorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySimpleStorage_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SimpleStorageToStructWrapper, + SimpleStorageToJson, + SimpleStorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_0_8/RedfishSimpleStorage_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/SimpleStorage/v1_0_8/RedfishSimpleStorage_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..2fc59ff764f --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_0_8/RedfishSimpleStorage_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SimpleStorage.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSimpleStorage_V1_0_8_Dxe + FILE_GUID = cbd4473f-769a-4a24-b9fb-62d42dbb2545 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSimpleStorage_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishSimpleStorage_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SimpleStorage_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SimpleStorageV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_0_8/SimpleStorage_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/SimpleStorage/v1_0_8/SimpleStorage_V1_0_8_Dxe.c new file mode 100644 index 00000000000..891999c9519 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_0_8/SimpleStorage_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SimpleStorage.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SimpleStorage"; +BOOLEAN IsRevisonController = TRUE; + +// Support SimpleStorage V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SimpleStorage", + "1", + "0", + "8" + }, + "SimpleStorage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_0_8 *SimpleStorageV1_0_8; + EFI_REDFISH_SIMPLESTORAGE_V1_0_8_CS *SimpleStorageV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SimpleStorage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SimpleStorage_V1_0_8_To_CS (ResoruceRaw, &SimpleStorageV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SimpleStorageV1_0_8 = (EFI_REDFISH_SIMPLESTORAGE_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIMPLESTORAGE_V1_0_8)); + if (SimpleStorageV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SimpleStorageV1_0_8; + SimpleStorageV1_0_8->SimpleStorage = SimpleStorageV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SimpleStorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SimpleStorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SimpleStorage_V1_0_8_JSON (*((EFI_REDFISH_SIMPLESTORAGE_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SimpleStorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_0_8 *SimpleStorageV1_0_8; + + SimpleStorageV1_0_8 = (EFI_REDFISH_SIMPLESTORAGE_V1_0_8 *)InterpProp; + DestroySimpleStorage_V1_0_8_CS (SimpleStorageV1_0_8->SimpleStorage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SimpleStorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySimpleStorage_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SimpleStorageToStructWrapper, + SimpleStorageToJson, + SimpleStorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_1_0/RedfishSimpleStorage_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/SimpleStorage/v1_1_0/RedfishSimpleStorage_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..471cc077f26 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_1_0/RedfishSimpleStorage_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SimpleStorage.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSimpleStorage_V1_1_0_Dxe + FILE_GUID = ac9ee0d0-b8e0-4ff4-ba5b-0fd9a6b385be + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSimpleStorage_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishSimpleStorage_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SimpleStorage_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SimpleStorageV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_1_0/SimpleStorage_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/SimpleStorage/v1_1_0/SimpleStorage_V1_1_0_Dxe.c new file mode 100644 index 00000000000..9e46fb0b051 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_1_0/SimpleStorage_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SimpleStorage.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SimpleStorage"; +BOOLEAN IsRevisonController = TRUE; + +// Support SimpleStorage V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SimpleStorage", + "1", + "1", + "0" + }, + "SimpleStorage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_1_0 *SimpleStorageV1_1_0; + EFI_REDFISH_SIMPLESTORAGE_V1_1_0_CS *SimpleStorageV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SimpleStorage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SimpleStorage_V1_1_0_To_CS (ResoruceRaw, &SimpleStorageV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SimpleStorageV1_1_0 = (EFI_REDFISH_SIMPLESTORAGE_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIMPLESTORAGE_V1_1_0)); + if (SimpleStorageV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SimpleStorageV1_1_0; + SimpleStorageV1_1_0->SimpleStorage = SimpleStorageV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SimpleStorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SimpleStorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SimpleStorage_V1_1_0_JSON (*((EFI_REDFISH_SIMPLESTORAGE_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SimpleStorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_1_0 *SimpleStorageV1_1_0; + + SimpleStorageV1_1_0 = (EFI_REDFISH_SIMPLESTORAGE_V1_1_0 *)InterpProp; + DestroySimpleStorage_V1_1_0_CS (SimpleStorageV1_1_0->SimpleStorage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SimpleStorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySimpleStorage_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SimpleStorageToStructWrapper, + SimpleStorageToJson, + SimpleStorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_1_1/RedfishSimpleStorage_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/SimpleStorage/v1_1_1/RedfishSimpleStorage_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..bf0da2a82a3 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_1_1/RedfishSimpleStorage_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SimpleStorage.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSimpleStorage_V1_1_1_Dxe + FILE_GUID = a183ef76-6044-48d8-8020-88b11f6a6f38 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSimpleStorage_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishSimpleStorage_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SimpleStorage_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SimpleStorageV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_1_1/SimpleStorage_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/SimpleStorage/v1_1_1/SimpleStorage_V1_1_1_Dxe.c new file mode 100644 index 00000000000..b9ba698468e --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_1_1/SimpleStorage_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SimpleStorage.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SimpleStorage"; +BOOLEAN IsRevisonController = TRUE; + +// Support SimpleStorage V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SimpleStorage", + "1", + "1", + "1" + }, + "SimpleStorage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_1_1 *SimpleStorageV1_1_1; + EFI_REDFISH_SIMPLESTORAGE_V1_1_1_CS *SimpleStorageV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SimpleStorage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SimpleStorage_V1_1_1_To_CS (ResoruceRaw, &SimpleStorageV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SimpleStorageV1_1_1 = (EFI_REDFISH_SIMPLESTORAGE_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIMPLESTORAGE_V1_1_1)); + if (SimpleStorageV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SimpleStorageV1_1_1; + SimpleStorageV1_1_1->SimpleStorage = SimpleStorageV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SimpleStorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SimpleStorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SimpleStorage_V1_1_1_JSON (*((EFI_REDFISH_SIMPLESTORAGE_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SimpleStorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_1_1 *SimpleStorageV1_1_1; + + SimpleStorageV1_1_1 = (EFI_REDFISH_SIMPLESTORAGE_V1_1_1 *)InterpProp; + DestroySimpleStorage_V1_1_1_CS (SimpleStorageV1_1_1->SimpleStorage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SimpleStorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySimpleStorage_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SimpleStorageToStructWrapper, + SimpleStorageToJson, + SimpleStorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_1_2/RedfishSimpleStorage_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/SimpleStorage/v1_1_2/RedfishSimpleStorage_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..61112872fcc --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_1_2/RedfishSimpleStorage_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SimpleStorage.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSimpleStorage_V1_1_2_Dxe + FILE_GUID = 9a915196-ffd8-4f21-8487-7ffbab9c0e6a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSimpleStorage_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishSimpleStorage_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SimpleStorage_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SimpleStorageV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_1_2/SimpleStorage_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/SimpleStorage/v1_1_2/SimpleStorage_V1_1_2_Dxe.c new file mode 100644 index 00000000000..2b2be0840de --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_1_2/SimpleStorage_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SimpleStorage.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SimpleStorage"; +BOOLEAN IsRevisonController = TRUE; + +// Support SimpleStorage V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SimpleStorage", + "1", + "1", + "2" + }, + "SimpleStorage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_1_2 *SimpleStorageV1_1_2; + EFI_REDFISH_SIMPLESTORAGE_V1_1_2_CS *SimpleStorageV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SimpleStorage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SimpleStorage_V1_1_2_To_CS (ResoruceRaw, &SimpleStorageV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SimpleStorageV1_1_2 = (EFI_REDFISH_SIMPLESTORAGE_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIMPLESTORAGE_V1_1_2)); + if (SimpleStorageV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SimpleStorageV1_1_2; + SimpleStorageV1_1_2->SimpleStorage = SimpleStorageV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SimpleStorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SimpleStorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SimpleStorage_V1_1_2_JSON (*((EFI_REDFISH_SIMPLESTORAGE_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SimpleStorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_1_2 *SimpleStorageV1_1_2; + + SimpleStorageV1_1_2 = (EFI_REDFISH_SIMPLESTORAGE_V1_1_2 *)InterpProp; + DestroySimpleStorage_V1_1_2_CS (SimpleStorageV1_1_2->SimpleStorage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SimpleStorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySimpleStorage_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SimpleStorageToStructWrapper, + SimpleStorageToJson, + SimpleStorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_1_3/RedfishSimpleStorage_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/SimpleStorage/v1_1_3/RedfishSimpleStorage_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..787cc750bdf --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_1_3/RedfishSimpleStorage_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SimpleStorage.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSimpleStorage_V1_1_3_Dxe + FILE_GUID = 6243ce6b-f7d8-43cd-a77d-c1cdbf2e1431 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSimpleStorage_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishSimpleStorage_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SimpleStorage_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SimpleStorageV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_1_3/SimpleStorage_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/SimpleStorage/v1_1_3/SimpleStorage_V1_1_3_Dxe.c new file mode 100644 index 00000000000..2423bf49b31 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_1_3/SimpleStorage_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SimpleStorage.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SimpleStorage"; +BOOLEAN IsRevisonController = TRUE; + +// Support SimpleStorage V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SimpleStorage", + "1", + "1", + "3" + }, + "SimpleStorage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_1_3 *SimpleStorageV1_1_3; + EFI_REDFISH_SIMPLESTORAGE_V1_1_3_CS *SimpleStorageV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SimpleStorage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SimpleStorage_V1_1_3_To_CS (ResoruceRaw, &SimpleStorageV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SimpleStorageV1_1_3 = (EFI_REDFISH_SIMPLESTORAGE_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIMPLESTORAGE_V1_1_3)); + if (SimpleStorageV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SimpleStorageV1_1_3; + SimpleStorageV1_1_3->SimpleStorage = SimpleStorageV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SimpleStorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SimpleStorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SimpleStorage_V1_1_3_JSON (*((EFI_REDFISH_SIMPLESTORAGE_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SimpleStorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_1_3 *SimpleStorageV1_1_3; + + SimpleStorageV1_1_3 = (EFI_REDFISH_SIMPLESTORAGE_V1_1_3 *)InterpProp; + DestroySimpleStorage_V1_1_3_CS (SimpleStorageV1_1_3->SimpleStorage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SimpleStorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySimpleStorage_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SimpleStorageToStructWrapper, + SimpleStorageToJson, + SimpleStorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_1_4/RedfishSimpleStorage_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/SimpleStorage/v1_1_4/RedfishSimpleStorage_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..80a36850166 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_1_4/RedfishSimpleStorage_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SimpleStorage.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSimpleStorage_V1_1_4_Dxe + FILE_GUID = 4841ce5f-2362-4d24-a376-ad7cfa1c06fe + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSimpleStorage_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishSimpleStorage_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SimpleStorage_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SimpleStorageV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_1_4/SimpleStorage_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/SimpleStorage/v1_1_4/SimpleStorage_V1_1_4_Dxe.c new file mode 100644 index 00000000000..8d68732de51 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_1_4/SimpleStorage_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SimpleStorage.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SimpleStorage"; +BOOLEAN IsRevisonController = TRUE; + +// Support SimpleStorage V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SimpleStorage", + "1", + "1", + "4" + }, + "SimpleStorage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_1_4 *SimpleStorageV1_1_4; + EFI_REDFISH_SIMPLESTORAGE_V1_1_4_CS *SimpleStorageV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SimpleStorage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SimpleStorage_V1_1_4_To_CS (ResoruceRaw, &SimpleStorageV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SimpleStorageV1_1_4 = (EFI_REDFISH_SIMPLESTORAGE_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIMPLESTORAGE_V1_1_4)); + if (SimpleStorageV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SimpleStorageV1_1_4; + SimpleStorageV1_1_4->SimpleStorage = SimpleStorageV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SimpleStorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SimpleStorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SimpleStorage_V1_1_4_JSON (*((EFI_REDFISH_SIMPLESTORAGE_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SimpleStorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_1_4 *SimpleStorageV1_1_4; + + SimpleStorageV1_1_4 = (EFI_REDFISH_SIMPLESTORAGE_V1_1_4 *)InterpProp; + DestroySimpleStorage_V1_1_4_CS (SimpleStorageV1_1_4->SimpleStorage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SimpleStorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySimpleStorage_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SimpleStorageToStructWrapper, + SimpleStorageToJson, + SimpleStorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_1_5/RedfishSimpleStorage_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/SimpleStorage/v1_1_5/RedfishSimpleStorage_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..ea142cca0ec --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_1_5/RedfishSimpleStorage_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SimpleStorage.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSimpleStorage_V1_1_5_Dxe + FILE_GUID = 6ac5d105-cac2-4980-bab1-3c5435a75883 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSimpleStorage_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishSimpleStorage_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SimpleStorage_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SimpleStorageV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_1_5/SimpleStorage_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/SimpleStorage/v1_1_5/SimpleStorage_V1_1_5_Dxe.c new file mode 100644 index 00000000000..e8864e17574 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_1_5/SimpleStorage_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SimpleStorage.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SimpleStorage"; +BOOLEAN IsRevisonController = TRUE; + +// Support SimpleStorage V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SimpleStorage", + "1", + "1", + "5" + }, + "SimpleStorage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_1_5 *SimpleStorageV1_1_5; + EFI_REDFISH_SIMPLESTORAGE_V1_1_5_CS *SimpleStorageV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SimpleStorage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SimpleStorage_V1_1_5_To_CS (ResoruceRaw, &SimpleStorageV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SimpleStorageV1_1_5 = (EFI_REDFISH_SIMPLESTORAGE_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIMPLESTORAGE_V1_1_5)); + if (SimpleStorageV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SimpleStorageV1_1_5; + SimpleStorageV1_1_5->SimpleStorage = SimpleStorageV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SimpleStorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SimpleStorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SimpleStorage_V1_1_5_JSON (*((EFI_REDFISH_SIMPLESTORAGE_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SimpleStorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_1_5 *SimpleStorageV1_1_5; + + SimpleStorageV1_1_5 = (EFI_REDFISH_SIMPLESTORAGE_V1_1_5 *)InterpProp; + DestroySimpleStorage_V1_1_5_CS (SimpleStorageV1_1_5->SimpleStorage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SimpleStorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySimpleStorage_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SimpleStorageToStructWrapper, + SimpleStorageToJson, + SimpleStorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_1_6/RedfishSimpleStorage_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/SimpleStorage/v1_1_6/RedfishSimpleStorage_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..3d91a8b4e8e --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_1_6/RedfishSimpleStorage_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SimpleStorage.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSimpleStorage_V1_1_6_Dxe + FILE_GUID = 100ee7a0-45c4-4704-a1cb-b3b5f2646699 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSimpleStorage_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishSimpleStorage_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SimpleStorage_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SimpleStorageV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_1_6/SimpleStorage_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/SimpleStorage/v1_1_6/SimpleStorage_V1_1_6_Dxe.c new file mode 100644 index 00000000000..80f2b6fa900 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_1_6/SimpleStorage_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SimpleStorage.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SimpleStorage"; +BOOLEAN IsRevisonController = TRUE; + +// Support SimpleStorage V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SimpleStorage", + "1", + "1", + "6" + }, + "SimpleStorage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_1_6 *SimpleStorageV1_1_6; + EFI_REDFISH_SIMPLESTORAGE_V1_1_6_CS *SimpleStorageV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SimpleStorage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SimpleStorage_V1_1_6_To_CS (ResoruceRaw, &SimpleStorageV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SimpleStorageV1_1_6 = (EFI_REDFISH_SIMPLESTORAGE_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIMPLESTORAGE_V1_1_6)); + if (SimpleStorageV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SimpleStorageV1_1_6; + SimpleStorageV1_1_6->SimpleStorage = SimpleStorageV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SimpleStorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SimpleStorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SimpleStorage_V1_1_6_JSON (*((EFI_REDFISH_SIMPLESTORAGE_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SimpleStorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_1_6 *SimpleStorageV1_1_6; + + SimpleStorageV1_1_6 = (EFI_REDFISH_SIMPLESTORAGE_V1_1_6 *)InterpProp; + DestroySimpleStorage_V1_1_6_CS (SimpleStorageV1_1_6->SimpleStorage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SimpleStorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySimpleStorage_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SimpleStorageToStructWrapper, + SimpleStorageToJson, + SimpleStorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_2_0/RedfishSimpleStorage_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/SimpleStorage/v1_2_0/RedfishSimpleStorage_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..d32980583b7 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_2_0/RedfishSimpleStorage_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SimpleStorage.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSimpleStorage_V1_2_0_Dxe + FILE_GUID = aea9f11a-ec38-4137-9261-16dfcbbfaa33 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSimpleStorage_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishSimpleStorage_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SimpleStorage_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SimpleStorageV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_2_0/SimpleStorage_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/SimpleStorage/v1_2_0/SimpleStorage_V1_2_0_Dxe.c new file mode 100644 index 00000000000..5176fd873e4 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_2_0/SimpleStorage_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SimpleStorage.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SimpleStorage"; +BOOLEAN IsRevisonController = TRUE; + +// Support SimpleStorage V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SimpleStorage", + "1", + "2", + "0" + }, + "SimpleStorage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_2_0 *SimpleStorageV1_2_0; + EFI_REDFISH_SIMPLESTORAGE_V1_2_0_CS *SimpleStorageV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SimpleStorage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SimpleStorage_V1_2_0_To_CS (ResoruceRaw, &SimpleStorageV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SimpleStorageV1_2_0 = (EFI_REDFISH_SIMPLESTORAGE_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIMPLESTORAGE_V1_2_0)); + if (SimpleStorageV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SimpleStorageV1_2_0; + SimpleStorageV1_2_0->SimpleStorage = SimpleStorageV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SimpleStorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SimpleStorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SimpleStorage_V1_2_0_JSON (*((EFI_REDFISH_SIMPLESTORAGE_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SimpleStorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_2_0 *SimpleStorageV1_2_0; + + SimpleStorageV1_2_0 = (EFI_REDFISH_SIMPLESTORAGE_V1_2_0 *)InterpProp; + DestroySimpleStorage_V1_2_0_CS (SimpleStorageV1_2_0->SimpleStorage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SimpleStorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySimpleStorage_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SimpleStorageToStructWrapper, + SimpleStorageToJson, + SimpleStorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_2_1/RedfishSimpleStorage_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/SimpleStorage/v1_2_1/RedfishSimpleStorage_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..85a45512cf5 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_2_1/RedfishSimpleStorage_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SimpleStorage.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSimpleStorage_V1_2_1_Dxe + FILE_GUID = 8cdbfcb0-af58-4cd4-8464-b35a759d2bb9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSimpleStorage_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishSimpleStorage_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SimpleStorage_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SimpleStorageV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_2_1/SimpleStorage_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/SimpleStorage/v1_2_1/SimpleStorage_V1_2_1_Dxe.c new file mode 100644 index 00000000000..e005644cad8 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_2_1/SimpleStorage_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SimpleStorage.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SimpleStorage"; +BOOLEAN IsRevisonController = TRUE; + +// Support SimpleStorage V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SimpleStorage", + "1", + "2", + "1" + }, + "SimpleStorage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_2_1 *SimpleStorageV1_2_1; + EFI_REDFISH_SIMPLESTORAGE_V1_2_1_CS *SimpleStorageV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SimpleStorage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SimpleStorage_V1_2_1_To_CS (ResoruceRaw, &SimpleStorageV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SimpleStorageV1_2_1 = (EFI_REDFISH_SIMPLESTORAGE_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIMPLESTORAGE_V1_2_1)); + if (SimpleStorageV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SimpleStorageV1_2_1; + SimpleStorageV1_2_1->SimpleStorage = SimpleStorageV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SimpleStorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SimpleStorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SimpleStorage_V1_2_1_JSON (*((EFI_REDFISH_SIMPLESTORAGE_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SimpleStorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_2_1 *SimpleStorageV1_2_1; + + SimpleStorageV1_2_1 = (EFI_REDFISH_SIMPLESTORAGE_V1_2_1 *)InterpProp; + DestroySimpleStorage_V1_2_1_CS (SimpleStorageV1_2_1->SimpleStorage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SimpleStorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySimpleStorage_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SimpleStorageToStructWrapper, + SimpleStorageToJson, + SimpleStorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_2_2/RedfishSimpleStorage_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/SimpleStorage/v1_2_2/RedfishSimpleStorage_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..774fbdd5c4b --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_2_2/RedfishSimpleStorage_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SimpleStorage.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSimpleStorage_V1_2_2_Dxe + FILE_GUID = dc6d47d9-0666-4aa2-bdd0-157ec66466a4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSimpleStorage_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishSimpleStorage_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SimpleStorage_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SimpleStorageV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_2_2/SimpleStorage_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/SimpleStorage/v1_2_2/SimpleStorage_V1_2_2_Dxe.c new file mode 100644 index 00000000000..51cbc21d1f0 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_2_2/SimpleStorage_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SimpleStorage.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SimpleStorage"; +BOOLEAN IsRevisonController = TRUE; + +// Support SimpleStorage V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SimpleStorage", + "1", + "2", + "2" + }, + "SimpleStorage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_2_2 *SimpleStorageV1_2_2; + EFI_REDFISH_SIMPLESTORAGE_V1_2_2_CS *SimpleStorageV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SimpleStorage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SimpleStorage_V1_2_2_To_CS (ResoruceRaw, &SimpleStorageV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SimpleStorageV1_2_2 = (EFI_REDFISH_SIMPLESTORAGE_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIMPLESTORAGE_V1_2_2)); + if (SimpleStorageV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SimpleStorageV1_2_2; + SimpleStorageV1_2_2->SimpleStorage = SimpleStorageV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SimpleStorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SimpleStorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SimpleStorage_V1_2_2_JSON (*((EFI_REDFISH_SIMPLESTORAGE_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SimpleStorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_2_2 *SimpleStorageV1_2_2; + + SimpleStorageV1_2_2 = (EFI_REDFISH_SIMPLESTORAGE_V1_2_2 *)InterpProp; + DestroySimpleStorage_V1_2_2_CS (SimpleStorageV1_2_2->SimpleStorage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SimpleStorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySimpleStorage_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SimpleStorageToStructWrapper, + SimpleStorageToJson, + SimpleStorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_2_3/RedfishSimpleStorage_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/SimpleStorage/v1_2_3/RedfishSimpleStorage_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..5b921dcc417 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_2_3/RedfishSimpleStorage_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SimpleStorage.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSimpleStorage_V1_2_3_Dxe + FILE_GUID = 32274446-5550-4d89-9269-a2a33468778f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSimpleStorage_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishSimpleStorage_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SimpleStorage_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SimpleStorageV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_2_3/SimpleStorage_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/SimpleStorage/v1_2_3/SimpleStorage_V1_2_3_Dxe.c new file mode 100644 index 00000000000..2b1a32f8819 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_2_3/SimpleStorage_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SimpleStorage.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SimpleStorage"; +BOOLEAN IsRevisonController = TRUE; + +// Support SimpleStorage V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SimpleStorage", + "1", + "2", + "3" + }, + "SimpleStorage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_2_3 *SimpleStorageV1_2_3; + EFI_REDFISH_SIMPLESTORAGE_V1_2_3_CS *SimpleStorageV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SimpleStorage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SimpleStorage_V1_2_3_To_CS (ResoruceRaw, &SimpleStorageV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SimpleStorageV1_2_3 = (EFI_REDFISH_SIMPLESTORAGE_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIMPLESTORAGE_V1_2_3)); + if (SimpleStorageV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SimpleStorageV1_2_3; + SimpleStorageV1_2_3->SimpleStorage = SimpleStorageV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SimpleStorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SimpleStorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SimpleStorage_V1_2_3_JSON (*((EFI_REDFISH_SIMPLESTORAGE_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SimpleStorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_2_3 *SimpleStorageV1_2_3; + + SimpleStorageV1_2_3 = (EFI_REDFISH_SIMPLESTORAGE_V1_2_3 *)InterpProp; + DestroySimpleStorage_V1_2_3_CS (SimpleStorageV1_2_3->SimpleStorage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SimpleStorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySimpleStorage_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SimpleStorageToStructWrapper, + SimpleStorageToJson, + SimpleStorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_2_4/RedfishSimpleStorage_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/SimpleStorage/v1_2_4/RedfishSimpleStorage_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..cf579409c53 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_2_4/RedfishSimpleStorage_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SimpleStorage.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSimpleStorage_V1_2_4_Dxe + FILE_GUID = c076c4f2-b963-44e3-a73a-f27c32a7162c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSimpleStorage_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishSimpleStorage_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SimpleStorage_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SimpleStorageV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_2_4/SimpleStorage_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/SimpleStorage/v1_2_4/SimpleStorage_V1_2_4_Dxe.c new file mode 100644 index 00000000000..b4776a56433 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_2_4/SimpleStorage_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SimpleStorage.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SimpleStorage"; +BOOLEAN IsRevisonController = TRUE; + +// Support SimpleStorage V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SimpleStorage", + "1", + "2", + "4" + }, + "SimpleStorage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_2_4 *SimpleStorageV1_2_4; + EFI_REDFISH_SIMPLESTORAGE_V1_2_4_CS *SimpleStorageV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SimpleStorage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SimpleStorage_V1_2_4_To_CS (ResoruceRaw, &SimpleStorageV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SimpleStorageV1_2_4 = (EFI_REDFISH_SIMPLESTORAGE_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIMPLESTORAGE_V1_2_4)); + if (SimpleStorageV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SimpleStorageV1_2_4; + SimpleStorageV1_2_4->SimpleStorage = SimpleStorageV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SimpleStorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SimpleStorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SimpleStorage_V1_2_4_JSON (*((EFI_REDFISH_SIMPLESTORAGE_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SimpleStorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_2_4 *SimpleStorageV1_2_4; + + SimpleStorageV1_2_4 = (EFI_REDFISH_SIMPLESTORAGE_V1_2_4 *)InterpProp; + DestroySimpleStorage_V1_2_4_CS (SimpleStorageV1_2_4->SimpleStorage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SimpleStorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySimpleStorage_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SimpleStorageToStructWrapper, + SimpleStorageToJson, + SimpleStorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_3_0/RedfishSimpleStorage_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/SimpleStorage/v1_3_0/RedfishSimpleStorage_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..889bec1b3a6 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_3_0/RedfishSimpleStorage_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SimpleStorage.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSimpleStorage_V1_3_0_Dxe + FILE_GUID = 31b3969e-6c70-4c7d-ac9c-bd42c3a44e0c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSimpleStorage_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishSimpleStorage_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SimpleStorage_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SimpleStorageV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_3_0/SimpleStorage_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/SimpleStorage/v1_3_0/SimpleStorage_V1_3_0_Dxe.c new file mode 100644 index 00000000000..5f5bd4c3edf --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_3_0/SimpleStorage_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SimpleStorage.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SimpleStorage"; +BOOLEAN IsRevisonController = TRUE; + +// Support SimpleStorage V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SimpleStorage", + "1", + "3", + "0" + }, + "SimpleStorage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_3_0 *SimpleStorageV1_3_0; + EFI_REDFISH_SIMPLESTORAGE_V1_3_0_CS *SimpleStorageV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SimpleStorage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SimpleStorage_V1_3_0_To_CS (ResoruceRaw, &SimpleStorageV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SimpleStorageV1_3_0 = (EFI_REDFISH_SIMPLESTORAGE_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIMPLESTORAGE_V1_3_0)); + if (SimpleStorageV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SimpleStorageV1_3_0; + SimpleStorageV1_3_0->SimpleStorage = SimpleStorageV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SimpleStorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SimpleStorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SimpleStorage_V1_3_0_JSON (*((EFI_REDFISH_SIMPLESTORAGE_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SimpleStorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_3_0 *SimpleStorageV1_3_0; + + SimpleStorageV1_3_0 = (EFI_REDFISH_SIMPLESTORAGE_V1_3_0 *)InterpProp; + DestroySimpleStorage_V1_3_0_CS (SimpleStorageV1_3_0->SimpleStorage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SimpleStorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySimpleStorage_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SimpleStorageToStructWrapper, + SimpleStorageToJson, + SimpleStorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_3_1/RedfishSimpleStorage_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/SimpleStorage/v1_3_1/RedfishSimpleStorage_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..dc93204624a --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_3_1/RedfishSimpleStorage_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SimpleStorage.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSimpleStorage_V1_3_1_Dxe + FILE_GUID = 533e8235-1562-43bc-927b-3c7426404df2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSimpleStorage_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishSimpleStorage_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SimpleStorage_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SimpleStorageV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SimpleStorage/v1_3_1/SimpleStorage_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/SimpleStorage/v1_3_1/SimpleStorage_V1_3_1_Dxe.c new file mode 100644 index 00000000000..e98fb5019f2 --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorage/v1_3_1/SimpleStorage_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SimpleStorage.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SimpleStorage"; +BOOLEAN IsRevisonController = TRUE; + +// Support SimpleStorage V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SimpleStorage", + "1", + "3", + "1" + }, + "SimpleStorage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_3_1 *SimpleStorageV1_3_1; + EFI_REDFISH_SIMPLESTORAGE_V1_3_1_CS *SimpleStorageV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SimpleStorage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SimpleStorage_V1_3_1_To_CS (ResoruceRaw, &SimpleStorageV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SimpleStorageV1_3_1 = (EFI_REDFISH_SIMPLESTORAGE_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIMPLESTORAGE_V1_3_1)); + if (SimpleStorageV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SimpleStorageV1_3_1; + SimpleStorageV1_3_1->SimpleStorage = SimpleStorageV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SimpleStorage"), "SimpleStorage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SimpleStorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SimpleStorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SimpleStorage_V1_3_1_JSON (*((EFI_REDFISH_SIMPLESTORAGE_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SimpleStorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGE_V1_3_1 *SimpleStorageV1_3_1; + + SimpleStorageV1_3_1 = (EFI_REDFISH_SIMPLESTORAGE_V1_3_1 *)InterpProp; + DestroySimpleStorage_V1_3_1_CS (SimpleStorageV1_3_1->SimpleStorage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SimpleStorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySimpleStorage_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SimpleStorageToStructWrapper, + SimpleStorageToJson, + SimpleStorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorage_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SimpleStorageCollection/RedfishSimpleStorageCollection_Dxe.inf b/RedfishClientPkg/Converter/SimpleStorageCollection/RedfishSimpleStorageCollection_Dxe.inf new file mode 100644 index 00000000000..b2b7978e1cb --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorageCollection/RedfishSimpleStorageCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SimpleStorageCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSimpleStorageCollection_Dxe + FILE_GUID = 8f76bd1e-bbab-43a2-87c1-f69e8c5c570c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSimpleStorageCollectionEntryPoint + UNLOAD_IMAGE = RedfishSimpleStorageCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SimpleStorageCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SimpleStorageCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SimpleStorageCollection/SimpleStorageCollection_Dxe.c b/RedfishClientPkg/Converter/SimpleStorageCollection/SimpleStorageCollection_Dxe.c new file mode 100644 index 00000000000..711e6d748bb --- /dev/null +++ b/RedfishClientPkg/Converter/SimpleStorageCollection/SimpleStorageCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SimpleStorageCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SimpleStorageCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support SimpleStorageCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SimpleStorageCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "SimpleStorageCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGECOLLECTION *SimpleStorageCollection; + EFI_REDFISH_SIMPLESTORAGECOLLECTION_CS *SimpleStorageCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SimpleStorageCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SimpleStorageCollection_To_CS (ResoruceRaw, &SimpleStorageCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + SimpleStorageCollection = (EFI_REDFISH_SIMPLESTORAGECOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SIMPLESTORAGECOLLECTION)); + if (SimpleStorageCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SimpleStorageCollection; + SimpleStorageCollection->SimpleStorageCollection = SimpleStorageCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorageCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SimpleStorageCollection"), "SimpleStorageCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SimpleStorageCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SimpleStorageCollection"), "SimpleStorageCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SimpleStorageCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SimpleStorageCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SimpleStorageCollection_JSON (*((EFI_REDFISH_SIMPLESTORAGECOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SimpleStorageCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SIMPLESTORAGECOLLECTION *SimpleStorageCollection; + + SimpleStorageCollection = (EFI_REDFISH_SIMPLESTORAGECOLLECTION *)InterpProp; + DestroySimpleStorageCollection_CS (SimpleStorageCollection->SimpleStorageCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SimpleStorageCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SimpleStorageCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySimpleStorageCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorageCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SimpleStorageCollectionToStructWrapper, + SimpleStorageCollectionToJson, + SimpleStorageCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSimpleStorageCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_0_0/RedfishSoftwareInventory_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/SoftwareInventory/v1_0_0/RedfishSoftwareInventory_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..31ed47ea0c3 --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_0_0/RedfishSoftwareInventory_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SoftwareInventory.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSoftwareInventory_V1_0_0_Dxe + FILE_GUID = f87cc61b-f4ef-4af0-a5b1-8f4ccc26728b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSoftwareInventory_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishSoftwareInventory_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SoftwareInventory_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SoftwareInventoryV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_0_0/SoftwareInventory_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/SoftwareInventory/v1_0_0/SoftwareInventory_V1_0_0_Dxe.c new file mode 100644 index 00000000000..ebccbf38ac7 --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_0_0/SoftwareInventory_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SoftwareInventory.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SoftwareInventory"; +BOOLEAN IsRevisonController = TRUE; + +// Support SoftwareInventory V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SoftwareInventory", + "1", + "0", + "0" + }, + "SoftwareInventory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_0_0 *SoftwareInventoryV1_0_0; + EFI_REDFISH_SOFTWAREINVENTORY_V1_0_0_CS *SoftwareInventoryV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SoftwareInventory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SoftwareInventory_V1_0_0_To_CS (ResoruceRaw, &SoftwareInventoryV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SoftwareInventoryV1_0_0 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SOFTWAREINVENTORY_V1_0_0)); + if (SoftwareInventoryV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SoftwareInventoryV1_0_0; + SoftwareInventoryV1_0_0->SoftwareInventory = SoftwareInventoryV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SoftwareInventoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SoftwareInventoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SoftwareInventory_V1_0_0_JSON (*((EFI_REDFISH_SOFTWAREINVENTORY_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SoftwareInventoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_0_0 *SoftwareInventoryV1_0_0; + + SoftwareInventoryV1_0_0 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_0_0 *)InterpProp; + DestroySoftwareInventory_V1_0_0_CS (SoftwareInventoryV1_0_0->SoftwareInventory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SoftwareInventoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySoftwareInventory_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SoftwareInventoryToStructWrapper, + SoftwareInventoryToJson, + SoftwareInventoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_0_1/RedfishSoftwareInventory_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/SoftwareInventory/v1_0_1/RedfishSoftwareInventory_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..7eec6fd7c82 --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_0_1/RedfishSoftwareInventory_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SoftwareInventory.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSoftwareInventory_V1_0_1_Dxe + FILE_GUID = d5b1ed7e-dfa8-4d84-8223-968bf59d6fbb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSoftwareInventory_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishSoftwareInventory_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SoftwareInventory_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SoftwareInventoryV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_0_1/SoftwareInventory_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/SoftwareInventory/v1_0_1/SoftwareInventory_V1_0_1_Dxe.c new file mode 100644 index 00000000000..f8cde0394b5 --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_0_1/SoftwareInventory_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SoftwareInventory.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SoftwareInventory"; +BOOLEAN IsRevisonController = TRUE; + +// Support SoftwareInventory V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SoftwareInventory", + "1", + "0", + "1" + }, + "SoftwareInventory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_0_1 *SoftwareInventoryV1_0_1; + EFI_REDFISH_SOFTWAREINVENTORY_V1_0_1_CS *SoftwareInventoryV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SoftwareInventory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SoftwareInventory_V1_0_1_To_CS (ResoruceRaw, &SoftwareInventoryV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SoftwareInventoryV1_0_1 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SOFTWAREINVENTORY_V1_0_1)); + if (SoftwareInventoryV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SoftwareInventoryV1_0_1; + SoftwareInventoryV1_0_1->SoftwareInventory = SoftwareInventoryV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SoftwareInventoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SoftwareInventoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SoftwareInventory_V1_0_1_JSON (*((EFI_REDFISH_SOFTWAREINVENTORY_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SoftwareInventoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_0_1 *SoftwareInventoryV1_0_1; + + SoftwareInventoryV1_0_1 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_0_1 *)InterpProp; + DestroySoftwareInventory_V1_0_1_CS (SoftwareInventoryV1_0_1->SoftwareInventory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SoftwareInventoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySoftwareInventory_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SoftwareInventoryToStructWrapper, + SoftwareInventoryToJson, + SoftwareInventoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_0_2/RedfishSoftwareInventory_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/SoftwareInventory/v1_0_2/RedfishSoftwareInventory_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..1fa4ccb1db6 --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_0_2/RedfishSoftwareInventory_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SoftwareInventory.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSoftwareInventory_V1_0_2_Dxe + FILE_GUID = ccc31a96-2adb-4625-affa-5c8f38444518 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSoftwareInventory_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishSoftwareInventory_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SoftwareInventory_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SoftwareInventoryV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_0_2/SoftwareInventory_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/SoftwareInventory/v1_0_2/SoftwareInventory_V1_0_2_Dxe.c new file mode 100644 index 00000000000..d5f9f1ade81 --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_0_2/SoftwareInventory_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SoftwareInventory.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SoftwareInventory"; +BOOLEAN IsRevisonController = TRUE; + +// Support SoftwareInventory V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SoftwareInventory", + "1", + "0", + "2" + }, + "SoftwareInventory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_0_2 *SoftwareInventoryV1_0_2; + EFI_REDFISH_SOFTWAREINVENTORY_V1_0_2_CS *SoftwareInventoryV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SoftwareInventory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SoftwareInventory_V1_0_2_To_CS (ResoruceRaw, &SoftwareInventoryV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SoftwareInventoryV1_0_2 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SOFTWAREINVENTORY_V1_0_2)); + if (SoftwareInventoryV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SoftwareInventoryV1_0_2; + SoftwareInventoryV1_0_2->SoftwareInventory = SoftwareInventoryV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SoftwareInventoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SoftwareInventoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SoftwareInventory_V1_0_2_JSON (*((EFI_REDFISH_SOFTWAREINVENTORY_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SoftwareInventoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_0_2 *SoftwareInventoryV1_0_2; + + SoftwareInventoryV1_0_2 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_0_2 *)InterpProp; + DestroySoftwareInventory_V1_0_2_CS (SoftwareInventoryV1_0_2->SoftwareInventory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SoftwareInventoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySoftwareInventory_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SoftwareInventoryToStructWrapper, + SoftwareInventoryToJson, + SoftwareInventoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_0_3/RedfishSoftwareInventory_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/SoftwareInventory/v1_0_3/RedfishSoftwareInventory_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..41dcac92da0 --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_0_3/RedfishSoftwareInventory_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SoftwareInventory.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSoftwareInventory_V1_0_3_Dxe + FILE_GUID = 6333e710-6f2b-4117-a314-a6563e869645 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSoftwareInventory_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishSoftwareInventory_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SoftwareInventory_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SoftwareInventoryV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_0_3/SoftwareInventory_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/SoftwareInventory/v1_0_3/SoftwareInventory_V1_0_3_Dxe.c new file mode 100644 index 00000000000..d61e7f8ef48 --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_0_3/SoftwareInventory_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SoftwareInventory.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SoftwareInventory"; +BOOLEAN IsRevisonController = TRUE; + +// Support SoftwareInventory V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SoftwareInventory", + "1", + "0", + "3" + }, + "SoftwareInventory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_0_3 *SoftwareInventoryV1_0_3; + EFI_REDFISH_SOFTWAREINVENTORY_V1_0_3_CS *SoftwareInventoryV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SoftwareInventory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SoftwareInventory_V1_0_3_To_CS (ResoruceRaw, &SoftwareInventoryV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SoftwareInventoryV1_0_3 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SOFTWAREINVENTORY_V1_0_3)); + if (SoftwareInventoryV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SoftwareInventoryV1_0_3; + SoftwareInventoryV1_0_3->SoftwareInventory = SoftwareInventoryV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SoftwareInventoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SoftwareInventoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SoftwareInventory_V1_0_3_JSON (*((EFI_REDFISH_SOFTWAREINVENTORY_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SoftwareInventoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_0_3 *SoftwareInventoryV1_0_3; + + SoftwareInventoryV1_0_3 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_0_3 *)InterpProp; + DestroySoftwareInventory_V1_0_3_CS (SoftwareInventoryV1_0_3->SoftwareInventory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SoftwareInventoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySoftwareInventory_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SoftwareInventoryToStructWrapper, + SoftwareInventoryToJson, + SoftwareInventoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_0_4/RedfishSoftwareInventory_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/SoftwareInventory/v1_0_4/RedfishSoftwareInventory_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..b85bb1d46de --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_0_4/RedfishSoftwareInventory_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SoftwareInventory.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSoftwareInventory_V1_0_4_Dxe + FILE_GUID = 8677d8fe-b7cd-43b3-adb5-99847ae95e3c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSoftwareInventory_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishSoftwareInventory_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SoftwareInventory_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SoftwareInventoryV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_0_4/SoftwareInventory_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/SoftwareInventory/v1_0_4/SoftwareInventory_V1_0_4_Dxe.c new file mode 100644 index 00000000000..807fea09a50 --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_0_4/SoftwareInventory_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SoftwareInventory.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SoftwareInventory"; +BOOLEAN IsRevisonController = TRUE; + +// Support SoftwareInventory V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SoftwareInventory", + "1", + "0", + "4" + }, + "SoftwareInventory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_0_4 *SoftwareInventoryV1_0_4; + EFI_REDFISH_SOFTWAREINVENTORY_V1_0_4_CS *SoftwareInventoryV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SoftwareInventory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SoftwareInventory_V1_0_4_To_CS (ResoruceRaw, &SoftwareInventoryV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SoftwareInventoryV1_0_4 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SOFTWAREINVENTORY_V1_0_4)); + if (SoftwareInventoryV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SoftwareInventoryV1_0_4; + SoftwareInventoryV1_0_4->SoftwareInventory = SoftwareInventoryV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SoftwareInventoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SoftwareInventoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SoftwareInventory_V1_0_4_JSON (*((EFI_REDFISH_SOFTWAREINVENTORY_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SoftwareInventoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_0_4 *SoftwareInventoryV1_0_4; + + SoftwareInventoryV1_0_4 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_0_4 *)InterpProp; + DestroySoftwareInventory_V1_0_4_CS (SoftwareInventoryV1_0_4->SoftwareInventory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SoftwareInventoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySoftwareInventory_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SoftwareInventoryToStructWrapper, + SoftwareInventoryToJson, + SoftwareInventoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_0_5/RedfishSoftwareInventory_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/SoftwareInventory/v1_0_5/RedfishSoftwareInventory_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..20866802a4a --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_0_5/RedfishSoftwareInventory_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SoftwareInventory.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSoftwareInventory_V1_0_5_Dxe + FILE_GUID = b747d16c-5dd9-49f4-be6b-57bfd839a6f3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSoftwareInventory_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishSoftwareInventory_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SoftwareInventory_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SoftwareInventoryV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_0_5/SoftwareInventory_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/SoftwareInventory/v1_0_5/SoftwareInventory_V1_0_5_Dxe.c new file mode 100644 index 00000000000..3ccdfc57f26 --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_0_5/SoftwareInventory_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SoftwareInventory.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SoftwareInventory"; +BOOLEAN IsRevisonController = TRUE; + +// Support SoftwareInventory V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SoftwareInventory", + "1", + "0", + "5" + }, + "SoftwareInventory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_0_5 *SoftwareInventoryV1_0_5; + EFI_REDFISH_SOFTWAREINVENTORY_V1_0_5_CS *SoftwareInventoryV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SoftwareInventory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SoftwareInventory_V1_0_5_To_CS (ResoruceRaw, &SoftwareInventoryV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SoftwareInventoryV1_0_5 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SOFTWAREINVENTORY_V1_0_5)); + if (SoftwareInventoryV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SoftwareInventoryV1_0_5; + SoftwareInventoryV1_0_5->SoftwareInventory = SoftwareInventoryV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SoftwareInventoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SoftwareInventoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SoftwareInventory_V1_0_5_JSON (*((EFI_REDFISH_SOFTWAREINVENTORY_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SoftwareInventoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_0_5 *SoftwareInventoryV1_0_5; + + SoftwareInventoryV1_0_5 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_0_5 *)InterpProp; + DestroySoftwareInventory_V1_0_5_CS (SoftwareInventoryV1_0_5->SoftwareInventory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SoftwareInventoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySoftwareInventory_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SoftwareInventoryToStructWrapper, + SoftwareInventoryToJson, + SoftwareInventoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_1_0/RedfishSoftwareInventory_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/SoftwareInventory/v1_1_0/RedfishSoftwareInventory_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..96ec5e430e4 --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_1_0/RedfishSoftwareInventory_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SoftwareInventory.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSoftwareInventory_V1_1_0_Dxe + FILE_GUID = 8b83a1e6-de2d-4bcf-8d2f-8424cc1ae8c6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSoftwareInventory_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishSoftwareInventory_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SoftwareInventory_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SoftwareInventoryV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_1_0/SoftwareInventory_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/SoftwareInventory/v1_1_0/SoftwareInventory_V1_1_0_Dxe.c new file mode 100644 index 00000000000..68df185dbf6 --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_1_0/SoftwareInventory_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SoftwareInventory.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SoftwareInventory"; +BOOLEAN IsRevisonController = TRUE; + +// Support SoftwareInventory V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SoftwareInventory", + "1", + "1", + "0" + }, + "SoftwareInventory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_1_0 *SoftwareInventoryV1_1_0; + EFI_REDFISH_SOFTWAREINVENTORY_V1_1_0_CS *SoftwareInventoryV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SoftwareInventory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SoftwareInventory_V1_1_0_To_CS (ResoruceRaw, &SoftwareInventoryV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SoftwareInventoryV1_1_0 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SOFTWAREINVENTORY_V1_1_0)); + if (SoftwareInventoryV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SoftwareInventoryV1_1_0; + SoftwareInventoryV1_1_0->SoftwareInventory = SoftwareInventoryV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SoftwareInventoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SoftwareInventoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SoftwareInventory_V1_1_0_JSON (*((EFI_REDFISH_SOFTWAREINVENTORY_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SoftwareInventoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_1_0 *SoftwareInventoryV1_1_0; + + SoftwareInventoryV1_1_0 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_1_0 *)InterpProp; + DestroySoftwareInventory_V1_1_0_CS (SoftwareInventoryV1_1_0->SoftwareInventory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SoftwareInventoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySoftwareInventory_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SoftwareInventoryToStructWrapper, + SoftwareInventoryToJson, + SoftwareInventoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_1_1/RedfishSoftwareInventory_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/SoftwareInventory/v1_1_1/RedfishSoftwareInventory_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..c6ed3bd83e5 --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_1_1/RedfishSoftwareInventory_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SoftwareInventory.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSoftwareInventory_V1_1_1_Dxe + FILE_GUID = 33c74280-63c2-4c71-bead-4fa4566d894d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSoftwareInventory_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishSoftwareInventory_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SoftwareInventory_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SoftwareInventoryV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_1_1/SoftwareInventory_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/SoftwareInventory/v1_1_1/SoftwareInventory_V1_1_1_Dxe.c new file mode 100644 index 00000000000..efcc09f4932 --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_1_1/SoftwareInventory_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SoftwareInventory.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SoftwareInventory"; +BOOLEAN IsRevisonController = TRUE; + +// Support SoftwareInventory V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SoftwareInventory", + "1", + "1", + "1" + }, + "SoftwareInventory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_1_1 *SoftwareInventoryV1_1_1; + EFI_REDFISH_SOFTWAREINVENTORY_V1_1_1_CS *SoftwareInventoryV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SoftwareInventory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SoftwareInventory_V1_1_1_To_CS (ResoruceRaw, &SoftwareInventoryV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SoftwareInventoryV1_1_1 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SOFTWAREINVENTORY_V1_1_1)); + if (SoftwareInventoryV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SoftwareInventoryV1_1_1; + SoftwareInventoryV1_1_1->SoftwareInventory = SoftwareInventoryV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SoftwareInventoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SoftwareInventoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SoftwareInventory_V1_1_1_JSON (*((EFI_REDFISH_SOFTWAREINVENTORY_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SoftwareInventoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_1_1 *SoftwareInventoryV1_1_1; + + SoftwareInventoryV1_1_1 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_1_1 *)InterpProp; + DestroySoftwareInventory_V1_1_1_CS (SoftwareInventoryV1_1_1->SoftwareInventory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SoftwareInventoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySoftwareInventory_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SoftwareInventoryToStructWrapper, + SoftwareInventoryToJson, + SoftwareInventoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_1_2/RedfishSoftwareInventory_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/SoftwareInventory/v1_1_2/RedfishSoftwareInventory_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..33d46b44863 --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_1_2/RedfishSoftwareInventory_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SoftwareInventory.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSoftwareInventory_V1_1_2_Dxe + FILE_GUID = 8b345df8-5c5e-40e0-a969-6b6bff6fef09 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSoftwareInventory_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishSoftwareInventory_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SoftwareInventory_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SoftwareInventoryV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_1_2/SoftwareInventory_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/SoftwareInventory/v1_1_2/SoftwareInventory_V1_1_2_Dxe.c new file mode 100644 index 00000000000..ecbb8792e0a --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_1_2/SoftwareInventory_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SoftwareInventory.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SoftwareInventory"; +BOOLEAN IsRevisonController = TRUE; + +// Support SoftwareInventory V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SoftwareInventory", + "1", + "1", + "2" + }, + "SoftwareInventory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_1_2 *SoftwareInventoryV1_1_2; + EFI_REDFISH_SOFTWAREINVENTORY_V1_1_2_CS *SoftwareInventoryV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SoftwareInventory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SoftwareInventory_V1_1_2_To_CS (ResoruceRaw, &SoftwareInventoryV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SoftwareInventoryV1_1_2 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SOFTWAREINVENTORY_V1_1_2)); + if (SoftwareInventoryV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SoftwareInventoryV1_1_2; + SoftwareInventoryV1_1_2->SoftwareInventory = SoftwareInventoryV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SoftwareInventoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SoftwareInventoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SoftwareInventory_V1_1_2_JSON (*((EFI_REDFISH_SOFTWAREINVENTORY_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SoftwareInventoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_1_2 *SoftwareInventoryV1_1_2; + + SoftwareInventoryV1_1_2 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_1_2 *)InterpProp; + DestroySoftwareInventory_V1_1_2_CS (SoftwareInventoryV1_1_2->SoftwareInventory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SoftwareInventoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySoftwareInventory_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SoftwareInventoryToStructWrapper, + SoftwareInventoryToJson, + SoftwareInventoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_1_3/RedfishSoftwareInventory_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/SoftwareInventory/v1_1_3/RedfishSoftwareInventory_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..c214d511e1e --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_1_3/RedfishSoftwareInventory_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SoftwareInventory.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSoftwareInventory_V1_1_3_Dxe + FILE_GUID = 60be6e42-f266-4a0c-9731-6e90fab282da + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSoftwareInventory_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishSoftwareInventory_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SoftwareInventory_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SoftwareInventoryV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_1_3/SoftwareInventory_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/SoftwareInventory/v1_1_3/SoftwareInventory_V1_1_3_Dxe.c new file mode 100644 index 00000000000..214e8b34f50 --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_1_3/SoftwareInventory_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SoftwareInventory.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SoftwareInventory"; +BOOLEAN IsRevisonController = TRUE; + +// Support SoftwareInventory V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SoftwareInventory", + "1", + "1", + "3" + }, + "SoftwareInventory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_1_3 *SoftwareInventoryV1_1_3; + EFI_REDFISH_SOFTWAREINVENTORY_V1_1_3_CS *SoftwareInventoryV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SoftwareInventory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SoftwareInventory_V1_1_3_To_CS (ResoruceRaw, &SoftwareInventoryV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SoftwareInventoryV1_1_3 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SOFTWAREINVENTORY_V1_1_3)); + if (SoftwareInventoryV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SoftwareInventoryV1_1_3; + SoftwareInventoryV1_1_3->SoftwareInventory = SoftwareInventoryV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SoftwareInventoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SoftwareInventoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SoftwareInventory_V1_1_3_JSON (*((EFI_REDFISH_SOFTWAREINVENTORY_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SoftwareInventoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_1_3 *SoftwareInventoryV1_1_3; + + SoftwareInventoryV1_1_3 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_1_3 *)InterpProp; + DestroySoftwareInventory_V1_1_3_CS (SoftwareInventoryV1_1_3->SoftwareInventory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SoftwareInventoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySoftwareInventory_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SoftwareInventoryToStructWrapper, + SoftwareInventoryToJson, + SoftwareInventoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_1_4/RedfishSoftwareInventory_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/SoftwareInventory/v1_1_4/RedfishSoftwareInventory_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..030e34281d2 --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_1_4/RedfishSoftwareInventory_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SoftwareInventory.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSoftwareInventory_V1_1_4_Dxe + FILE_GUID = 0504273f-2bf1-49f1-9bfd-0919d3e4e293 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSoftwareInventory_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishSoftwareInventory_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SoftwareInventory_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SoftwareInventoryV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_1_4/SoftwareInventory_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/SoftwareInventory/v1_1_4/SoftwareInventory_V1_1_4_Dxe.c new file mode 100644 index 00000000000..30bd66d4de1 --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_1_4/SoftwareInventory_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SoftwareInventory.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SoftwareInventory"; +BOOLEAN IsRevisonController = TRUE; + +// Support SoftwareInventory V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SoftwareInventory", + "1", + "1", + "4" + }, + "SoftwareInventory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_1_4 *SoftwareInventoryV1_1_4; + EFI_REDFISH_SOFTWAREINVENTORY_V1_1_4_CS *SoftwareInventoryV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SoftwareInventory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SoftwareInventory_V1_1_4_To_CS (ResoruceRaw, &SoftwareInventoryV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SoftwareInventoryV1_1_4 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SOFTWAREINVENTORY_V1_1_4)); + if (SoftwareInventoryV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SoftwareInventoryV1_1_4; + SoftwareInventoryV1_1_4->SoftwareInventory = SoftwareInventoryV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SoftwareInventoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SoftwareInventoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SoftwareInventory_V1_1_4_JSON (*((EFI_REDFISH_SOFTWAREINVENTORY_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SoftwareInventoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_1_4 *SoftwareInventoryV1_1_4; + + SoftwareInventoryV1_1_4 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_1_4 *)InterpProp; + DestroySoftwareInventory_V1_1_4_CS (SoftwareInventoryV1_1_4->SoftwareInventory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SoftwareInventoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySoftwareInventory_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SoftwareInventoryToStructWrapper, + SoftwareInventoryToJson, + SoftwareInventoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_2_0/RedfishSoftwareInventory_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/SoftwareInventory/v1_2_0/RedfishSoftwareInventory_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..fbea307449f --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_2_0/RedfishSoftwareInventory_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SoftwareInventory.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSoftwareInventory_V1_2_0_Dxe + FILE_GUID = f2638be0-b59d-4e36-9f58-e3b193f13c00 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSoftwareInventory_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishSoftwareInventory_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SoftwareInventory_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SoftwareInventoryV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_2_0/SoftwareInventory_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/SoftwareInventory/v1_2_0/SoftwareInventory_V1_2_0_Dxe.c new file mode 100644 index 00000000000..cd1378cb5fa --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_2_0/SoftwareInventory_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SoftwareInventory.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SoftwareInventory"; +BOOLEAN IsRevisonController = TRUE; + +// Support SoftwareInventory V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SoftwareInventory", + "1", + "2", + "0" + }, + "SoftwareInventory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_2_0 *SoftwareInventoryV1_2_0; + EFI_REDFISH_SOFTWAREINVENTORY_V1_2_0_CS *SoftwareInventoryV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SoftwareInventory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SoftwareInventory_V1_2_0_To_CS (ResoruceRaw, &SoftwareInventoryV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SoftwareInventoryV1_2_0 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SOFTWAREINVENTORY_V1_2_0)); + if (SoftwareInventoryV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SoftwareInventoryV1_2_0; + SoftwareInventoryV1_2_0->SoftwareInventory = SoftwareInventoryV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SoftwareInventoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SoftwareInventoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SoftwareInventory_V1_2_0_JSON (*((EFI_REDFISH_SOFTWAREINVENTORY_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SoftwareInventoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_2_0 *SoftwareInventoryV1_2_0; + + SoftwareInventoryV1_2_0 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_2_0 *)InterpProp; + DestroySoftwareInventory_V1_2_0_CS (SoftwareInventoryV1_2_0->SoftwareInventory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SoftwareInventoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySoftwareInventory_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SoftwareInventoryToStructWrapper, + SoftwareInventoryToJson, + SoftwareInventoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_2_1/RedfishSoftwareInventory_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/SoftwareInventory/v1_2_1/RedfishSoftwareInventory_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..b66036a1353 --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_2_1/RedfishSoftwareInventory_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SoftwareInventory.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSoftwareInventory_V1_2_1_Dxe + FILE_GUID = 62141952-f4cf-4a37-a952-d62dd59d31d7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSoftwareInventory_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishSoftwareInventory_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SoftwareInventory_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SoftwareInventoryV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_2_1/SoftwareInventory_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/SoftwareInventory/v1_2_1/SoftwareInventory_V1_2_1_Dxe.c new file mode 100644 index 00000000000..7958051843e --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_2_1/SoftwareInventory_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SoftwareInventory.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SoftwareInventory"; +BOOLEAN IsRevisonController = TRUE; + +// Support SoftwareInventory V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SoftwareInventory", + "1", + "2", + "1" + }, + "SoftwareInventory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_2_1 *SoftwareInventoryV1_2_1; + EFI_REDFISH_SOFTWAREINVENTORY_V1_2_1_CS *SoftwareInventoryV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SoftwareInventory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SoftwareInventory_V1_2_1_To_CS (ResoruceRaw, &SoftwareInventoryV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SoftwareInventoryV1_2_1 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SOFTWAREINVENTORY_V1_2_1)); + if (SoftwareInventoryV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SoftwareInventoryV1_2_1; + SoftwareInventoryV1_2_1->SoftwareInventory = SoftwareInventoryV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SoftwareInventoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SoftwareInventoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SoftwareInventory_V1_2_1_JSON (*((EFI_REDFISH_SOFTWAREINVENTORY_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SoftwareInventoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_2_1 *SoftwareInventoryV1_2_1; + + SoftwareInventoryV1_2_1 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_2_1 *)InterpProp; + DestroySoftwareInventory_V1_2_1_CS (SoftwareInventoryV1_2_1->SoftwareInventory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SoftwareInventoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySoftwareInventory_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SoftwareInventoryToStructWrapper, + SoftwareInventoryToJson, + SoftwareInventoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_2_2/RedfishSoftwareInventory_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/SoftwareInventory/v1_2_2/RedfishSoftwareInventory_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..121c0471d2a --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_2_2/RedfishSoftwareInventory_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SoftwareInventory.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSoftwareInventory_V1_2_2_Dxe + FILE_GUID = 41ae7f04-89ba-4468-b3c0-7ee5adee05e1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSoftwareInventory_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishSoftwareInventory_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SoftwareInventory_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SoftwareInventoryV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_2_2/SoftwareInventory_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/SoftwareInventory/v1_2_2/SoftwareInventory_V1_2_2_Dxe.c new file mode 100644 index 00000000000..d0656286c00 --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_2_2/SoftwareInventory_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SoftwareInventory.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SoftwareInventory"; +BOOLEAN IsRevisonController = TRUE; + +// Support SoftwareInventory V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SoftwareInventory", + "1", + "2", + "2" + }, + "SoftwareInventory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_2_2 *SoftwareInventoryV1_2_2; + EFI_REDFISH_SOFTWAREINVENTORY_V1_2_2_CS *SoftwareInventoryV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SoftwareInventory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SoftwareInventory_V1_2_2_To_CS (ResoruceRaw, &SoftwareInventoryV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SoftwareInventoryV1_2_2 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SOFTWAREINVENTORY_V1_2_2)); + if (SoftwareInventoryV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SoftwareInventoryV1_2_2; + SoftwareInventoryV1_2_2->SoftwareInventory = SoftwareInventoryV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SoftwareInventoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SoftwareInventoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SoftwareInventory_V1_2_2_JSON (*((EFI_REDFISH_SOFTWAREINVENTORY_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SoftwareInventoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_2_2 *SoftwareInventoryV1_2_2; + + SoftwareInventoryV1_2_2 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_2_2 *)InterpProp; + DestroySoftwareInventory_V1_2_2_CS (SoftwareInventoryV1_2_2->SoftwareInventory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SoftwareInventoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySoftwareInventory_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SoftwareInventoryToStructWrapper, + SoftwareInventoryToJson, + SoftwareInventoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_2_3/RedfishSoftwareInventory_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/SoftwareInventory/v1_2_3/RedfishSoftwareInventory_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..13301e4dd86 --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_2_3/RedfishSoftwareInventory_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SoftwareInventory.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSoftwareInventory_V1_2_3_Dxe + FILE_GUID = 4901ea52-d9f8-4902-b5cb-24f6ff86c0a3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSoftwareInventory_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishSoftwareInventory_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SoftwareInventory_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SoftwareInventoryV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_2_3/SoftwareInventory_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/SoftwareInventory/v1_2_3/SoftwareInventory_V1_2_3_Dxe.c new file mode 100644 index 00000000000..459d8c961ce --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_2_3/SoftwareInventory_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SoftwareInventory.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SoftwareInventory"; +BOOLEAN IsRevisonController = TRUE; + +// Support SoftwareInventory V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SoftwareInventory", + "1", + "2", + "3" + }, + "SoftwareInventory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_2_3 *SoftwareInventoryV1_2_3; + EFI_REDFISH_SOFTWAREINVENTORY_V1_2_3_CS *SoftwareInventoryV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SoftwareInventory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SoftwareInventory_V1_2_3_To_CS (ResoruceRaw, &SoftwareInventoryV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SoftwareInventoryV1_2_3 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SOFTWAREINVENTORY_V1_2_3)); + if (SoftwareInventoryV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SoftwareInventoryV1_2_3; + SoftwareInventoryV1_2_3->SoftwareInventory = SoftwareInventoryV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SoftwareInventoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SoftwareInventoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SoftwareInventory_V1_2_3_JSON (*((EFI_REDFISH_SOFTWAREINVENTORY_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SoftwareInventoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_2_3 *SoftwareInventoryV1_2_3; + + SoftwareInventoryV1_2_3 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_2_3 *)InterpProp; + DestroySoftwareInventory_V1_2_3_CS (SoftwareInventoryV1_2_3->SoftwareInventory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SoftwareInventoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySoftwareInventory_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SoftwareInventoryToStructWrapper, + SoftwareInventoryToJson, + SoftwareInventoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_3_0/RedfishSoftwareInventory_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/SoftwareInventory/v1_3_0/RedfishSoftwareInventory_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..8fd6f77a497 --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_3_0/RedfishSoftwareInventory_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SoftwareInventory.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSoftwareInventory_V1_3_0_Dxe + FILE_GUID = 4f969dee-2590-47de-841f-d58627ecebfd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSoftwareInventory_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishSoftwareInventory_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SoftwareInventory_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SoftwareInventoryV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_3_0/SoftwareInventory_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/SoftwareInventory/v1_3_0/SoftwareInventory_V1_3_0_Dxe.c new file mode 100644 index 00000000000..35e89b33e7e --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_3_0/SoftwareInventory_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SoftwareInventory.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SoftwareInventory"; +BOOLEAN IsRevisonController = TRUE; + +// Support SoftwareInventory V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SoftwareInventory", + "1", + "3", + "0" + }, + "SoftwareInventory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_3_0 *SoftwareInventoryV1_3_0; + EFI_REDFISH_SOFTWAREINVENTORY_V1_3_0_CS *SoftwareInventoryV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SoftwareInventory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SoftwareInventory_V1_3_0_To_CS (ResoruceRaw, &SoftwareInventoryV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SoftwareInventoryV1_3_0 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SOFTWAREINVENTORY_V1_3_0)); + if (SoftwareInventoryV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SoftwareInventoryV1_3_0; + SoftwareInventoryV1_3_0->SoftwareInventory = SoftwareInventoryV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SoftwareInventoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SoftwareInventoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SoftwareInventory_V1_3_0_JSON (*((EFI_REDFISH_SOFTWAREINVENTORY_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SoftwareInventoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_3_0 *SoftwareInventoryV1_3_0; + + SoftwareInventoryV1_3_0 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_3_0 *)InterpProp; + DestroySoftwareInventory_V1_3_0_CS (SoftwareInventoryV1_3_0->SoftwareInventory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SoftwareInventoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySoftwareInventory_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SoftwareInventoryToStructWrapper, + SoftwareInventoryToJson, + SoftwareInventoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_4_0/RedfishSoftwareInventory_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/SoftwareInventory/v1_4_0/RedfishSoftwareInventory_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..336d7f20426 --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_4_0/RedfishSoftwareInventory_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SoftwareInventory.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSoftwareInventory_V1_4_0_Dxe + FILE_GUID = a40d90cc-0d7b-4ce5-99d4-d2f9ede4a3d6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSoftwareInventory_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishSoftwareInventory_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SoftwareInventory_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SoftwareInventoryV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SoftwareInventory/v1_4_0/SoftwareInventory_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/SoftwareInventory/v1_4_0/SoftwareInventory_V1_4_0_Dxe.c new file mode 100644 index 00000000000..c39ef913d70 --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventory/v1_4_0/SoftwareInventory_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SoftwareInventory.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SoftwareInventory"; +BOOLEAN IsRevisonController = TRUE; + +// Support SoftwareInventory V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SoftwareInventory", + "1", + "4", + "0" + }, + "SoftwareInventory" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_4_0 *SoftwareInventoryV1_4_0; + EFI_REDFISH_SOFTWAREINVENTORY_V1_4_0_CS *SoftwareInventoryV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SoftwareInventory") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SoftwareInventory_V1_4_0_To_CS (ResoruceRaw, &SoftwareInventoryV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SoftwareInventoryV1_4_0 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SOFTWAREINVENTORY_V1_4_0)); + if (SoftwareInventoryV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SoftwareInventoryV1_4_0; + SoftwareInventoryV1_4_0->SoftwareInventory = SoftwareInventoryV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventory")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SoftwareInventory"), "SoftwareInventory"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SoftwareInventoryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SoftwareInventoryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SoftwareInventory_V1_4_0_JSON (*((EFI_REDFISH_SOFTWAREINVENTORY_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SoftwareInventoryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORY_V1_4_0 *SoftwareInventoryV1_4_0; + + SoftwareInventoryV1_4_0 = (EFI_REDFISH_SOFTWAREINVENTORY_V1_4_0 *)InterpProp; + DestroySoftwareInventory_V1_4_0_CS (SoftwareInventoryV1_4_0->SoftwareInventory); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SoftwareInventoryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySoftwareInventory_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SoftwareInventoryToStructWrapper, + SoftwareInventoryToJson, + SoftwareInventoryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventory_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SoftwareInventoryCollection/RedfishSoftwareInventoryCollection_Dxe.inf b/RedfishClientPkg/Converter/SoftwareInventoryCollection/RedfishSoftwareInventoryCollection_Dxe.inf new file mode 100644 index 00000000000..4c717e22729 --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventoryCollection/RedfishSoftwareInventoryCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SoftwareInventoryCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSoftwareInventoryCollection_Dxe + FILE_GUID = 6fcc5e91-5f38-4bf0-be72-8d5ec7b01079 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSoftwareInventoryCollectionEntryPoint + UNLOAD_IMAGE = RedfishSoftwareInventoryCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SoftwareInventoryCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SoftwareInventoryCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SoftwareInventoryCollection/SoftwareInventoryCollection_Dxe.c b/RedfishClientPkg/Converter/SoftwareInventoryCollection/SoftwareInventoryCollection_Dxe.c new file mode 100644 index 00000000000..983b375206f --- /dev/null +++ b/RedfishClientPkg/Converter/SoftwareInventoryCollection/SoftwareInventoryCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SoftwareInventoryCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SoftwareInventoryCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support SoftwareInventoryCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SoftwareInventoryCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "SoftwareInventoryCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORYCOLLECTION *SoftwareInventoryCollection; + EFI_REDFISH_SOFTWAREINVENTORYCOLLECTION_CS *SoftwareInventoryCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SoftwareInventoryCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SoftwareInventoryCollection_To_CS (ResoruceRaw, &SoftwareInventoryCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + SoftwareInventoryCollection = (EFI_REDFISH_SOFTWAREINVENTORYCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SOFTWAREINVENTORYCOLLECTION)); + if (SoftwareInventoryCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SoftwareInventoryCollection; + SoftwareInventoryCollection->SoftwareInventoryCollection = SoftwareInventoryCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventoryCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SoftwareInventoryCollection"), "SoftwareInventoryCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SoftwareInventoryCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SoftwareInventoryCollection"), "SoftwareInventoryCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SoftwareInventoryCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SoftwareInventoryCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SoftwareInventoryCollection_JSON (*((EFI_REDFISH_SOFTWAREINVENTORYCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SoftwareInventoryCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SOFTWAREINVENTORYCOLLECTION *SoftwareInventoryCollection; + + SoftwareInventoryCollection = (EFI_REDFISH_SOFTWAREINVENTORYCOLLECTION *)InterpProp; + DestroySoftwareInventoryCollection_CS (SoftwareInventoryCollection->SoftwareInventoryCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SoftwareInventoryCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SoftwareInventoryCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySoftwareInventoryCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventoryCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SoftwareInventoryCollectionToStructWrapper, + SoftwareInventoryCollectionToJson, + SoftwareInventoryCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSoftwareInventoryCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_0_1/RedfishStorage_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_0_1/RedfishStorage_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..8652e226a7c --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_0_1/RedfishStorage_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_0_1_Dxe + FILE_GUID = 5176617e-fde5-4b38-9f52-576877d987e2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_0_1/Storage_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_0_1/Storage_V1_0_1_Dxe.c new file mode 100644 index 00000000000..37660bc41fd --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_0_1/Storage_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "0", + "1" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_0_1 *StorageV1_0_1; + EFI_REDFISH_STORAGE_V1_0_1_CS *StorageV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_0_1_To_CS (ResoruceRaw, &StorageV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_0_1 = (EFI_REDFISH_STORAGE_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_0_1)); + if (StorageV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_0_1; + StorageV1_0_1->Storage = StorageV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_0_1_JSON (*((EFI_REDFISH_STORAGE_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_0_1 *StorageV1_0_1; + + StorageV1_0_1 = (EFI_REDFISH_STORAGE_V1_0_1 *)InterpProp; + DestroyStorage_V1_0_1_CS (StorageV1_0_1->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_0_10/RedfishStorage_V1_0_10_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_0_10/RedfishStorage_V1_0_10_Dxe.inf new file mode 100644 index 00000000000..d8914fea3ec --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_0_10/RedfishStorage_V1_0_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_0_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_0_10_Dxe + FILE_GUID = 008bdfd1-db2b-4852-bc21-f2a73ed454b7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_0_10EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_0_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_0_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_0_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_0_10/Storage_V1_0_10_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_0_10/Storage_V1_0_10_Dxe.c new file mode 100644 index 00000000000..25bf7943972 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_0_10/Storage_V1_0_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_0_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "0", + "10" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_0_10 *StorageV1_0_10; + EFI_REDFISH_STORAGE_V1_0_10_CS *StorageV1_0_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_0_10_To_CS (ResoruceRaw, &StorageV1_0_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_0_10 = (EFI_REDFISH_STORAGE_V1_0_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_0_10)); + if (StorageV1_0_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_0_10; + StorageV1_0_10->Storage = StorageV1_0_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_0_10_JSON (*((EFI_REDFISH_STORAGE_V1_0_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_0_10 *StorageV1_0_10; + + StorageV1_0_10 = (EFI_REDFISH_STORAGE_V1_0_10 *)InterpProp; + DestroyStorage_V1_0_10_CS (StorageV1_0_10->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_0_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_0_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_0_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_0_2/RedfishStorage_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_0_2/RedfishStorage_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..bc135ef92d3 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_0_2/RedfishStorage_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_0_2_Dxe + FILE_GUID = 5fb9eaca-415c-41e5-8ae3-f85b41f7e91c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_0_2/Storage_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_0_2/Storage_V1_0_2_Dxe.c new file mode 100644 index 00000000000..9c790eef22c --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_0_2/Storage_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "0", + "2" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_0_2 *StorageV1_0_2; + EFI_REDFISH_STORAGE_V1_0_2_CS *StorageV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_0_2_To_CS (ResoruceRaw, &StorageV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_0_2 = (EFI_REDFISH_STORAGE_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_0_2)); + if (StorageV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_0_2; + StorageV1_0_2->Storage = StorageV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_0_2_JSON (*((EFI_REDFISH_STORAGE_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_0_2 *StorageV1_0_2; + + StorageV1_0_2 = (EFI_REDFISH_STORAGE_V1_0_2 *)InterpProp; + DestroyStorage_V1_0_2_CS (StorageV1_0_2->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_0_3/RedfishStorage_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_0_3/RedfishStorage_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..122a37393ee --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_0_3/RedfishStorage_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_0_3_Dxe + FILE_GUID = b56e56b9-9449-4755-95dc-a9faf28b9aae + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_0_3/Storage_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_0_3/Storage_V1_0_3_Dxe.c new file mode 100644 index 00000000000..96b539e9433 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_0_3/Storage_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "0", + "3" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_0_3 *StorageV1_0_3; + EFI_REDFISH_STORAGE_V1_0_3_CS *StorageV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_0_3_To_CS (ResoruceRaw, &StorageV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_0_3 = (EFI_REDFISH_STORAGE_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_0_3)); + if (StorageV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_0_3; + StorageV1_0_3->Storage = StorageV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_0_3_JSON (*((EFI_REDFISH_STORAGE_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_0_3 *StorageV1_0_3; + + StorageV1_0_3 = (EFI_REDFISH_STORAGE_V1_0_3 *)InterpProp; + DestroyStorage_V1_0_3_CS (StorageV1_0_3->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_0_4/RedfishStorage_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_0_4/RedfishStorage_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..673b54d4bde --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_0_4/RedfishStorage_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_0_4_Dxe + FILE_GUID = ec2743a1-158a-4710-b9ec-5e24bc56f889 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_0_4/Storage_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_0_4/Storage_V1_0_4_Dxe.c new file mode 100644 index 00000000000..c2d2ffb8eab --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_0_4/Storage_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "0", + "4" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_0_4 *StorageV1_0_4; + EFI_REDFISH_STORAGE_V1_0_4_CS *StorageV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_0_4_To_CS (ResoruceRaw, &StorageV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_0_4 = (EFI_REDFISH_STORAGE_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_0_4)); + if (StorageV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_0_4; + StorageV1_0_4->Storage = StorageV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_0_4_JSON (*((EFI_REDFISH_STORAGE_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_0_4 *StorageV1_0_4; + + StorageV1_0_4 = (EFI_REDFISH_STORAGE_V1_0_4 *)InterpProp; + DestroyStorage_V1_0_4_CS (StorageV1_0_4->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_0_5/RedfishStorage_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_0_5/RedfishStorage_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..6897ba1892c --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_0_5/RedfishStorage_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_0_5_Dxe + FILE_GUID = 4715f651-ffab-4b75-b7cb-da4c2e00f572 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_0_5/Storage_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_0_5/Storage_V1_0_5_Dxe.c new file mode 100644 index 00000000000..25a981f1cc7 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_0_5/Storage_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "0", + "5" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_0_5 *StorageV1_0_5; + EFI_REDFISH_STORAGE_V1_0_5_CS *StorageV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_0_5_To_CS (ResoruceRaw, &StorageV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_0_5 = (EFI_REDFISH_STORAGE_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_0_5)); + if (StorageV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_0_5; + StorageV1_0_5->Storage = StorageV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_0_5_JSON (*((EFI_REDFISH_STORAGE_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_0_5 *StorageV1_0_5; + + StorageV1_0_5 = (EFI_REDFISH_STORAGE_V1_0_5 *)InterpProp; + DestroyStorage_V1_0_5_CS (StorageV1_0_5->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_0_6/RedfishStorage_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_0_6/RedfishStorage_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..d412be4564b --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_0_6/RedfishStorage_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_0_6_Dxe + FILE_GUID = 89f463a1-ac60-4f64-8124-f5a05d2e7865 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_0_6/Storage_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_0_6/Storage_V1_0_6_Dxe.c new file mode 100644 index 00000000000..8bc46349f76 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_0_6/Storage_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "0", + "6" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_0_6 *StorageV1_0_6; + EFI_REDFISH_STORAGE_V1_0_6_CS *StorageV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_0_6_To_CS (ResoruceRaw, &StorageV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_0_6 = (EFI_REDFISH_STORAGE_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_0_6)); + if (StorageV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_0_6; + StorageV1_0_6->Storage = StorageV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_0_6_JSON (*((EFI_REDFISH_STORAGE_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_0_6 *StorageV1_0_6; + + StorageV1_0_6 = (EFI_REDFISH_STORAGE_V1_0_6 *)InterpProp; + DestroyStorage_V1_0_6_CS (StorageV1_0_6->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_0_7/RedfishStorage_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_0_7/RedfishStorage_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..fdc72188c61 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_0_7/RedfishStorage_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_0_7_Dxe + FILE_GUID = c7aca2ee-14c6-4042-beb8-a40aeff36d92 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_0_7/Storage_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_0_7/Storage_V1_0_7_Dxe.c new file mode 100644 index 00000000000..a2ea94b719b --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_0_7/Storage_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "0", + "7" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_0_7 *StorageV1_0_7; + EFI_REDFISH_STORAGE_V1_0_7_CS *StorageV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_0_7_To_CS (ResoruceRaw, &StorageV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_0_7 = (EFI_REDFISH_STORAGE_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_0_7)); + if (StorageV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_0_7; + StorageV1_0_7->Storage = StorageV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_0_7_JSON (*((EFI_REDFISH_STORAGE_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_0_7 *StorageV1_0_7; + + StorageV1_0_7 = (EFI_REDFISH_STORAGE_V1_0_7 *)InterpProp; + DestroyStorage_V1_0_7_CS (StorageV1_0_7->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_0_8/RedfishStorage_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_0_8/RedfishStorage_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..3857bb823c7 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_0_8/RedfishStorage_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_0_8_Dxe + FILE_GUID = c4c6e397-5fd0-4d72-bdd6-f94e12889c3c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_0_8/Storage_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_0_8/Storage_V1_0_8_Dxe.c new file mode 100644 index 00000000000..16441dfa5a3 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_0_8/Storage_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "0", + "8" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_0_8 *StorageV1_0_8; + EFI_REDFISH_STORAGE_V1_0_8_CS *StorageV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_0_8_To_CS (ResoruceRaw, &StorageV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_0_8 = (EFI_REDFISH_STORAGE_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_0_8)); + if (StorageV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_0_8; + StorageV1_0_8->Storage = StorageV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_0_8_JSON (*((EFI_REDFISH_STORAGE_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_0_8 *StorageV1_0_8; + + StorageV1_0_8 = (EFI_REDFISH_STORAGE_V1_0_8 *)InterpProp; + DestroyStorage_V1_0_8_CS (StorageV1_0_8->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_0_9/RedfishStorage_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_0_9/RedfishStorage_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..373028e4c63 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_0_9/RedfishStorage_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_0_9_Dxe + FILE_GUID = a3e418d2-1fca-4b04-897c-8c3d2a5c87a0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_0_9/Storage_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_0_9/Storage_V1_0_9_Dxe.c new file mode 100644 index 00000000000..bf6e8ab3f15 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_0_9/Storage_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "0", + "9" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_0_9 *StorageV1_0_9; + EFI_REDFISH_STORAGE_V1_0_9_CS *StorageV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_0_9_To_CS (ResoruceRaw, &StorageV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_0_9 = (EFI_REDFISH_STORAGE_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_0_9)); + if (StorageV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_0_9; + StorageV1_0_9->Storage = StorageV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_0_9_JSON (*((EFI_REDFISH_STORAGE_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_0_9 *StorageV1_0_9; + + StorageV1_0_9 = (EFI_REDFISH_STORAGE_V1_0_9 *)InterpProp; + DestroyStorage_V1_0_9_CS (StorageV1_0_9->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_10_0/RedfishStorage_V1_10_0_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_10_0/RedfishStorage_V1_10_0_Dxe.inf new file mode 100644 index 00000000000..91e1f0c8adf --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_10_0/RedfishStorage_V1_10_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_10_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_10_0_Dxe + FILE_GUID = eb56089b-48ae-4689-9351-fbf11242c012 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_10_0EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_10_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_10_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_10_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_10_0/Storage_V1_10_0_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_10_0/Storage_V1_10_0_Dxe.c new file mode 100644 index 00000000000..9b18e82b17c --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_10_0/Storage_V1_10_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_10_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_10_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "10", + "0" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_10_0 *StorageV1_10_0; + EFI_REDFISH_STORAGE_V1_10_0_CS *StorageV1_10_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_10_0_To_CS (ResoruceRaw, &StorageV1_10_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_10_0 = (EFI_REDFISH_STORAGE_V1_10_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_10_0)); + if (StorageV1_10_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_10_0; + StorageV1_10_0->Storage = StorageV1_10_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "10"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_10_0_JSON (*((EFI_REDFISH_STORAGE_V1_10_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_10_0 *StorageV1_10_0; + + StorageV1_10_0 = (EFI_REDFISH_STORAGE_V1_10_0 *)InterpProp; + DestroyStorage_V1_10_0_CS (StorageV1_10_0->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_10_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_10_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_10_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_1_1/RedfishStorage_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_1_1/RedfishStorage_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..f477db65396 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_1_1/RedfishStorage_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_1_1_Dxe + FILE_GUID = af5a0172-810c-413c-a0e8-d89cba7db111 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_1_1/Storage_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_1_1/Storage_V1_1_1_Dxe.c new file mode 100644 index 00000000000..20c0ec0c8bf --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_1_1/Storage_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "1", + "1" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_1_1 *StorageV1_1_1; + EFI_REDFISH_STORAGE_V1_1_1_CS *StorageV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_1_1_To_CS (ResoruceRaw, &StorageV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_1_1 = (EFI_REDFISH_STORAGE_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_1_1)); + if (StorageV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_1_1; + StorageV1_1_1->Storage = StorageV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_1_1_JSON (*((EFI_REDFISH_STORAGE_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_1_1 *StorageV1_1_1; + + StorageV1_1_1 = (EFI_REDFISH_STORAGE_V1_1_1 *)InterpProp; + DestroyStorage_V1_1_1_CS (StorageV1_1_1->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_1_2/RedfishStorage_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_1_2/RedfishStorage_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..b812d8e4dd7 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_1_2/RedfishStorage_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_1_2_Dxe + FILE_GUID = c97c6b83-5c4f-4701-8e6d-722d37f976b5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_1_2/Storage_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_1_2/Storage_V1_1_2_Dxe.c new file mode 100644 index 00000000000..46c09bd1fc9 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_1_2/Storage_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "1", + "2" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_1_2 *StorageV1_1_2; + EFI_REDFISH_STORAGE_V1_1_2_CS *StorageV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_1_2_To_CS (ResoruceRaw, &StorageV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_1_2 = (EFI_REDFISH_STORAGE_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_1_2)); + if (StorageV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_1_2; + StorageV1_1_2->Storage = StorageV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_1_2_JSON (*((EFI_REDFISH_STORAGE_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_1_2 *StorageV1_1_2; + + StorageV1_1_2 = (EFI_REDFISH_STORAGE_V1_1_2 *)InterpProp; + DestroyStorage_V1_1_2_CS (StorageV1_1_2->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_1_3/RedfishStorage_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_1_3/RedfishStorage_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..adc00935238 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_1_3/RedfishStorage_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_1_3_Dxe + FILE_GUID = 0775e1dc-f815-4f74-935c-ab26e29351b8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_1_3/Storage_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_1_3/Storage_V1_1_3_Dxe.c new file mode 100644 index 00000000000..b1cc5108f2b --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_1_3/Storage_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "1", + "3" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_1_3 *StorageV1_1_3; + EFI_REDFISH_STORAGE_V1_1_3_CS *StorageV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_1_3_To_CS (ResoruceRaw, &StorageV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_1_3 = (EFI_REDFISH_STORAGE_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_1_3)); + if (StorageV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_1_3; + StorageV1_1_3->Storage = StorageV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_1_3_JSON (*((EFI_REDFISH_STORAGE_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_1_3 *StorageV1_1_3; + + StorageV1_1_3 = (EFI_REDFISH_STORAGE_V1_1_3 *)InterpProp; + DestroyStorage_V1_1_3_CS (StorageV1_1_3->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_1_4/RedfishStorage_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_1_4/RedfishStorage_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..8d5aff63fd1 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_1_4/RedfishStorage_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_1_4_Dxe + FILE_GUID = 84745052-2465-4df4-9e9f-83a1a465926d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_1_4/Storage_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_1_4/Storage_V1_1_4_Dxe.c new file mode 100644 index 00000000000..01291ac5077 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_1_4/Storage_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "1", + "4" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_1_4 *StorageV1_1_4; + EFI_REDFISH_STORAGE_V1_1_4_CS *StorageV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_1_4_To_CS (ResoruceRaw, &StorageV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_1_4 = (EFI_REDFISH_STORAGE_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_1_4)); + if (StorageV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_1_4; + StorageV1_1_4->Storage = StorageV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_1_4_JSON (*((EFI_REDFISH_STORAGE_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_1_4 *StorageV1_1_4; + + StorageV1_1_4 = (EFI_REDFISH_STORAGE_V1_1_4 *)InterpProp; + DestroyStorage_V1_1_4_CS (StorageV1_1_4->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_1_5/RedfishStorage_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_1_5/RedfishStorage_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..05d480f2a46 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_1_5/RedfishStorage_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_1_5_Dxe + FILE_GUID = 9a972c0b-25d9-40ad-8912-d79969aa5fbb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_1_5/Storage_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_1_5/Storage_V1_1_5_Dxe.c new file mode 100644 index 00000000000..0f7cd3a6263 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_1_5/Storage_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "1", + "5" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_1_5 *StorageV1_1_5; + EFI_REDFISH_STORAGE_V1_1_5_CS *StorageV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_1_5_To_CS (ResoruceRaw, &StorageV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_1_5 = (EFI_REDFISH_STORAGE_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_1_5)); + if (StorageV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_1_5; + StorageV1_1_5->Storage = StorageV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_1_5_JSON (*((EFI_REDFISH_STORAGE_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_1_5 *StorageV1_1_5; + + StorageV1_1_5 = (EFI_REDFISH_STORAGE_V1_1_5 *)InterpProp; + DestroyStorage_V1_1_5_CS (StorageV1_1_5->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_1_6/RedfishStorage_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_1_6/RedfishStorage_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..f56d9f7da1c --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_1_6/RedfishStorage_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_1_6_Dxe + FILE_GUID = a420b82c-c43e-46e2-bded-3b591acdfa38 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_1_6/Storage_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_1_6/Storage_V1_1_6_Dxe.c new file mode 100644 index 00000000000..73188c712ff --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_1_6/Storage_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "1", + "6" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_1_6 *StorageV1_1_6; + EFI_REDFISH_STORAGE_V1_1_6_CS *StorageV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_1_6_To_CS (ResoruceRaw, &StorageV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_1_6 = (EFI_REDFISH_STORAGE_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_1_6)); + if (StorageV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_1_6; + StorageV1_1_6->Storage = StorageV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_1_6_JSON (*((EFI_REDFISH_STORAGE_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_1_6 *StorageV1_1_6; + + StorageV1_1_6 = (EFI_REDFISH_STORAGE_V1_1_6 *)InterpProp; + DestroyStorage_V1_1_6_CS (StorageV1_1_6->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_1_7/RedfishStorage_V1_1_7_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_1_7/RedfishStorage_V1_1_7_Dxe.inf new file mode 100644 index 00000000000..1e3dd5e6803 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_1_7/RedfishStorage_V1_1_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_1_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_1_7_Dxe + FILE_GUID = f609a4a3-1409-497a-ae9a-1d6006ebbf1f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_1_7EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_1_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_1_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_1_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_1_7/Storage_V1_1_7_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_1_7/Storage_V1_1_7_Dxe.c new file mode 100644 index 00000000000..e019e783c80 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_1_7/Storage_V1_1_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_1_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "1", + "7" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_1_7 *StorageV1_1_7; + EFI_REDFISH_STORAGE_V1_1_7_CS *StorageV1_1_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_1_7_To_CS (ResoruceRaw, &StorageV1_1_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_1_7 = (EFI_REDFISH_STORAGE_V1_1_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_1_7)); + if (StorageV1_1_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_1_7; + StorageV1_1_7->Storage = StorageV1_1_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_1_7_JSON (*((EFI_REDFISH_STORAGE_V1_1_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_1_7 *StorageV1_1_7; + + StorageV1_1_7 = (EFI_REDFISH_STORAGE_V1_1_7 *)InterpProp; + DestroyStorage_V1_1_7_CS (StorageV1_1_7->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_1_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_1_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_1_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_1_8/RedfishStorage_V1_1_8_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_1_8/RedfishStorage_V1_1_8_Dxe.inf new file mode 100644 index 00000000000..1a836a3ec85 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_1_8/RedfishStorage_V1_1_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_1_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_1_8_Dxe + FILE_GUID = cc159888-01a5-4315-8742-926ba16239a3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_1_8EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_1_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_1_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_1_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_1_8/Storage_V1_1_8_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_1_8/Storage_V1_1_8_Dxe.c new file mode 100644 index 00000000000..be3ba9db829 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_1_8/Storage_V1_1_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_1_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "1", + "8" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_1_8 *StorageV1_1_8; + EFI_REDFISH_STORAGE_V1_1_8_CS *StorageV1_1_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_1_8_To_CS (ResoruceRaw, &StorageV1_1_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_1_8 = (EFI_REDFISH_STORAGE_V1_1_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_1_8)); + if (StorageV1_1_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_1_8; + StorageV1_1_8->Storage = StorageV1_1_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_1_8_JSON (*((EFI_REDFISH_STORAGE_V1_1_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_1_8 *StorageV1_1_8; + + StorageV1_1_8 = (EFI_REDFISH_STORAGE_V1_1_8 *)InterpProp; + DestroyStorage_V1_1_8_CS (StorageV1_1_8->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_1_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_1_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_1_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_1_9/RedfishStorage_V1_1_9_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_1_9/RedfishStorage_V1_1_9_Dxe.inf new file mode 100644 index 00000000000..d55055ffecd --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_1_9/RedfishStorage_V1_1_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_1_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_1_9_Dxe + FILE_GUID = 983c0744-98e8-4da6-8ea5-5da8aab4e109 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_1_9EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_1_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_1_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_1_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_1_9/Storage_V1_1_9_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_1_9/Storage_V1_1_9_Dxe.c new file mode 100644 index 00000000000..5d696a06131 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_1_9/Storage_V1_1_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_1_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "1", + "9" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_1_9 *StorageV1_1_9; + EFI_REDFISH_STORAGE_V1_1_9_CS *StorageV1_1_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_1_9_To_CS (ResoruceRaw, &StorageV1_1_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_1_9 = (EFI_REDFISH_STORAGE_V1_1_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_1_9)); + if (StorageV1_1_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_1_9; + StorageV1_1_9->Storage = StorageV1_1_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_1_9_JSON (*((EFI_REDFISH_STORAGE_V1_1_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_1_9 *StorageV1_1_9; + + StorageV1_1_9 = (EFI_REDFISH_STORAGE_V1_1_9 *)InterpProp; + DestroyStorage_V1_1_9_CS (StorageV1_1_9->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_1_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_1_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_1_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_2_0/RedfishStorage_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_2_0/RedfishStorage_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..39cbf9f1a83 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_2_0/RedfishStorage_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_2_0_Dxe + FILE_GUID = ef0d5cb4-066b-434d-a7ec-7aad13bf12d3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_2_0/Storage_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_2_0/Storage_V1_2_0_Dxe.c new file mode 100644 index 00000000000..3527de2012b --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_2_0/Storage_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "2", + "0" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_2_0 *StorageV1_2_0; + EFI_REDFISH_STORAGE_V1_2_0_CS *StorageV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_2_0_To_CS (ResoruceRaw, &StorageV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_2_0 = (EFI_REDFISH_STORAGE_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_2_0)); + if (StorageV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_2_0; + StorageV1_2_0->Storage = StorageV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_2_0_JSON (*((EFI_REDFISH_STORAGE_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_2_0 *StorageV1_2_0; + + StorageV1_2_0 = (EFI_REDFISH_STORAGE_V1_2_0 *)InterpProp; + DestroyStorage_V1_2_0_CS (StorageV1_2_0->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_2_1/RedfishStorage_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_2_1/RedfishStorage_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..5ab0243a2ed --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_2_1/RedfishStorage_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_2_1_Dxe + FILE_GUID = 152c9a87-156e-4fa4-86d1-6562ac530a88 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_2_1/Storage_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_2_1/Storage_V1_2_1_Dxe.c new file mode 100644 index 00000000000..552d6ecc03d --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_2_1/Storage_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "2", + "1" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_2_1 *StorageV1_2_1; + EFI_REDFISH_STORAGE_V1_2_1_CS *StorageV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_2_1_To_CS (ResoruceRaw, &StorageV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_2_1 = (EFI_REDFISH_STORAGE_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_2_1)); + if (StorageV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_2_1; + StorageV1_2_1->Storage = StorageV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_2_1_JSON (*((EFI_REDFISH_STORAGE_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_2_1 *StorageV1_2_1; + + StorageV1_2_1 = (EFI_REDFISH_STORAGE_V1_2_1 *)InterpProp; + DestroyStorage_V1_2_1_CS (StorageV1_2_1->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_2_2/RedfishStorage_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_2_2/RedfishStorage_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..d9a1084da4c --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_2_2/RedfishStorage_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_2_2_Dxe + FILE_GUID = 15b45415-177b-4ab4-8d71-e3bf082ab330 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_2_2/Storage_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_2_2/Storage_V1_2_2_Dxe.c new file mode 100644 index 00000000000..37f6084f901 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_2_2/Storage_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "2", + "2" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_2_2 *StorageV1_2_2; + EFI_REDFISH_STORAGE_V1_2_2_CS *StorageV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_2_2_To_CS (ResoruceRaw, &StorageV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_2_2 = (EFI_REDFISH_STORAGE_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_2_2)); + if (StorageV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_2_2; + StorageV1_2_2->Storage = StorageV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_2_2_JSON (*((EFI_REDFISH_STORAGE_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_2_2 *StorageV1_2_2; + + StorageV1_2_2 = (EFI_REDFISH_STORAGE_V1_2_2 *)InterpProp; + DestroyStorage_V1_2_2_CS (StorageV1_2_2->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_2_3/RedfishStorage_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_2_3/RedfishStorage_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..7e44367e3e3 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_2_3/RedfishStorage_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_2_3_Dxe + FILE_GUID = 4cbbc603-1a76-46d2-a7d1-00267ff7f851 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_2_3/Storage_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_2_3/Storage_V1_2_3_Dxe.c new file mode 100644 index 00000000000..496cc3166f0 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_2_3/Storage_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "2", + "3" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_2_3 *StorageV1_2_3; + EFI_REDFISH_STORAGE_V1_2_3_CS *StorageV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_2_3_To_CS (ResoruceRaw, &StorageV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_2_3 = (EFI_REDFISH_STORAGE_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_2_3)); + if (StorageV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_2_3; + StorageV1_2_3->Storage = StorageV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_2_3_JSON (*((EFI_REDFISH_STORAGE_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_2_3 *StorageV1_2_3; + + StorageV1_2_3 = (EFI_REDFISH_STORAGE_V1_2_3 *)InterpProp; + DestroyStorage_V1_2_3_CS (StorageV1_2_3->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_2_4/RedfishStorage_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_2_4/RedfishStorage_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..f2e4739cd0f --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_2_4/RedfishStorage_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_2_4_Dxe + FILE_GUID = 2e3558ac-c340-439f-98ea-d42865250019 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_2_4/Storage_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_2_4/Storage_V1_2_4_Dxe.c new file mode 100644 index 00000000000..a457d48fb94 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_2_4/Storage_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "2", + "4" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_2_4 *StorageV1_2_4; + EFI_REDFISH_STORAGE_V1_2_4_CS *StorageV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_2_4_To_CS (ResoruceRaw, &StorageV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_2_4 = (EFI_REDFISH_STORAGE_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_2_4)); + if (StorageV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_2_4; + StorageV1_2_4->Storage = StorageV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_2_4_JSON (*((EFI_REDFISH_STORAGE_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_2_4 *StorageV1_2_4; + + StorageV1_2_4 = (EFI_REDFISH_STORAGE_V1_2_4 *)InterpProp; + DestroyStorage_V1_2_4_CS (StorageV1_2_4->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_2_5/RedfishStorage_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_2_5/RedfishStorage_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..625a3028d35 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_2_5/RedfishStorage_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_2_5_Dxe + FILE_GUID = 41a2ab0c-2f4c-4405-a49e-af63464d2fd9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_2_5/Storage_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_2_5/Storage_V1_2_5_Dxe.c new file mode 100644 index 00000000000..22b62c984ab --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_2_5/Storage_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "2", + "5" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_2_5 *StorageV1_2_5; + EFI_REDFISH_STORAGE_V1_2_5_CS *StorageV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_2_5_To_CS (ResoruceRaw, &StorageV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_2_5 = (EFI_REDFISH_STORAGE_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_2_5)); + if (StorageV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_2_5; + StorageV1_2_5->Storage = StorageV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_2_5_JSON (*((EFI_REDFISH_STORAGE_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_2_5 *StorageV1_2_5; + + StorageV1_2_5 = (EFI_REDFISH_STORAGE_V1_2_5 *)InterpProp; + DestroyStorage_V1_2_5_CS (StorageV1_2_5->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_2_6/RedfishStorage_V1_2_6_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_2_6/RedfishStorage_V1_2_6_Dxe.inf new file mode 100644 index 00000000000..6f87d7d30e5 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_2_6/RedfishStorage_V1_2_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_2_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_2_6_Dxe + FILE_GUID = 923480b5-76f9-40f0-8e75-a34171bb285c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_2_6EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_2_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_2_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_2_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_2_6/Storage_V1_2_6_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_2_6/Storage_V1_2_6_Dxe.c new file mode 100644 index 00000000000..668ccd62146 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_2_6/Storage_V1_2_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_2_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "2", + "6" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_2_6 *StorageV1_2_6; + EFI_REDFISH_STORAGE_V1_2_6_CS *StorageV1_2_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_2_6_To_CS (ResoruceRaw, &StorageV1_2_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_2_6 = (EFI_REDFISH_STORAGE_V1_2_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_2_6)); + if (StorageV1_2_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_2_6; + StorageV1_2_6->Storage = StorageV1_2_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_2_6_JSON (*((EFI_REDFISH_STORAGE_V1_2_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_2_6 *StorageV1_2_6; + + StorageV1_2_6 = (EFI_REDFISH_STORAGE_V1_2_6 *)InterpProp; + DestroyStorage_V1_2_6_CS (StorageV1_2_6->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_2_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_2_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_2_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_2_7/RedfishStorage_V1_2_7_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_2_7/RedfishStorage_V1_2_7_Dxe.inf new file mode 100644 index 00000000000..424eda615b8 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_2_7/RedfishStorage_V1_2_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_2_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_2_7_Dxe + FILE_GUID = 9a622be4-c57f-4b73-a784-567623d4e5c3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_2_7EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_2_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_2_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_2_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_2_7/Storage_V1_2_7_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_2_7/Storage_V1_2_7_Dxe.c new file mode 100644 index 00000000000..af1bf0d96ae --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_2_7/Storage_V1_2_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_2_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "2", + "7" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_2_7 *StorageV1_2_7; + EFI_REDFISH_STORAGE_V1_2_7_CS *StorageV1_2_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_2_7_To_CS (ResoruceRaw, &StorageV1_2_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_2_7 = (EFI_REDFISH_STORAGE_V1_2_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_2_7)); + if (StorageV1_2_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_2_7; + StorageV1_2_7->Storage = StorageV1_2_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_2_7_JSON (*((EFI_REDFISH_STORAGE_V1_2_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_2_7 *StorageV1_2_7; + + StorageV1_2_7 = (EFI_REDFISH_STORAGE_V1_2_7 *)InterpProp; + DestroyStorage_V1_2_7_CS (StorageV1_2_7->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_2_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_2_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_2_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_3_0/RedfishStorage_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_3_0/RedfishStorage_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..0dd24bce3d9 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_3_0/RedfishStorage_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_3_0_Dxe + FILE_GUID = b212bdaf-3822-431f-b8b9-4a7fc9c4a9e5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_3_0/Storage_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_3_0/Storage_V1_3_0_Dxe.c new file mode 100644 index 00000000000..0a453ea3b6d --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_3_0/Storage_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "3", + "0" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_3_0 *StorageV1_3_0; + EFI_REDFISH_STORAGE_V1_3_0_CS *StorageV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_3_0_To_CS (ResoruceRaw, &StorageV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_3_0 = (EFI_REDFISH_STORAGE_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_3_0)); + if (StorageV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_3_0; + StorageV1_3_0->Storage = StorageV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_3_0_JSON (*((EFI_REDFISH_STORAGE_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_3_0 *StorageV1_3_0; + + StorageV1_3_0 = (EFI_REDFISH_STORAGE_V1_3_0 *)InterpProp; + DestroyStorage_V1_3_0_CS (StorageV1_3_0->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_3_1/RedfishStorage_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_3_1/RedfishStorage_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..7d85c07e0f4 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_3_1/RedfishStorage_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_3_1_Dxe + FILE_GUID = fd1ea699-e71c-47b0-90ec-cbb413ca005e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_3_1/Storage_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_3_1/Storage_V1_3_1_Dxe.c new file mode 100644 index 00000000000..55e68c80e47 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_3_1/Storage_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "3", + "1" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_3_1 *StorageV1_3_1; + EFI_REDFISH_STORAGE_V1_3_1_CS *StorageV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_3_1_To_CS (ResoruceRaw, &StorageV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_3_1 = (EFI_REDFISH_STORAGE_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_3_1)); + if (StorageV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_3_1; + StorageV1_3_1->Storage = StorageV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_3_1_JSON (*((EFI_REDFISH_STORAGE_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_3_1 *StorageV1_3_1; + + StorageV1_3_1 = (EFI_REDFISH_STORAGE_V1_3_1 *)InterpProp; + DestroyStorage_V1_3_1_CS (StorageV1_3_1->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_3_2/RedfishStorage_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_3_2/RedfishStorage_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..2771cf7a464 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_3_2/RedfishStorage_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_3_2_Dxe + FILE_GUID = 268e1549-aa72-4327-abc8-5e4c8a8bb508 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_3_2/Storage_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_3_2/Storage_V1_3_2_Dxe.c new file mode 100644 index 00000000000..4ddd15f0f1a --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_3_2/Storage_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "3", + "2" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_3_2 *StorageV1_3_2; + EFI_REDFISH_STORAGE_V1_3_2_CS *StorageV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_3_2_To_CS (ResoruceRaw, &StorageV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_3_2 = (EFI_REDFISH_STORAGE_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_3_2)); + if (StorageV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_3_2; + StorageV1_3_2->Storage = StorageV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_3_2_JSON (*((EFI_REDFISH_STORAGE_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_3_2 *StorageV1_3_2; + + StorageV1_3_2 = (EFI_REDFISH_STORAGE_V1_3_2 *)InterpProp; + DestroyStorage_V1_3_2_CS (StorageV1_3_2->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_3_3/RedfishStorage_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_3_3/RedfishStorage_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..616731c6b15 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_3_3/RedfishStorage_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_3_3_Dxe + FILE_GUID = 064a2ec8-69c2-404b-91e1-23e9667c205e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_3_3/Storage_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_3_3/Storage_V1_3_3_Dxe.c new file mode 100644 index 00000000000..7c1c79289bb --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_3_3/Storage_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "3", + "3" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_3_3 *StorageV1_3_3; + EFI_REDFISH_STORAGE_V1_3_3_CS *StorageV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_3_3_To_CS (ResoruceRaw, &StorageV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_3_3 = (EFI_REDFISH_STORAGE_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_3_3)); + if (StorageV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_3_3; + StorageV1_3_3->Storage = StorageV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_3_3_JSON (*((EFI_REDFISH_STORAGE_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_3_3 *StorageV1_3_3; + + StorageV1_3_3 = (EFI_REDFISH_STORAGE_V1_3_3 *)InterpProp; + DestroyStorage_V1_3_3_CS (StorageV1_3_3->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_3_4/RedfishStorage_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_3_4/RedfishStorage_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..1695c52679d --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_3_4/RedfishStorage_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_3_4_Dxe + FILE_GUID = bcb032e0-d10f-4a44-9237-29669f0fe124 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_3_4/Storage_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_3_4/Storage_V1_3_4_Dxe.c new file mode 100644 index 00000000000..d24252639e7 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_3_4/Storage_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "3", + "4" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_3_4 *StorageV1_3_4; + EFI_REDFISH_STORAGE_V1_3_4_CS *StorageV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_3_4_To_CS (ResoruceRaw, &StorageV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_3_4 = (EFI_REDFISH_STORAGE_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_3_4)); + if (StorageV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_3_4; + StorageV1_3_4->Storage = StorageV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_3_4_JSON (*((EFI_REDFISH_STORAGE_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_3_4 *StorageV1_3_4; + + StorageV1_3_4 = (EFI_REDFISH_STORAGE_V1_3_4 *)InterpProp; + DestroyStorage_V1_3_4_CS (StorageV1_3_4->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_3_5/RedfishStorage_V1_3_5_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_3_5/RedfishStorage_V1_3_5_Dxe.inf new file mode 100644 index 00000000000..6e4131d7602 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_3_5/RedfishStorage_V1_3_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_3_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_3_5_Dxe + FILE_GUID = ad446a33-1aec-4bfb-8ffa-661cca7916e8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_3_5EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_3_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_3_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_3_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_3_5/Storage_V1_3_5_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_3_5/Storage_V1_3_5_Dxe.c new file mode 100644 index 00000000000..9d2df486936 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_3_5/Storage_V1_3_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_3_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "3", + "5" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_3_5 *StorageV1_3_5; + EFI_REDFISH_STORAGE_V1_3_5_CS *StorageV1_3_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_3_5_To_CS (ResoruceRaw, &StorageV1_3_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_3_5 = (EFI_REDFISH_STORAGE_V1_3_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_3_5)); + if (StorageV1_3_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_3_5; + StorageV1_3_5->Storage = StorageV1_3_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_3_5_JSON (*((EFI_REDFISH_STORAGE_V1_3_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_3_5 *StorageV1_3_5; + + StorageV1_3_5 = (EFI_REDFISH_STORAGE_V1_3_5 *)InterpProp; + DestroyStorage_V1_3_5_CS (StorageV1_3_5->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_3_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_3_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_3_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_3_6/RedfishStorage_V1_3_6_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_3_6/RedfishStorage_V1_3_6_Dxe.inf new file mode 100644 index 00000000000..73802c88bef --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_3_6/RedfishStorage_V1_3_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_3_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_3_6_Dxe + FILE_GUID = aded61f2-4747-4e2f-9683-188ac464872a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_3_6EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_3_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_3_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_3_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_3_6/Storage_V1_3_6_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_3_6/Storage_V1_3_6_Dxe.c new file mode 100644 index 00000000000..22c9be0a9c8 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_3_6/Storage_V1_3_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_3_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "3", + "6" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_3_6 *StorageV1_3_6; + EFI_REDFISH_STORAGE_V1_3_6_CS *StorageV1_3_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_3_6_To_CS (ResoruceRaw, &StorageV1_3_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_3_6 = (EFI_REDFISH_STORAGE_V1_3_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_3_6)); + if (StorageV1_3_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_3_6; + StorageV1_3_6->Storage = StorageV1_3_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_3_6_JSON (*((EFI_REDFISH_STORAGE_V1_3_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_3_6 *StorageV1_3_6; + + StorageV1_3_6 = (EFI_REDFISH_STORAGE_V1_3_6 *)InterpProp; + DestroyStorage_V1_3_6_CS (StorageV1_3_6->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_3_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_3_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_3_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_3_7/RedfishStorage_V1_3_7_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_3_7/RedfishStorage_V1_3_7_Dxe.inf new file mode 100644 index 00000000000..4bf1bde77ad --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_3_7/RedfishStorage_V1_3_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_3_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_3_7_Dxe + FILE_GUID = b491c3e5-1d22-4aab-b9ef-e4e0439bbb49 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_3_7EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_3_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_3_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_3_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_3_7/Storage_V1_3_7_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_3_7/Storage_V1_3_7_Dxe.c new file mode 100644 index 00000000000..c3bad1e9261 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_3_7/Storage_V1_3_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_3_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_3_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "3", + "7" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_3_7 *StorageV1_3_7; + EFI_REDFISH_STORAGE_V1_3_7_CS *StorageV1_3_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_3_7_To_CS (ResoruceRaw, &StorageV1_3_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_3_7 = (EFI_REDFISH_STORAGE_V1_3_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_3_7)); + if (StorageV1_3_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_3_7; + StorageV1_3_7->Storage = StorageV1_3_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_3_7_JSON (*((EFI_REDFISH_STORAGE_V1_3_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_3_7 *StorageV1_3_7; + + StorageV1_3_7 = (EFI_REDFISH_STORAGE_V1_3_7 *)InterpProp; + DestroyStorage_V1_3_7_CS (StorageV1_3_7->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_3_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_3_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_3_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_4_0/RedfishStorage_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_4_0/RedfishStorage_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..dea8ef74ba9 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_4_0/RedfishStorage_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_4_0_Dxe + FILE_GUID = 3fab2b2d-a365-4d1a-91fa-f2714e663e1f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_4_0/Storage_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_4_0/Storage_V1_4_0_Dxe.c new file mode 100644 index 00000000000..8d96943f3c3 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_4_0/Storage_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "4", + "0" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_4_0 *StorageV1_4_0; + EFI_REDFISH_STORAGE_V1_4_0_CS *StorageV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_4_0_To_CS (ResoruceRaw, &StorageV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_4_0 = (EFI_REDFISH_STORAGE_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_4_0)); + if (StorageV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_4_0; + StorageV1_4_0->Storage = StorageV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_4_0_JSON (*((EFI_REDFISH_STORAGE_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_4_0 *StorageV1_4_0; + + StorageV1_4_0 = (EFI_REDFISH_STORAGE_V1_4_0 *)InterpProp; + DestroyStorage_V1_4_0_CS (StorageV1_4_0->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_4_1/RedfishStorage_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_4_1/RedfishStorage_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..a9a13d548b6 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_4_1/RedfishStorage_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_4_1_Dxe + FILE_GUID = 304641e8-d330-4171-9b16-f43c1a697b3a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_4_1/Storage_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_4_1/Storage_V1_4_1_Dxe.c new file mode 100644 index 00000000000..c1cd11c9668 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_4_1/Storage_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "4", + "1" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_4_1 *StorageV1_4_1; + EFI_REDFISH_STORAGE_V1_4_1_CS *StorageV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_4_1_To_CS (ResoruceRaw, &StorageV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_4_1 = (EFI_REDFISH_STORAGE_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_4_1)); + if (StorageV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_4_1; + StorageV1_4_1->Storage = StorageV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_4_1_JSON (*((EFI_REDFISH_STORAGE_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_4_1 *StorageV1_4_1; + + StorageV1_4_1 = (EFI_REDFISH_STORAGE_V1_4_1 *)InterpProp; + DestroyStorage_V1_4_1_CS (StorageV1_4_1->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_4_2/RedfishStorage_V1_4_2_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_4_2/RedfishStorage_V1_4_2_Dxe.inf new file mode 100644 index 00000000000..ee872583810 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_4_2/RedfishStorage_V1_4_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_4_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_4_2_Dxe + FILE_GUID = 8ad51283-0a3b-47c8-83c2-e6f8dee1c818 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_4_2EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_4_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_4_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_4_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_4_2/Storage_V1_4_2_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_4_2/Storage_V1_4_2_Dxe.c new file mode 100644 index 00000000000..c075c0da7f8 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_4_2/Storage_V1_4_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_4_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "4", + "2" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_4_2 *StorageV1_4_2; + EFI_REDFISH_STORAGE_V1_4_2_CS *StorageV1_4_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_4_2_To_CS (ResoruceRaw, &StorageV1_4_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_4_2 = (EFI_REDFISH_STORAGE_V1_4_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_4_2)); + if (StorageV1_4_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_4_2; + StorageV1_4_2->Storage = StorageV1_4_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_4_2_JSON (*((EFI_REDFISH_STORAGE_V1_4_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_4_2 *StorageV1_4_2; + + StorageV1_4_2 = (EFI_REDFISH_STORAGE_V1_4_2 *)InterpProp; + DestroyStorage_V1_4_2_CS (StorageV1_4_2->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_4_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_4_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_4_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_4_3/RedfishStorage_V1_4_3_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_4_3/RedfishStorage_V1_4_3_Dxe.inf new file mode 100644 index 00000000000..d1a3a440199 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_4_3/RedfishStorage_V1_4_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_4_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_4_3_Dxe + FILE_GUID = 10e1286e-2479-430f-90e0-5b457305f71c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_4_3EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_4_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_4_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_4_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_4_3/Storage_V1_4_3_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_4_3/Storage_V1_4_3_Dxe.c new file mode 100644 index 00000000000..024cb53233b --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_4_3/Storage_V1_4_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_4_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "4", + "3" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_4_3 *StorageV1_4_3; + EFI_REDFISH_STORAGE_V1_4_3_CS *StorageV1_4_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_4_3_To_CS (ResoruceRaw, &StorageV1_4_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_4_3 = (EFI_REDFISH_STORAGE_V1_4_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_4_3)); + if (StorageV1_4_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_4_3; + StorageV1_4_3->Storage = StorageV1_4_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_4_3_JSON (*((EFI_REDFISH_STORAGE_V1_4_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_4_3 *StorageV1_4_3; + + StorageV1_4_3 = (EFI_REDFISH_STORAGE_V1_4_3 *)InterpProp; + DestroyStorage_V1_4_3_CS (StorageV1_4_3->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_4_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_4_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_4_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_4_4/RedfishStorage_V1_4_4_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_4_4/RedfishStorage_V1_4_4_Dxe.inf new file mode 100644 index 00000000000..3375ef11448 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_4_4/RedfishStorage_V1_4_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_4_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_4_4_Dxe + FILE_GUID = 4ffb5291-4190-4b01-8d4f-4aaf26407479 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_4_4EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_4_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_4_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_4_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_4_4/Storage_V1_4_4_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_4_4/Storage_V1_4_4_Dxe.c new file mode 100644 index 00000000000..9c771f2f1ed --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_4_4/Storage_V1_4_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_4_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "4", + "4" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_4_4 *StorageV1_4_4; + EFI_REDFISH_STORAGE_V1_4_4_CS *StorageV1_4_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_4_4_To_CS (ResoruceRaw, &StorageV1_4_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_4_4 = (EFI_REDFISH_STORAGE_V1_4_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_4_4)); + if (StorageV1_4_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_4_4; + StorageV1_4_4->Storage = StorageV1_4_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_4_4_JSON (*((EFI_REDFISH_STORAGE_V1_4_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_4_4 *StorageV1_4_4; + + StorageV1_4_4 = (EFI_REDFISH_STORAGE_V1_4_4 *)InterpProp; + DestroyStorage_V1_4_4_CS (StorageV1_4_4->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_4_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_4_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_4_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_4_5/RedfishStorage_V1_4_5_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_4_5/RedfishStorage_V1_4_5_Dxe.inf new file mode 100644 index 00000000000..68c9f103105 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_4_5/RedfishStorage_V1_4_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_4_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_4_5_Dxe + FILE_GUID = 5ea4ca8a-4335-4039-985a-b2e56121276c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_4_5EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_4_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_4_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_4_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_4_5/Storage_V1_4_5_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_4_5/Storage_V1_4_5_Dxe.c new file mode 100644 index 00000000000..3d4e5ed1008 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_4_5/Storage_V1_4_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_4_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "4", + "5" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_4_5 *StorageV1_4_5; + EFI_REDFISH_STORAGE_V1_4_5_CS *StorageV1_4_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_4_5_To_CS (ResoruceRaw, &StorageV1_4_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_4_5 = (EFI_REDFISH_STORAGE_V1_4_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_4_5)); + if (StorageV1_4_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_4_5; + StorageV1_4_5->Storage = StorageV1_4_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_4_5_JSON (*((EFI_REDFISH_STORAGE_V1_4_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_4_5 *StorageV1_4_5; + + StorageV1_4_5 = (EFI_REDFISH_STORAGE_V1_4_5 *)InterpProp; + DestroyStorage_V1_4_5_CS (StorageV1_4_5->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_4_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_4_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_4_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_4_6/RedfishStorage_V1_4_6_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_4_6/RedfishStorage_V1_4_6_Dxe.inf new file mode 100644 index 00000000000..ba2777fd93c --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_4_6/RedfishStorage_V1_4_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_4_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_4_6_Dxe + FILE_GUID = 549817fd-74f1-432d-bc4a-80a0541fece6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_4_6EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_4_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_4_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_4_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_4_6/Storage_V1_4_6_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_4_6/Storage_V1_4_6_Dxe.c new file mode 100644 index 00000000000..53c272f7305 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_4_6/Storage_V1_4_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_4_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_4_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "4", + "6" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_4_6 *StorageV1_4_6; + EFI_REDFISH_STORAGE_V1_4_6_CS *StorageV1_4_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_4_6_To_CS (ResoruceRaw, &StorageV1_4_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_4_6 = (EFI_REDFISH_STORAGE_V1_4_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_4_6)); + if (StorageV1_4_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_4_6; + StorageV1_4_6->Storage = StorageV1_4_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_4_6_JSON (*((EFI_REDFISH_STORAGE_V1_4_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_4_6 *StorageV1_4_6; + + StorageV1_4_6 = (EFI_REDFISH_STORAGE_V1_4_6 *)InterpProp; + DestroyStorage_V1_4_6_CS (StorageV1_4_6->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_4_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_4_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_4_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_5_0/RedfishStorage_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_5_0/RedfishStorage_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..82cafb3cf3a --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_5_0/RedfishStorage_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_5_0_Dxe + FILE_GUID = c0988822-5da9-4165-8620-3fd2f1a62f02 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_5_0/Storage_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_5_0/Storage_V1_5_0_Dxe.c new file mode 100644 index 00000000000..819884a8d7e --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_5_0/Storage_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "5", + "0" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_5_0 *StorageV1_5_0; + EFI_REDFISH_STORAGE_V1_5_0_CS *StorageV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_5_0_To_CS (ResoruceRaw, &StorageV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_5_0 = (EFI_REDFISH_STORAGE_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_5_0)); + if (StorageV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_5_0; + StorageV1_5_0->Storage = StorageV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_5_0_JSON (*((EFI_REDFISH_STORAGE_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_5_0 *StorageV1_5_0; + + StorageV1_5_0 = (EFI_REDFISH_STORAGE_V1_5_0 *)InterpProp; + DestroyStorage_V1_5_0_CS (StorageV1_5_0->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_5_1/RedfishStorage_V1_5_1_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_5_1/RedfishStorage_V1_5_1_Dxe.inf new file mode 100644 index 00000000000..be8ea23cc7c --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_5_1/RedfishStorage_V1_5_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_5_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_5_1_Dxe + FILE_GUID = bfe4f5cb-5645-4506-a025-163c2ed41e96 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_5_1EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_5_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_5_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_5_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_5_1/Storage_V1_5_1_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_5_1/Storage_V1_5_1_Dxe.c new file mode 100644 index 00000000000..d60f40908da --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_5_1/Storage_V1_5_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_5_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "5", + "1" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_5_1 *StorageV1_5_1; + EFI_REDFISH_STORAGE_V1_5_1_CS *StorageV1_5_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_5_1_To_CS (ResoruceRaw, &StorageV1_5_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_5_1 = (EFI_REDFISH_STORAGE_V1_5_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_5_1)); + if (StorageV1_5_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_5_1; + StorageV1_5_1->Storage = StorageV1_5_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_5_1_JSON (*((EFI_REDFISH_STORAGE_V1_5_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_5_1 *StorageV1_5_1; + + StorageV1_5_1 = (EFI_REDFISH_STORAGE_V1_5_1 *)InterpProp; + DestroyStorage_V1_5_1_CS (StorageV1_5_1->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_5_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_5_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_5_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_5_2/RedfishStorage_V1_5_2_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_5_2/RedfishStorage_V1_5_2_Dxe.inf new file mode 100644 index 00000000000..3cfbecb1814 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_5_2/RedfishStorage_V1_5_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_5_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_5_2_Dxe + FILE_GUID = cbf73f6a-34e3-479a-9e01-7bbf56c80f7c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_5_2EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_5_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_5_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_5_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_5_2/Storage_V1_5_2_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_5_2/Storage_V1_5_2_Dxe.c new file mode 100644 index 00000000000..bfd7afac3e0 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_5_2/Storage_V1_5_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_5_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "5", + "2" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_5_2 *StorageV1_5_2; + EFI_REDFISH_STORAGE_V1_5_2_CS *StorageV1_5_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_5_2_To_CS (ResoruceRaw, &StorageV1_5_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_5_2 = (EFI_REDFISH_STORAGE_V1_5_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_5_2)); + if (StorageV1_5_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_5_2; + StorageV1_5_2->Storage = StorageV1_5_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_5_2_JSON (*((EFI_REDFISH_STORAGE_V1_5_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_5_2 *StorageV1_5_2; + + StorageV1_5_2 = (EFI_REDFISH_STORAGE_V1_5_2 *)InterpProp; + DestroyStorage_V1_5_2_CS (StorageV1_5_2->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_5_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_5_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_5_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_5_3/RedfishStorage_V1_5_3_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_5_3/RedfishStorage_V1_5_3_Dxe.inf new file mode 100644 index 00000000000..50801a193bc --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_5_3/RedfishStorage_V1_5_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_5_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_5_3_Dxe + FILE_GUID = daa14ac3-3143-4016-b917-7775d62f65c0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_5_3EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_5_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_5_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_5_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_5_3/Storage_V1_5_3_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_5_3/Storage_V1_5_3_Dxe.c new file mode 100644 index 00000000000..8453252a02d --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_5_3/Storage_V1_5_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_5_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "5", + "3" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_5_3 *StorageV1_5_3; + EFI_REDFISH_STORAGE_V1_5_3_CS *StorageV1_5_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_5_3_To_CS (ResoruceRaw, &StorageV1_5_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_5_3 = (EFI_REDFISH_STORAGE_V1_5_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_5_3)); + if (StorageV1_5_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_5_3; + StorageV1_5_3->Storage = StorageV1_5_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_5_3_JSON (*((EFI_REDFISH_STORAGE_V1_5_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_5_3 *StorageV1_5_3; + + StorageV1_5_3 = (EFI_REDFISH_STORAGE_V1_5_3 *)InterpProp; + DestroyStorage_V1_5_3_CS (StorageV1_5_3->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_5_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_5_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_5_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_5_4/RedfishStorage_V1_5_4_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_5_4/RedfishStorage_V1_5_4_Dxe.inf new file mode 100644 index 00000000000..480dbf98f32 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_5_4/RedfishStorage_V1_5_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_5_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_5_4_Dxe + FILE_GUID = 6862b97e-e46e-4842-b871-903393ae5b4b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_5_4EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_5_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_5_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_5_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_5_4/Storage_V1_5_4_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_5_4/Storage_V1_5_4_Dxe.c new file mode 100644 index 00000000000..6267571c2bf --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_5_4/Storage_V1_5_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_5_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "5", + "4" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_5_4 *StorageV1_5_4; + EFI_REDFISH_STORAGE_V1_5_4_CS *StorageV1_5_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_5_4_To_CS (ResoruceRaw, &StorageV1_5_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_5_4 = (EFI_REDFISH_STORAGE_V1_5_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_5_4)); + if (StorageV1_5_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_5_4; + StorageV1_5_4->Storage = StorageV1_5_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_5_4_JSON (*((EFI_REDFISH_STORAGE_V1_5_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_5_4 *StorageV1_5_4; + + StorageV1_5_4 = (EFI_REDFISH_STORAGE_V1_5_4 *)InterpProp; + DestroyStorage_V1_5_4_CS (StorageV1_5_4->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_5_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_5_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_5_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_5_5/RedfishStorage_V1_5_5_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_5_5/RedfishStorage_V1_5_5_Dxe.inf new file mode 100644 index 00000000000..0fbc01100fd --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_5_5/RedfishStorage_V1_5_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_5_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_5_5_Dxe + FILE_GUID = 6c1649a3-cb1e-4b18-ba11-31db0b2d50d9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_5_5EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_5_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_5_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_5_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_5_5/Storage_V1_5_5_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_5_5/Storage_V1_5_5_Dxe.c new file mode 100644 index 00000000000..c1394d68024 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_5_5/Storage_V1_5_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_5_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_5_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "5", + "5" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_5_5 *StorageV1_5_5; + EFI_REDFISH_STORAGE_V1_5_5_CS *StorageV1_5_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_5_5_To_CS (ResoruceRaw, &StorageV1_5_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_5_5 = (EFI_REDFISH_STORAGE_V1_5_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_5_5)); + if (StorageV1_5_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_5_5; + StorageV1_5_5->Storage = StorageV1_5_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_5_5_JSON (*((EFI_REDFISH_STORAGE_V1_5_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_5_5 *StorageV1_5_5; + + StorageV1_5_5 = (EFI_REDFISH_STORAGE_V1_5_5 *)InterpProp; + DestroyStorage_V1_5_5_CS (StorageV1_5_5->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_5_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_5_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_5_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_6_0/RedfishStorage_V1_6_0_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_6_0/RedfishStorage_V1_6_0_Dxe.inf new file mode 100644 index 00000000000..72bd434b447 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_6_0/RedfishStorage_V1_6_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_6_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_6_0_Dxe + FILE_GUID = a449eed0-fd15-48f8-be1e-e8ec8b642e57 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_6_0EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_6_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_6_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_6_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_6_0/Storage_V1_6_0_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_6_0/Storage_V1_6_0_Dxe.c new file mode 100644 index 00000000000..029e173045f --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_6_0/Storage_V1_6_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_6_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "6", + "0" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_6_0 *StorageV1_6_0; + EFI_REDFISH_STORAGE_V1_6_0_CS *StorageV1_6_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_6_0_To_CS (ResoruceRaw, &StorageV1_6_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_6_0 = (EFI_REDFISH_STORAGE_V1_6_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_6_0)); + if (StorageV1_6_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_6_0; + StorageV1_6_0->Storage = StorageV1_6_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_6_0_JSON (*((EFI_REDFISH_STORAGE_V1_6_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_6_0 *StorageV1_6_0; + + StorageV1_6_0 = (EFI_REDFISH_STORAGE_V1_6_0 *)InterpProp; + DestroyStorage_V1_6_0_CS (StorageV1_6_0->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_6_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_6_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_6_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_6_1/RedfishStorage_V1_6_1_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_6_1/RedfishStorage_V1_6_1_Dxe.inf new file mode 100644 index 00000000000..5d76bffca07 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_6_1/RedfishStorage_V1_6_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_6_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_6_1_Dxe + FILE_GUID = 4397f951-b3e2-47d6-b137-78021f6691ed + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_6_1EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_6_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_6_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_6_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_6_1/Storage_V1_6_1_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_6_1/Storage_V1_6_1_Dxe.c new file mode 100644 index 00000000000..55b03a2ebbf --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_6_1/Storage_V1_6_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_6_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "6", + "1" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_6_1 *StorageV1_6_1; + EFI_REDFISH_STORAGE_V1_6_1_CS *StorageV1_6_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_6_1_To_CS (ResoruceRaw, &StorageV1_6_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_6_1 = (EFI_REDFISH_STORAGE_V1_6_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_6_1)); + if (StorageV1_6_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_6_1; + StorageV1_6_1->Storage = StorageV1_6_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_6_1_JSON (*((EFI_REDFISH_STORAGE_V1_6_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_6_1 *StorageV1_6_1; + + StorageV1_6_1 = (EFI_REDFISH_STORAGE_V1_6_1 *)InterpProp; + DestroyStorage_V1_6_1_CS (StorageV1_6_1->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_6_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_6_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_6_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_6_2/RedfishStorage_V1_6_2_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_6_2/RedfishStorage_V1_6_2_Dxe.inf new file mode 100644 index 00000000000..705f10ecf77 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_6_2/RedfishStorage_V1_6_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_6_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_6_2_Dxe + FILE_GUID = c539278a-2b1a-4ba0-a1b1-e600f62a74e4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_6_2EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_6_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_6_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_6_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_6_2/Storage_V1_6_2_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_6_2/Storage_V1_6_2_Dxe.c new file mode 100644 index 00000000000..a01d0a05fbc --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_6_2/Storage_V1_6_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_6_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "6", + "2" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_6_2 *StorageV1_6_2; + EFI_REDFISH_STORAGE_V1_6_2_CS *StorageV1_6_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_6_2_To_CS (ResoruceRaw, &StorageV1_6_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_6_2 = (EFI_REDFISH_STORAGE_V1_6_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_6_2)); + if (StorageV1_6_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_6_2; + StorageV1_6_2->Storage = StorageV1_6_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_6_2_JSON (*((EFI_REDFISH_STORAGE_V1_6_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_6_2 *StorageV1_6_2; + + StorageV1_6_2 = (EFI_REDFISH_STORAGE_V1_6_2 *)InterpProp; + DestroyStorage_V1_6_2_CS (StorageV1_6_2->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_6_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_6_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_6_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_6_3/RedfishStorage_V1_6_3_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_6_3/RedfishStorage_V1_6_3_Dxe.inf new file mode 100644 index 00000000000..80bc58dcc3e --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_6_3/RedfishStorage_V1_6_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_6_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_6_3_Dxe + FILE_GUID = d3b8b52c-fc59-411c-857c-b2d87882113e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_6_3EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_6_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_6_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_6_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_6_3/Storage_V1_6_3_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_6_3/Storage_V1_6_3_Dxe.c new file mode 100644 index 00000000000..c854572fb2d --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_6_3/Storage_V1_6_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_6_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_6_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "6", + "3" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_6_3 *StorageV1_6_3; + EFI_REDFISH_STORAGE_V1_6_3_CS *StorageV1_6_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_6_3_To_CS (ResoruceRaw, &StorageV1_6_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_6_3 = (EFI_REDFISH_STORAGE_V1_6_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_6_3)); + if (StorageV1_6_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_6_3; + StorageV1_6_3->Storage = StorageV1_6_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_6_3_JSON (*((EFI_REDFISH_STORAGE_V1_6_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_6_3 *StorageV1_6_3; + + StorageV1_6_3 = (EFI_REDFISH_STORAGE_V1_6_3 *)InterpProp; + DestroyStorage_V1_6_3_CS (StorageV1_6_3->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_6_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_6_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_6_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_6_4/RedfishStorage_V1_6_4_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_6_4/RedfishStorage_V1_6_4_Dxe.inf new file mode 100644 index 00000000000..17f6d1f79f0 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_6_4/RedfishStorage_V1_6_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_6_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_6_4_Dxe + FILE_GUID = 1b5e4ca9-905e-4827-bceb-eb05996ac8dd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_6_4EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_6_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_6_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_6_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_6_4/Storage_V1_6_4_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_6_4/Storage_V1_6_4_Dxe.c new file mode 100644 index 00000000000..5c0cd88895d --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_6_4/Storage_V1_6_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_6_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_6_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "6", + "4" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_6_4 *StorageV1_6_4; + EFI_REDFISH_STORAGE_V1_6_4_CS *StorageV1_6_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_6_4_To_CS (ResoruceRaw, &StorageV1_6_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_6_4 = (EFI_REDFISH_STORAGE_V1_6_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_6_4)); + if (StorageV1_6_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_6_4; + StorageV1_6_4->Storage = StorageV1_6_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_6_4_JSON (*((EFI_REDFISH_STORAGE_V1_6_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_6_4 *StorageV1_6_4; + + StorageV1_6_4 = (EFI_REDFISH_STORAGE_V1_6_4 *)InterpProp; + DestroyStorage_V1_6_4_CS (StorageV1_6_4->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_6_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_6_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_6_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_7_0/RedfishStorage_V1_7_0_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_7_0/RedfishStorage_V1_7_0_Dxe.inf new file mode 100644 index 00000000000..c9413710649 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_7_0/RedfishStorage_V1_7_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_7_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_7_0_Dxe + FILE_GUID = 954b8796-c183-48f7-92a2-345979105c77 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_7_0EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_7_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_7_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_7_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_7_0/Storage_V1_7_0_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_7_0/Storage_V1_7_0_Dxe.c new file mode 100644 index 00000000000..4fb20d19add --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_7_0/Storage_V1_7_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_7_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "7", + "0" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_7_0 *StorageV1_7_0; + EFI_REDFISH_STORAGE_V1_7_0_CS *StorageV1_7_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_7_0_To_CS (ResoruceRaw, &StorageV1_7_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_7_0 = (EFI_REDFISH_STORAGE_V1_7_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_7_0)); + if (StorageV1_7_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_7_0; + StorageV1_7_0->Storage = StorageV1_7_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_7_0_JSON (*((EFI_REDFISH_STORAGE_V1_7_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_7_0 *StorageV1_7_0; + + StorageV1_7_0 = (EFI_REDFISH_STORAGE_V1_7_0 *)InterpProp; + DestroyStorage_V1_7_0_CS (StorageV1_7_0->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_7_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_7_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_7_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_7_1/RedfishStorage_V1_7_1_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_7_1/RedfishStorage_V1_7_1_Dxe.inf new file mode 100644 index 00000000000..f96af2a9329 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_7_1/RedfishStorage_V1_7_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_7_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_7_1_Dxe + FILE_GUID = 5256a5cc-15c4-418b-9967-72549325238b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_7_1EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_7_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_7_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_7_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_7_1/Storage_V1_7_1_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_7_1/Storage_V1_7_1_Dxe.c new file mode 100644 index 00000000000..b22b2095c2a --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_7_1/Storage_V1_7_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_7_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_7_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "7", + "1" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_7_1 *StorageV1_7_1; + EFI_REDFISH_STORAGE_V1_7_1_CS *StorageV1_7_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_7_1_To_CS (ResoruceRaw, &StorageV1_7_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_7_1 = (EFI_REDFISH_STORAGE_V1_7_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_7_1)); + if (StorageV1_7_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_7_1; + StorageV1_7_1->Storage = StorageV1_7_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_7_1_JSON (*((EFI_REDFISH_STORAGE_V1_7_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_7_1 *StorageV1_7_1; + + StorageV1_7_1 = (EFI_REDFISH_STORAGE_V1_7_1 *)InterpProp; + DestroyStorage_V1_7_1_CS (StorageV1_7_1->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_7_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_7_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_7_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_7_2/RedfishStorage_V1_7_2_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_7_2/RedfishStorage_V1_7_2_Dxe.inf new file mode 100644 index 00000000000..cb9bd76d65d --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_7_2/RedfishStorage_V1_7_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_7_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_7_2_Dxe + FILE_GUID = 40dbcad1-e441-4fe8-a3ee-a95daeaa23d4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_7_2EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_7_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_7_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_7_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_7_2/Storage_V1_7_2_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_7_2/Storage_V1_7_2_Dxe.c new file mode 100644 index 00000000000..1d1398e0bf7 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_7_2/Storage_V1_7_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_7_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_7_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "7", + "2" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_7_2 *StorageV1_7_2; + EFI_REDFISH_STORAGE_V1_7_2_CS *StorageV1_7_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_7_2_To_CS (ResoruceRaw, &StorageV1_7_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_7_2 = (EFI_REDFISH_STORAGE_V1_7_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_7_2)); + if (StorageV1_7_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_7_2; + StorageV1_7_2->Storage = StorageV1_7_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_7_2_JSON (*((EFI_REDFISH_STORAGE_V1_7_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_7_2 *StorageV1_7_2; + + StorageV1_7_2 = (EFI_REDFISH_STORAGE_V1_7_2 *)InterpProp; + DestroyStorage_V1_7_2_CS (StorageV1_7_2->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_7_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_7_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_7_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_7_3/RedfishStorage_V1_7_3_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_7_3/RedfishStorage_V1_7_3_Dxe.inf new file mode 100644 index 00000000000..de5f3dc8345 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_7_3/RedfishStorage_V1_7_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_7_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_7_3_Dxe + FILE_GUID = 0e756e30-951b-423b-87b2-3b47d832ee56 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_7_3EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_7_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_7_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_7_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_7_3/Storage_V1_7_3_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_7_3/Storage_V1_7_3_Dxe.c new file mode 100644 index 00000000000..b12df736c12 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_7_3/Storage_V1_7_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_7_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_7_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "7", + "3" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_7_3 *StorageV1_7_3; + EFI_REDFISH_STORAGE_V1_7_3_CS *StorageV1_7_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_7_3_To_CS (ResoruceRaw, &StorageV1_7_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_7_3 = (EFI_REDFISH_STORAGE_V1_7_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_7_3)); + if (StorageV1_7_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_7_3; + StorageV1_7_3->Storage = StorageV1_7_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_7_3_JSON (*((EFI_REDFISH_STORAGE_V1_7_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_7_3 *StorageV1_7_3; + + StorageV1_7_3 = (EFI_REDFISH_STORAGE_V1_7_3 *)InterpProp; + DestroyStorage_V1_7_3_CS (StorageV1_7_3->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_7_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_7_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_7_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_8_0/RedfishStorage_V1_8_0_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_8_0/RedfishStorage_V1_8_0_Dxe.inf new file mode 100644 index 00000000000..8ecd3529d7b --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_8_0/RedfishStorage_V1_8_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_8_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_8_0_Dxe + FILE_GUID = 462eae91-d0c6-40e3-a441-f7d41d7d866b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_8_0EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_8_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_8_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_8_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_8_0/Storage_V1_8_0_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_8_0/Storage_V1_8_0_Dxe.c new file mode 100644 index 00000000000..ead3658f540 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_8_0/Storage_V1_8_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_8_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_8_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "8", + "0" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_8_0 *StorageV1_8_0; + EFI_REDFISH_STORAGE_V1_8_0_CS *StorageV1_8_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_8_0_To_CS (ResoruceRaw, &StorageV1_8_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_8_0 = (EFI_REDFISH_STORAGE_V1_8_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_8_0)); + if (StorageV1_8_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_8_0; + StorageV1_8_0->Storage = StorageV1_8_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_8_0_JSON (*((EFI_REDFISH_STORAGE_V1_8_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_8_0 *StorageV1_8_0; + + StorageV1_8_0 = (EFI_REDFISH_STORAGE_V1_8_0 *)InterpProp; + DestroyStorage_V1_8_0_CS (StorageV1_8_0->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_8_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_8_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_8_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_8_1/RedfishStorage_V1_8_1_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_8_1/RedfishStorage_V1_8_1_Dxe.inf new file mode 100644 index 00000000000..c354f0fefad --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_8_1/RedfishStorage_V1_8_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_8_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_8_1_Dxe + FILE_GUID = d8fccc82-3afb-48ca-9c9b-c471bfa748b8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_8_1EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_8_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_8_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_8_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_8_1/Storage_V1_8_1_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_8_1/Storage_V1_8_1_Dxe.c new file mode 100644 index 00000000000..33e2594f99d --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_8_1/Storage_V1_8_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_8_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_8_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "8", + "1" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_8_1 *StorageV1_8_1; + EFI_REDFISH_STORAGE_V1_8_1_CS *StorageV1_8_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_8_1_To_CS (ResoruceRaw, &StorageV1_8_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_8_1 = (EFI_REDFISH_STORAGE_V1_8_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_8_1)); + if (StorageV1_8_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_8_1; + StorageV1_8_1->Storage = StorageV1_8_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_8_1_JSON (*((EFI_REDFISH_STORAGE_V1_8_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_8_1 *StorageV1_8_1; + + StorageV1_8_1 = (EFI_REDFISH_STORAGE_V1_8_1 *)InterpProp; + DestroyStorage_V1_8_1_CS (StorageV1_8_1->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_8_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_8_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_8_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_8_2/RedfishStorage_V1_8_2_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_8_2/RedfishStorage_V1_8_2_Dxe.inf new file mode 100644 index 00000000000..c404386d712 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_8_2/RedfishStorage_V1_8_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_8_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_8_2_Dxe + FILE_GUID = 7bfe24bc-8c5d-4325-9a20-4e32c8a236f9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_8_2EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_8_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_8_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_8_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_8_2/Storage_V1_8_2_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_8_2/Storage_V1_8_2_Dxe.c new file mode 100644 index 00000000000..f21d203ed92 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_8_2/Storage_V1_8_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_8_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_8_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "8", + "2" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_8_2 *StorageV1_8_2; + EFI_REDFISH_STORAGE_V1_8_2_CS *StorageV1_8_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_8_2_To_CS (ResoruceRaw, &StorageV1_8_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_8_2 = (EFI_REDFISH_STORAGE_V1_8_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_8_2)); + if (StorageV1_8_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_8_2; + StorageV1_8_2->Storage = StorageV1_8_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_8_2_JSON (*((EFI_REDFISH_STORAGE_V1_8_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_8_2 *StorageV1_8_2; + + StorageV1_8_2 = (EFI_REDFISH_STORAGE_V1_8_2 *)InterpProp; + DestroyStorage_V1_8_2_CS (StorageV1_8_2->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_8_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_8_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_8_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_9_0/RedfishStorage_V1_9_0_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_9_0/RedfishStorage_V1_9_0_Dxe.inf new file mode 100644 index 00000000000..8276e4e4610 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_9_0/RedfishStorage_V1_9_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_9_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_9_0_Dxe + FILE_GUID = 92c6e9e1-d9c6-40a9-9d8f-94b7f1f27210 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_9_0EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_9_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_9_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_9_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_9_0/Storage_V1_9_0_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_9_0/Storage_V1_9_0_Dxe.c new file mode 100644 index 00000000000..00506ff5a26 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_9_0/Storage_V1_9_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_9_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_9_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "9", + "0" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_9_0 *StorageV1_9_0; + EFI_REDFISH_STORAGE_V1_9_0_CS *StorageV1_9_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_9_0_To_CS (ResoruceRaw, &StorageV1_9_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_9_0 = (EFI_REDFISH_STORAGE_V1_9_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_9_0)); + if (StorageV1_9_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_9_0; + StorageV1_9_0->Storage = StorageV1_9_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_9_0_JSON (*((EFI_REDFISH_STORAGE_V1_9_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_9_0 *StorageV1_9_0; + + StorageV1_9_0 = (EFI_REDFISH_STORAGE_V1_9_0 *)InterpProp; + DestroyStorage_V1_9_0_CS (StorageV1_9_0->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_9_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_9_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_9_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Storage/v1_9_1/RedfishStorage_V1_9_1_Dxe.inf b/RedfishClientPkg/Converter/Storage/v1_9_1/RedfishStorage_V1_9_1_Dxe.inf new file mode 100644 index 00000000000..72bd2e2b975 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_9_1/RedfishStorage_V1_9_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Storage.v1_9_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorage_V1_9_1_Dxe + FILE_GUID = 93d7f2b2-d279-4b4d-8a4a-09bb27d66dd6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorage_V1_9_1EntryPoint + UNLOAD_IMAGE = RedfishStorage_V1_9_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Storage_V1_9_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageV1_9_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Storage/v1_9_1/Storage_V1_9_1_Dxe.c b/RedfishClientPkg/Converter/Storage/v1_9_1/Storage_V1_9_1_Dxe.c new file mode 100644 index 00000000000..5cc5d165136 --- /dev/null +++ b/RedfishClientPkg/Converter/Storage/v1_9_1/Storage_V1_9_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Storage.v1_9_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Storage"; +BOOLEAN IsRevisonController = TRUE; + +// Support Storage V1_9_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Storage", + "1", + "9", + "1" + }, + "Storage" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_9_1 *StorageV1_9_1; + EFI_REDFISH_STORAGE_V1_9_1_CS *StorageV1_9_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Storage") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Storage_V1_9_1_To_CS (ResoruceRaw, &StorageV1_9_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageV1_9_1 = (EFI_REDFISH_STORAGE_V1_9_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGE_V1_9_1)); + if (StorageV1_9_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageV1_9_1; + StorageV1_9_1->Storage = StorageV1_9_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "9"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Storage"), "Storage"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Storage")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Storage"), "Storage"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Storage_V1_9_1_JSON (*((EFI_REDFISH_STORAGE_V1_9_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGE_V1_9_1 *StorageV1_9_1; + + StorageV1_9_1 = (EFI_REDFISH_STORAGE_V1_9_1 *)InterpProp; + DestroyStorage_V1_9_1_CS (StorageV1_9_1->Storage); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorage_V1_9_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_9_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageToStructWrapper, + StorageToJson, + StorageDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorage_V1_9_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/StorageCollection/RedfishStorageCollection_Dxe.inf b/RedfishClientPkg/Converter/StorageCollection/RedfishStorageCollection_Dxe.inf new file mode 100644 index 00000000000..b0e974870d6 --- /dev/null +++ b/RedfishClientPkg/Converter/StorageCollection/RedfishStorageCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of StorageCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorageCollection_Dxe + FILE_GUID = 67691c37-d14d-4d0c-a6e2-47fe3f488fe9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorageCollectionEntryPoint + UNLOAD_IMAGE = RedfishStorageCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + StorageCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/StorageCollection/StorageCollection_Dxe.c b/RedfishClientPkg/Converter/StorageCollection/StorageCollection_Dxe.c new file mode 100644 index 00000000000..231f5269d26 --- /dev/null +++ b/RedfishClientPkg/Converter/StorageCollection/StorageCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - StorageCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#StorageCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support StorageCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "StorageCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "StorageCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGECOLLECTION *StorageCollection; + EFI_REDFISH_STORAGECOLLECTION_CS *StorageCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "StorageCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_StorageCollection_To_CS (ResoruceRaw, &StorageCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageCollection = (EFI_REDFISH_STORAGECOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGECOLLECTION)); + if (StorageCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageCollection; + StorageCollection->StorageCollection = StorageCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("StorageCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("StorageCollection"), "StorageCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("StorageCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("StorageCollection"), "StorageCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_StorageCollection_JSON (*((EFI_REDFISH_STORAGECOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGECOLLECTION *StorageCollection; + + StorageCollection = (EFI_REDFISH_STORAGECOLLECTION *)InterpProp; + DestroyStorageCollection_CS (StorageCollection->StorageCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorageCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorageCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageCollectionToStructWrapper, + StorageCollectionToJson, + StorageCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorageCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/StorageController/v1_0_0/RedfishStorageController_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/StorageController/v1_0_0/RedfishStorageController_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..1ef245004d1 --- /dev/null +++ b/RedfishClientPkg/Converter/StorageController/v1_0_0/RedfishStorageController_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of StorageController.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorageController_V1_0_0_Dxe + FILE_GUID = 5b6cd0a5-4a41-43f6-b886-1b4b66c66806 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorageController_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishStorageController_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + StorageController_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageControllerV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/StorageController/v1_0_0/StorageController_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/StorageController/v1_0_0/StorageController_V1_0_0_Dxe.c new file mode 100644 index 00000000000..d25e750a9d8 --- /dev/null +++ b/RedfishClientPkg/Converter/StorageController/v1_0_0/StorageController_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - StorageController.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#StorageController"; +BOOLEAN IsRevisonController = TRUE; + +// Support StorageController V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "StorageController", + "1", + "0", + "0" + }, + "StorageController" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageControllerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGECONTROLLER_V1_0_0 *StorageControllerV1_0_0; + EFI_REDFISH_STORAGECONTROLLER_V1_0_0_CS *StorageControllerV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "StorageController") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_StorageController_V1_0_0_To_CS (ResoruceRaw, &StorageControllerV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageControllerV1_0_0 = (EFI_REDFISH_STORAGECONTROLLER_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGECONTROLLER_V1_0_0)); + if (StorageControllerV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageControllerV1_0_0; + StorageControllerV1_0_0->StorageController = StorageControllerV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("StorageController")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("StorageController"), "StorageController"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("StorageController")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("StorageController"), "StorageController"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageControllerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageControllerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageControllerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageControllerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_StorageController_V1_0_0_JSON (*((EFI_REDFISH_STORAGECONTROLLER_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageControllerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageControllerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGECONTROLLER_V1_0_0 *StorageControllerV1_0_0; + + StorageControllerV1_0_0 = (EFI_REDFISH_STORAGECONTROLLER_V1_0_0 *)InterpProp; + DestroyStorageController_V1_0_0_CS (StorageControllerV1_0_0->StorageController); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageControllerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageControllerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorageController_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorageController_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageControllerToStructWrapper, + StorageControllerToJson, + StorageControllerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorageController_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/StorageController/v1_0_1/RedfishStorageController_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/StorageController/v1_0_1/RedfishStorageController_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..fee6a5df7ff --- /dev/null +++ b/RedfishClientPkg/Converter/StorageController/v1_0_1/RedfishStorageController_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of StorageController.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorageController_V1_0_1_Dxe + FILE_GUID = 85589af4-5005-4cca-bdcf-b8f1acdd2554 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorageController_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishStorageController_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + StorageController_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageControllerV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/StorageController/v1_0_1/StorageController_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/StorageController/v1_0_1/StorageController_V1_0_1_Dxe.c new file mode 100644 index 00000000000..5b66a6ff804 --- /dev/null +++ b/RedfishClientPkg/Converter/StorageController/v1_0_1/StorageController_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - StorageController.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#StorageController"; +BOOLEAN IsRevisonController = TRUE; + +// Support StorageController V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "StorageController", + "1", + "0", + "1" + }, + "StorageController" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageControllerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGECONTROLLER_V1_0_1 *StorageControllerV1_0_1; + EFI_REDFISH_STORAGECONTROLLER_V1_0_1_CS *StorageControllerV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "StorageController") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_StorageController_V1_0_1_To_CS (ResoruceRaw, &StorageControllerV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageControllerV1_0_1 = (EFI_REDFISH_STORAGECONTROLLER_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGECONTROLLER_V1_0_1)); + if (StorageControllerV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageControllerV1_0_1; + StorageControllerV1_0_1->StorageController = StorageControllerV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("StorageController")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("StorageController"), "StorageController"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("StorageController")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("StorageController"), "StorageController"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageControllerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageControllerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageControllerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageControllerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_StorageController_V1_0_1_JSON (*((EFI_REDFISH_STORAGECONTROLLER_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageControllerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageControllerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGECONTROLLER_V1_0_1 *StorageControllerV1_0_1; + + StorageControllerV1_0_1 = (EFI_REDFISH_STORAGECONTROLLER_V1_0_1 *)InterpProp; + DestroyStorageController_V1_0_1_CS (StorageControllerV1_0_1->StorageController); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageControllerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageControllerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorageController_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorageController_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageControllerToStructWrapper, + StorageControllerToJson, + StorageControllerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorageController_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/StorageController/v1_1_0/RedfishStorageController_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/StorageController/v1_1_0/RedfishStorageController_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..6f56169177a --- /dev/null +++ b/RedfishClientPkg/Converter/StorageController/v1_1_0/RedfishStorageController_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of StorageController.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorageController_V1_1_0_Dxe + FILE_GUID = 03f823a2-8333-4aa9-af3c-020f59c9a305 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorageController_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishStorageController_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + StorageController_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageControllerV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/StorageController/v1_1_0/StorageController_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/StorageController/v1_1_0/StorageController_V1_1_0_Dxe.c new file mode 100644 index 00000000000..0ff149e1e27 --- /dev/null +++ b/RedfishClientPkg/Converter/StorageController/v1_1_0/StorageController_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - StorageController.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#StorageController"; +BOOLEAN IsRevisonController = TRUE; + +// Support StorageController V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "StorageController", + "1", + "1", + "0" + }, + "StorageController" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageControllerToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGECONTROLLER_V1_1_0 *StorageControllerV1_1_0; + EFI_REDFISH_STORAGECONTROLLER_V1_1_0_CS *StorageControllerV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "StorageController") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_StorageController_V1_1_0_To_CS (ResoruceRaw, &StorageControllerV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageControllerV1_1_0 = (EFI_REDFISH_STORAGECONTROLLER_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGECONTROLLER_V1_1_0)); + if (StorageControllerV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageControllerV1_1_0; + StorageControllerV1_1_0->StorageController = StorageControllerV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("StorageController")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("StorageController"), "StorageController"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("StorageController")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("StorageController"), "StorageController"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageControllerToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageControllerToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageControllerToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageControllerToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_StorageController_V1_1_0_JSON (*((EFI_REDFISH_STORAGECONTROLLER_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageControllerToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageControllerDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGECONTROLLER_V1_1_0 *StorageControllerV1_1_0; + + StorageControllerV1_1_0 = (EFI_REDFISH_STORAGECONTROLLER_V1_1_0 *)InterpProp; + DestroyStorageController_V1_1_0_CS (StorageControllerV1_1_0->StorageController); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageControllerFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageControllerDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorageController_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorageController_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageControllerToStructWrapper, + StorageControllerToJson, + StorageControllerDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorageController_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/StorageControllerCollection/RedfishStorageControllerCollection_Dxe.inf b/RedfishClientPkg/Converter/StorageControllerCollection/RedfishStorageControllerCollection_Dxe.inf new file mode 100644 index 00000000000..888905a19fb --- /dev/null +++ b/RedfishClientPkg/Converter/StorageControllerCollection/RedfishStorageControllerCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of StorageControllerCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishStorageControllerCollection_Dxe + FILE_GUID = 3b546222-4da3-462e-9d71-97f21efe7499 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishStorageControllerCollectionEntryPoint + UNLOAD_IMAGE = RedfishStorageControllerCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + StorageControllerCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + StorageControllerCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/StorageControllerCollection/StorageControllerCollection_Dxe.c b/RedfishClientPkg/Converter/StorageControllerCollection/StorageControllerCollection_Dxe.c new file mode 100644 index 00000000000..953033bc5c0 --- /dev/null +++ b/RedfishClientPkg/Converter/StorageControllerCollection/StorageControllerCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - StorageControllerCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#StorageControllerCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support StorageControllerCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "StorageControllerCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "StorageControllerCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageControllerCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_STORAGECONTROLLERCOLLECTION *StorageControllerCollection; + EFI_REDFISH_STORAGECONTROLLERCOLLECTION_CS *StorageControllerCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "StorageControllerCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_StorageControllerCollection_To_CS (ResoruceRaw, &StorageControllerCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + StorageControllerCollection = (EFI_REDFISH_STORAGECONTROLLERCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_STORAGECONTROLLERCOLLECTION)); + if (StorageControllerCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)StorageControllerCollection; + StorageControllerCollection->StorageControllerCollection = StorageControllerCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("StorageControllerCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("StorageControllerCollection"), "StorageControllerCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("StorageControllerCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("StorageControllerCollection"), "StorageControllerCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of StorageControllerCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageControllerCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return StorageControllerCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageControllerCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_StorageControllerCollection_JSON (*((EFI_REDFISH_STORAGECONTROLLERCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in StorageControllerCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageControllerCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_STORAGECONTROLLERCOLLECTION *StorageControllerCollection; + + StorageControllerCollection = (EFI_REDFISH_STORAGECONTROLLERCOLLECTION *)InterpProp; + DestroyStorageControllerCollection_CS (StorageControllerCollection->StorageControllerCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from StorageControllerCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +StorageControllerCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyStorageControllerCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishStorageControllerCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + StorageControllerCollectionToStructWrapper, + StorageControllerCollectionToJson, + StorageControllerCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishStorageControllerCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Switch/v1_0_0/RedfishSwitch_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Switch/v1_0_0/RedfishSwitch_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..533120bcb68 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_0_0/RedfishSwitch_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Switch.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSwitch_V1_0_0_Dxe + FILE_GUID = 43bd28cf-f4f9-4b8f-90ad-c916bccde479 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSwitch_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishSwitch_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Switch_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SwitchV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Switch/v1_0_0/Switch_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Switch/v1_0_0/Switch_V1_0_0_Dxe.c new file mode 100644 index 00000000000..83d25db7b72 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_0_0/Switch_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Switch.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Switch"; +BOOLEAN IsRevisonController = TRUE; + +// Support Switch V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Switch", + "1", + "0", + "0" + }, + "Switch" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_0_0 *SwitchV1_0_0; + EFI_REDFISH_SWITCH_V1_0_0_CS *SwitchV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Switch") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Switch_V1_0_0_To_CS (ResoruceRaw, &SwitchV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SwitchV1_0_0 = (EFI_REDFISH_SWITCH_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SWITCH_V1_0_0)); + if (SwitchV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SwitchV1_0_0; + SwitchV1_0_0->Switch = SwitchV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Switch"), "Switch"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Switch"), "Switch"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SwitchToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SwitchToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Switch_V1_0_0_JSON (*((EFI_REDFISH_SWITCH_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SwitchToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_0_0 *SwitchV1_0_0; + + SwitchV1_0_0 = (EFI_REDFISH_SWITCH_V1_0_0 *)InterpProp; + DestroySwitch_V1_0_0_CS (SwitchV1_0_0->Switch); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SwitchFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySwitch_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SwitchToStructWrapper, + SwitchToJson, + SwitchDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Switch/v1_0_1/RedfishSwitch_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/Switch/v1_0_1/RedfishSwitch_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..18d04c673b9 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_0_1/RedfishSwitch_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Switch.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSwitch_V1_0_1_Dxe + FILE_GUID = 3f9e4f00-641d-4492-a73c-c084fc7005fc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSwitch_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishSwitch_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Switch_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SwitchV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Switch/v1_0_1/Switch_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/Switch/v1_0_1/Switch_V1_0_1_Dxe.c new file mode 100644 index 00000000000..fc46f7baccb --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_0_1/Switch_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Switch.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Switch"; +BOOLEAN IsRevisonController = TRUE; + +// Support Switch V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Switch", + "1", + "0", + "1" + }, + "Switch" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_0_1 *SwitchV1_0_1; + EFI_REDFISH_SWITCH_V1_0_1_CS *SwitchV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Switch") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Switch_V1_0_1_To_CS (ResoruceRaw, &SwitchV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SwitchV1_0_1 = (EFI_REDFISH_SWITCH_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SWITCH_V1_0_1)); + if (SwitchV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SwitchV1_0_1; + SwitchV1_0_1->Switch = SwitchV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Switch"), "Switch"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Switch"), "Switch"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SwitchToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SwitchToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Switch_V1_0_1_JSON (*((EFI_REDFISH_SWITCH_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SwitchToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_0_1 *SwitchV1_0_1; + + SwitchV1_0_1 = (EFI_REDFISH_SWITCH_V1_0_1 *)InterpProp; + DestroySwitch_V1_0_1_CS (SwitchV1_0_1->Switch); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SwitchFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySwitch_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SwitchToStructWrapper, + SwitchToJson, + SwitchDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Switch/v1_0_2/RedfishSwitch_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Switch/v1_0_2/RedfishSwitch_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..7f5ac40392a --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_0_2/RedfishSwitch_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Switch.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSwitch_V1_0_2_Dxe + FILE_GUID = 51158429-1137-41a6-86c7-98313e7db3a5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSwitch_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishSwitch_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Switch_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SwitchV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Switch/v1_0_2/Switch_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Switch/v1_0_2/Switch_V1_0_2_Dxe.c new file mode 100644 index 00000000000..0ae972cfa24 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_0_2/Switch_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Switch.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Switch"; +BOOLEAN IsRevisonController = TRUE; + +// Support Switch V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Switch", + "1", + "0", + "2" + }, + "Switch" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_0_2 *SwitchV1_0_2; + EFI_REDFISH_SWITCH_V1_0_2_CS *SwitchV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Switch") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Switch_V1_0_2_To_CS (ResoruceRaw, &SwitchV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SwitchV1_0_2 = (EFI_REDFISH_SWITCH_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SWITCH_V1_0_2)); + if (SwitchV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SwitchV1_0_2; + SwitchV1_0_2->Switch = SwitchV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Switch"), "Switch"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Switch"), "Switch"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SwitchToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SwitchToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Switch_V1_0_2_JSON (*((EFI_REDFISH_SWITCH_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SwitchToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_0_2 *SwitchV1_0_2; + + SwitchV1_0_2 = (EFI_REDFISH_SWITCH_V1_0_2 *)InterpProp; + DestroySwitch_V1_0_2_CS (SwitchV1_0_2->Switch); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SwitchFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySwitch_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SwitchToStructWrapper, + SwitchToJson, + SwitchDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Switch/v1_0_3/RedfishSwitch_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/Switch/v1_0_3/RedfishSwitch_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..b25189fdb70 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_0_3/RedfishSwitch_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Switch.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSwitch_V1_0_3_Dxe + FILE_GUID = 06efd568-3413-41d0-aa51-1dd39ff66b0a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSwitch_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishSwitch_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Switch_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SwitchV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Switch/v1_0_3/Switch_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/Switch/v1_0_3/Switch_V1_0_3_Dxe.c new file mode 100644 index 00000000000..e9992660c32 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_0_3/Switch_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Switch.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Switch"; +BOOLEAN IsRevisonController = TRUE; + +// Support Switch V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Switch", + "1", + "0", + "3" + }, + "Switch" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_0_3 *SwitchV1_0_3; + EFI_REDFISH_SWITCH_V1_0_3_CS *SwitchV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Switch") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Switch_V1_0_3_To_CS (ResoruceRaw, &SwitchV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SwitchV1_0_3 = (EFI_REDFISH_SWITCH_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SWITCH_V1_0_3)); + if (SwitchV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SwitchV1_0_3; + SwitchV1_0_3->Switch = SwitchV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Switch"), "Switch"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Switch"), "Switch"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SwitchToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SwitchToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Switch_V1_0_3_JSON (*((EFI_REDFISH_SWITCH_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SwitchToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_0_3 *SwitchV1_0_3; + + SwitchV1_0_3 = (EFI_REDFISH_SWITCH_V1_0_3 *)InterpProp; + DestroySwitch_V1_0_3_CS (SwitchV1_0_3->Switch); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SwitchFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySwitch_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SwitchToStructWrapper, + SwitchToJson, + SwitchDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Switch/v1_0_4/RedfishSwitch_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/Switch/v1_0_4/RedfishSwitch_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..6c03d99af5a --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_0_4/RedfishSwitch_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Switch.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSwitch_V1_0_4_Dxe + FILE_GUID = cfc94b62-7831-4645-842e-7aaaa7eee985 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSwitch_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishSwitch_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Switch_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SwitchV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Switch/v1_0_4/Switch_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/Switch/v1_0_4/Switch_V1_0_4_Dxe.c new file mode 100644 index 00000000000..918d4284928 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_0_4/Switch_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Switch.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Switch"; +BOOLEAN IsRevisonController = TRUE; + +// Support Switch V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Switch", + "1", + "0", + "4" + }, + "Switch" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_0_4 *SwitchV1_0_4; + EFI_REDFISH_SWITCH_V1_0_4_CS *SwitchV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Switch") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Switch_V1_0_4_To_CS (ResoruceRaw, &SwitchV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SwitchV1_0_4 = (EFI_REDFISH_SWITCH_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SWITCH_V1_0_4)); + if (SwitchV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SwitchV1_0_4; + SwitchV1_0_4->Switch = SwitchV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Switch"), "Switch"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Switch"), "Switch"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SwitchToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SwitchToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Switch_V1_0_4_JSON (*((EFI_REDFISH_SWITCH_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SwitchToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_0_4 *SwitchV1_0_4; + + SwitchV1_0_4 = (EFI_REDFISH_SWITCH_V1_0_4 *)InterpProp; + DestroySwitch_V1_0_4_CS (SwitchV1_0_4->Switch); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SwitchFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySwitch_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SwitchToStructWrapper, + SwitchToJson, + SwitchDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Switch/v1_0_5/RedfishSwitch_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/Switch/v1_0_5/RedfishSwitch_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..1e7f1c87741 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_0_5/RedfishSwitch_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Switch.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSwitch_V1_0_5_Dxe + FILE_GUID = aefecf02-fdf1-4a6b-9b80-1ea4ab4d623e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSwitch_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishSwitch_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Switch_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SwitchV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Switch/v1_0_5/Switch_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/Switch/v1_0_5/Switch_V1_0_5_Dxe.c new file mode 100644 index 00000000000..418d61db78c --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_0_5/Switch_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Switch.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Switch"; +BOOLEAN IsRevisonController = TRUE; + +// Support Switch V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Switch", + "1", + "0", + "5" + }, + "Switch" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_0_5 *SwitchV1_0_5; + EFI_REDFISH_SWITCH_V1_0_5_CS *SwitchV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Switch") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Switch_V1_0_5_To_CS (ResoruceRaw, &SwitchV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SwitchV1_0_5 = (EFI_REDFISH_SWITCH_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SWITCH_V1_0_5)); + if (SwitchV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SwitchV1_0_5; + SwitchV1_0_5->Switch = SwitchV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Switch"), "Switch"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Switch"), "Switch"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SwitchToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SwitchToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Switch_V1_0_5_JSON (*((EFI_REDFISH_SWITCH_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SwitchToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_0_5 *SwitchV1_0_5; + + SwitchV1_0_5 = (EFI_REDFISH_SWITCH_V1_0_5 *)InterpProp; + DestroySwitch_V1_0_5_CS (SwitchV1_0_5->Switch); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SwitchFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySwitch_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SwitchToStructWrapper, + SwitchToJson, + SwitchDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Switch/v1_0_6/RedfishSwitch_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/Switch/v1_0_6/RedfishSwitch_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..54a14dbc519 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_0_6/RedfishSwitch_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Switch.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSwitch_V1_0_6_Dxe + FILE_GUID = 023067be-bf08-4737-99ab-dabf9f584334 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSwitch_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishSwitch_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Switch_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SwitchV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Switch/v1_0_6/Switch_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/Switch/v1_0_6/Switch_V1_0_6_Dxe.c new file mode 100644 index 00000000000..2d049ea55fa --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_0_6/Switch_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Switch.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Switch"; +BOOLEAN IsRevisonController = TRUE; + +// Support Switch V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Switch", + "1", + "0", + "6" + }, + "Switch" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_0_6 *SwitchV1_0_6; + EFI_REDFISH_SWITCH_V1_0_6_CS *SwitchV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Switch") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Switch_V1_0_6_To_CS (ResoruceRaw, &SwitchV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SwitchV1_0_6 = (EFI_REDFISH_SWITCH_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SWITCH_V1_0_6)); + if (SwitchV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SwitchV1_0_6; + SwitchV1_0_6->Switch = SwitchV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Switch"), "Switch"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Switch"), "Switch"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SwitchToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SwitchToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Switch_V1_0_6_JSON (*((EFI_REDFISH_SWITCH_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SwitchToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_0_6 *SwitchV1_0_6; + + SwitchV1_0_6 = (EFI_REDFISH_SWITCH_V1_0_6 *)InterpProp; + DestroySwitch_V1_0_6_CS (SwitchV1_0_6->Switch); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SwitchFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySwitch_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SwitchToStructWrapper, + SwitchToJson, + SwitchDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Switch/v1_0_7/RedfishSwitch_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/Switch/v1_0_7/RedfishSwitch_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..212d18c013c --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_0_7/RedfishSwitch_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Switch.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSwitch_V1_0_7_Dxe + FILE_GUID = 86b06298-82d0-4754-9945-feb3aaa8b28f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSwitch_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishSwitch_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Switch_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SwitchV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Switch/v1_0_7/Switch_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/Switch/v1_0_7/Switch_V1_0_7_Dxe.c new file mode 100644 index 00000000000..5f424d2e18b --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_0_7/Switch_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Switch.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Switch"; +BOOLEAN IsRevisonController = TRUE; + +// Support Switch V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Switch", + "1", + "0", + "7" + }, + "Switch" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_0_7 *SwitchV1_0_7; + EFI_REDFISH_SWITCH_V1_0_7_CS *SwitchV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Switch") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Switch_V1_0_7_To_CS (ResoruceRaw, &SwitchV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SwitchV1_0_7 = (EFI_REDFISH_SWITCH_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SWITCH_V1_0_7)); + if (SwitchV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SwitchV1_0_7; + SwitchV1_0_7->Switch = SwitchV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Switch"), "Switch"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Switch"), "Switch"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SwitchToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SwitchToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Switch_V1_0_7_JSON (*((EFI_REDFISH_SWITCH_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SwitchToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_0_7 *SwitchV1_0_7; + + SwitchV1_0_7 = (EFI_REDFISH_SWITCH_V1_0_7 *)InterpProp; + DestroySwitch_V1_0_7_CS (SwitchV1_0_7->Switch); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SwitchFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySwitch_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SwitchToStructWrapper, + SwitchToJson, + SwitchDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Switch/v1_0_8/RedfishSwitch_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/Switch/v1_0_8/RedfishSwitch_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..8c8dfa56615 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_0_8/RedfishSwitch_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Switch.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSwitch_V1_0_8_Dxe + FILE_GUID = bacf8ef4-6fd6-4cd1-b5db-688e01a9c8c1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSwitch_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishSwitch_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Switch_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SwitchV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Switch/v1_0_8/Switch_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/Switch/v1_0_8/Switch_V1_0_8_Dxe.c new file mode 100644 index 00000000000..82ef624eaf3 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_0_8/Switch_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Switch.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Switch"; +BOOLEAN IsRevisonController = TRUE; + +// Support Switch V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Switch", + "1", + "0", + "8" + }, + "Switch" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_0_8 *SwitchV1_0_8; + EFI_REDFISH_SWITCH_V1_0_8_CS *SwitchV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Switch") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Switch_V1_0_8_To_CS (ResoruceRaw, &SwitchV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SwitchV1_0_8 = (EFI_REDFISH_SWITCH_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SWITCH_V1_0_8)); + if (SwitchV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SwitchV1_0_8; + SwitchV1_0_8->Switch = SwitchV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Switch"), "Switch"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Switch"), "Switch"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SwitchToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SwitchToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Switch_V1_0_8_JSON (*((EFI_REDFISH_SWITCH_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SwitchToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_0_8 *SwitchV1_0_8; + + SwitchV1_0_8 = (EFI_REDFISH_SWITCH_V1_0_8 *)InterpProp; + DestroySwitch_V1_0_8_CS (SwitchV1_0_8->Switch); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SwitchFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySwitch_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SwitchToStructWrapper, + SwitchToJson, + SwitchDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Switch/v1_1_0/RedfishSwitch_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/Switch/v1_1_0/RedfishSwitch_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..01dcaba9e73 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_1_0/RedfishSwitch_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Switch.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSwitch_V1_1_0_Dxe + FILE_GUID = 8e3e3a12-4798-4c84-a23f-1b98ba45847b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSwitch_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishSwitch_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Switch_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SwitchV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Switch/v1_1_0/Switch_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/Switch/v1_1_0/Switch_V1_1_0_Dxe.c new file mode 100644 index 00000000000..3427b51800b --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_1_0/Switch_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Switch.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Switch"; +BOOLEAN IsRevisonController = TRUE; + +// Support Switch V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Switch", + "1", + "1", + "0" + }, + "Switch" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_1_0 *SwitchV1_1_0; + EFI_REDFISH_SWITCH_V1_1_0_CS *SwitchV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Switch") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Switch_V1_1_0_To_CS (ResoruceRaw, &SwitchV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SwitchV1_1_0 = (EFI_REDFISH_SWITCH_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SWITCH_V1_1_0)); + if (SwitchV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SwitchV1_1_0; + SwitchV1_1_0->Switch = SwitchV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Switch"), "Switch"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Switch"), "Switch"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SwitchToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SwitchToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Switch_V1_1_0_JSON (*((EFI_REDFISH_SWITCH_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SwitchToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_1_0 *SwitchV1_1_0; + + SwitchV1_1_0 = (EFI_REDFISH_SWITCH_V1_1_0 *)InterpProp; + DestroySwitch_V1_1_0_CS (SwitchV1_1_0->Switch); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SwitchFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySwitch_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SwitchToStructWrapper, + SwitchToJson, + SwitchDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Switch/v1_1_1/RedfishSwitch_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/Switch/v1_1_1/RedfishSwitch_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..9038f7c5b7d --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_1_1/RedfishSwitch_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Switch.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSwitch_V1_1_1_Dxe + FILE_GUID = dd46556b-ae61-4b47-a892-26d27cc8bff9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSwitch_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishSwitch_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Switch_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SwitchV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Switch/v1_1_1/Switch_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/Switch/v1_1_1/Switch_V1_1_1_Dxe.c new file mode 100644 index 00000000000..f5482382998 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_1_1/Switch_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Switch.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Switch"; +BOOLEAN IsRevisonController = TRUE; + +// Support Switch V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Switch", + "1", + "1", + "1" + }, + "Switch" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_1_1 *SwitchV1_1_1; + EFI_REDFISH_SWITCH_V1_1_1_CS *SwitchV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Switch") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Switch_V1_1_1_To_CS (ResoruceRaw, &SwitchV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SwitchV1_1_1 = (EFI_REDFISH_SWITCH_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SWITCH_V1_1_1)); + if (SwitchV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SwitchV1_1_1; + SwitchV1_1_1->Switch = SwitchV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Switch"), "Switch"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Switch"), "Switch"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SwitchToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SwitchToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Switch_V1_1_1_JSON (*((EFI_REDFISH_SWITCH_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SwitchToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_1_1 *SwitchV1_1_1; + + SwitchV1_1_1 = (EFI_REDFISH_SWITCH_V1_1_1 *)InterpProp; + DestroySwitch_V1_1_1_CS (SwitchV1_1_1->Switch); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SwitchFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySwitch_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SwitchToStructWrapper, + SwitchToJson, + SwitchDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Switch/v1_1_2/RedfishSwitch_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/Switch/v1_1_2/RedfishSwitch_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..e2094cb2df1 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_1_2/RedfishSwitch_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Switch.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSwitch_V1_1_2_Dxe + FILE_GUID = ccf44891-1c11-4fa0-8e69-eb172c894c90 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSwitch_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishSwitch_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Switch_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SwitchV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Switch/v1_1_2/Switch_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/Switch/v1_1_2/Switch_V1_1_2_Dxe.c new file mode 100644 index 00000000000..bf90172dcbe --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_1_2/Switch_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Switch.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Switch"; +BOOLEAN IsRevisonController = TRUE; + +// Support Switch V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Switch", + "1", + "1", + "2" + }, + "Switch" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_1_2 *SwitchV1_1_2; + EFI_REDFISH_SWITCH_V1_1_2_CS *SwitchV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Switch") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Switch_V1_1_2_To_CS (ResoruceRaw, &SwitchV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SwitchV1_1_2 = (EFI_REDFISH_SWITCH_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SWITCH_V1_1_2)); + if (SwitchV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SwitchV1_1_2; + SwitchV1_1_2->Switch = SwitchV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Switch"), "Switch"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Switch"), "Switch"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SwitchToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SwitchToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Switch_V1_1_2_JSON (*((EFI_REDFISH_SWITCH_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SwitchToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_1_2 *SwitchV1_1_2; + + SwitchV1_1_2 = (EFI_REDFISH_SWITCH_V1_1_2 *)InterpProp; + DestroySwitch_V1_1_2_CS (SwitchV1_1_2->Switch); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SwitchFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySwitch_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SwitchToStructWrapper, + SwitchToJson, + SwitchDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Switch/v1_1_3/RedfishSwitch_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/Switch/v1_1_3/RedfishSwitch_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..728a4c69e67 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_1_3/RedfishSwitch_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Switch.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSwitch_V1_1_3_Dxe + FILE_GUID = 5b39fc98-e961-4cc2-957c-37170a6672d1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSwitch_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishSwitch_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Switch_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SwitchV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Switch/v1_1_3/Switch_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/Switch/v1_1_3/Switch_V1_1_3_Dxe.c new file mode 100644 index 00000000000..f810322f06d --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_1_3/Switch_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Switch.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Switch"; +BOOLEAN IsRevisonController = TRUE; + +// Support Switch V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Switch", + "1", + "1", + "3" + }, + "Switch" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_1_3 *SwitchV1_1_3; + EFI_REDFISH_SWITCH_V1_1_3_CS *SwitchV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Switch") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Switch_V1_1_3_To_CS (ResoruceRaw, &SwitchV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SwitchV1_1_3 = (EFI_REDFISH_SWITCH_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SWITCH_V1_1_3)); + if (SwitchV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SwitchV1_1_3; + SwitchV1_1_3->Switch = SwitchV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Switch"), "Switch"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Switch"), "Switch"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SwitchToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SwitchToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Switch_V1_1_3_JSON (*((EFI_REDFISH_SWITCH_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SwitchToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_1_3 *SwitchV1_1_3; + + SwitchV1_1_3 = (EFI_REDFISH_SWITCH_V1_1_3 *)InterpProp; + DestroySwitch_V1_1_3_CS (SwitchV1_1_3->Switch); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SwitchFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySwitch_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SwitchToStructWrapper, + SwitchToJson, + SwitchDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Switch/v1_1_4/RedfishSwitch_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/Switch/v1_1_4/RedfishSwitch_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..d25cd525e85 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_1_4/RedfishSwitch_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Switch.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSwitch_V1_1_4_Dxe + FILE_GUID = 9b253b6b-a481-487d-8e34-24ba00a2d62f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSwitch_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishSwitch_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Switch_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SwitchV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Switch/v1_1_4/Switch_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/Switch/v1_1_4/Switch_V1_1_4_Dxe.c new file mode 100644 index 00000000000..0a6a00cb718 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_1_4/Switch_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Switch.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Switch"; +BOOLEAN IsRevisonController = TRUE; + +// Support Switch V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Switch", + "1", + "1", + "4" + }, + "Switch" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_1_4 *SwitchV1_1_4; + EFI_REDFISH_SWITCH_V1_1_4_CS *SwitchV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Switch") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Switch_V1_1_4_To_CS (ResoruceRaw, &SwitchV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SwitchV1_1_4 = (EFI_REDFISH_SWITCH_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SWITCH_V1_1_4)); + if (SwitchV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SwitchV1_1_4; + SwitchV1_1_4->Switch = SwitchV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Switch"), "Switch"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Switch"), "Switch"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SwitchToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SwitchToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Switch_V1_1_4_JSON (*((EFI_REDFISH_SWITCH_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SwitchToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_1_4 *SwitchV1_1_4; + + SwitchV1_1_4 = (EFI_REDFISH_SWITCH_V1_1_4 *)InterpProp; + DestroySwitch_V1_1_4_CS (SwitchV1_1_4->Switch); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SwitchFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySwitch_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SwitchToStructWrapper, + SwitchToJson, + SwitchDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Switch/v1_1_5/RedfishSwitch_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/Switch/v1_1_5/RedfishSwitch_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..0038274f771 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_1_5/RedfishSwitch_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Switch.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSwitch_V1_1_5_Dxe + FILE_GUID = d3caecb2-883a-4f41-a787-ee308fa6c3b5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSwitch_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishSwitch_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Switch_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SwitchV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Switch/v1_1_5/Switch_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/Switch/v1_1_5/Switch_V1_1_5_Dxe.c new file mode 100644 index 00000000000..604e5f72243 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_1_5/Switch_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Switch.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Switch"; +BOOLEAN IsRevisonController = TRUE; + +// Support Switch V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Switch", + "1", + "1", + "5" + }, + "Switch" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_1_5 *SwitchV1_1_5; + EFI_REDFISH_SWITCH_V1_1_5_CS *SwitchV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Switch") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Switch_V1_1_5_To_CS (ResoruceRaw, &SwitchV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SwitchV1_1_5 = (EFI_REDFISH_SWITCH_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SWITCH_V1_1_5)); + if (SwitchV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SwitchV1_1_5; + SwitchV1_1_5->Switch = SwitchV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Switch"), "Switch"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Switch"), "Switch"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SwitchToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SwitchToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Switch_V1_1_5_JSON (*((EFI_REDFISH_SWITCH_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SwitchToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_1_5 *SwitchV1_1_5; + + SwitchV1_1_5 = (EFI_REDFISH_SWITCH_V1_1_5 *)InterpProp; + DestroySwitch_V1_1_5_CS (SwitchV1_1_5->Switch); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SwitchFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySwitch_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SwitchToStructWrapper, + SwitchToJson, + SwitchDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Switch/v1_2_0/RedfishSwitch_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/Switch/v1_2_0/RedfishSwitch_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..b1ad946b8f1 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_2_0/RedfishSwitch_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Switch.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSwitch_V1_2_0_Dxe + FILE_GUID = 327ec69b-dfce-410d-8287-571a80e5da93 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSwitch_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishSwitch_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Switch_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SwitchV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Switch/v1_2_0/Switch_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/Switch/v1_2_0/Switch_V1_2_0_Dxe.c new file mode 100644 index 00000000000..eada247f2a8 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_2_0/Switch_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Switch.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Switch"; +BOOLEAN IsRevisonController = TRUE; + +// Support Switch V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Switch", + "1", + "2", + "0" + }, + "Switch" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_2_0 *SwitchV1_2_0; + EFI_REDFISH_SWITCH_V1_2_0_CS *SwitchV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Switch") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Switch_V1_2_0_To_CS (ResoruceRaw, &SwitchV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SwitchV1_2_0 = (EFI_REDFISH_SWITCH_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SWITCH_V1_2_0)); + if (SwitchV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SwitchV1_2_0; + SwitchV1_2_0->Switch = SwitchV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Switch"), "Switch"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Switch"), "Switch"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SwitchToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SwitchToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Switch_V1_2_0_JSON (*((EFI_REDFISH_SWITCH_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SwitchToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_2_0 *SwitchV1_2_0; + + SwitchV1_2_0 = (EFI_REDFISH_SWITCH_V1_2_0 *)InterpProp; + DestroySwitch_V1_2_0_CS (SwitchV1_2_0->Switch); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SwitchFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySwitch_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SwitchToStructWrapper, + SwitchToJson, + SwitchDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Switch/v1_2_1/RedfishSwitch_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/Switch/v1_2_1/RedfishSwitch_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..465d0a60a0c --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_2_1/RedfishSwitch_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Switch.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSwitch_V1_2_1_Dxe + FILE_GUID = d317816d-4d40-478b-a095-1050374ffd99 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSwitch_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishSwitch_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Switch_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SwitchV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Switch/v1_2_1/Switch_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/Switch/v1_2_1/Switch_V1_2_1_Dxe.c new file mode 100644 index 00000000000..154a1ff47bc --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_2_1/Switch_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Switch.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Switch"; +BOOLEAN IsRevisonController = TRUE; + +// Support Switch V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Switch", + "1", + "2", + "1" + }, + "Switch" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_2_1 *SwitchV1_2_1; + EFI_REDFISH_SWITCH_V1_2_1_CS *SwitchV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Switch") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Switch_V1_2_1_To_CS (ResoruceRaw, &SwitchV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SwitchV1_2_1 = (EFI_REDFISH_SWITCH_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SWITCH_V1_2_1)); + if (SwitchV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SwitchV1_2_1; + SwitchV1_2_1->Switch = SwitchV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Switch"), "Switch"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Switch"), "Switch"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SwitchToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SwitchToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Switch_V1_2_1_JSON (*((EFI_REDFISH_SWITCH_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SwitchToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_2_1 *SwitchV1_2_1; + + SwitchV1_2_1 = (EFI_REDFISH_SWITCH_V1_2_1 *)InterpProp; + DestroySwitch_V1_2_1_CS (SwitchV1_2_1->Switch); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SwitchFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySwitch_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SwitchToStructWrapper, + SwitchToJson, + SwitchDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Switch/v1_2_2/RedfishSwitch_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/Switch/v1_2_2/RedfishSwitch_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..638b1e96988 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_2_2/RedfishSwitch_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Switch.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSwitch_V1_2_2_Dxe + FILE_GUID = 619a4ef1-bdae-4883-a669-7058e18e009a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSwitch_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishSwitch_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Switch_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SwitchV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Switch/v1_2_2/Switch_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/Switch/v1_2_2/Switch_V1_2_2_Dxe.c new file mode 100644 index 00000000000..1acde91c5c5 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_2_2/Switch_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Switch.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Switch"; +BOOLEAN IsRevisonController = TRUE; + +// Support Switch V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Switch", + "1", + "2", + "2" + }, + "Switch" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_2_2 *SwitchV1_2_2; + EFI_REDFISH_SWITCH_V1_2_2_CS *SwitchV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Switch") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Switch_V1_2_2_To_CS (ResoruceRaw, &SwitchV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SwitchV1_2_2 = (EFI_REDFISH_SWITCH_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SWITCH_V1_2_2)); + if (SwitchV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SwitchV1_2_2; + SwitchV1_2_2->Switch = SwitchV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Switch"), "Switch"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Switch"), "Switch"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SwitchToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SwitchToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Switch_V1_2_2_JSON (*((EFI_REDFISH_SWITCH_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SwitchToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_2_2 *SwitchV1_2_2; + + SwitchV1_2_2 = (EFI_REDFISH_SWITCH_V1_2_2 *)InterpProp; + DestroySwitch_V1_2_2_CS (SwitchV1_2_2->Switch); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SwitchFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySwitch_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SwitchToStructWrapper, + SwitchToJson, + SwitchDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Switch/v1_3_0/RedfishSwitch_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/Switch/v1_3_0/RedfishSwitch_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..943803224ba --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_3_0/RedfishSwitch_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Switch.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSwitch_V1_3_0_Dxe + FILE_GUID = b550f0e3-3194-4ec0-8092-593c25130246 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSwitch_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishSwitch_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Switch_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SwitchV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Switch/v1_3_0/Switch_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/Switch/v1_3_0/Switch_V1_3_0_Dxe.c new file mode 100644 index 00000000000..2bc9fb3e60e --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_3_0/Switch_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Switch.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Switch"; +BOOLEAN IsRevisonController = TRUE; + +// Support Switch V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Switch", + "1", + "3", + "0" + }, + "Switch" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_3_0 *SwitchV1_3_0; + EFI_REDFISH_SWITCH_V1_3_0_CS *SwitchV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Switch") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Switch_V1_3_0_To_CS (ResoruceRaw, &SwitchV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SwitchV1_3_0 = (EFI_REDFISH_SWITCH_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SWITCH_V1_3_0)); + if (SwitchV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SwitchV1_3_0; + SwitchV1_3_0->Switch = SwitchV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Switch"), "Switch"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Switch"), "Switch"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SwitchToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SwitchToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Switch_V1_3_0_JSON (*((EFI_REDFISH_SWITCH_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SwitchToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_3_0 *SwitchV1_3_0; + + SwitchV1_3_0 = (EFI_REDFISH_SWITCH_V1_3_0 *)InterpProp; + DestroySwitch_V1_3_0_CS (SwitchV1_3_0->Switch); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SwitchFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySwitch_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SwitchToStructWrapper, + SwitchToJson, + SwitchDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Switch/v1_3_1/RedfishSwitch_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/Switch/v1_3_1/RedfishSwitch_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..3d9537e2af1 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_3_1/RedfishSwitch_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Switch.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSwitch_V1_3_1_Dxe + FILE_GUID = 4df08d15-11e7-4d07-bf12-940e410bd288 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSwitch_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishSwitch_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Switch_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SwitchV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Switch/v1_3_1/Switch_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/Switch/v1_3_1/Switch_V1_3_1_Dxe.c new file mode 100644 index 00000000000..8619477acb3 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_3_1/Switch_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Switch.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Switch"; +BOOLEAN IsRevisonController = TRUE; + +// Support Switch V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Switch", + "1", + "3", + "1" + }, + "Switch" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_3_1 *SwitchV1_3_1; + EFI_REDFISH_SWITCH_V1_3_1_CS *SwitchV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Switch") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Switch_V1_3_1_To_CS (ResoruceRaw, &SwitchV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SwitchV1_3_1 = (EFI_REDFISH_SWITCH_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SWITCH_V1_3_1)); + if (SwitchV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SwitchV1_3_1; + SwitchV1_3_1->Switch = SwitchV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Switch"), "Switch"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Switch"), "Switch"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SwitchToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SwitchToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Switch_V1_3_1_JSON (*((EFI_REDFISH_SWITCH_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SwitchToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_3_1 *SwitchV1_3_1; + + SwitchV1_3_1 = (EFI_REDFISH_SWITCH_V1_3_1 *)InterpProp; + DestroySwitch_V1_3_1_CS (SwitchV1_3_1->Switch); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SwitchFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySwitch_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SwitchToStructWrapper, + SwitchToJson, + SwitchDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Switch/v1_3_2/RedfishSwitch_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/Switch/v1_3_2/RedfishSwitch_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..7b7212ef7c3 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_3_2/RedfishSwitch_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Switch.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSwitch_V1_3_2_Dxe + FILE_GUID = d3e0deee-b635-4441-8c50-0b1b6007e14e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSwitch_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishSwitch_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Switch_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SwitchV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Switch/v1_3_2/Switch_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/Switch/v1_3_2/Switch_V1_3_2_Dxe.c new file mode 100644 index 00000000000..0883934e4c6 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_3_2/Switch_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Switch.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Switch"; +BOOLEAN IsRevisonController = TRUE; + +// Support Switch V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Switch", + "1", + "3", + "2" + }, + "Switch" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_3_2 *SwitchV1_3_2; + EFI_REDFISH_SWITCH_V1_3_2_CS *SwitchV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Switch") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Switch_V1_3_2_To_CS (ResoruceRaw, &SwitchV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SwitchV1_3_2 = (EFI_REDFISH_SWITCH_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SWITCH_V1_3_2)); + if (SwitchV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SwitchV1_3_2; + SwitchV1_3_2->Switch = SwitchV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Switch"), "Switch"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Switch"), "Switch"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SwitchToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SwitchToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Switch_V1_3_2_JSON (*((EFI_REDFISH_SWITCH_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SwitchToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_3_2 *SwitchV1_3_2; + + SwitchV1_3_2 = (EFI_REDFISH_SWITCH_V1_3_2 *)InterpProp; + DestroySwitch_V1_3_2_CS (SwitchV1_3_2->Switch); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SwitchFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySwitch_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SwitchToStructWrapper, + SwitchToJson, + SwitchDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Switch/v1_4_0/RedfishSwitch_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/Switch/v1_4_0/RedfishSwitch_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..535956e597e --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_4_0/RedfishSwitch_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Switch.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSwitch_V1_4_0_Dxe + FILE_GUID = 697b43f4-ebf2-4976-bedd-b500d8d4686a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSwitch_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishSwitch_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Switch_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SwitchV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Switch/v1_4_0/Switch_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/Switch/v1_4_0/Switch_V1_4_0_Dxe.c new file mode 100644 index 00000000000..e2e7b2b2f03 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_4_0/Switch_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Switch.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Switch"; +BOOLEAN IsRevisonController = TRUE; + +// Support Switch V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Switch", + "1", + "4", + "0" + }, + "Switch" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_4_0 *SwitchV1_4_0; + EFI_REDFISH_SWITCH_V1_4_0_CS *SwitchV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Switch") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Switch_V1_4_0_To_CS (ResoruceRaw, &SwitchV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SwitchV1_4_0 = (EFI_REDFISH_SWITCH_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SWITCH_V1_4_0)); + if (SwitchV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SwitchV1_4_0; + SwitchV1_4_0->Switch = SwitchV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Switch"), "Switch"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Switch"), "Switch"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SwitchToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SwitchToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Switch_V1_4_0_JSON (*((EFI_REDFISH_SWITCH_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SwitchToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_4_0 *SwitchV1_4_0; + + SwitchV1_4_0 = (EFI_REDFISH_SWITCH_V1_4_0 *)InterpProp; + DestroySwitch_V1_4_0_CS (SwitchV1_4_0->Switch); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SwitchFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySwitch_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SwitchToStructWrapper, + SwitchToJson, + SwitchDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Switch/v1_4_1/RedfishSwitch_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/Switch/v1_4_1/RedfishSwitch_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..30c4bf9a69d --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_4_1/RedfishSwitch_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Switch.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSwitch_V1_4_1_Dxe + FILE_GUID = 83ebafb9-821c-42b5-bb62-fb5378d73408 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSwitch_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishSwitch_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Switch_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SwitchV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Switch/v1_4_1/Switch_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/Switch/v1_4_1/Switch_V1_4_1_Dxe.c new file mode 100644 index 00000000000..a11bc3cb3b5 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_4_1/Switch_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Switch.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Switch"; +BOOLEAN IsRevisonController = TRUE; + +// Support Switch V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Switch", + "1", + "4", + "1" + }, + "Switch" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_4_1 *SwitchV1_4_1; + EFI_REDFISH_SWITCH_V1_4_1_CS *SwitchV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Switch") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Switch_V1_4_1_To_CS (ResoruceRaw, &SwitchV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SwitchV1_4_1 = (EFI_REDFISH_SWITCH_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SWITCH_V1_4_1)); + if (SwitchV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SwitchV1_4_1; + SwitchV1_4_1->Switch = SwitchV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Switch"), "Switch"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Switch"), "Switch"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SwitchToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SwitchToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Switch_V1_4_1_JSON (*((EFI_REDFISH_SWITCH_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SwitchToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_4_1 *SwitchV1_4_1; + + SwitchV1_4_1 = (EFI_REDFISH_SWITCH_V1_4_1 *)InterpProp; + DestroySwitch_V1_4_1_CS (SwitchV1_4_1->Switch); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SwitchFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySwitch_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SwitchToStructWrapper, + SwitchToJson, + SwitchDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Switch/v1_5_0/RedfishSwitch_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/Switch/v1_5_0/RedfishSwitch_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..b5b046b7f62 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_5_0/RedfishSwitch_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Switch.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSwitch_V1_5_0_Dxe + FILE_GUID = 4fd72dc9-70fc-4b69-b73e-f6ec7674d271 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSwitch_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishSwitch_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Switch_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SwitchV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Switch/v1_5_0/Switch_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/Switch/v1_5_0/Switch_V1_5_0_Dxe.c new file mode 100644 index 00000000000..2c9aea00a98 --- /dev/null +++ b/RedfishClientPkg/Converter/Switch/v1_5_0/Switch_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Switch.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Switch"; +BOOLEAN IsRevisonController = TRUE; + +// Support Switch V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Switch", + "1", + "5", + "0" + }, + "Switch" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_5_0 *SwitchV1_5_0; + EFI_REDFISH_SWITCH_V1_5_0_CS *SwitchV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Switch") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Switch_V1_5_0_To_CS (ResoruceRaw, &SwitchV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + SwitchV1_5_0 = (EFI_REDFISH_SWITCH_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SWITCH_V1_5_0)); + if (SwitchV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SwitchV1_5_0; + SwitchV1_5_0->Switch = SwitchV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Switch"), "Switch"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Switch")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Switch"), "Switch"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SwitchToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SwitchToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Switch_V1_5_0_JSON (*((EFI_REDFISH_SWITCH_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SwitchToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SWITCH_V1_5_0 *SwitchV1_5_0; + + SwitchV1_5_0 = (EFI_REDFISH_SWITCH_V1_5_0 *)InterpProp; + DestroySwitch_V1_5_0_CS (SwitchV1_5_0->Switch); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SwitchFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySwitch_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SwitchToStructWrapper, + SwitchToJson, + SwitchDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSwitch_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/SwitchCollection/RedfishSwitchCollection_Dxe.inf b/RedfishClientPkg/Converter/SwitchCollection/RedfishSwitchCollection_Dxe.inf new file mode 100644 index 00000000000..6221885a8c9 --- /dev/null +++ b/RedfishClientPkg/Converter/SwitchCollection/RedfishSwitchCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of SwitchCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishSwitchCollection_Dxe + FILE_GUID = d0dc3e89-d6ce-48fc-a21c-a0e3a9106cc3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishSwitchCollectionEntryPoint + UNLOAD_IMAGE = RedfishSwitchCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + SwitchCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + SwitchCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/SwitchCollection/SwitchCollection_Dxe.c b/RedfishClientPkg/Converter/SwitchCollection/SwitchCollection_Dxe.c new file mode 100644 index 00000000000..b6cddcfba44 --- /dev/null +++ b/RedfishClientPkg/Converter/SwitchCollection/SwitchCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - SwitchCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#SwitchCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support SwitchCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "SwitchCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "SwitchCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_SWITCHCOLLECTION *SwitchCollection; + EFI_REDFISH_SWITCHCOLLECTION_CS *SwitchCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "SwitchCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_SwitchCollection_To_CS (ResoruceRaw, &SwitchCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + SwitchCollection = (EFI_REDFISH_SWITCHCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_SWITCHCOLLECTION)); + if (SwitchCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)SwitchCollection; + SwitchCollection->SwitchCollection = SwitchCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("SwitchCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("SwitchCollection"), "SwitchCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("SwitchCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("SwitchCollection"), "SwitchCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of SwitchCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return SwitchCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_SwitchCollection_JSON (*((EFI_REDFISH_SWITCHCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in SwitchCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_SWITCHCOLLECTION *SwitchCollection; + + SwitchCollection = (EFI_REDFISH_SWITCHCOLLECTION *)InterpProp; + DestroySwitchCollection_CS (SwitchCollection->SwitchCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from SwitchCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +SwitchCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroySwitchCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishSwitchCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + SwitchCollectionToStructWrapper, + SwitchCollectionToJson, + SwitchCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishSwitchCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_0_0/RedfishTask_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_0_0/RedfishTask_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..298fd35e409 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_0_0/RedfishTask_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_0_0_Dxe + FILE_GUID = 1e2df997-8935-4b7b-aed3-f3b3d898d474 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_0_0/Task_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Task/v1_0_0/Task_V1_0_0_Dxe.c new file mode 100644 index 00000000000..6260658d6dd --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_0_0/Task_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "0", + "0" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_0_0 *TaskV1_0_0; + EFI_REDFISH_TASK_V1_0_0_CS *TaskV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_0_0_To_CS (ResoruceRaw, &TaskV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_0_0 = (EFI_REDFISH_TASK_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_0_0)); + if (TaskV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_0_0; + TaskV1_0_0->Task = TaskV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_0_0_JSON (*((EFI_REDFISH_TASK_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_0_0 *TaskV1_0_0; + + TaskV1_0_0 = (EFI_REDFISH_TASK_V1_0_0 *)InterpProp; + DestroyTask_V1_0_0_CS (TaskV1_0_0->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_0_2/RedfishTask_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_0_2/RedfishTask_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..3a084dc1100 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_0_2/RedfishTask_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_0_2_Dxe + FILE_GUID = af2b8f76-7166-4ecc-91c2-f6ace19a7bdb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_0_2/Task_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Task/v1_0_2/Task_V1_0_2_Dxe.c new file mode 100644 index 00000000000..cd91ff4df6b --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_0_2/Task_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "0", + "2" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_0_2 *TaskV1_0_2; + EFI_REDFISH_TASK_V1_0_2_CS *TaskV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_0_2_To_CS (ResoruceRaw, &TaskV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_0_2 = (EFI_REDFISH_TASK_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_0_2)); + if (TaskV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_0_2; + TaskV1_0_2->Task = TaskV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_0_2_JSON (*((EFI_REDFISH_TASK_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_0_2 *TaskV1_0_2; + + TaskV1_0_2 = (EFI_REDFISH_TASK_V1_0_2 *)InterpProp; + DestroyTask_V1_0_2_CS (TaskV1_0_2->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_0_3/RedfishTask_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_0_3/RedfishTask_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..6f89182fffe --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_0_3/RedfishTask_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_0_3_Dxe + FILE_GUID = c15ef338-3806-4956-b2e1-e2c4db559d78 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_0_3/Task_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/Task/v1_0_3/Task_V1_0_3_Dxe.c new file mode 100644 index 00000000000..37414b0f1ba --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_0_3/Task_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "0", + "3" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_0_3 *TaskV1_0_3; + EFI_REDFISH_TASK_V1_0_3_CS *TaskV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_0_3_To_CS (ResoruceRaw, &TaskV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_0_3 = (EFI_REDFISH_TASK_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_0_3)); + if (TaskV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_0_3; + TaskV1_0_3->Task = TaskV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_0_3_JSON (*((EFI_REDFISH_TASK_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_0_3 *TaskV1_0_3; + + TaskV1_0_3 = (EFI_REDFISH_TASK_V1_0_3 *)InterpProp; + DestroyTask_V1_0_3_CS (TaskV1_0_3->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_0_4/RedfishTask_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_0_4/RedfishTask_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..3b3e608f235 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_0_4/RedfishTask_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_0_4_Dxe + FILE_GUID = cd390118-f7d9-4395-acf0-3de5d7a11b6e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_0_4/Task_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/Task/v1_0_4/Task_V1_0_4_Dxe.c new file mode 100644 index 00000000000..b069748e58b --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_0_4/Task_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "0", + "4" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_0_4 *TaskV1_0_4; + EFI_REDFISH_TASK_V1_0_4_CS *TaskV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_0_4_To_CS (ResoruceRaw, &TaskV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_0_4 = (EFI_REDFISH_TASK_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_0_4)); + if (TaskV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_0_4; + TaskV1_0_4->Task = TaskV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_0_4_JSON (*((EFI_REDFISH_TASK_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_0_4 *TaskV1_0_4; + + TaskV1_0_4 = (EFI_REDFISH_TASK_V1_0_4 *)InterpProp; + DestroyTask_V1_0_4_CS (TaskV1_0_4->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_0_5/RedfishTask_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_0_5/RedfishTask_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..a5025899efb --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_0_5/RedfishTask_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_0_5_Dxe + FILE_GUID = d6eeb02b-7f1b-4c52-a384-074afdd1a8d0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_0_5/Task_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/Task/v1_0_5/Task_V1_0_5_Dxe.c new file mode 100644 index 00000000000..08ecad0c121 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_0_5/Task_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "0", + "5" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_0_5 *TaskV1_0_5; + EFI_REDFISH_TASK_V1_0_5_CS *TaskV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_0_5_To_CS (ResoruceRaw, &TaskV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_0_5 = (EFI_REDFISH_TASK_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_0_5)); + if (TaskV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_0_5; + TaskV1_0_5->Task = TaskV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_0_5_JSON (*((EFI_REDFISH_TASK_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_0_5 *TaskV1_0_5; + + TaskV1_0_5 = (EFI_REDFISH_TASK_V1_0_5 *)InterpProp; + DestroyTask_V1_0_5_CS (TaskV1_0_5->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_0_6/RedfishTask_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_0_6/RedfishTask_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..073c87d5753 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_0_6/RedfishTask_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_0_6_Dxe + FILE_GUID = cf795bc9-fc01-436d-a829-742e38c30fb1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_0_6/Task_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/Task/v1_0_6/Task_V1_0_6_Dxe.c new file mode 100644 index 00000000000..b535c73090a --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_0_6/Task_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "0", + "6" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_0_6 *TaskV1_0_6; + EFI_REDFISH_TASK_V1_0_6_CS *TaskV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_0_6_To_CS (ResoruceRaw, &TaskV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_0_6 = (EFI_REDFISH_TASK_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_0_6)); + if (TaskV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_0_6; + TaskV1_0_6->Task = TaskV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_0_6_JSON (*((EFI_REDFISH_TASK_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_0_6 *TaskV1_0_6; + + TaskV1_0_6 = (EFI_REDFISH_TASK_V1_0_6 *)InterpProp; + DestroyTask_V1_0_6_CS (TaskV1_0_6->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_0_7/RedfishTask_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_0_7/RedfishTask_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..08b343d4a8e --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_0_7/RedfishTask_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_0_7_Dxe + FILE_GUID = 27991d18-afc3-4ee3-980d-3a0437bfa6cd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_0_7/Task_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/Task/v1_0_7/Task_V1_0_7_Dxe.c new file mode 100644 index 00000000000..3baf0da24a2 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_0_7/Task_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "0", + "7" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_0_7 *TaskV1_0_7; + EFI_REDFISH_TASK_V1_0_7_CS *TaskV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_0_7_To_CS (ResoruceRaw, &TaskV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_0_7 = (EFI_REDFISH_TASK_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_0_7)); + if (TaskV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_0_7; + TaskV1_0_7->Task = TaskV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_0_7_JSON (*((EFI_REDFISH_TASK_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_0_7 *TaskV1_0_7; + + TaskV1_0_7 = (EFI_REDFISH_TASK_V1_0_7 *)InterpProp; + DestroyTask_V1_0_7_CS (TaskV1_0_7->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_0_8/RedfishTask_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_0_8/RedfishTask_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..5942ba7f067 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_0_8/RedfishTask_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_0_8_Dxe + FILE_GUID = 0684e799-0043-40ad-bc93-8b15e7d9a569 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_0_8/Task_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/Task/v1_0_8/Task_V1_0_8_Dxe.c new file mode 100644 index 00000000000..42b94ee5e41 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_0_8/Task_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "0", + "8" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_0_8 *TaskV1_0_8; + EFI_REDFISH_TASK_V1_0_8_CS *TaskV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_0_8_To_CS (ResoruceRaw, &TaskV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_0_8 = (EFI_REDFISH_TASK_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_0_8)); + if (TaskV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_0_8; + TaskV1_0_8->Task = TaskV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_0_8_JSON (*((EFI_REDFISH_TASK_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_0_8 *TaskV1_0_8; + + TaskV1_0_8 = (EFI_REDFISH_TASK_V1_0_8 *)InterpProp; + DestroyTask_V1_0_8_CS (TaskV1_0_8->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_0_9/RedfishTask_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_0_9/RedfishTask_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..acc569ae1ed --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_0_9/RedfishTask_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_0_9_Dxe + FILE_GUID = f8313da0-3077-48d9-b6eb-554a235819fc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_0_9/Task_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/Task/v1_0_9/Task_V1_0_9_Dxe.c new file mode 100644 index 00000000000..65164d62b79 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_0_9/Task_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "0", + "9" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_0_9 *TaskV1_0_9; + EFI_REDFISH_TASK_V1_0_9_CS *TaskV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_0_9_To_CS (ResoruceRaw, &TaskV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_0_9 = (EFI_REDFISH_TASK_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_0_9)); + if (TaskV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_0_9; + TaskV1_0_9->Task = TaskV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_0_9_JSON (*((EFI_REDFISH_TASK_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_0_9 *TaskV1_0_9; + + TaskV1_0_9 = (EFI_REDFISH_TASK_V1_0_9 *)InterpProp; + DestroyTask_V1_0_9_CS (TaskV1_0_9->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_1_0/RedfishTask_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_1_0/RedfishTask_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..8cedc0efd94 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_1_0/RedfishTask_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_1_0_Dxe + FILE_GUID = 300ae0aa-baac-44c5-a570-ac1b20d738ee + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_1_0/Task_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/Task/v1_1_0/Task_V1_1_0_Dxe.c new file mode 100644 index 00000000000..9d32fd85517 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_1_0/Task_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "1", + "0" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_1_0 *TaskV1_1_0; + EFI_REDFISH_TASK_V1_1_0_CS *TaskV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_1_0_To_CS (ResoruceRaw, &TaskV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_1_0 = (EFI_REDFISH_TASK_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_1_0)); + if (TaskV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_1_0; + TaskV1_1_0->Task = TaskV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_1_0_JSON (*((EFI_REDFISH_TASK_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_1_0 *TaskV1_1_0; + + TaskV1_1_0 = (EFI_REDFISH_TASK_V1_1_0 *)InterpProp; + DestroyTask_V1_1_0_CS (TaskV1_1_0->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_1_1/RedfishTask_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_1_1/RedfishTask_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..910928e2579 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_1_1/RedfishTask_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_1_1_Dxe + FILE_GUID = 5e87da67-cf85-4882-888a-1b87f73bee3f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_1_1/Task_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/Task/v1_1_1/Task_V1_1_1_Dxe.c new file mode 100644 index 00000000000..55533bc1e82 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_1_1/Task_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "1", + "1" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_1_1 *TaskV1_1_1; + EFI_REDFISH_TASK_V1_1_1_CS *TaskV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_1_1_To_CS (ResoruceRaw, &TaskV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_1_1 = (EFI_REDFISH_TASK_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_1_1)); + if (TaskV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_1_1; + TaskV1_1_1->Task = TaskV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_1_1_JSON (*((EFI_REDFISH_TASK_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_1_1 *TaskV1_1_1; + + TaskV1_1_1 = (EFI_REDFISH_TASK_V1_1_1 *)InterpProp; + DestroyTask_V1_1_1_CS (TaskV1_1_1->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_1_2/RedfishTask_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_1_2/RedfishTask_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..23727a721ea --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_1_2/RedfishTask_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_1_2_Dxe + FILE_GUID = 7147482b-e364-4920-ad1d-52ec7f4a8dc4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_1_2/Task_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/Task/v1_1_2/Task_V1_1_2_Dxe.c new file mode 100644 index 00000000000..7b71646f2e2 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_1_2/Task_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "1", + "2" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_1_2 *TaskV1_1_2; + EFI_REDFISH_TASK_V1_1_2_CS *TaskV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_1_2_To_CS (ResoruceRaw, &TaskV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_1_2 = (EFI_REDFISH_TASK_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_1_2)); + if (TaskV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_1_2; + TaskV1_1_2->Task = TaskV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_1_2_JSON (*((EFI_REDFISH_TASK_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_1_2 *TaskV1_1_2; + + TaskV1_1_2 = (EFI_REDFISH_TASK_V1_1_2 *)InterpProp; + DestroyTask_V1_1_2_CS (TaskV1_1_2->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_1_3/RedfishTask_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_1_3/RedfishTask_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..1059cd7d2e9 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_1_3/RedfishTask_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_1_3_Dxe + FILE_GUID = 435963b0-398e-48ee-b4b8-f3d7b48b2a7e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_1_3/Task_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/Task/v1_1_3/Task_V1_1_3_Dxe.c new file mode 100644 index 00000000000..5192d22ff8a --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_1_3/Task_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "1", + "3" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_1_3 *TaskV1_1_3; + EFI_REDFISH_TASK_V1_1_3_CS *TaskV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_1_3_To_CS (ResoruceRaw, &TaskV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_1_3 = (EFI_REDFISH_TASK_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_1_3)); + if (TaskV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_1_3; + TaskV1_1_3->Task = TaskV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_1_3_JSON (*((EFI_REDFISH_TASK_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_1_3 *TaskV1_1_3; + + TaskV1_1_3 = (EFI_REDFISH_TASK_V1_1_3 *)InterpProp; + DestroyTask_V1_1_3_CS (TaskV1_1_3->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_1_4/RedfishTask_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_1_4/RedfishTask_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..0cc765c2720 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_1_4/RedfishTask_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_1_4_Dxe + FILE_GUID = 0d7114f3-7707-4801-a4cf-af83a7feecba + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_1_4/Task_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/Task/v1_1_4/Task_V1_1_4_Dxe.c new file mode 100644 index 00000000000..dd173a9389e --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_1_4/Task_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "1", + "4" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_1_4 *TaskV1_1_4; + EFI_REDFISH_TASK_V1_1_4_CS *TaskV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_1_4_To_CS (ResoruceRaw, &TaskV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_1_4 = (EFI_REDFISH_TASK_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_1_4)); + if (TaskV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_1_4; + TaskV1_1_4->Task = TaskV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_1_4_JSON (*((EFI_REDFISH_TASK_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_1_4 *TaskV1_1_4; + + TaskV1_1_4 = (EFI_REDFISH_TASK_V1_1_4 *)InterpProp; + DestroyTask_V1_1_4_CS (TaskV1_1_4->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_1_5/RedfishTask_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_1_5/RedfishTask_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..67f3f9b6cc1 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_1_5/RedfishTask_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_1_5_Dxe + FILE_GUID = 5a6bf72b-2044-43df-b184-1d8038d26b69 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_1_5/Task_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/Task/v1_1_5/Task_V1_1_5_Dxe.c new file mode 100644 index 00000000000..5d2796c9441 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_1_5/Task_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "1", + "5" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_1_5 *TaskV1_1_5; + EFI_REDFISH_TASK_V1_1_5_CS *TaskV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_1_5_To_CS (ResoruceRaw, &TaskV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_1_5 = (EFI_REDFISH_TASK_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_1_5)); + if (TaskV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_1_5; + TaskV1_1_5->Task = TaskV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_1_5_JSON (*((EFI_REDFISH_TASK_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_1_5 *TaskV1_1_5; + + TaskV1_1_5 = (EFI_REDFISH_TASK_V1_1_5 *)InterpProp; + DestroyTask_V1_1_5_CS (TaskV1_1_5->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_1_6/RedfishTask_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_1_6/RedfishTask_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..6276bd09c8f --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_1_6/RedfishTask_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_1_6_Dxe + FILE_GUID = 985340d1-432d-47d7-aa2e-1b7a89638494 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_1_6/Task_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/Task/v1_1_6/Task_V1_1_6_Dxe.c new file mode 100644 index 00000000000..fb92c664f0c --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_1_6/Task_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "1", + "6" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_1_6 *TaskV1_1_6; + EFI_REDFISH_TASK_V1_1_6_CS *TaskV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_1_6_To_CS (ResoruceRaw, &TaskV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_1_6 = (EFI_REDFISH_TASK_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_1_6)); + if (TaskV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_1_6; + TaskV1_1_6->Task = TaskV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_1_6_JSON (*((EFI_REDFISH_TASK_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_1_6 *TaskV1_1_6; + + TaskV1_1_6 = (EFI_REDFISH_TASK_V1_1_6 *)InterpProp; + DestroyTask_V1_1_6_CS (TaskV1_1_6->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_2_0/RedfishTask_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_2_0/RedfishTask_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..13daa849ca9 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_2_0/RedfishTask_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_2_0_Dxe + FILE_GUID = 7f596bfa-494b-4f89-84a4-7381cf9122d1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_2_0/Task_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/Task/v1_2_0/Task_V1_2_0_Dxe.c new file mode 100644 index 00000000000..29121f90193 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_2_0/Task_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "2", + "0" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_2_0 *TaskV1_2_0; + EFI_REDFISH_TASK_V1_2_0_CS *TaskV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_2_0_To_CS (ResoruceRaw, &TaskV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_2_0 = (EFI_REDFISH_TASK_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_2_0)); + if (TaskV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_2_0; + TaskV1_2_0->Task = TaskV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_2_0_JSON (*((EFI_REDFISH_TASK_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_2_0 *TaskV1_2_0; + + TaskV1_2_0 = (EFI_REDFISH_TASK_V1_2_0 *)InterpProp; + DestroyTask_V1_2_0_CS (TaskV1_2_0->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_2_1/RedfishTask_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_2_1/RedfishTask_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..de97535b0e9 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_2_1/RedfishTask_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_2_1_Dxe + FILE_GUID = e751fb86-8454-4166-bf29-64a85787ac6e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_2_1/Task_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/Task/v1_2_1/Task_V1_2_1_Dxe.c new file mode 100644 index 00000000000..4a89c60bef7 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_2_1/Task_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "2", + "1" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_2_1 *TaskV1_2_1; + EFI_REDFISH_TASK_V1_2_1_CS *TaskV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_2_1_To_CS (ResoruceRaw, &TaskV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_2_1 = (EFI_REDFISH_TASK_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_2_1)); + if (TaskV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_2_1; + TaskV1_2_1->Task = TaskV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_2_1_JSON (*((EFI_REDFISH_TASK_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_2_1 *TaskV1_2_1; + + TaskV1_2_1 = (EFI_REDFISH_TASK_V1_2_1 *)InterpProp; + DestroyTask_V1_2_1_CS (TaskV1_2_1->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_2_2/RedfishTask_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_2_2/RedfishTask_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..98618533a12 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_2_2/RedfishTask_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_2_2_Dxe + FILE_GUID = cb3db07a-75dd-45ae-b868-e66f3bf8b186 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_2_2/Task_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/Task/v1_2_2/Task_V1_2_2_Dxe.c new file mode 100644 index 00000000000..0a5e083d870 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_2_2/Task_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "2", + "2" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_2_2 *TaskV1_2_2; + EFI_REDFISH_TASK_V1_2_2_CS *TaskV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_2_2_To_CS (ResoruceRaw, &TaskV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_2_2 = (EFI_REDFISH_TASK_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_2_2)); + if (TaskV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_2_2; + TaskV1_2_2->Task = TaskV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_2_2_JSON (*((EFI_REDFISH_TASK_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_2_2 *TaskV1_2_2; + + TaskV1_2_2 = (EFI_REDFISH_TASK_V1_2_2 *)InterpProp; + DestroyTask_V1_2_2_CS (TaskV1_2_2->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_2_3/RedfishTask_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_2_3/RedfishTask_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..b0d61eb9f39 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_2_3/RedfishTask_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_2_3_Dxe + FILE_GUID = 106bb081-5aa4-4e57-a9cc-0577c56af4b9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_2_3/Task_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/Task/v1_2_3/Task_V1_2_3_Dxe.c new file mode 100644 index 00000000000..acd5ad19d50 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_2_3/Task_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "2", + "3" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_2_3 *TaskV1_2_3; + EFI_REDFISH_TASK_V1_2_3_CS *TaskV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_2_3_To_CS (ResoruceRaw, &TaskV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_2_3 = (EFI_REDFISH_TASK_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_2_3)); + if (TaskV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_2_3; + TaskV1_2_3->Task = TaskV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_2_3_JSON (*((EFI_REDFISH_TASK_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_2_3 *TaskV1_2_3; + + TaskV1_2_3 = (EFI_REDFISH_TASK_V1_2_3 *)InterpProp; + DestroyTask_V1_2_3_CS (TaskV1_2_3->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_2_4/RedfishTask_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_2_4/RedfishTask_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..c77ea952fef --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_2_4/RedfishTask_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_2_4_Dxe + FILE_GUID = 13094ef7-d8eb-45df-80da-709fde5f9838 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_2_4/Task_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/Task/v1_2_4/Task_V1_2_4_Dxe.c new file mode 100644 index 00000000000..5f55e7fbc39 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_2_4/Task_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "2", + "4" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_2_4 *TaskV1_2_4; + EFI_REDFISH_TASK_V1_2_4_CS *TaskV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_2_4_To_CS (ResoruceRaw, &TaskV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_2_4 = (EFI_REDFISH_TASK_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_2_4)); + if (TaskV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_2_4; + TaskV1_2_4->Task = TaskV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_2_4_JSON (*((EFI_REDFISH_TASK_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_2_4 *TaskV1_2_4; + + TaskV1_2_4 = (EFI_REDFISH_TASK_V1_2_4 *)InterpProp; + DestroyTask_V1_2_4_CS (TaskV1_2_4->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_2_5/RedfishTask_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_2_5/RedfishTask_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..96431e27ffc --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_2_5/RedfishTask_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_2_5_Dxe + FILE_GUID = 8fa90a6e-7933-4557-8505-b8b8f52a0a22 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_2_5/Task_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/Task/v1_2_5/Task_V1_2_5_Dxe.c new file mode 100644 index 00000000000..307d3e2f4ae --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_2_5/Task_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "2", + "5" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_2_5 *TaskV1_2_5; + EFI_REDFISH_TASK_V1_2_5_CS *TaskV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_2_5_To_CS (ResoruceRaw, &TaskV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_2_5 = (EFI_REDFISH_TASK_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_2_5)); + if (TaskV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_2_5; + TaskV1_2_5->Task = TaskV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_2_5_JSON (*((EFI_REDFISH_TASK_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_2_5 *TaskV1_2_5; + + TaskV1_2_5 = (EFI_REDFISH_TASK_V1_2_5 *)InterpProp; + DestroyTask_V1_2_5_CS (TaskV1_2_5->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_3_0/RedfishTask_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_3_0/RedfishTask_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..7c7bbd75914 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_3_0/RedfishTask_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_3_0_Dxe + FILE_GUID = 8df78c92-766a-40f4-984b-de2f9031f507 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_3_0/Task_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/Task/v1_3_0/Task_V1_3_0_Dxe.c new file mode 100644 index 00000000000..d82f109755f --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_3_0/Task_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "3", + "0" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_3_0 *TaskV1_3_0; + EFI_REDFISH_TASK_V1_3_0_CS *TaskV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_3_0_To_CS (ResoruceRaw, &TaskV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_3_0 = (EFI_REDFISH_TASK_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_3_0)); + if (TaskV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_3_0; + TaskV1_3_0->Task = TaskV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_3_0_JSON (*((EFI_REDFISH_TASK_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_3_0 *TaskV1_3_0; + + TaskV1_3_0 = (EFI_REDFISH_TASK_V1_3_0 *)InterpProp; + DestroyTask_V1_3_0_CS (TaskV1_3_0->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_3_1/RedfishTask_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_3_1/RedfishTask_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..38f438be656 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_3_1/RedfishTask_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_3_1_Dxe + FILE_GUID = ab9edd30-41cf-4fed-b748-eebeb3ca80a2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_3_1/Task_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/Task/v1_3_1/Task_V1_3_1_Dxe.c new file mode 100644 index 00000000000..9b9474af0ab --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_3_1/Task_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "3", + "1" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_3_1 *TaskV1_3_1; + EFI_REDFISH_TASK_V1_3_1_CS *TaskV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_3_1_To_CS (ResoruceRaw, &TaskV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_3_1 = (EFI_REDFISH_TASK_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_3_1)); + if (TaskV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_3_1; + TaskV1_3_1->Task = TaskV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_3_1_JSON (*((EFI_REDFISH_TASK_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_3_1 *TaskV1_3_1; + + TaskV1_3_1 = (EFI_REDFISH_TASK_V1_3_1 *)InterpProp; + DestroyTask_V1_3_1_CS (TaskV1_3_1->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_3_2/RedfishTask_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_3_2/RedfishTask_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..97b3684a5b4 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_3_2/RedfishTask_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_3_2_Dxe + FILE_GUID = af3c9fae-f147-471a-8a6b-63b928ff9952 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_3_2/Task_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/Task/v1_3_2/Task_V1_3_2_Dxe.c new file mode 100644 index 00000000000..5a0fc5be8f7 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_3_2/Task_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "3", + "2" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_3_2 *TaskV1_3_2; + EFI_REDFISH_TASK_V1_3_2_CS *TaskV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_3_2_To_CS (ResoruceRaw, &TaskV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_3_2 = (EFI_REDFISH_TASK_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_3_2)); + if (TaskV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_3_2; + TaskV1_3_2->Task = TaskV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_3_2_JSON (*((EFI_REDFISH_TASK_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_3_2 *TaskV1_3_2; + + TaskV1_3_2 = (EFI_REDFISH_TASK_V1_3_2 *)InterpProp; + DestroyTask_V1_3_2_CS (TaskV1_3_2->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_3_3/RedfishTask_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_3_3/RedfishTask_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..658dd886476 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_3_3/RedfishTask_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_3_3_Dxe + FILE_GUID = 5c7255e8-0dd1-439b-bdea-151dfe1984ae + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_3_3/Task_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/Task/v1_3_3/Task_V1_3_3_Dxe.c new file mode 100644 index 00000000000..d910d89e9b4 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_3_3/Task_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "3", + "3" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_3_3 *TaskV1_3_3; + EFI_REDFISH_TASK_V1_3_3_CS *TaskV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_3_3_To_CS (ResoruceRaw, &TaskV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_3_3 = (EFI_REDFISH_TASK_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_3_3)); + if (TaskV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_3_3; + TaskV1_3_3->Task = TaskV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_3_3_JSON (*((EFI_REDFISH_TASK_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_3_3 *TaskV1_3_3; + + TaskV1_3_3 = (EFI_REDFISH_TASK_V1_3_3 *)InterpProp; + DestroyTask_V1_3_3_CS (TaskV1_3_3->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_3_4/RedfishTask_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_3_4/RedfishTask_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..a32eba9e7fe --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_3_4/RedfishTask_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_3_4_Dxe + FILE_GUID = ce1fa356-f413-445c-bceb-85d2f1ead1c3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_3_4/Task_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/Task/v1_3_4/Task_V1_3_4_Dxe.c new file mode 100644 index 00000000000..042cc041ee8 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_3_4/Task_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "3", + "4" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_3_4 *TaskV1_3_4; + EFI_REDFISH_TASK_V1_3_4_CS *TaskV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_3_4_To_CS (ResoruceRaw, &TaskV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_3_4 = (EFI_REDFISH_TASK_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_3_4)); + if (TaskV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_3_4; + TaskV1_3_4->Task = TaskV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_3_4_JSON (*((EFI_REDFISH_TASK_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_3_4 *TaskV1_3_4; + + TaskV1_3_4 = (EFI_REDFISH_TASK_V1_3_4 *)InterpProp; + DestroyTask_V1_3_4_CS (TaskV1_3_4->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_3_5/RedfishTask_V1_3_5_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_3_5/RedfishTask_V1_3_5_Dxe.inf new file mode 100644 index 00000000000..925607dfe52 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_3_5/RedfishTask_V1_3_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_3_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_3_5_Dxe + FILE_GUID = 20b42b04-c36a-42c4-8a9d-17db171edd97 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_3_5EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_3_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_3_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_3_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_3_5/Task_V1_3_5_Dxe.c b/RedfishClientPkg/Converter/Task/v1_3_5/Task_V1_3_5_Dxe.c new file mode 100644 index 00000000000..312ef8e4203 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_3_5/Task_V1_3_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_3_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "3", + "5" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_3_5 *TaskV1_3_5; + EFI_REDFISH_TASK_V1_3_5_CS *TaskV1_3_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_3_5_To_CS (ResoruceRaw, &TaskV1_3_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_3_5 = (EFI_REDFISH_TASK_V1_3_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_3_5)); + if (TaskV1_3_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_3_5; + TaskV1_3_5->Task = TaskV1_3_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_3_5_JSON (*((EFI_REDFISH_TASK_V1_3_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_3_5 *TaskV1_3_5; + + TaskV1_3_5 = (EFI_REDFISH_TASK_V1_3_5 *)InterpProp; + DestroyTask_V1_3_5_CS (TaskV1_3_5->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_3_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_3_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_3_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_4_0/RedfishTask_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_4_0/RedfishTask_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..7880f811282 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_4_0/RedfishTask_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_4_0_Dxe + FILE_GUID = aba4a562-8a0d-462e-8fa1-1d49fba309b8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_4_0/Task_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/Task/v1_4_0/Task_V1_4_0_Dxe.c new file mode 100644 index 00000000000..ccf2501b788 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_4_0/Task_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "4", + "0" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_4_0 *TaskV1_4_0; + EFI_REDFISH_TASK_V1_4_0_CS *TaskV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_4_0_To_CS (ResoruceRaw, &TaskV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_4_0 = (EFI_REDFISH_TASK_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_4_0)); + if (TaskV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_4_0; + TaskV1_4_0->Task = TaskV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_4_0_JSON (*((EFI_REDFISH_TASK_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_4_0 *TaskV1_4_0; + + TaskV1_4_0 = (EFI_REDFISH_TASK_V1_4_0 *)InterpProp; + DestroyTask_V1_4_0_CS (TaskV1_4_0->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_4_1/RedfishTask_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_4_1/RedfishTask_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..8f6e9222add --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_4_1/RedfishTask_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_4_1_Dxe + FILE_GUID = ff6984c4-0fd6-49b8-8692-c0cb74067aa0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_4_1/Task_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/Task/v1_4_1/Task_V1_4_1_Dxe.c new file mode 100644 index 00000000000..8b578a00cc3 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_4_1/Task_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "4", + "1" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_4_1 *TaskV1_4_1; + EFI_REDFISH_TASK_V1_4_1_CS *TaskV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_4_1_To_CS (ResoruceRaw, &TaskV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_4_1 = (EFI_REDFISH_TASK_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_4_1)); + if (TaskV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_4_1; + TaskV1_4_1->Task = TaskV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_4_1_JSON (*((EFI_REDFISH_TASK_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_4_1 *TaskV1_4_1; + + TaskV1_4_1 = (EFI_REDFISH_TASK_V1_4_1 *)InterpProp; + DestroyTask_V1_4_1_CS (TaskV1_4_1->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_4_2/RedfishTask_V1_4_2_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_4_2/RedfishTask_V1_4_2_Dxe.inf new file mode 100644 index 00000000000..44e9ae41a25 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_4_2/RedfishTask_V1_4_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_4_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_4_2_Dxe + FILE_GUID = 017215f7-621c-493b-aa6d-99d2007f36ff + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_4_2EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_4_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_4_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_4_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_4_2/Task_V1_4_2_Dxe.c b/RedfishClientPkg/Converter/Task/v1_4_2/Task_V1_4_2_Dxe.c new file mode 100644 index 00000000000..0574553e8af --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_4_2/Task_V1_4_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_4_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "4", + "2" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_4_2 *TaskV1_4_2; + EFI_REDFISH_TASK_V1_4_2_CS *TaskV1_4_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_4_2_To_CS (ResoruceRaw, &TaskV1_4_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_4_2 = (EFI_REDFISH_TASK_V1_4_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_4_2)); + if (TaskV1_4_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_4_2; + TaskV1_4_2->Task = TaskV1_4_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_4_2_JSON (*((EFI_REDFISH_TASK_V1_4_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_4_2 *TaskV1_4_2; + + TaskV1_4_2 = (EFI_REDFISH_TASK_V1_4_2 *)InterpProp; + DestroyTask_V1_4_2_CS (TaskV1_4_2->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_4_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_4_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_4_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_4_3/RedfishTask_V1_4_3_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_4_3/RedfishTask_V1_4_3_Dxe.inf new file mode 100644 index 00000000000..571072947f9 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_4_3/RedfishTask_V1_4_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_4_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_4_3_Dxe + FILE_GUID = e7761dfe-36c5-4f69-a23e-71210410e633 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_4_3EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_4_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_4_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_4_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_4_3/Task_V1_4_3_Dxe.c b/RedfishClientPkg/Converter/Task/v1_4_3/Task_V1_4_3_Dxe.c new file mode 100644 index 00000000000..86bddaf2249 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_4_3/Task_V1_4_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_4_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "4", + "3" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_4_3 *TaskV1_4_3; + EFI_REDFISH_TASK_V1_4_3_CS *TaskV1_4_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_4_3_To_CS (ResoruceRaw, &TaskV1_4_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_4_3 = (EFI_REDFISH_TASK_V1_4_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_4_3)); + if (TaskV1_4_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_4_3; + TaskV1_4_3->Task = TaskV1_4_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_4_3_JSON (*((EFI_REDFISH_TASK_V1_4_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_4_3 *TaskV1_4_3; + + TaskV1_4_3 = (EFI_REDFISH_TASK_V1_4_3 *)InterpProp; + DestroyTask_V1_4_3_CS (TaskV1_4_3->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_4_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_4_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_4_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_4_4/RedfishTask_V1_4_4_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_4_4/RedfishTask_V1_4_4_Dxe.inf new file mode 100644 index 00000000000..a9007d024d6 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_4_4/RedfishTask_V1_4_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_4_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_4_4_Dxe + FILE_GUID = 8a457f55-c689-439d-b42b-052332f8f30e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_4_4EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_4_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_4_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_4_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_4_4/Task_V1_4_4_Dxe.c b/RedfishClientPkg/Converter/Task/v1_4_4/Task_V1_4_4_Dxe.c new file mode 100644 index 00000000000..e9df2ac0230 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_4_4/Task_V1_4_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_4_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "4", + "4" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_4_4 *TaskV1_4_4; + EFI_REDFISH_TASK_V1_4_4_CS *TaskV1_4_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_4_4_To_CS (ResoruceRaw, &TaskV1_4_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_4_4 = (EFI_REDFISH_TASK_V1_4_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_4_4)); + if (TaskV1_4_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_4_4; + TaskV1_4_4->Task = TaskV1_4_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_4_4_JSON (*((EFI_REDFISH_TASK_V1_4_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_4_4 *TaskV1_4_4; + + TaskV1_4_4 = (EFI_REDFISH_TASK_V1_4_4 *)InterpProp; + DestroyTask_V1_4_4_CS (TaskV1_4_4->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_4_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_4_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_4_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_5_0/RedfishTask_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_5_0/RedfishTask_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..90c6c3d733b --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_5_0/RedfishTask_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_5_0_Dxe + FILE_GUID = 9aa1d9c9-ec7c-4178-9510-ae9d41213235 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_5_0/Task_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/Task/v1_5_0/Task_V1_5_0_Dxe.c new file mode 100644 index 00000000000..c6e93d225a0 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_5_0/Task_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "5", + "0" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_5_0 *TaskV1_5_0; + EFI_REDFISH_TASK_V1_5_0_CS *TaskV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_5_0_To_CS (ResoruceRaw, &TaskV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_5_0 = (EFI_REDFISH_TASK_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_5_0)); + if (TaskV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_5_0; + TaskV1_5_0->Task = TaskV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_5_0_JSON (*((EFI_REDFISH_TASK_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_5_0 *TaskV1_5_0; + + TaskV1_5_0 = (EFI_REDFISH_TASK_V1_5_0 *)InterpProp; + DestroyTask_V1_5_0_CS (TaskV1_5_0->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Task/v1_5_1/RedfishTask_V1_5_1_Dxe.inf b/RedfishClientPkg/Converter/Task/v1_5_1/RedfishTask_V1_5_1_Dxe.inf new file mode 100644 index 00000000000..75b15a1266b --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_5_1/RedfishTask_V1_5_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Task.v1_5_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTask_V1_5_1_Dxe + FILE_GUID = 00a259b7-8d62-4c9b-80cf-b19827e0ad56 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTask_V1_5_1EntryPoint + UNLOAD_IMAGE = RedfishTask_V1_5_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Task_V1_5_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskV1_5_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Task/v1_5_1/Task_V1_5_1_Dxe.c b/RedfishClientPkg/Converter/Task/v1_5_1/Task_V1_5_1_Dxe.c new file mode 100644 index 00000000000..b7ce0a57900 --- /dev/null +++ b/RedfishClientPkg/Converter/Task/v1_5_1/Task_V1_5_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Task.v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Task"; +BOOLEAN IsRevisonController = TRUE; + +// Support Task V1_5_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Task", + "1", + "5", + "1" + }, + "Task" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASK_V1_5_1 *TaskV1_5_1; + EFI_REDFISH_TASK_V1_5_1_CS *TaskV1_5_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Task") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Task_V1_5_1_To_CS (ResoruceRaw, &TaskV1_5_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskV1_5_1 = (EFI_REDFISH_TASK_V1_5_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASK_V1_5_1)); + if (TaskV1_5_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskV1_5_1; + TaskV1_5_1->Task = TaskV1_5_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Task"), "Task"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Task")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Task"), "Task"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Task_V1_5_1_JSON (*((EFI_REDFISH_TASK_V1_5_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASK_V1_5_1 *TaskV1_5_1; + + TaskV1_5_1 = (EFI_REDFISH_TASK_V1_5_1 *)InterpProp; + DestroyTask_V1_5_1_CS (TaskV1_5_1->Task); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTask_V1_5_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_5_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskToStructWrapper, + TaskToJson, + TaskDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTask_V1_5_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TaskCollection/RedfishTaskCollection_Dxe.inf b/RedfishClientPkg/Converter/TaskCollection/RedfishTaskCollection_Dxe.inf new file mode 100644 index 00000000000..b95877ee3fb --- /dev/null +++ b/RedfishClientPkg/Converter/TaskCollection/RedfishTaskCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TaskCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTaskCollection_Dxe + FILE_GUID = 30a13adc-29c5-4232-9106-e802b9921fdf + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTaskCollectionEntryPoint + UNLOAD_IMAGE = RedfishTaskCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TaskCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TaskCollection/TaskCollection_Dxe.c b/RedfishClientPkg/Converter/TaskCollection/TaskCollection_Dxe.c new file mode 100644 index 00000000000..78a14e22210 --- /dev/null +++ b/RedfishClientPkg/Converter/TaskCollection/TaskCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TaskCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TaskCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support TaskCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TaskCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "TaskCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASKCOLLECTION *TaskCollection; + EFI_REDFISH_TASKCOLLECTION_CS *TaskCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TaskCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TaskCollection_To_CS (ResoruceRaw, &TaskCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskCollection = (EFI_REDFISH_TASKCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASKCOLLECTION)); + if (TaskCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskCollection; + TaskCollection->TaskCollection = TaskCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TaskCollection"), "TaskCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TaskCollection"), "TaskCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TaskCollection_JSON (*((EFI_REDFISH_TASKCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASKCOLLECTION *TaskCollection; + + TaskCollection = (EFI_REDFISH_TASKCOLLECTION *)InterpProp; + DestroyTaskCollection_CS (TaskCollection->TaskCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTaskCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTaskCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskCollectionToStructWrapper, + TaskCollectionToJson, + TaskCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTaskCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TaskService/v1_0_0/RedfishTaskService_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/TaskService/v1_0_0/RedfishTaskService_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..0bdc2a3378a --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_0_0/RedfishTaskService_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TaskService.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTaskService_V1_0_0_Dxe + FILE_GUID = a407b925-cde7-4909-8457-0437a1b664ef + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTaskService_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishTaskService_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TaskService_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskServiceV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TaskService/v1_0_0/TaskService_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/TaskService/v1_0_0/TaskService_V1_0_0_Dxe.c new file mode 100644 index 00000000000..c132e002978 --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_0_0/TaskService_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TaskService.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TaskService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TaskService V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TaskService", + "1", + "0", + "0" + }, + "TaskService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_0_0 *TaskServiceV1_0_0; + EFI_REDFISH_TASKSERVICE_V1_0_0_CS *TaskServiceV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TaskService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TaskService_V1_0_0_To_CS (ResoruceRaw, &TaskServiceV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskServiceV1_0_0 = (EFI_REDFISH_TASKSERVICE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASKSERVICE_V1_0_0)); + if (TaskServiceV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskServiceV1_0_0; + TaskServiceV1_0_0->TaskService = TaskServiceV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TaskService"), "TaskService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TaskService"), "TaskService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TaskService_V1_0_0_JSON (*((EFI_REDFISH_TASKSERVICE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_0_0 *TaskServiceV1_0_0; + + TaskServiceV1_0_0 = (EFI_REDFISH_TASKSERVICE_V1_0_0 *)InterpProp; + DestroyTaskService_V1_0_0_CS (TaskServiceV1_0_0->TaskService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTaskService_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskServiceToStructWrapper, + TaskServiceToJson, + TaskServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TaskService/v1_0_2/RedfishTaskService_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/TaskService/v1_0_2/RedfishTaskService_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..5043424e53c --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_0_2/RedfishTaskService_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TaskService.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTaskService_V1_0_2_Dxe + FILE_GUID = 1c32c736-3b4c-4a43-be7c-36f6d79e8aec + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTaskService_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishTaskService_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TaskService_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskServiceV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TaskService/v1_0_2/TaskService_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/TaskService/v1_0_2/TaskService_V1_0_2_Dxe.c new file mode 100644 index 00000000000..d554cd074c3 --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_0_2/TaskService_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TaskService.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TaskService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TaskService V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TaskService", + "1", + "0", + "2" + }, + "TaskService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_0_2 *TaskServiceV1_0_2; + EFI_REDFISH_TASKSERVICE_V1_0_2_CS *TaskServiceV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TaskService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TaskService_V1_0_2_To_CS (ResoruceRaw, &TaskServiceV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskServiceV1_0_2 = (EFI_REDFISH_TASKSERVICE_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASKSERVICE_V1_0_2)); + if (TaskServiceV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskServiceV1_0_2; + TaskServiceV1_0_2->TaskService = TaskServiceV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TaskService"), "TaskService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TaskService"), "TaskService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TaskService_V1_0_2_JSON (*((EFI_REDFISH_TASKSERVICE_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_0_2 *TaskServiceV1_0_2; + + TaskServiceV1_0_2 = (EFI_REDFISH_TASKSERVICE_V1_0_2 *)InterpProp; + DestroyTaskService_V1_0_2_CS (TaskServiceV1_0_2->TaskService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTaskService_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskServiceToStructWrapper, + TaskServiceToJson, + TaskServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TaskService/v1_0_3/RedfishTaskService_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/TaskService/v1_0_3/RedfishTaskService_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..4de6490a173 --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_0_3/RedfishTaskService_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TaskService.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTaskService_V1_0_3_Dxe + FILE_GUID = 138784e2-cf87-476d-a9cd-cfaf1c255530 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTaskService_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishTaskService_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TaskService_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskServiceV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TaskService/v1_0_3/TaskService_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/TaskService/v1_0_3/TaskService_V1_0_3_Dxe.c new file mode 100644 index 00000000000..f1fc14dedaf --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_0_3/TaskService_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TaskService.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TaskService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TaskService V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TaskService", + "1", + "0", + "3" + }, + "TaskService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_0_3 *TaskServiceV1_0_3; + EFI_REDFISH_TASKSERVICE_V1_0_3_CS *TaskServiceV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TaskService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TaskService_V1_0_3_To_CS (ResoruceRaw, &TaskServiceV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskServiceV1_0_3 = (EFI_REDFISH_TASKSERVICE_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASKSERVICE_V1_0_3)); + if (TaskServiceV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskServiceV1_0_3; + TaskServiceV1_0_3->TaskService = TaskServiceV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TaskService"), "TaskService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TaskService"), "TaskService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TaskService_V1_0_3_JSON (*((EFI_REDFISH_TASKSERVICE_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_0_3 *TaskServiceV1_0_3; + + TaskServiceV1_0_3 = (EFI_REDFISH_TASKSERVICE_V1_0_3 *)InterpProp; + DestroyTaskService_V1_0_3_CS (TaskServiceV1_0_3->TaskService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTaskService_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskServiceToStructWrapper, + TaskServiceToJson, + TaskServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TaskService/v1_0_4/RedfishTaskService_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/TaskService/v1_0_4/RedfishTaskService_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..a431caf939f --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_0_4/RedfishTaskService_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TaskService.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTaskService_V1_0_4_Dxe + FILE_GUID = e39e7805-5e57-4db3-baee-d0361e3bdb79 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTaskService_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishTaskService_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TaskService_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskServiceV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TaskService/v1_0_4/TaskService_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/TaskService/v1_0_4/TaskService_V1_0_4_Dxe.c new file mode 100644 index 00000000000..55647143e98 --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_0_4/TaskService_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TaskService.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TaskService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TaskService V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TaskService", + "1", + "0", + "4" + }, + "TaskService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_0_4 *TaskServiceV1_0_4; + EFI_REDFISH_TASKSERVICE_V1_0_4_CS *TaskServiceV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TaskService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TaskService_V1_0_4_To_CS (ResoruceRaw, &TaskServiceV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskServiceV1_0_4 = (EFI_REDFISH_TASKSERVICE_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASKSERVICE_V1_0_4)); + if (TaskServiceV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskServiceV1_0_4; + TaskServiceV1_0_4->TaskService = TaskServiceV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TaskService"), "TaskService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TaskService"), "TaskService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TaskService_V1_0_4_JSON (*((EFI_REDFISH_TASKSERVICE_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_0_4 *TaskServiceV1_0_4; + + TaskServiceV1_0_4 = (EFI_REDFISH_TASKSERVICE_V1_0_4 *)InterpProp; + DestroyTaskService_V1_0_4_CS (TaskServiceV1_0_4->TaskService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTaskService_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskServiceToStructWrapper, + TaskServiceToJson, + TaskServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TaskService/v1_0_5/RedfishTaskService_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/TaskService/v1_0_5/RedfishTaskService_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..dbe73734273 --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_0_5/RedfishTaskService_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TaskService.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTaskService_V1_0_5_Dxe + FILE_GUID = 988a1dfe-571b-4cc8-ad26-47f107905c8d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTaskService_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishTaskService_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TaskService_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskServiceV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TaskService/v1_0_5/TaskService_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/TaskService/v1_0_5/TaskService_V1_0_5_Dxe.c new file mode 100644 index 00000000000..a10892c1d21 --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_0_5/TaskService_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TaskService.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TaskService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TaskService V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TaskService", + "1", + "0", + "5" + }, + "TaskService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_0_5 *TaskServiceV1_0_5; + EFI_REDFISH_TASKSERVICE_V1_0_5_CS *TaskServiceV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TaskService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TaskService_V1_0_5_To_CS (ResoruceRaw, &TaskServiceV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskServiceV1_0_5 = (EFI_REDFISH_TASKSERVICE_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASKSERVICE_V1_0_5)); + if (TaskServiceV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskServiceV1_0_5; + TaskServiceV1_0_5->TaskService = TaskServiceV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TaskService"), "TaskService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TaskService"), "TaskService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TaskService_V1_0_5_JSON (*((EFI_REDFISH_TASKSERVICE_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_0_5 *TaskServiceV1_0_5; + + TaskServiceV1_0_5 = (EFI_REDFISH_TASKSERVICE_V1_0_5 *)InterpProp; + DestroyTaskService_V1_0_5_CS (TaskServiceV1_0_5->TaskService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTaskService_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskServiceToStructWrapper, + TaskServiceToJson, + TaskServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TaskService/v1_0_6/RedfishTaskService_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/TaskService/v1_0_6/RedfishTaskService_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..abc788a8ea2 --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_0_6/RedfishTaskService_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TaskService.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTaskService_V1_0_6_Dxe + FILE_GUID = cb90d9bb-7820-496b-bc45-322e66674fc1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTaskService_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishTaskService_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TaskService_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskServiceV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TaskService/v1_0_6/TaskService_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/TaskService/v1_0_6/TaskService_V1_0_6_Dxe.c new file mode 100644 index 00000000000..0a45efcff9f --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_0_6/TaskService_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TaskService.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TaskService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TaskService V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TaskService", + "1", + "0", + "6" + }, + "TaskService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_0_6 *TaskServiceV1_0_6; + EFI_REDFISH_TASKSERVICE_V1_0_6_CS *TaskServiceV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TaskService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TaskService_V1_0_6_To_CS (ResoruceRaw, &TaskServiceV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskServiceV1_0_6 = (EFI_REDFISH_TASKSERVICE_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASKSERVICE_V1_0_6)); + if (TaskServiceV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskServiceV1_0_6; + TaskServiceV1_0_6->TaskService = TaskServiceV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TaskService"), "TaskService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TaskService"), "TaskService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TaskService_V1_0_6_JSON (*((EFI_REDFISH_TASKSERVICE_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_0_6 *TaskServiceV1_0_6; + + TaskServiceV1_0_6 = (EFI_REDFISH_TASKSERVICE_V1_0_6 *)InterpProp; + DestroyTaskService_V1_0_6_CS (TaskServiceV1_0_6->TaskService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTaskService_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskServiceToStructWrapper, + TaskServiceToJson, + TaskServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TaskService/v1_0_7/RedfishTaskService_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/TaskService/v1_0_7/RedfishTaskService_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..e7cde221211 --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_0_7/RedfishTaskService_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TaskService.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTaskService_V1_0_7_Dxe + FILE_GUID = b1e26bdc-43cb-44fb-b3b5-5d7e20502809 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTaskService_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishTaskService_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TaskService_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskServiceV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TaskService/v1_0_7/TaskService_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/TaskService/v1_0_7/TaskService_V1_0_7_Dxe.c new file mode 100644 index 00000000000..4daa3118e32 --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_0_7/TaskService_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TaskService.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TaskService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TaskService V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TaskService", + "1", + "0", + "7" + }, + "TaskService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_0_7 *TaskServiceV1_0_7; + EFI_REDFISH_TASKSERVICE_V1_0_7_CS *TaskServiceV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TaskService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TaskService_V1_0_7_To_CS (ResoruceRaw, &TaskServiceV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskServiceV1_0_7 = (EFI_REDFISH_TASKSERVICE_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASKSERVICE_V1_0_7)); + if (TaskServiceV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskServiceV1_0_7; + TaskServiceV1_0_7->TaskService = TaskServiceV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TaskService"), "TaskService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TaskService"), "TaskService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TaskService_V1_0_7_JSON (*((EFI_REDFISH_TASKSERVICE_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_0_7 *TaskServiceV1_0_7; + + TaskServiceV1_0_7 = (EFI_REDFISH_TASKSERVICE_V1_0_7 *)InterpProp; + DestroyTaskService_V1_0_7_CS (TaskServiceV1_0_7->TaskService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTaskService_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskServiceToStructWrapper, + TaskServiceToJson, + TaskServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TaskService/v1_0_8/RedfishTaskService_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/TaskService/v1_0_8/RedfishTaskService_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..f87fa3e162f --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_0_8/RedfishTaskService_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TaskService.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTaskService_V1_0_8_Dxe + FILE_GUID = db5fe789-7633-4388-84c6-ec4aea18932f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTaskService_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishTaskService_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TaskService_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskServiceV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TaskService/v1_0_8/TaskService_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/TaskService/v1_0_8/TaskService_V1_0_8_Dxe.c new file mode 100644 index 00000000000..45c492a9a8c --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_0_8/TaskService_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TaskService.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TaskService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TaskService V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TaskService", + "1", + "0", + "8" + }, + "TaskService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_0_8 *TaskServiceV1_0_8; + EFI_REDFISH_TASKSERVICE_V1_0_8_CS *TaskServiceV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TaskService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TaskService_V1_0_8_To_CS (ResoruceRaw, &TaskServiceV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskServiceV1_0_8 = (EFI_REDFISH_TASKSERVICE_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASKSERVICE_V1_0_8)); + if (TaskServiceV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskServiceV1_0_8; + TaskServiceV1_0_8->TaskService = TaskServiceV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TaskService"), "TaskService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TaskService"), "TaskService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TaskService_V1_0_8_JSON (*((EFI_REDFISH_TASKSERVICE_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_0_8 *TaskServiceV1_0_8; + + TaskServiceV1_0_8 = (EFI_REDFISH_TASKSERVICE_V1_0_8 *)InterpProp; + DestroyTaskService_V1_0_8_CS (TaskServiceV1_0_8->TaskService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTaskService_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskServiceToStructWrapper, + TaskServiceToJson, + TaskServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TaskService/v1_0_9/RedfishTaskService_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/TaskService/v1_0_9/RedfishTaskService_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..6fe00fc6b18 --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_0_9/RedfishTaskService_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TaskService.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTaskService_V1_0_9_Dxe + FILE_GUID = 7c061799-9f73-46e0-aa24-db864d895491 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTaskService_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishTaskService_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TaskService_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskServiceV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TaskService/v1_0_9/TaskService_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/TaskService/v1_0_9/TaskService_V1_0_9_Dxe.c new file mode 100644 index 00000000000..8d782faeda4 --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_0_9/TaskService_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TaskService.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TaskService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TaskService V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TaskService", + "1", + "0", + "9" + }, + "TaskService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_0_9 *TaskServiceV1_0_9; + EFI_REDFISH_TASKSERVICE_V1_0_9_CS *TaskServiceV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TaskService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TaskService_V1_0_9_To_CS (ResoruceRaw, &TaskServiceV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskServiceV1_0_9 = (EFI_REDFISH_TASKSERVICE_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASKSERVICE_V1_0_9)); + if (TaskServiceV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskServiceV1_0_9; + TaskServiceV1_0_9->TaskService = TaskServiceV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TaskService"), "TaskService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TaskService"), "TaskService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TaskService_V1_0_9_JSON (*((EFI_REDFISH_TASKSERVICE_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_0_9 *TaskServiceV1_0_9; + + TaskServiceV1_0_9 = (EFI_REDFISH_TASKSERVICE_V1_0_9 *)InterpProp; + DestroyTaskService_V1_0_9_CS (TaskServiceV1_0_9->TaskService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTaskService_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskServiceToStructWrapper, + TaskServiceToJson, + TaskServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TaskService/v1_1_0/RedfishTaskService_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/TaskService/v1_1_0/RedfishTaskService_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..61e44f01ff4 --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_1_0/RedfishTaskService_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TaskService.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTaskService_V1_1_0_Dxe + FILE_GUID = b75f6c25-1dee-42df-8c9c-d5e417f038f8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTaskService_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishTaskService_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TaskService_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskServiceV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TaskService/v1_1_0/TaskService_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/TaskService/v1_1_0/TaskService_V1_1_0_Dxe.c new file mode 100644 index 00000000000..968b0724ae0 --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_1_0/TaskService_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TaskService.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TaskService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TaskService V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TaskService", + "1", + "1", + "0" + }, + "TaskService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_1_0 *TaskServiceV1_1_0; + EFI_REDFISH_TASKSERVICE_V1_1_0_CS *TaskServiceV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TaskService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TaskService_V1_1_0_To_CS (ResoruceRaw, &TaskServiceV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskServiceV1_1_0 = (EFI_REDFISH_TASKSERVICE_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASKSERVICE_V1_1_0)); + if (TaskServiceV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskServiceV1_1_0; + TaskServiceV1_1_0->TaskService = TaskServiceV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TaskService"), "TaskService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TaskService"), "TaskService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TaskService_V1_1_0_JSON (*((EFI_REDFISH_TASKSERVICE_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_1_0 *TaskServiceV1_1_0; + + TaskServiceV1_1_0 = (EFI_REDFISH_TASKSERVICE_V1_1_0 *)InterpProp; + DestroyTaskService_V1_1_0_CS (TaskServiceV1_1_0->TaskService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTaskService_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskServiceToStructWrapper, + TaskServiceToJson, + TaskServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TaskService/v1_1_1/RedfishTaskService_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/TaskService/v1_1_1/RedfishTaskService_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..c61de6d4d54 --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_1_1/RedfishTaskService_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TaskService.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTaskService_V1_1_1_Dxe + FILE_GUID = 5de9b3d6-3068-440e-9190-6334163e5674 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTaskService_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishTaskService_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TaskService_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskServiceV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TaskService/v1_1_1/TaskService_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/TaskService/v1_1_1/TaskService_V1_1_1_Dxe.c new file mode 100644 index 00000000000..8084845c208 --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_1_1/TaskService_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TaskService.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TaskService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TaskService V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TaskService", + "1", + "1", + "1" + }, + "TaskService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_1_1 *TaskServiceV1_1_1; + EFI_REDFISH_TASKSERVICE_V1_1_1_CS *TaskServiceV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TaskService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TaskService_V1_1_1_To_CS (ResoruceRaw, &TaskServiceV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskServiceV1_1_1 = (EFI_REDFISH_TASKSERVICE_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASKSERVICE_V1_1_1)); + if (TaskServiceV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskServiceV1_1_1; + TaskServiceV1_1_1->TaskService = TaskServiceV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TaskService"), "TaskService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TaskService"), "TaskService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TaskService_V1_1_1_JSON (*((EFI_REDFISH_TASKSERVICE_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_1_1 *TaskServiceV1_1_1; + + TaskServiceV1_1_1 = (EFI_REDFISH_TASKSERVICE_V1_1_1 *)InterpProp; + DestroyTaskService_V1_1_1_CS (TaskServiceV1_1_1->TaskService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTaskService_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskServiceToStructWrapper, + TaskServiceToJson, + TaskServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TaskService/v1_1_2/RedfishTaskService_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/TaskService/v1_1_2/RedfishTaskService_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..04ff18889c8 --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_1_2/RedfishTaskService_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TaskService.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTaskService_V1_1_2_Dxe + FILE_GUID = 8150097f-2026-4239-bf39-9361ab790ee6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTaskService_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishTaskService_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TaskService_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskServiceV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TaskService/v1_1_2/TaskService_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/TaskService/v1_1_2/TaskService_V1_1_2_Dxe.c new file mode 100644 index 00000000000..99ae02835cb --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_1_2/TaskService_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TaskService.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TaskService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TaskService V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TaskService", + "1", + "1", + "2" + }, + "TaskService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_1_2 *TaskServiceV1_1_2; + EFI_REDFISH_TASKSERVICE_V1_1_2_CS *TaskServiceV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TaskService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TaskService_V1_1_2_To_CS (ResoruceRaw, &TaskServiceV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskServiceV1_1_2 = (EFI_REDFISH_TASKSERVICE_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASKSERVICE_V1_1_2)); + if (TaskServiceV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskServiceV1_1_2; + TaskServiceV1_1_2->TaskService = TaskServiceV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TaskService"), "TaskService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TaskService"), "TaskService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TaskService_V1_1_2_JSON (*((EFI_REDFISH_TASKSERVICE_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_1_2 *TaskServiceV1_1_2; + + TaskServiceV1_1_2 = (EFI_REDFISH_TASKSERVICE_V1_1_2 *)InterpProp; + DestroyTaskService_V1_1_2_CS (TaskServiceV1_1_2->TaskService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTaskService_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskServiceToStructWrapper, + TaskServiceToJson, + TaskServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TaskService/v1_1_3/RedfishTaskService_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/TaskService/v1_1_3/RedfishTaskService_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..09486a59c5d --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_1_3/RedfishTaskService_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TaskService.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTaskService_V1_1_3_Dxe + FILE_GUID = 86e265fe-e19b-4cba-9a4b-ae13b277369e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTaskService_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishTaskService_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TaskService_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskServiceV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TaskService/v1_1_3/TaskService_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/TaskService/v1_1_3/TaskService_V1_1_3_Dxe.c new file mode 100644 index 00000000000..4026fc09bfb --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_1_3/TaskService_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TaskService.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TaskService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TaskService V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TaskService", + "1", + "1", + "3" + }, + "TaskService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_1_3 *TaskServiceV1_1_3; + EFI_REDFISH_TASKSERVICE_V1_1_3_CS *TaskServiceV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TaskService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TaskService_V1_1_3_To_CS (ResoruceRaw, &TaskServiceV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskServiceV1_1_3 = (EFI_REDFISH_TASKSERVICE_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASKSERVICE_V1_1_3)); + if (TaskServiceV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskServiceV1_1_3; + TaskServiceV1_1_3->TaskService = TaskServiceV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TaskService"), "TaskService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TaskService"), "TaskService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TaskService_V1_1_3_JSON (*((EFI_REDFISH_TASKSERVICE_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_1_3 *TaskServiceV1_1_3; + + TaskServiceV1_1_3 = (EFI_REDFISH_TASKSERVICE_V1_1_3 *)InterpProp; + DestroyTaskService_V1_1_3_CS (TaskServiceV1_1_3->TaskService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTaskService_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskServiceToStructWrapper, + TaskServiceToJson, + TaskServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TaskService/v1_1_4/RedfishTaskService_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/TaskService/v1_1_4/RedfishTaskService_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..b672c1e86b5 --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_1_4/RedfishTaskService_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TaskService.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTaskService_V1_1_4_Dxe + FILE_GUID = 09ec5111-955f-460b-9b41-c47f7efe1dd4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTaskService_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishTaskService_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TaskService_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskServiceV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TaskService/v1_1_4/TaskService_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/TaskService/v1_1_4/TaskService_V1_1_4_Dxe.c new file mode 100644 index 00000000000..c56dda7198d --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_1_4/TaskService_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TaskService.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TaskService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TaskService V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TaskService", + "1", + "1", + "4" + }, + "TaskService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_1_4 *TaskServiceV1_1_4; + EFI_REDFISH_TASKSERVICE_V1_1_4_CS *TaskServiceV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TaskService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TaskService_V1_1_4_To_CS (ResoruceRaw, &TaskServiceV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskServiceV1_1_4 = (EFI_REDFISH_TASKSERVICE_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASKSERVICE_V1_1_4)); + if (TaskServiceV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskServiceV1_1_4; + TaskServiceV1_1_4->TaskService = TaskServiceV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TaskService"), "TaskService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TaskService"), "TaskService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TaskService_V1_1_4_JSON (*((EFI_REDFISH_TASKSERVICE_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_1_4 *TaskServiceV1_1_4; + + TaskServiceV1_1_4 = (EFI_REDFISH_TASKSERVICE_V1_1_4 *)InterpProp; + DestroyTaskService_V1_1_4_CS (TaskServiceV1_1_4->TaskService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTaskService_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskServiceToStructWrapper, + TaskServiceToJson, + TaskServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TaskService/v1_1_5/RedfishTaskService_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/TaskService/v1_1_5/RedfishTaskService_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..efd70cc5cda --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_1_5/RedfishTaskService_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TaskService.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTaskService_V1_1_5_Dxe + FILE_GUID = 07bf26b6-d836-4ea8-8491-9427c23410e0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTaskService_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishTaskService_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TaskService_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskServiceV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TaskService/v1_1_5/TaskService_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/TaskService/v1_1_5/TaskService_V1_1_5_Dxe.c new file mode 100644 index 00000000000..97a214379c7 --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_1_5/TaskService_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TaskService.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TaskService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TaskService V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TaskService", + "1", + "1", + "5" + }, + "TaskService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_1_5 *TaskServiceV1_1_5; + EFI_REDFISH_TASKSERVICE_V1_1_5_CS *TaskServiceV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TaskService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TaskService_V1_1_5_To_CS (ResoruceRaw, &TaskServiceV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskServiceV1_1_5 = (EFI_REDFISH_TASKSERVICE_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASKSERVICE_V1_1_5)); + if (TaskServiceV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskServiceV1_1_5; + TaskServiceV1_1_5->TaskService = TaskServiceV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TaskService"), "TaskService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TaskService"), "TaskService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TaskService_V1_1_5_JSON (*((EFI_REDFISH_TASKSERVICE_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_1_5 *TaskServiceV1_1_5; + + TaskServiceV1_1_5 = (EFI_REDFISH_TASKSERVICE_V1_1_5 *)InterpProp; + DestroyTaskService_V1_1_5_CS (TaskServiceV1_1_5->TaskService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTaskService_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskServiceToStructWrapper, + TaskServiceToJson, + TaskServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TaskService/v1_1_6/RedfishTaskService_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/TaskService/v1_1_6/RedfishTaskService_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..bd17d300adf --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_1_6/RedfishTaskService_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TaskService.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTaskService_V1_1_6_Dxe + FILE_GUID = 1a7bc88c-6699-4360-a59b-901b503fe9d7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTaskService_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishTaskService_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TaskService_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TaskServiceV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TaskService/v1_1_6/TaskService_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/TaskService/v1_1_6/TaskService_V1_1_6_Dxe.c new file mode 100644 index 00000000000..2af1847bf28 --- /dev/null +++ b/RedfishClientPkg/Converter/TaskService/v1_1_6/TaskService_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TaskService.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TaskService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TaskService V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TaskService", + "1", + "1", + "6" + }, + "TaskService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_1_6 *TaskServiceV1_1_6; + EFI_REDFISH_TASKSERVICE_V1_1_6_CS *TaskServiceV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TaskService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TaskService_V1_1_6_To_CS (ResoruceRaw, &TaskServiceV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TaskServiceV1_1_6 = (EFI_REDFISH_TASKSERVICE_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TASKSERVICE_V1_1_6)); + if (TaskServiceV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TaskServiceV1_1_6; + TaskServiceV1_1_6->TaskService = TaskServiceV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TaskService"), "TaskService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TaskService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TaskService"), "TaskService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TaskServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TaskServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TaskService_V1_1_6_JSON (*((EFI_REDFISH_TASKSERVICE_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TaskServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TASKSERVICE_V1_1_6 *TaskServiceV1_1_6; + + TaskServiceV1_1_6 = (EFI_REDFISH_TASKSERVICE_V1_1_6 *)InterpProp; + DestroyTaskService_V1_1_6_CS (TaskServiceV1_1_6->TaskService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TaskServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TaskServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTaskService_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TaskServiceToStructWrapper, + TaskServiceToJson, + TaskServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTaskService_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_0_0/RedfishTelemetryService_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/TelemetryService/v1_0_0/RedfishTelemetryService_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..bbab4041da1 --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_0_0/RedfishTelemetryService_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TelemetryService.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTelemetryService_V1_0_0_Dxe + FILE_GUID = e1b9d7bd-0ce9-42e0-9874-a28cbe1de0f3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTelemetryService_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishTelemetryService_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TelemetryService_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TelemetryServiceV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_0_0/TelemetryService_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/TelemetryService/v1_0_0/TelemetryService_V1_0_0_Dxe.c new file mode 100644 index 00000000000..ca38b151581 --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_0_0/TelemetryService_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TelemetryService.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TelemetryService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TelemetryService V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TelemetryService", + "1", + "0", + "0" + }, + "TelemetryService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_0_0 *TelemetryServiceV1_0_0; + EFI_REDFISH_TELEMETRYSERVICE_V1_0_0_CS *TelemetryServiceV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TelemetryService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TelemetryService_V1_0_0_To_CS (ResoruceRaw, &TelemetryServiceV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TelemetryServiceV1_0_0 = (EFI_REDFISH_TELEMETRYSERVICE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TELEMETRYSERVICE_V1_0_0)); + if (TelemetryServiceV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TelemetryServiceV1_0_0; + TelemetryServiceV1_0_0->TelemetryService = TelemetryServiceV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TelemetryService"), "TelemetryService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TelemetryService"), "TelemetryService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TelemetryServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TelemetryServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TelemetryService_V1_0_0_JSON (*((EFI_REDFISH_TELEMETRYSERVICE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TelemetryServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_0_0 *TelemetryServiceV1_0_0; + + TelemetryServiceV1_0_0 = (EFI_REDFISH_TELEMETRYSERVICE_V1_0_0 *)InterpProp; + DestroyTelemetryService_V1_0_0_CS (TelemetryServiceV1_0_0->TelemetryService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TelemetryServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTelemetryService_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TelemetryServiceToStructWrapper, + TelemetryServiceToJson, + TelemetryServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_0_1/RedfishTelemetryService_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/TelemetryService/v1_0_1/RedfishTelemetryService_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..8bd68beca45 --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_0_1/RedfishTelemetryService_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TelemetryService.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTelemetryService_V1_0_1_Dxe + FILE_GUID = ef6c33ee-2c09-4a26-bb42-f637da8b9b55 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTelemetryService_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishTelemetryService_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TelemetryService_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TelemetryServiceV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_0_1/TelemetryService_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/TelemetryService/v1_0_1/TelemetryService_V1_0_1_Dxe.c new file mode 100644 index 00000000000..38da81cd152 --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_0_1/TelemetryService_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TelemetryService.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TelemetryService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TelemetryService V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TelemetryService", + "1", + "0", + "1" + }, + "TelemetryService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_0_1 *TelemetryServiceV1_0_1; + EFI_REDFISH_TELEMETRYSERVICE_V1_0_1_CS *TelemetryServiceV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TelemetryService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TelemetryService_V1_0_1_To_CS (ResoruceRaw, &TelemetryServiceV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TelemetryServiceV1_0_1 = (EFI_REDFISH_TELEMETRYSERVICE_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TELEMETRYSERVICE_V1_0_1)); + if (TelemetryServiceV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TelemetryServiceV1_0_1; + TelemetryServiceV1_0_1->TelemetryService = TelemetryServiceV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TelemetryService"), "TelemetryService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TelemetryService"), "TelemetryService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TelemetryServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TelemetryServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TelemetryService_V1_0_1_JSON (*((EFI_REDFISH_TELEMETRYSERVICE_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TelemetryServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_0_1 *TelemetryServiceV1_0_1; + + TelemetryServiceV1_0_1 = (EFI_REDFISH_TELEMETRYSERVICE_V1_0_1 *)InterpProp; + DestroyTelemetryService_V1_0_1_CS (TelemetryServiceV1_0_1->TelemetryService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TelemetryServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTelemetryService_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TelemetryServiceToStructWrapper, + TelemetryServiceToJson, + TelemetryServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_0_2/RedfishTelemetryService_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/TelemetryService/v1_0_2/RedfishTelemetryService_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..66605a5cd30 --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_0_2/RedfishTelemetryService_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TelemetryService.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTelemetryService_V1_0_2_Dxe + FILE_GUID = 504fe41a-578d-4cf7-a576-109276c1b9bb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTelemetryService_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishTelemetryService_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TelemetryService_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TelemetryServiceV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_0_2/TelemetryService_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/TelemetryService/v1_0_2/TelemetryService_V1_0_2_Dxe.c new file mode 100644 index 00000000000..624c36e5c96 --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_0_2/TelemetryService_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TelemetryService.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TelemetryService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TelemetryService V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TelemetryService", + "1", + "0", + "2" + }, + "TelemetryService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_0_2 *TelemetryServiceV1_0_2; + EFI_REDFISH_TELEMETRYSERVICE_V1_0_2_CS *TelemetryServiceV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TelemetryService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TelemetryService_V1_0_2_To_CS (ResoruceRaw, &TelemetryServiceV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TelemetryServiceV1_0_2 = (EFI_REDFISH_TELEMETRYSERVICE_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TELEMETRYSERVICE_V1_0_2)); + if (TelemetryServiceV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TelemetryServiceV1_0_2; + TelemetryServiceV1_0_2->TelemetryService = TelemetryServiceV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TelemetryService"), "TelemetryService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TelemetryService"), "TelemetryService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TelemetryServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TelemetryServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TelemetryService_V1_0_2_JSON (*((EFI_REDFISH_TELEMETRYSERVICE_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TelemetryServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_0_2 *TelemetryServiceV1_0_2; + + TelemetryServiceV1_0_2 = (EFI_REDFISH_TELEMETRYSERVICE_V1_0_2 *)InterpProp; + DestroyTelemetryService_V1_0_2_CS (TelemetryServiceV1_0_2->TelemetryService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TelemetryServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTelemetryService_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TelemetryServiceToStructWrapper, + TelemetryServiceToJson, + TelemetryServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_0_3/RedfishTelemetryService_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/TelemetryService/v1_0_3/RedfishTelemetryService_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..42567ecf9cd --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_0_3/RedfishTelemetryService_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TelemetryService.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTelemetryService_V1_0_3_Dxe + FILE_GUID = 704a6a60-e88a-427d-baf3-a30f2402146b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTelemetryService_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishTelemetryService_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TelemetryService_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TelemetryServiceV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_0_3/TelemetryService_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/TelemetryService/v1_0_3/TelemetryService_V1_0_3_Dxe.c new file mode 100644 index 00000000000..ef10570e1dc --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_0_3/TelemetryService_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TelemetryService.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TelemetryService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TelemetryService V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TelemetryService", + "1", + "0", + "3" + }, + "TelemetryService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_0_3 *TelemetryServiceV1_0_3; + EFI_REDFISH_TELEMETRYSERVICE_V1_0_3_CS *TelemetryServiceV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TelemetryService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TelemetryService_V1_0_3_To_CS (ResoruceRaw, &TelemetryServiceV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TelemetryServiceV1_0_3 = (EFI_REDFISH_TELEMETRYSERVICE_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TELEMETRYSERVICE_V1_0_3)); + if (TelemetryServiceV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TelemetryServiceV1_0_3; + TelemetryServiceV1_0_3->TelemetryService = TelemetryServiceV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TelemetryService"), "TelemetryService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TelemetryService"), "TelemetryService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TelemetryServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TelemetryServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TelemetryService_V1_0_3_JSON (*((EFI_REDFISH_TELEMETRYSERVICE_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TelemetryServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_0_3 *TelemetryServiceV1_0_3; + + TelemetryServiceV1_0_3 = (EFI_REDFISH_TELEMETRYSERVICE_V1_0_3 *)InterpProp; + DestroyTelemetryService_V1_0_3_CS (TelemetryServiceV1_0_3->TelemetryService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TelemetryServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTelemetryService_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TelemetryServiceToStructWrapper, + TelemetryServiceToJson, + TelemetryServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_0_4/RedfishTelemetryService_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/TelemetryService/v1_0_4/RedfishTelemetryService_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..bc604584e22 --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_0_4/RedfishTelemetryService_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TelemetryService.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTelemetryService_V1_0_4_Dxe + FILE_GUID = 6dd6d7d9-c3a9-4f35-97f4-85161b29498e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTelemetryService_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishTelemetryService_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TelemetryService_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TelemetryServiceV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_0_4/TelemetryService_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/TelemetryService/v1_0_4/TelemetryService_V1_0_4_Dxe.c new file mode 100644 index 00000000000..71d0b63184a --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_0_4/TelemetryService_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TelemetryService.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TelemetryService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TelemetryService V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TelemetryService", + "1", + "0", + "4" + }, + "TelemetryService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_0_4 *TelemetryServiceV1_0_4; + EFI_REDFISH_TELEMETRYSERVICE_V1_0_4_CS *TelemetryServiceV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TelemetryService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TelemetryService_V1_0_4_To_CS (ResoruceRaw, &TelemetryServiceV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TelemetryServiceV1_0_4 = (EFI_REDFISH_TELEMETRYSERVICE_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TELEMETRYSERVICE_V1_0_4)); + if (TelemetryServiceV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TelemetryServiceV1_0_4; + TelemetryServiceV1_0_4->TelemetryService = TelemetryServiceV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TelemetryService"), "TelemetryService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TelemetryService"), "TelemetryService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TelemetryServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TelemetryServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TelemetryService_V1_0_4_JSON (*((EFI_REDFISH_TELEMETRYSERVICE_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TelemetryServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_0_4 *TelemetryServiceV1_0_4; + + TelemetryServiceV1_0_4 = (EFI_REDFISH_TELEMETRYSERVICE_V1_0_4 *)InterpProp; + DestroyTelemetryService_V1_0_4_CS (TelemetryServiceV1_0_4->TelemetryService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TelemetryServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTelemetryService_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TelemetryServiceToStructWrapper, + TelemetryServiceToJson, + TelemetryServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_1_0/RedfishTelemetryService_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/TelemetryService/v1_1_0/RedfishTelemetryService_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..64a3e1ca107 --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_1_0/RedfishTelemetryService_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TelemetryService.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTelemetryService_V1_1_0_Dxe + FILE_GUID = 919391e4-034d-4cfa-aa44-e7e5fee0365a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTelemetryService_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishTelemetryService_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TelemetryService_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TelemetryServiceV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_1_0/TelemetryService_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/TelemetryService/v1_1_0/TelemetryService_V1_1_0_Dxe.c new file mode 100644 index 00000000000..cfe1338ffb9 --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_1_0/TelemetryService_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TelemetryService.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TelemetryService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TelemetryService V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TelemetryService", + "1", + "1", + "0" + }, + "TelemetryService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_1_0 *TelemetryServiceV1_1_0; + EFI_REDFISH_TELEMETRYSERVICE_V1_1_0_CS *TelemetryServiceV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TelemetryService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TelemetryService_V1_1_0_To_CS (ResoruceRaw, &TelemetryServiceV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TelemetryServiceV1_1_0 = (EFI_REDFISH_TELEMETRYSERVICE_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TELEMETRYSERVICE_V1_1_0)); + if (TelemetryServiceV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TelemetryServiceV1_1_0; + TelemetryServiceV1_1_0->TelemetryService = TelemetryServiceV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TelemetryService"), "TelemetryService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TelemetryService"), "TelemetryService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TelemetryServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TelemetryServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TelemetryService_V1_1_0_JSON (*((EFI_REDFISH_TELEMETRYSERVICE_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TelemetryServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_1_0 *TelemetryServiceV1_1_0; + + TelemetryServiceV1_1_0 = (EFI_REDFISH_TELEMETRYSERVICE_V1_1_0 *)InterpProp; + DestroyTelemetryService_V1_1_0_CS (TelemetryServiceV1_1_0->TelemetryService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TelemetryServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTelemetryService_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TelemetryServiceToStructWrapper, + TelemetryServiceToJson, + TelemetryServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_1_1/RedfishTelemetryService_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/TelemetryService/v1_1_1/RedfishTelemetryService_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..9f31bdc2121 --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_1_1/RedfishTelemetryService_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TelemetryService.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTelemetryService_V1_1_1_Dxe + FILE_GUID = e2cc64ff-93e6-4a23-b04a-73d5cd533cca + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTelemetryService_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishTelemetryService_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TelemetryService_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TelemetryServiceV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_1_1/TelemetryService_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/TelemetryService/v1_1_1/TelemetryService_V1_1_1_Dxe.c new file mode 100644 index 00000000000..91e726adc3d --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_1_1/TelemetryService_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TelemetryService.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TelemetryService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TelemetryService V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TelemetryService", + "1", + "1", + "1" + }, + "TelemetryService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_1_1 *TelemetryServiceV1_1_1; + EFI_REDFISH_TELEMETRYSERVICE_V1_1_1_CS *TelemetryServiceV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TelemetryService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TelemetryService_V1_1_1_To_CS (ResoruceRaw, &TelemetryServiceV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TelemetryServiceV1_1_1 = (EFI_REDFISH_TELEMETRYSERVICE_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TELEMETRYSERVICE_V1_1_1)); + if (TelemetryServiceV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TelemetryServiceV1_1_1; + TelemetryServiceV1_1_1->TelemetryService = TelemetryServiceV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TelemetryService"), "TelemetryService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TelemetryService"), "TelemetryService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TelemetryServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TelemetryServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TelemetryService_V1_1_1_JSON (*((EFI_REDFISH_TELEMETRYSERVICE_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TelemetryServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_1_1 *TelemetryServiceV1_1_1; + + TelemetryServiceV1_1_1 = (EFI_REDFISH_TELEMETRYSERVICE_V1_1_1 *)InterpProp; + DestroyTelemetryService_V1_1_1_CS (TelemetryServiceV1_1_1->TelemetryService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TelemetryServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTelemetryService_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TelemetryServiceToStructWrapper, + TelemetryServiceToJson, + TelemetryServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_1_2/RedfishTelemetryService_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/TelemetryService/v1_1_2/RedfishTelemetryService_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..7adcf35c9e7 --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_1_2/RedfishTelemetryService_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TelemetryService.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTelemetryService_V1_1_2_Dxe + FILE_GUID = 1458e291-be23-4883-9860-5ef2d1194c18 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTelemetryService_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishTelemetryService_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TelemetryService_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TelemetryServiceV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_1_2/TelemetryService_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/TelemetryService/v1_1_2/TelemetryService_V1_1_2_Dxe.c new file mode 100644 index 00000000000..71607240d4e --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_1_2/TelemetryService_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TelemetryService.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TelemetryService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TelemetryService V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TelemetryService", + "1", + "1", + "2" + }, + "TelemetryService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_1_2 *TelemetryServiceV1_1_2; + EFI_REDFISH_TELEMETRYSERVICE_V1_1_2_CS *TelemetryServiceV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TelemetryService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TelemetryService_V1_1_2_To_CS (ResoruceRaw, &TelemetryServiceV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TelemetryServiceV1_1_2 = (EFI_REDFISH_TELEMETRYSERVICE_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TELEMETRYSERVICE_V1_1_2)); + if (TelemetryServiceV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TelemetryServiceV1_1_2; + TelemetryServiceV1_1_2->TelemetryService = TelemetryServiceV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TelemetryService"), "TelemetryService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TelemetryService"), "TelemetryService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TelemetryServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TelemetryServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TelemetryService_V1_1_2_JSON (*((EFI_REDFISH_TELEMETRYSERVICE_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TelemetryServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_1_2 *TelemetryServiceV1_1_2; + + TelemetryServiceV1_1_2 = (EFI_REDFISH_TELEMETRYSERVICE_V1_1_2 *)InterpProp; + DestroyTelemetryService_V1_1_2_CS (TelemetryServiceV1_1_2->TelemetryService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TelemetryServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTelemetryService_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TelemetryServiceToStructWrapper, + TelemetryServiceToJson, + TelemetryServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_1_3/RedfishTelemetryService_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/TelemetryService/v1_1_3/RedfishTelemetryService_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..c6dc35be81c --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_1_3/RedfishTelemetryService_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TelemetryService.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTelemetryService_V1_1_3_Dxe + FILE_GUID = 55d5acd1-aa82-4ad5-aaf9-8f3a5f4bbdfb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTelemetryService_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishTelemetryService_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TelemetryService_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TelemetryServiceV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_1_3/TelemetryService_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/TelemetryService/v1_1_3/TelemetryService_V1_1_3_Dxe.c new file mode 100644 index 00000000000..49be67f3106 --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_1_3/TelemetryService_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TelemetryService.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TelemetryService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TelemetryService V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TelemetryService", + "1", + "1", + "3" + }, + "TelemetryService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_1_3 *TelemetryServiceV1_1_3; + EFI_REDFISH_TELEMETRYSERVICE_V1_1_3_CS *TelemetryServiceV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TelemetryService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TelemetryService_V1_1_3_To_CS (ResoruceRaw, &TelemetryServiceV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TelemetryServiceV1_1_3 = (EFI_REDFISH_TELEMETRYSERVICE_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TELEMETRYSERVICE_V1_1_3)); + if (TelemetryServiceV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TelemetryServiceV1_1_3; + TelemetryServiceV1_1_3->TelemetryService = TelemetryServiceV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TelemetryService"), "TelemetryService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TelemetryService"), "TelemetryService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TelemetryServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TelemetryServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TelemetryService_V1_1_3_JSON (*((EFI_REDFISH_TELEMETRYSERVICE_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TelemetryServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_1_3 *TelemetryServiceV1_1_3; + + TelemetryServiceV1_1_3 = (EFI_REDFISH_TELEMETRYSERVICE_V1_1_3 *)InterpProp; + DestroyTelemetryService_V1_1_3_CS (TelemetryServiceV1_1_3->TelemetryService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TelemetryServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTelemetryService_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TelemetryServiceToStructWrapper, + TelemetryServiceToJson, + TelemetryServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_1_4/RedfishTelemetryService_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/TelemetryService/v1_1_4/RedfishTelemetryService_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..c0b88d6c75f --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_1_4/RedfishTelemetryService_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TelemetryService.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTelemetryService_V1_1_4_Dxe + FILE_GUID = b57bccd4-c7cb-4091-a7df-6c829a4f7d03 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTelemetryService_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishTelemetryService_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TelemetryService_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TelemetryServiceV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_1_4/TelemetryService_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/TelemetryService/v1_1_4/TelemetryService_V1_1_4_Dxe.c new file mode 100644 index 00000000000..cb1d45b95db --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_1_4/TelemetryService_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TelemetryService.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TelemetryService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TelemetryService V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TelemetryService", + "1", + "1", + "4" + }, + "TelemetryService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_1_4 *TelemetryServiceV1_1_4; + EFI_REDFISH_TELEMETRYSERVICE_V1_1_4_CS *TelemetryServiceV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TelemetryService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TelemetryService_V1_1_4_To_CS (ResoruceRaw, &TelemetryServiceV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TelemetryServiceV1_1_4 = (EFI_REDFISH_TELEMETRYSERVICE_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TELEMETRYSERVICE_V1_1_4)); + if (TelemetryServiceV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TelemetryServiceV1_1_4; + TelemetryServiceV1_1_4->TelemetryService = TelemetryServiceV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TelemetryService"), "TelemetryService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TelemetryService"), "TelemetryService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TelemetryServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TelemetryServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TelemetryService_V1_1_4_JSON (*((EFI_REDFISH_TELEMETRYSERVICE_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TelemetryServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_1_4 *TelemetryServiceV1_1_4; + + TelemetryServiceV1_1_4 = (EFI_REDFISH_TELEMETRYSERVICE_V1_1_4 *)InterpProp; + DestroyTelemetryService_V1_1_4_CS (TelemetryServiceV1_1_4->TelemetryService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TelemetryServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTelemetryService_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TelemetryServiceToStructWrapper, + TelemetryServiceToJson, + TelemetryServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_2_0/RedfishTelemetryService_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/TelemetryService/v1_2_0/RedfishTelemetryService_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..52e9d355fbc --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_2_0/RedfishTelemetryService_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TelemetryService.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTelemetryService_V1_2_0_Dxe + FILE_GUID = ca61b5e0-9a8b-4313-a6ab-0089793c12fd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTelemetryService_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishTelemetryService_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TelemetryService_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TelemetryServiceV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_2_0/TelemetryService_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/TelemetryService/v1_2_0/TelemetryService_V1_2_0_Dxe.c new file mode 100644 index 00000000000..da2276fa1c9 --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_2_0/TelemetryService_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TelemetryService.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TelemetryService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TelemetryService V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TelemetryService", + "1", + "2", + "0" + }, + "TelemetryService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_2_0 *TelemetryServiceV1_2_0; + EFI_REDFISH_TELEMETRYSERVICE_V1_2_0_CS *TelemetryServiceV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TelemetryService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TelemetryService_V1_2_0_To_CS (ResoruceRaw, &TelemetryServiceV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TelemetryServiceV1_2_0 = (EFI_REDFISH_TELEMETRYSERVICE_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TELEMETRYSERVICE_V1_2_0)); + if (TelemetryServiceV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TelemetryServiceV1_2_0; + TelemetryServiceV1_2_0->TelemetryService = TelemetryServiceV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TelemetryService"), "TelemetryService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TelemetryService"), "TelemetryService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TelemetryServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TelemetryServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TelemetryService_V1_2_0_JSON (*((EFI_REDFISH_TELEMETRYSERVICE_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TelemetryServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_2_0 *TelemetryServiceV1_2_0; + + TelemetryServiceV1_2_0 = (EFI_REDFISH_TELEMETRYSERVICE_V1_2_0 *)InterpProp; + DestroyTelemetryService_V1_2_0_CS (TelemetryServiceV1_2_0->TelemetryService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TelemetryServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTelemetryService_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TelemetryServiceToStructWrapper, + TelemetryServiceToJson, + TelemetryServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_2_1/RedfishTelemetryService_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/TelemetryService/v1_2_1/RedfishTelemetryService_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..0ff41ccaa14 --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_2_1/RedfishTelemetryService_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TelemetryService.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTelemetryService_V1_2_1_Dxe + FILE_GUID = b605d4c3-e245-4103-93d8-c0fc0d3ae87a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTelemetryService_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishTelemetryService_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TelemetryService_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TelemetryServiceV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_2_1/TelemetryService_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/TelemetryService/v1_2_1/TelemetryService_V1_2_1_Dxe.c new file mode 100644 index 00000000000..bd68e06b4bb --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_2_1/TelemetryService_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TelemetryService.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TelemetryService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TelemetryService V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TelemetryService", + "1", + "2", + "1" + }, + "TelemetryService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_2_1 *TelemetryServiceV1_2_1; + EFI_REDFISH_TELEMETRYSERVICE_V1_2_1_CS *TelemetryServiceV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TelemetryService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TelemetryService_V1_2_1_To_CS (ResoruceRaw, &TelemetryServiceV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TelemetryServiceV1_2_1 = (EFI_REDFISH_TELEMETRYSERVICE_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TELEMETRYSERVICE_V1_2_1)); + if (TelemetryServiceV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TelemetryServiceV1_2_1; + TelemetryServiceV1_2_1->TelemetryService = TelemetryServiceV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TelemetryService"), "TelemetryService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TelemetryService"), "TelemetryService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TelemetryServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TelemetryServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TelemetryService_V1_2_1_JSON (*((EFI_REDFISH_TELEMETRYSERVICE_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TelemetryServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_2_1 *TelemetryServiceV1_2_1; + + TelemetryServiceV1_2_1 = (EFI_REDFISH_TELEMETRYSERVICE_V1_2_1 *)InterpProp; + DestroyTelemetryService_V1_2_1_CS (TelemetryServiceV1_2_1->TelemetryService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TelemetryServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTelemetryService_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TelemetryServiceToStructWrapper, + TelemetryServiceToJson, + TelemetryServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_2_2/RedfishTelemetryService_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/TelemetryService/v1_2_2/RedfishTelemetryService_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..d49c8f13692 --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_2_2/RedfishTelemetryService_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TelemetryService.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTelemetryService_V1_2_2_Dxe + FILE_GUID = 8e01386c-cca9-4b4b-9210-7eff07825bd4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTelemetryService_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishTelemetryService_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TelemetryService_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TelemetryServiceV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_2_2/TelemetryService_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/TelemetryService/v1_2_2/TelemetryService_V1_2_2_Dxe.c new file mode 100644 index 00000000000..4e9b1ecadbf --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_2_2/TelemetryService_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TelemetryService.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TelemetryService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TelemetryService V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TelemetryService", + "1", + "2", + "2" + }, + "TelemetryService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_2_2 *TelemetryServiceV1_2_2; + EFI_REDFISH_TELEMETRYSERVICE_V1_2_2_CS *TelemetryServiceV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TelemetryService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TelemetryService_V1_2_2_To_CS (ResoruceRaw, &TelemetryServiceV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TelemetryServiceV1_2_2 = (EFI_REDFISH_TELEMETRYSERVICE_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TELEMETRYSERVICE_V1_2_2)); + if (TelemetryServiceV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TelemetryServiceV1_2_2; + TelemetryServiceV1_2_2->TelemetryService = TelemetryServiceV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TelemetryService"), "TelemetryService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TelemetryService"), "TelemetryService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TelemetryServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TelemetryServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TelemetryService_V1_2_2_JSON (*((EFI_REDFISH_TELEMETRYSERVICE_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TelemetryServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_2_2 *TelemetryServiceV1_2_2; + + TelemetryServiceV1_2_2 = (EFI_REDFISH_TELEMETRYSERVICE_V1_2_2 *)InterpProp; + DestroyTelemetryService_V1_2_2_CS (TelemetryServiceV1_2_2->TelemetryService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TelemetryServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTelemetryService_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TelemetryServiceToStructWrapper, + TelemetryServiceToJson, + TelemetryServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_3_0/RedfishTelemetryService_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/TelemetryService/v1_3_0/RedfishTelemetryService_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..2691023962f --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_3_0/RedfishTelemetryService_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TelemetryService.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTelemetryService_V1_3_0_Dxe + FILE_GUID = c4cc5f5a-2a2c-4dca-85c2-ebf49944267b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTelemetryService_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishTelemetryService_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TelemetryService_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TelemetryServiceV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TelemetryService/v1_3_0/TelemetryService_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/TelemetryService/v1_3_0/TelemetryService_V1_3_0_Dxe.c new file mode 100644 index 00000000000..e2f566abded --- /dev/null +++ b/RedfishClientPkg/Converter/TelemetryService/v1_3_0/TelemetryService_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TelemetryService.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TelemetryService"; +BOOLEAN IsRevisonController = TRUE; + +// Support TelemetryService V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TelemetryService", + "1", + "3", + "0" + }, + "TelemetryService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_3_0 *TelemetryServiceV1_3_0; + EFI_REDFISH_TELEMETRYSERVICE_V1_3_0_CS *TelemetryServiceV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TelemetryService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TelemetryService_V1_3_0_To_CS (ResoruceRaw, &TelemetryServiceV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TelemetryServiceV1_3_0 = (EFI_REDFISH_TELEMETRYSERVICE_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TELEMETRYSERVICE_V1_3_0)); + if (TelemetryServiceV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TelemetryServiceV1_3_0; + TelemetryServiceV1_3_0->TelemetryService = TelemetryServiceV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TelemetryService"), "TelemetryService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TelemetryService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TelemetryService"), "TelemetryService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TelemetryServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TelemetryServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TelemetryService_V1_3_0_JSON (*((EFI_REDFISH_TELEMETRYSERVICE_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TelemetryServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TELEMETRYSERVICE_V1_3_0 *TelemetryServiceV1_3_0; + + TelemetryServiceV1_3_0 = (EFI_REDFISH_TELEMETRYSERVICE_V1_3_0 *)InterpProp; + DestroyTelemetryService_V1_3_0_CS (TelemetryServiceV1_3_0->TelemetryService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TelemetryServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TelemetryServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTelemetryService_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TelemetryServiceToStructWrapper, + TelemetryServiceToJson, + TelemetryServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTelemetryService_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_0_0/RedfishThermal_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_0_0/RedfishThermal_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..76a1830bcb5 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_0_0/RedfishThermal_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_0_0_Dxe + FILE_GUID = 0d69ba07-fb3c-4bcb-8e21-6bf8672e3a71 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_0_0/Thermal_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_0_0/Thermal_V1_0_0_Dxe.c new file mode 100644 index 00000000000..0d06de5045b --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_0_0/Thermal_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "0", + "0" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_0_0 *ThermalV1_0_0; + EFI_REDFISH_THERMAL_V1_0_0_CS *ThermalV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_0_0_To_CS (ResoruceRaw, &ThermalV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_0_0 = (EFI_REDFISH_THERMAL_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_0_0)); + if (ThermalV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_0_0; + ThermalV1_0_0->Thermal = ThermalV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_0_0_JSON (*((EFI_REDFISH_THERMAL_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_0_0 *ThermalV1_0_0; + + ThermalV1_0_0 = (EFI_REDFISH_THERMAL_V1_0_0 *)InterpProp; + DestroyThermal_V1_0_0_CS (ThermalV1_0_0->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_0_1/RedfishThermal_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_0_1/RedfishThermal_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..f7e2cebda8c --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_0_1/RedfishThermal_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_0_1_Dxe + FILE_GUID = aca272e7-84a3-44da-a528-cb57e410dae0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_0_1/Thermal_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_0_1/Thermal_V1_0_1_Dxe.c new file mode 100644 index 00000000000..53199b59ef1 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_0_1/Thermal_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "0", + "1" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_0_1 *ThermalV1_0_1; + EFI_REDFISH_THERMAL_V1_0_1_CS *ThermalV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_0_1_To_CS (ResoruceRaw, &ThermalV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_0_1 = (EFI_REDFISH_THERMAL_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_0_1)); + if (ThermalV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_0_1; + ThermalV1_0_1->Thermal = ThermalV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_0_1_JSON (*((EFI_REDFISH_THERMAL_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_0_1 *ThermalV1_0_1; + + ThermalV1_0_1 = (EFI_REDFISH_THERMAL_V1_0_1 *)InterpProp; + DestroyThermal_V1_0_1_CS (ThermalV1_0_1->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_0_10/RedfishThermal_V1_0_10_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_0_10/RedfishThermal_V1_0_10_Dxe.inf new file mode 100644 index 00000000000..6588228655c --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_0_10/RedfishThermal_V1_0_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_0_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_0_10_Dxe + FILE_GUID = 358c028a-e2cc-4795-bf59-fd72da90e483 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_0_10EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_0_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_0_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_0_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_0_10/Thermal_V1_0_10_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_0_10/Thermal_V1_0_10_Dxe.c new file mode 100644 index 00000000000..91cf7d7b5ce --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_0_10/Thermal_V1_0_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_0_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "0", + "10" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_0_10 *ThermalV1_0_10; + EFI_REDFISH_THERMAL_V1_0_10_CS *ThermalV1_0_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_0_10_To_CS (ResoruceRaw, &ThermalV1_0_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_0_10 = (EFI_REDFISH_THERMAL_V1_0_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_0_10)); + if (ThermalV1_0_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_0_10; + ThermalV1_0_10->Thermal = ThermalV1_0_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_0_10_JSON (*((EFI_REDFISH_THERMAL_V1_0_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_0_10 *ThermalV1_0_10; + + ThermalV1_0_10 = (EFI_REDFISH_THERMAL_V1_0_10 *)InterpProp; + DestroyThermal_V1_0_10_CS (ThermalV1_0_10->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_0_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_0_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_0_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_0_11/RedfishThermal_V1_0_11_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_0_11/RedfishThermal_V1_0_11_Dxe.inf new file mode 100644 index 00000000000..7e5167d6540 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_0_11/RedfishThermal_V1_0_11_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_0_11 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_0_11_Dxe + FILE_GUID = 6b9c85ff-726d-4a6b-8ea3-563117e0cebb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_0_11EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_0_11Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_0_11_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_0_11Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_0_11/Thermal_V1_0_11_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_0_11/Thermal_V1_0_11_Dxe.c new file mode 100644 index 00000000000..238984a42c9 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_0_11/Thermal_V1_0_11_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_0_11 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "0", + "11" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_0_11 *ThermalV1_0_11; + EFI_REDFISH_THERMAL_V1_0_11_CS *ThermalV1_0_11Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "11") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_0_11_To_CS (ResoruceRaw, &ThermalV1_0_11Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_0_11 = (EFI_REDFISH_THERMAL_V1_0_11 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_0_11)); + if (ThermalV1_0_11 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_0_11; + ThermalV1_0_11->Thermal = ThermalV1_0_11Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "11"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_0_11_JSON (*((EFI_REDFISH_THERMAL_V1_0_11_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_0_11 *ThermalV1_0_11; + + ThermalV1_0_11 = (EFI_REDFISH_THERMAL_V1_0_11 *)InterpProp; + DestroyThermal_V1_0_11_CS (ThermalV1_0_11->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_0_11_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_0_11EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_0_11Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_0_2/RedfishThermal_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_0_2/RedfishThermal_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..a248a8ffaff --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_0_2/RedfishThermal_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_0_2_Dxe + FILE_GUID = 61207dc0-2f9f-4fac-8a38-6737c1a5b746 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_0_2/Thermal_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_0_2/Thermal_V1_0_2_Dxe.c new file mode 100644 index 00000000000..922ab2c6778 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_0_2/Thermal_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "0", + "2" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_0_2 *ThermalV1_0_2; + EFI_REDFISH_THERMAL_V1_0_2_CS *ThermalV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_0_2_To_CS (ResoruceRaw, &ThermalV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_0_2 = (EFI_REDFISH_THERMAL_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_0_2)); + if (ThermalV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_0_2; + ThermalV1_0_2->Thermal = ThermalV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_0_2_JSON (*((EFI_REDFISH_THERMAL_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_0_2 *ThermalV1_0_2; + + ThermalV1_0_2 = (EFI_REDFISH_THERMAL_V1_0_2 *)InterpProp; + DestroyThermal_V1_0_2_CS (ThermalV1_0_2->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_0_3/RedfishThermal_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_0_3/RedfishThermal_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..3494361afea --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_0_3/RedfishThermal_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_0_3_Dxe + FILE_GUID = 5569e849-f1f7-463a-9df9-94e70be5e327 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_0_3/Thermal_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_0_3/Thermal_V1_0_3_Dxe.c new file mode 100644 index 00000000000..42ac4bb7c94 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_0_3/Thermal_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "0", + "3" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_0_3 *ThermalV1_0_3; + EFI_REDFISH_THERMAL_V1_0_3_CS *ThermalV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_0_3_To_CS (ResoruceRaw, &ThermalV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_0_3 = (EFI_REDFISH_THERMAL_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_0_3)); + if (ThermalV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_0_3; + ThermalV1_0_3->Thermal = ThermalV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_0_3_JSON (*((EFI_REDFISH_THERMAL_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_0_3 *ThermalV1_0_3; + + ThermalV1_0_3 = (EFI_REDFISH_THERMAL_V1_0_3 *)InterpProp; + DestroyThermal_V1_0_3_CS (ThermalV1_0_3->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_0_4/RedfishThermal_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_0_4/RedfishThermal_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..b2fcd3f3217 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_0_4/RedfishThermal_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_0_4_Dxe + FILE_GUID = cd28a68c-5b8a-4bf3-8493-0501beabee29 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_0_4/Thermal_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_0_4/Thermal_V1_0_4_Dxe.c new file mode 100644 index 00000000000..4d00093619b --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_0_4/Thermal_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "0", + "4" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_0_4 *ThermalV1_0_4; + EFI_REDFISH_THERMAL_V1_0_4_CS *ThermalV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_0_4_To_CS (ResoruceRaw, &ThermalV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_0_4 = (EFI_REDFISH_THERMAL_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_0_4)); + if (ThermalV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_0_4; + ThermalV1_0_4->Thermal = ThermalV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_0_4_JSON (*((EFI_REDFISH_THERMAL_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_0_4 *ThermalV1_0_4; + + ThermalV1_0_4 = (EFI_REDFISH_THERMAL_V1_0_4 *)InterpProp; + DestroyThermal_V1_0_4_CS (ThermalV1_0_4->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_0_5/RedfishThermal_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_0_5/RedfishThermal_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..878aa854147 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_0_5/RedfishThermal_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_0_5_Dxe + FILE_GUID = fbf7d108-3a2c-4239-be9e-48b9aa3ff970 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_0_5/Thermal_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_0_5/Thermal_V1_0_5_Dxe.c new file mode 100644 index 00000000000..7f122b3b8ff --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_0_5/Thermal_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "0", + "5" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_0_5 *ThermalV1_0_5; + EFI_REDFISH_THERMAL_V1_0_5_CS *ThermalV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_0_5_To_CS (ResoruceRaw, &ThermalV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_0_5 = (EFI_REDFISH_THERMAL_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_0_5)); + if (ThermalV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_0_5; + ThermalV1_0_5->Thermal = ThermalV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_0_5_JSON (*((EFI_REDFISH_THERMAL_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_0_5 *ThermalV1_0_5; + + ThermalV1_0_5 = (EFI_REDFISH_THERMAL_V1_0_5 *)InterpProp; + DestroyThermal_V1_0_5_CS (ThermalV1_0_5->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_0_6/RedfishThermal_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_0_6/RedfishThermal_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..ac90620cb3a --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_0_6/RedfishThermal_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_0_6_Dxe + FILE_GUID = 327eea4e-947c-4d96-96b0-20496dbaa541 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_0_6/Thermal_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_0_6/Thermal_V1_0_6_Dxe.c new file mode 100644 index 00000000000..05eebc706a9 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_0_6/Thermal_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "0", + "6" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_0_6 *ThermalV1_0_6; + EFI_REDFISH_THERMAL_V1_0_6_CS *ThermalV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_0_6_To_CS (ResoruceRaw, &ThermalV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_0_6 = (EFI_REDFISH_THERMAL_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_0_6)); + if (ThermalV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_0_6; + ThermalV1_0_6->Thermal = ThermalV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_0_6_JSON (*((EFI_REDFISH_THERMAL_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_0_6 *ThermalV1_0_6; + + ThermalV1_0_6 = (EFI_REDFISH_THERMAL_V1_0_6 *)InterpProp; + DestroyThermal_V1_0_6_CS (ThermalV1_0_6->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_0_7/RedfishThermal_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_0_7/RedfishThermal_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..76dadc5abd1 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_0_7/RedfishThermal_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_0_7_Dxe + FILE_GUID = f8f7f374-d60f-47f0-bb2f-9d1f30a1a7ca + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_0_7/Thermal_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_0_7/Thermal_V1_0_7_Dxe.c new file mode 100644 index 00000000000..efe0e01302e --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_0_7/Thermal_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "0", + "7" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_0_7 *ThermalV1_0_7; + EFI_REDFISH_THERMAL_V1_0_7_CS *ThermalV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_0_7_To_CS (ResoruceRaw, &ThermalV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_0_7 = (EFI_REDFISH_THERMAL_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_0_7)); + if (ThermalV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_0_7; + ThermalV1_0_7->Thermal = ThermalV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_0_7_JSON (*((EFI_REDFISH_THERMAL_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_0_7 *ThermalV1_0_7; + + ThermalV1_0_7 = (EFI_REDFISH_THERMAL_V1_0_7 *)InterpProp; + DestroyThermal_V1_0_7_CS (ThermalV1_0_7->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_0_8/RedfishThermal_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_0_8/RedfishThermal_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..9864bb62c90 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_0_8/RedfishThermal_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_0_8_Dxe + FILE_GUID = 0851d77f-bb4b-49dd-ac29-bb7df538a666 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_0_8/Thermal_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_0_8/Thermal_V1_0_8_Dxe.c new file mode 100644 index 00000000000..d5b556f7e08 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_0_8/Thermal_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "0", + "8" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_0_8 *ThermalV1_0_8; + EFI_REDFISH_THERMAL_V1_0_8_CS *ThermalV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_0_8_To_CS (ResoruceRaw, &ThermalV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_0_8 = (EFI_REDFISH_THERMAL_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_0_8)); + if (ThermalV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_0_8; + ThermalV1_0_8->Thermal = ThermalV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_0_8_JSON (*((EFI_REDFISH_THERMAL_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_0_8 *ThermalV1_0_8; + + ThermalV1_0_8 = (EFI_REDFISH_THERMAL_V1_0_8 *)InterpProp; + DestroyThermal_V1_0_8_CS (ThermalV1_0_8->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_0_9/RedfishThermal_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_0_9/RedfishThermal_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..b26c0f2409b --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_0_9/RedfishThermal_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_0_9_Dxe + FILE_GUID = 5dc70893-17d1-410c-8bae-a5edceadc8fd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_0_9/Thermal_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_0_9/Thermal_V1_0_9_Dxe.c new file mode 100644 index 00000000000..30eb8c86df1 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_0_9/Thermal_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "0", + "9" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_0_9 *ThermalV1_0_9; + EFI_REDFISH_THERMAL_V1_0_9_CS *ThermalV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_0_9_To_CS (ResoruceRaw, &ThermalV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_0_9 = (EFI_REDFISH_THERMAL_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_0_9)); + if (ThermalV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_0_9; + ThermalV1_0_9->Thermal = ThermalV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_0_9_JSON (*((EFI_REDFISH_THERMAL_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_0_9 *ThermalV1_0_9; + + ThermalV1_0_9 = (EFI_REDFISH_THERMAL_V1_0_9 *)InterpProp; + DestroyThermal_V1_0_9_CS (ThermalV1_0_9->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_1_0/RedfishThermal_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_1_0/RedfishThermal_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..b653a7e4a4e --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_1_0/RedfishThermal_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_1_0_Dxe + FILE_GUID = c3c710be-43d3-474a-832e-cddf2e27c843 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_1_0/Thermal_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_1_0/Thermal_V1_1_0_Dxe.c new file mode 100644 index 00000000000..b3b7d90ae33 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_1_0/Thermal_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "1", + "0" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_1_0 *ThermalV1_1_0; + EFI_REDFISH_THERMAL_V1_1_0_CS *ThermalV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_1_0_To_CS (ResoruceRaw, &ThermalV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_1_0 = (EFI_REDFISH_THERMAL_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_1_0)); + if (ThermalV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_1_0; + ThermalV1_1_0->Thermal = ThermalV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_1_0_JSON (*((EFI_REDFISH_THERMAL_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_1_0 *ThermalV1_1_0; + + ThermalV1_1_0 = (EFI_REDFISH_THERMAL_V1_1_0 *)InterpProp; + DestroyThermal_V1_1_0_CS (ThermalV1_1_0->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_1_1/RedfishThermal_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_1_1/RedfishThermal_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..c95995c1e80 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_1_1/RedfishThermal_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_1_1_Dxe + FILE_GUID = 55bfc4c0-3e8c-42eb-ba5f-b96d7e77d5bf + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_1_1/Thermal_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_1_1/Thermal_V1_1_1_Dxe.c new file mode 100644 index 00000000000..093eff2ba25 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_1_1/Thermal_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "1", + "1" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_1_1 *ThermalV1_1_1; + EFI_REDFISH_THERMAL_V1_1_1_CS *ThermalV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_1_1_To_CS (ResoruceRaw, &ThermalV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_1_1 = (EFI_REDFISH_THERMAL_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_1_1)); + if (ThermalV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_1_1; + ThermalV1_1_1->Thermal = ThermalV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_1_1_JSON (*((EFI_REDFISH_THERMAL_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_1_1 *ThermalV1_1_1; + + ThermalV1_1_1 = (EFI_REDFISH_THERMAL_V1_1_1 *)InterpProp; + DestroyThermal_V1_1_1_CS (ThermalV1_1_1->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_1_2/RedfishThermal_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_1_2/RedfishThermal_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..abf3522a160 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_1_2/RedfishThermal_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_1_2_Dxe + FILE_GUID = 1f9284fd-5e93-4e7e-8b7d-a481b099dd53 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_1_2/Thermal_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_1_2/Thermal_V1_1_2_Dxe.c new file mode 100644 index 00000000000..aae2ee0ad38 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_1_2/Thermal_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "1", + "2" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_1_2 *ThermalV1_1_2; + EFI_REDFISH_THERMAL_V1_1_2_CS *ThermalV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_1_2_To_CS (ResoruceRaw, &ThermalV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_1_2 = (EFI_REDFISH_THERMAL_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_1_2)); + if (ThermalV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_1_2; + ThermalV1_1_2->Thermal = ThermalV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_1_2_JSON (*((EFI_REDFISH_THERMAL_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_1_2 *ThermalV1_1_2; + + ThermalV1_1_2 = (EFI_REDFISH_THERMAL_V1_1_2 *)InterpProp; + DestroyThermal_V1_1_2_CS (ThermalV1_1_2->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_1_3/RedfishThermal_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_1_3/RedfishThermal_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..d60d1124615 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_1_3/RedfishThermal_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_1_3_Dxe + FILE_GUID = 956612cd-a1a6-43da-9180-9021d2bbab49 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_1_3/Thermal_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_1_3/Thermal_V1_1_3_Dxe.c new file mode 100644 index 00000000000..bd290ca92a7 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_1_3/Thermal_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "1", + "3" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_1_3 *ThermalV1_1_3; + EFI_REDFISH_THERMAL_V1_1_3_CS *ThermalV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_1_3_To_CS (ResoruceRaw, &ThermalV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_1_3 = (EFI_REDFISH_THERMAL_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_1_3)); + if (ThermalV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_1_3; + ThermalV1_1_3->Thermal = ThermalV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_1_3_JSON (*((EFI_REDFISH_THERMAL_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_1_3 *ThermalV1_1_3; + + ThermalV1_1_3 = (EFI_REDFISH_THERMAL_V1_1_3 *)InterpProp; + DestroyThermal_V1_1_3_CS (ThermalV1_1_3->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_1_4/RedfishThermal_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_1_4/RedfishThermal_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..89abdfb3dc4 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_1_4/RedfishThermal_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_1_4_Dxe + FILE_GUID = b4a8cc47-5301-489a-b1e9-81fe871c950a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_1_4/Thermal_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_1_4/Thermal_V1_1_4_Dxe.c new file mode 100644 index 00000000000..1c695eda65f --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_1_4/Thermal_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "1", + "4" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_1_4 *ThermalV1_1_4; + EFI_REDFISH_THERMAL_V1_1_4_CS *ThermalV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_1_4_To_CS (ResoruceRaw, &ThermalV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_1_4 = (EFI_REDFISH_THERMAL_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_1_4)); + if (ThermalV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_1_4; + ThermalV1_1_4->Thermal = ThermalV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_1_4_JSON (*((EFI_REDFISH_THERMAL_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_1_4 *ThermalV1_1_4; + + ThermalV1_1_4 = (EFI_REDFISH_THERMAL_V1_1_4 *)InterpProp; + DestroyThermal_V1_1_4_CS (ThermalV1_1_4->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_1_5/RedfishThermal_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_1_5/RedfishThermal_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..7766dc14c7a --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_1_5/RedfishThermal_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_1_5_Dxe + FILE_GUID = a2de3789-0f9d-4751-bdeb-6b6f8cca401a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_1_5/Thermal_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_1_5/Thermal_V1_1_5_Dxe.c new file mode 100644 index 00000000000..40b566ca097 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_1_5/Thermal_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "1", + "5" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_1_5 *ThermalV1_1_5; + EFI_REDFISH_THERMAL_V1_1_5_CS *ThermalV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_1_5_To_CS (ResoruceRaw, &ThermalV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_1_5 = (EFI_REDFISH_THERMAL_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_1_5)); + if (ThermalV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_1_5; + ThermalV1_1_5->Thermal = ThermalV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_1_5_JSON (*((EFI_REDFISH_THERMAL_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_1_5 *ThermalV1_1_5; + + ThermalV1_1_5 = (EFI_REDFISH_THERMAL_V1_1_5 *)InterpProp; + DestroyThermal_V1_1_5_CS (ThermalV1_1_5->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_1_6/RedfishThermal_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_1_6/RedfishThermal_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..16f8b125942 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_1_6/RedfishThermal_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_1_6_Dxe + FILE_GUID = 405165e2-560c-4f65-8bf6-3d56b21f8926 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_1_6/Thermal_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_1_6/Thermal_V1_1_6_Dxe.c new file mode 100644 index 00000000000..3c76886ce2d --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_1_6/Thermal_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "1", + "6" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_1_6 *ThermalV1_1_6; + EFI_REDFISH_THERMAL_V1_1_6_CS *ThermalV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_1_6_To_CS (ResoruceRaw, &ThermalV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_1_6 = (EFI_REDFISH_THERMAL_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_1_6)); + if (ThermalV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_1_6; + ThermalV1_1_6->Thermal = ThermalV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_1_6_JSON (*((EFI_REDFISH_THERMAL_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_1_6 *ThermalV1_1_6; + + ThermalV1_1_6 = (EFI_REDFISH_THERMAL_V1_1_6 *)InterpProp; + DestroyThermal_V1_1_6_CS (ThermalV1_1_6->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_1_7/RedfishThermal_V1_1_7_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_1_7/RedfishThermal_V1_1_7_Dxe.inf new file mode 100644 index 00000000000..1df305391fd --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_1_7/RedfishThermal_V1_1_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_1_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_1_7_Dxe + FILE_GUID = 3988cd65-10d7-429e-a43c-a9151692316b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_1_7EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_1_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_1_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_1_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_1_7/Thermal_V1_1_7_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_1_7/Thermal_V1_1_7_Dxe.c new file mode 100644 index 00000000000..ec2c451eed5 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_1_7/Thermal_V1_1_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_1_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "1", + "7" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_1_7 *ThermalV1_1_7; + EFI_REDFISH_THERMAL_V1_1_7_CS *ThermalV1_1_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_1_7_To_CS (ResoruceRaw, &ThermalV1_1_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_1_7 = (EFI_REDFISH_THERMAL_V1_1_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_1_7)); + if (ThermalV1_1_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_1_7; + ThermalV1_1_7->Thermal = ThermalV1_1_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_1_7_JSON (*((EFI_REDFISH_THERMAL_V1_1_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_1_7 *ThermalV1_1_7; + + ThermalV1_1_7 = (EFI_REDFISH_THERMAL_V1_1_7 *)InterpProp; + DestroyThermal_V1_1_7_CS (ThermalV1_1_7->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_1_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_1_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_1_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_1_8/RedfishThermal_V1_1_8_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_1_8/RedfishThermal_V1_1_8_Dxe.inf new file mode 100644 index 00000000000..3f3e577d67c --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_1_8/RedfishThermal_V1_1_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_1_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_1_8_Dxe + FILE_GUID = 526aae65-0bca-472e-be13-e8f677206291 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_1_8EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_1_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_1_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_1_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_1_8/Thermal_V1_1_8_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_1_8/Thermal_V1_1_8_Dxe.c new file mode 100644 index 00000000000..81c27e9c068 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_1_8/Thermal_V1_1_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_1_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "1", + "8" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_1_8 *ThermalV1_1_8; + EFI_REDFISH_THERMAL_V1_1_8_CS *ThermalV1_1_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_1_8_To_CS (ResoruceRaw, &ThermalV1_1_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_1_8 = (EFI_REDFISH_THERMAL_V1_1_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_1_8)); + if (ThermalV1_1_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_1_8; + ThermalV1_1_8->Thermal = ThermalV1_1_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_1_8_JSON (*((EFI_REDFISH_THERMAL_V1_1_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_1_8 *ThermalV1_1_8; + + ThermalV1_1_8 = (EFI_REDFISH_THERMAL_V1_1_8 *)InterpProp; + DestroyThermal_V1_1_8_CS (ThermalV1_1_8->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_1_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_1_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_1_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_1_9/RedfishThermal_V1_1_9_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_1_9/RedfishThermal_V1_1_9_Dxe.inf new file mode 100644 index 00000000000..c0eba508747 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_1_9/RedfishThermal_V1_1_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_1_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_1_9_Dxe + FILE_GUID = 67aa8b92-1675-4e20-adac-74c8898aef46 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_1_9EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_1_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_1_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_1_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_1_9/Thermal_V1_1_9_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_1_9/Thermal_V1_1_9_Dxe.c new file mode 100644 index 00000000000..0a29a6dc1fd --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_1_9/Thermal_V1_1_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_1_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "1", + "9" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_1_9 *ThermalV1_1_9; + EFI_REDFISH_THERMAL_V1_1_9_CS *ThermalV1_1_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_1_9_To_CS (ResoruceRaw, &ThermalV1_1_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_1_9 = (EFI_REDFISH_THERMAL_V1_1_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_1_9)); + if (ThermalV1_1_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_1_9; + ThermalV1_1_9->Thermal = ThermalV1_1_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_1_9_JSON (*((EFI_REDFISH_THERMAL_V1_1_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_1_9 *ThermalV1_1_9; + + ThermalV1_1_9 = (EFI_REDFISH_THERMAL_V1_1_9 *)InterpProp; + DestroyThermal_V1_1_9_CS (ThermalV1_1_9->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_1_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_1_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_1_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_2_0/RedfishThermal_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_2_0/RedfishThermal_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..b83370f4fa8 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_2_0/RedfishThermal_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_2_0_Dxe + FILE_GUID = 16c43789-ae5d-421d-b297-3e5c97b070d0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_2_0/Thermal_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_2_0/Thermal_V1_2_0_Dxe.c new file mode 100644 index 00000000000..5e741099ed9 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_2_0/Thermal_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "2", + "0" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_2_0 *ThermalV1_2_0; + EFI_REDFISH_THERMAL_V1_2_0_CS *ThermalV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_2_0_To_CS (ResoruceRaw, &ThermalV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_2_0 = (EFI_REDFISH_THERMAL_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_2_0)); + if (ThermalV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_2_0; + ThermalV1_2_0->Thermal = ThermalV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_2_0_JSON (*((EFI_REDFISH_THERMAL_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_2_0 *ThermalV1_2_0; + + ThermalV1_2_0 = (EFI_REDFISH_THERMAL_V1_2_0 *)InterpProp; + DestroyThermal_V1_2_0_CS (ThermalV1_2_0->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_2_1/RedfishThermal_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_2_1/RedfishThermal_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..eeecbe0c199 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_2_1/RedfishThermal_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_2_1_Dxe + FILE_GUID = 9cc59442-34ff-44b7-a4ab-8d7e814639a3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_2_1/Thermal_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_2_1/Thermal_V1_2_1_Dxe.c new file mode 100644 index 00000000000..3225b32908f --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_2_1/Thermal_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "2", + "1" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_2_1 *ThermalV1_2_1; + EFI_REDFISH_THERMAL_V1_2_1_CS *ThermalV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_2_1_To_CS (ResoruceRaw, &ThermalV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_2_1 = (EFI_REDFISH_THERMAL_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_2_1)); + if (ThermalV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_2_1; + ThermalV1_2_1->Thermal = ThermalV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_2_1_JSON (*((EFI_REDFISH_THERMAL_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_2_1 *ThermalV1_2_1; + + ThermalV1_2_1 = (EFI_REDFISH_THERMAL_V1_2_1 *)InterpProp; + DestroyThermal_V1_2_1_CS (ThermalV1_2_1->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_2_2/RedfishThermal_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_2_2/RedfishThermal_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..8e67a1e0928 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_2_2/RedfishThermal_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_2_2_Dxe + FILE_GUID = 27bde2e0-0124-4281-810a-42b05e996b6a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_2_2/Thermal_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_2_2/Thermal_V1_2_2_Dxe.c new file mode 100644 index 00000000000..1114e9ba457 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_2_2/Thermal_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "2", + "2" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_2_2 *ThermalV1_2_2; + EFI_REDFISH_THERMAL_V1_2_2_CS *ThermalV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_2_2_To_CS (ResoruceRaw, &ThermalV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_2_2 = (EFI_REDFISH_THERMAL_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_2_2)); + if (ThermalV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_2_2; + ThermalV1_2_2->Thermal = ThermalV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_2_2_JSON (*((EFI_REDFISH_THERMAL_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_2_2 *ThermalV1_2_2; + + ThermalV1_2_2 = (EFI_REDFISH_THERMAL_V1_2_2 *)InterpProp; + DestroyThermal_V1_2_2_CS (ThermalV1_2_2->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_2_3/RedfishThermal_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_2_3/RedfishThermal_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..4ba423141a7 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_2_3/RedfishThermal_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_2_3_Dxe + FILE_GUID = 256e6308-bcd7-4d67-94d0-9841595137f9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_2_3/Thermal_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_2_3/Thermal_V1_2_3_Dxe.c new file mode 100644 index 00000000000..3893e155ee4 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_2_3/Thermal_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "2", + "3" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_2_3 *ThermalV1_2_3; + EFI_REDFISH_THERMAL_V1_2_3_CS *ThermalV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_2_3_To_CS (ResoruceRaw, &ThermalV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_2_3 = (EFI_REDFISH_THERMAL_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_2_3)); + if (ThermalV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_2_3; + ThermalV1_2_3->Thermal = ThermalV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_2_3_JSON (*((EFI_REDFISH_THERMAL_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_2_3 *ThermalV1_2_3; + + ThermalV1_2_3 = (EFI_REDFISH_THERMAL_V1_2_3 *)InterpProp; + DestroyThermal_V1_2_3_CS (ThermalV1_2_3->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_2_4/RedfishThermal_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_2_4/RedfishThermal_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..5c20c20ced8 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_2_4/RedfishThermal_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_2_4_Dxe + FILE_GUID = e4774a6a-422c-40e4-8946-e7e33f6b450c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_2_4/Thermal_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_2_4/Thermal_V1_2_4_Dxe.c new file mode 100644 index 00000000000..95087f4eab8 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_2_4/Thermal_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "2", + "4" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_2_4 *ThermalV1_2_4; + EFI_REDFISH_THERMAL_V1_2_4_CS *ThermalV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_2_4_To_CS (ResoruceRaw, &ThermalV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_2_4 = (EFI_REDFISH_THERMAL_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_2_4)); + if (ThermalV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_2_4; + ThermalV1_2_4->Thermal = ThermalV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_2_4_JSON (*((EFI_REDFISH_THERMAL_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_2_4 *ThermalV1_2_4; + + ThermalV1_2_4 = (EFI_REDFISH_THERMAL_V1_2_4 *)InterpProp; + DestroyThermal_V1_2_4_CS (ThermalV1_2_4->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_2_5/RedfishThermal_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_2_5/RedfishThermal_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..7f3844c1722 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_2_5/RedfishThermal_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_2_5_Dxe + FILE_GUID = 04abe6b8-df56-4e04-b122-df5cd11a5926 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_2_5/Thermal_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_2_5/Thermal_V1_2_5_Dxe.c new file mode 100644 index 00000000000..4bc3483ad15 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_2_5/Thermal_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "2", + "5" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_2_5 *ThermalV1_2_5; + EFI_REDFISH_THERMAL_V1_2_5_CS *ThermalV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_2_5_To_CS (ResoruceRaw, &ThermalV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_2_5 = (EFI_REDFISH_THERMAL_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_2_5)); + if (ThermalV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_2_5; + ThermalV1_2_5->Thermal = ThermalV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_2_5_JSON (*((EFI_REDFISH_THERMAL_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_2_5 *ThermalV1_2_5; + + ThermalV1_2_5 = (EFI_REDFISH_THERMAL_V1_2_5 *)InterpProp; + DestroyThermal_V1_2_5_CS (ThermalV1_2_5->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_2_6/RedfishThermal_V1_2_6_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_2_6/RedfishThermal_V1_2_6_Dxe.inf new file mode 100644 index 00000000000..5fd9bdf5b7a --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_2_6/RedfishThermal_V1_2_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_2_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_2_6_Dxe + FILE_GUID = 3bbbbc77-9bc4-4d1a-9d1a-3e6ee2776026 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_2_6EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_2_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_2_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_2_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_2_6/Thermal_V1_2_6_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_2_6/Thermal_V1_2_6_Dxe.c new file mode 100644 index 00000000000..9d3bde3a884 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_2_6/Thermal_V1_2_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_2_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "2", + "6" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_2_6 *ThermalV1_2_6; + EFI_REDFISH_THERMAL_V1_2_6_CS *ThermalV1_2_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_2_6_To_CS (ResoruceRaw, &ThermalV1_2_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_2_6 = (EFI_REDFISH_THERMAL_V1_2_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_2_6)); + if (ThermalV1_2_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_2_6; + ThermalV1_2_6->Thermal = ThermalV1_2_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_2_6_JSON (*((EFI_REDFISH_THERMAL_V1_2_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_2_6 *ThermalV1_2_6; + + ThermalV1_2_6 = (EFI_REDFISH_THERMAL_V1_2_6 *)InterpProp; + DestroyThermal_V1_2_6_CS (ThermalV1_2_6->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_2_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_2_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_2_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_2_7/RedfishThermal_V1_2_7_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_2_7/RedfishThermal_V1_2_7_Dxe.inf new file mode 100644 index 00000000000..8ba49ccc156 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_2_7/RedfishThermal_V1_2_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_2_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_2_7_Dxe + FILE_GUID = 1fdfecc1-7a6e-4d8d-b062-e50c3c18a54e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_2_7EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_2_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_2_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_2_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_2_7/Thermal_V1_2_7_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_2_7/Thermal_V1_2_7_Dxe.c new file mode 100644 index 00000000000..7c1817bdffa --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_2_7/Thermal_V1_2_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_2_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "2", + "7" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_2_7 *ThermalV1_2_7; + EFI_REDFISH_THERMAL_V1_2_7_CS *ThermalV1_2_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_2_7_To_CS (ResoruceRaw, &ThermalV1_2_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_2_7 = (EFI_REDFISH_THERMAL_V1_2_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_2_7)); + if (ThermalV1_2_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_2_7; + ThermalV1_2_7->Thermal = ThermalV1_2_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_2_7_JSON (*((EFI_REDFISH_THERMAL_V1_2_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_2_7 *ThermalV1_2_7; + + ThermalV1_2_7 = (EFI_REDFISH_THERMAL_V1_2_7 *)InterpProp; + DestroyThermal_V1_2_7_CS (ThermalV1_2_7->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_2_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_2_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_2_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_2_8/RedfishThermal_V1_2_8_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_2_8/RedfishThermal_V1_2_8_Dxe.inf new file mode 100644 index 00000000000..b9944827d23 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_2_8/RedfishThermal_V1_2_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_2_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_2_8_Dxe + FILE_GUID = 6f75f3e6-554e-4b6c-b43c-235d744c27d2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_2_8EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_2_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_2_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_2_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_2_8/Thermal_V1_2_8_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_2_8/Thermal_V1_2_8_Dxe.c new file mode 100644 index 00000000000..a14b4d924cb --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_2_8/Thermal_V1_2_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_2_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "2", + "8" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_2_8 *ThermalV1_2_8; + EFI_REDFISH_THERMAL_V1_2_8_CS *ThermalV1_2_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_2_8_To_CS (ResoruceRaw, &ThermalV1_2_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_2_8 = (EFI_REDFISH_THERMAL_V1_2_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_2_8)); + if (ThermalV1_2_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_2_8; + ThermalV1_2_8->Thermal = ThermalV1_2_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_2_8_JSON (*((EFI_REDFISH_THERMAL_V1_2_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_2_8 *ThermalV1_2_8; + + ThermalV1_2_8 = (EFI_REDFISH_THERMAL_V1_2_8 *)InterpProp; + DestroyThermal_V1_2_8_CS (ThermalV1_2_8->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_2_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_2_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_2_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_3_0/RedfishThermal_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_3_0/RedfishThermal_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..ef5125d1268 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_3_0/RedfishThermal_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_3_0_Dxe + FILE_GUID = 4d0d62fd-4389-4575-b795-fe46c2ce9cc0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_3_0/Thermal_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_3_0/Thermal_V1_3_0_Dxe.c new file mode 100644 index 00000000000..3388cc7df4a --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_3_0/Thermal_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "3", + "0" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_3_0 *ThermalV1_3_0; + EFI_REDFISH_THERMAL_V1_3_0_CS *ThermalV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_3_0_To_CS (ResoruceRaw, &ThermalV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_3_0 = (EFI_REDFISH_THERMAL_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_3_0)); + if (ThermalV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_3_0; + ThermalV1_3_0->Thermal = ThermalV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_3_0_JSON (*((EFI_REDFISH_THERMAL_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_3_0 *ThermalV1_3_0; + + ThermalV1_3_0 = (EFI_REDFISH_THERMAL_V1_3_0 *)InterpProp; + DestroyThermal_V1_3_0_CS (ThermalV1_3_0->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_3_1/RedfishThermal_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_3_1/RedfishThermal_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..8d9715f2f25 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_3_1/RedfishThermal_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_3_1_Dxe + FILE_GUID = 35a927c9-5951-44e8-8f29-357e5c6059de + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_3_1/Thermal_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_3_1/Thermal_V1_3_1_Dxe.c new file mode 100644 index 00000000000..d62836e8202 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_3_1/Thermal_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "3", + "1" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_3_1 *ThermalV1_3_1; + EFI_REDFISH_THERMAL_V1_3_1_CS *ThermalV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_3_1_To_CS (ResoruceRaw, &ThermalV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_3_1 = (EFI_REDFISH_THERMAL_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_3_1)); + if (ThermalV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_3_1; + ThermalV1_3_1->Thermal = ThermalV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_3_1_JSON (*((EFI_REDFISH_THERMAL_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_3_1 *ThermalV1_3_1; + + ThermalV1_3_1 = (EFI_REDFISH_THERMAL_V1_3_1 *)InterpProp; + DestroyThermal_V1_3_1_CS (ThermalV1_3_1->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_3_2/RedfishThermal_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_3_2/RedfishThermal_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..e6ced177dd3 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_3_2/RedfishThermal_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_3_2_Dxe + FILE_GUID = 5722fe3f-57ba-4a19-a834-d39839b39abd + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_3_2/Thermal_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_3_2/Thermal_V1_3_2_Dxe.c new file mode 100644 index 00000000000..628d7e5bdf9 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_3_2/Thermal_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "3", + "2" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_3_2 *ThermalV1_3_2; + EFI_REDFISH_THERMAL_V1_3_2_CS *ThermalV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_3_2_To_CS (ResoruceRaw, &ThermalV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_3_2 = (EFI_REDFISH_THERMAL_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_3_2)); + if (ThermalV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_3_2; + ThermalV1_3_2->Thermal = ThermalV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_3_2_JSON (*((EFI_REDFISH_THERMAL_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_3_2 *ThermalV1_3_2; + + ThermalV1_3_2 = (EFI_REDFISH_THERMAL_V1_3_2 *)InterpProp; + DestroyThermal_V1_3_2_CS (ThermalV1_3_2->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_3_3/RedfishThermal_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_3_3/RedfishThermal_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..7f922ba038c --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_3_3/RedfishThermal_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_3_3_Dxe + FILE_GUID = 3d607988-88bc-414f-a170-6b52a6137b57 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_3_3/Thermal_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_3_3/Thermal_V1_3_3_Dxe.c new file mode 100644 index 00000000000..cd94a9a33aa --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_3_3/Thermal_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "3", + "3" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_3_3 *ThermalV1_3_3; + EFI_REDFISH_THERMAL_V1_3_3_CS *ThermalV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_3_3_To_CS (ResoruceRaw, &ThermalV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_3_3 = (EFI_REDFISH_THERMAL_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_3_3)); + if (ThermalV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_3_3; + ThermalV1_3_3->Thermal = ThermalV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_3_3_JSON (*((EFI_REDFISH_THERMAL_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_3_3 *ThermalV1_3_3; + + ThermalV1_3_3 = (EFI_REDFISH_THERMAL_V1_3_3 *)InterpProp; + DestroyThermal_V1_3_3_CS (ThermalV1_3_3->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_3_4/RedfishThermal_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_3_4/RedfishThermal_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..4cf4d4c070f --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_3_4/RedfishThermal_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_3_4_Dxe + FILE_GUID = 94b04af4-9f83-4b54-840f-4c1f955d8bfb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_3_4/Thermal_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_3_4/Thermal_V1_3_4_Dxe.c new file mode 100644 index 00000000000..196093487d6 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_3_4/Thermal_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "3", + "4" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_3_4 *ThermalV1_3_4; + EFI_REDFISH_THERMAL_V1_3_4_CS *ThermalV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_3_4_To_CS (ResoruceRaw, &ThermalV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_3_4 = (EFI_REDFISH_THERMAL_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_3_4)); + if (ThermalV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_3_4; + ThermalV1_3_4->Thermal = ThermalV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_3_4_JSON (*((EFI_REDFISH_THERMAL_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_3_4 *ThermalV1_3_4; + + ThermalV1_3_4 = (EFI_REDFISH_THERMAL_V1_3_4 *)InterpProp; + DestroyThermal_V1_3_4_CS (ThermalV1_3_4->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_3_5/RedfishThermal_V1_3_5_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_3_5/RedfishThermal_V1_3_5_Dxe.inf new file mode 100644 index 00000000000..7c1194d3339 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_3_5/RedfishThermal_V1_3_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_3_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_3_5_Dxe + FILE_GUID = 8d3b1b5b-917a-47aa-b756-bb7edfa6d791 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_3_5EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_3_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_3_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_3_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_3_5/Thermal_V1_3_5_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_3_5/Thermal_V1_3_5_Dxe.c new file mode 100644 index 00000000000..f2b9cdf7228 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_3_5/Thermal_V1_3_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_3_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "3", + "5" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_3_5 *ThermalV1_3_5; + EFI_REDFISH_THERMAL_V1_3_5_CS *ThermalV1_3_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_3_5_To_CS (ResoruceRaw, &ThermalV1_3_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_3_5 = (EFI_REDFISH_THERMAL_V1_3_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_3_5)); + if (ThermalV1_3_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_3_5; + ThermalV1_3_5->Thermal = ThermalV1_3_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_3_5_JSON (*((EFI_REDFISH_THERMAL_V1_3_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_3_5 *ThermalV1_3_5; + + ThermalV1_3_5 = (EFI_REDFISH_THERMAL_V1_3_5 *)InterpProp; + DestroyThermal_V1_3_5_CS (ThermalV1_3_5->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_3_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_3_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_3_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_3_6/RedfishThermal_V1_3_6_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_3_6/RedfishThermal_V1_3_6_Dxe.inf new file mode 100644 index 00000000000..29db1fc897e --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_3_6/RedfishThermal_V1_3_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_3_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_3_6_Dxe + FILE_GUID = fba75a1c-d2f4-4b00-abf1-056f52bf5a01 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_3_6EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_3_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_3_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_3_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_3_6/Thermal_V1_3_6_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_3_6/Thermal_V1_3_6_Dxe.c new file mode 100644 index 00000000000..dd6f711f55e --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_3_6/Thermal_V1_3_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_3_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "3", + "6" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_3_6 *ThermalV1_3_6; + EFI_REDFISH_THERMAL_V1_3_6_CS *ThermalV1_3_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_3_6_To_CS (ResoruceRaw, &ThermalV1_3_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_3_6 = (EFI_REDFISH_THERMAL_V1_3_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_3_6)); + if (ThermalV1_3_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_3_6; + ThermalV1_3_6->Thermal = ThermalV1_3_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_3_6_JSON (*((EFI_REDFISH_THERMAL_V1_3_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_3_6 *ThermalV1_3_6; + + ThermalV1_3_6 = (EFI_REDFISH_THERMAL_V1_3_6 *)InterpProp; + DestroyThermal_V1_3_6_CS (ThermalV1_3_6->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_3_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_3_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_3_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_3_7/RedfishThermal_V1_3_7_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_3_7/RedfishThermal_V1_3_7_Dxe.inf new file mode 100644 index 00000000000..7a5a0fe1366 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_3_7/RedfishThermal_V1_3_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_3_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_3_7_Dxe + FILE_GUID = 2bfc2679-91e7-4c0b-895f-d50da4346d18 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_3_7EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_3_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_3_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_3_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_3_7/Thermal_V1_3_7_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_3_7/Thermal_V1_3_7_Dxe.c new file mode 100644 index 00000000000..e2bb15f4d54 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_3_7/Thermal_V1_3_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_3_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_3_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "3", + "7" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_3_7 *ThermalV1_3_7; + EFI_REDFISH_THERMAL_V1_3_7_CS *ThermalV1_3_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_3_7_To_CS (ResoruceRaw, &ThermalV1_3_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_3_7 = (EFI_REDFISH_THERMAL_V1_3_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_3_7)); + if (ThermalV1_3_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_3_7; + ThermalV1_3_7->Thermal = ThermalV1_3_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_3_7_JSON (*((EFI_REDFISH_THERMAL_V1_3_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_3_7 *ThermalV1_3_7; + + ThermalV1_3_7 = (EFI_REDFISH_THERMAL_V1_3_7 *)InterpProp; + DestroyThermal_V1_3_7_CS (ThermalV1_3_7->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_3_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_3_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_3_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_4_0/RedfishThermal_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_4_0/RedfishThermal_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..ff8e4a76c33 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_4_0/RedfishThermal_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_4_0_Dxe + FILE_GUID = dec452c0-ce1c-4b03-ad9e-e41a85a90950 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_4_0/Thermal_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_4_0/Thermal_V1_4_0_Dxe.c new file mode 100644 index 00000000000..20bf93e0a01 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_4_0/Thermal_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "4", + "0" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_4_0 *ThermalV1_4_0; + EFI_REDFISH_THERMAL_V1_4_0_CS *ThermalV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_4_0_To_CS (ResoruceRaw, &ThermalV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_4_0 = (EFI_REDFISH_THERMAL_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_4_0)); + if (ThermalV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_4_0; + ThermalV1_4_0->Thermal = ThermalV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_4_0_JSON (*((EFI_REDFISH_THERMAL_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_4_0 *ThermalV1_4_0; + + ThermalV1_4_0 = (EFI_REDFISH_THERMAL_V1_4_0 *)InterpProp; + DestroyThermal_V1_4_0_CS (ThermalV1_4_0->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_4_1/RedfishThermal_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_4_1/RedfishThermal_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..6fc1c2723aa --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_4_1/RedfishThermal_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_4_1_Dxe + FILE_GUID = 43aae179-b86c-485d-aa2b-7eea5dc82a96 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_4_1/Thermal_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_4_1/Thermal_V1_4_1_Dxe.c new file mode 100644 index 00000000000..8b15cb9b461 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_4_1/Thermal_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "4", + "1" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_4_1 *ThermalV1_4_1; + EFI_REDFISH_THERMAL_V1_4_1_CS *ThermalV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_4_1_To_CS (ResoruceRaw, &ThermalV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_4_1 = (EFI_REDFISH_THERMAL_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_4_1)); + if (ThermalV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_4_1; + ThermalV1_4_1->Thermal = ThermalV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_4_1_JSON (*((EFI_REDFISH_THERMAL_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_4_1 *ThermalV1_4_1; + + ThermalV1_4_1 = (EFI_REDFISH_THERMAL_V1_4_1 *)InterpProp; + DestroyThermal_V1_4_1_CS (ThermalV1_4_1->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_4_2/RedfishThermal_V1_4_2_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_4_2/RedfishThermal_V1_4_2_Dxe.inf new file mode 100644 index 00000000000..77acd16935e --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_4_2/RedfishThermal_V1_4_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_4_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_4_2_Dxe + FILE_GUID = cd309d5b-dd75-4f58-86fc-e0bb6bd45c83 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_4_2EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_4_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_4_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_4_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_4_2/Thermal_V1_4_2_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_4_2/Thermal_V1_4_2_Dxe.c new file mode 100644 index 00000000000..a624b1297a4 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_4_2/Thermal_V1_4_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_4_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "4", + "2" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_4_2 *ThermalV1_4_2; + EFI_REDFISH_THERMAL_V1_4_2_CS *ThermalV1_4_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_4_2_To_CS (ResoruceRaw, &ThermalV1_4_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_4_2 = (EFI_REDFISH_THERMAL_V1_4_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_4_2)); + if (ThermalV1_4_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_4_2; + ThermalV1_4_2->Thermal = ThermalV1_4_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_4_2_JSON (*((EFI_REDFISH_THERMAL_V1_4_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_4_2 *ThermalV1_4_2; + + ThermalV1_4_2 = (EFI_REDFISH_THERMAL_V1_4_2 *)InterpProp; + DestroyThermal_V1_4_2_CS (ThermalV1_4_2->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_4_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_4_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_4_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_4_3/RedfishThermal_V1_4_3_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_4_3/RedfishThermal_V1_4_3_Dxe.inf new file mode 100644 index 00000000000..da64f090dd2 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_4_3/RedfishThermal_V1_4_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_4_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_4_3_Dxe + FILE_GUID = 7542c270-bd64-41dd-87d8-c8a8e5c0dbfc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_4_3EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_4_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_4_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_4_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_4_3/Thermal_V1_4_3_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_4_3/Thermal_V1_4_3_Dxe.c new file mode 100644 index 00000000000..1cf1796cb08 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_4_3/Thermal_V1_4_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_4_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "4", + "3" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_4_3 *ThermalV1_4_3; + EFI_REDFISH_THERMAL_V1_4_3_CS *ThermalV1_4_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_4_3_To_CS (ResoruceRaw, &ThermalV1_4_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_4_3 = (EFI_REDFISH_THERMAL_V1_4_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_4_3)); + if (ThermalV1_4_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_4_3; + ThermalV1_4_3->Thermal = ThermalV1_4_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_4_3_JSON (*((EFI_REDFISH_THERMAL_V1_4_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_4_3 *ThermalV1_4_3; + + ThermalV1_4_3 = (EFI_REDFISH_THERMAL_V1_4_3 *)InterpProp; + DestroyThermal_V1_4_3_CS (ThermalV1_4_3->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_4_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_4_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_4_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_4_4/RedfishThermal_V1_4_4_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_4_4/RedfishThermal_V1_4_4_Dxe.inf new file mode 100644 index 00000000000..c6c59d3bc04 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_4_4/RedfishThermal_V1_4_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_4_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_4_4_Dxe + FILE_GUID = c30006f4-7f40-4af6-8820-617836aa14b0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_4_4EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_4_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_4_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_4_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_4_4/Thermal_V1_4_4_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_4_4/Thermal_V1_4_4_Dxe.c new file mode 100644 index 00000000000..e22173c76c7 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_4_4/Thermal_V1_4_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_4_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "4", + "4" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_4_4 *ThermalV1_4_4; + EFI_REDFISH_THERMAL_V1_4_4_CS *ThermalV1_4_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_4_4_To_CS (ResoruceRaw, &ThermalV1_4_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_4_4 = (EFI_REDFISH_THERMAL_V1_4_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_4_4)); + if (ThermalV1_4_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_4_4; + ThermalV1_4_4->Thermal = ThermalV1_4_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_4_4_JSON (*((EFI_REDFISH_THERMAL_V1_4_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_4_4 *ThermalV1_4_4; + + ThermalV1_4_4 = (EFI_REDFISH_THERMAL_V1_4_4 *)InterpProp; + DestroyThermal_V1_4_4_CS (ThermalV1_4_4->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_4_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_4_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_4_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_4_5/RedfishThermal_V1_4_5_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_4_5/RedfishThermal_V1_4_5_Dxe.inf new file mode 100644 index 00000000000..9ddf8b20d48 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_4_5/RedfishThermal_V1_4_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_4_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_4_5_Dxe + FILE_GUID = d0c88c66-9ecd-44bc-ad23-fd40877022d0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_4_5EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_4_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_4_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_4_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_4_5/Thermal_V1_4_5_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_4_5/Thermal_V1_4_5_Dxe.c new file mode 100644 index 00000000000..a1627666694 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_4_5/Thermal_V1_4_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_4_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "4", + "5" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_4_5 *ThermalV1_4_5; + EFI_REDFISH_THERMAL_V1_4_5_CS *ThermalV1_4_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_4_5_To_CS (ResoruceRaw, &ThermalV1_4_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_4_5 = (EFI_REDFISH_THERMAL_V1_4_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_4_5)); + if (ThermalV1_4_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_4_5; + ThermalV1_4_5->Thermal = ThermalV1_4_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_4_5_JSON (*((EFI_REDFISH_THERMAL_V1_4_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_4_5 *ThermalV1_4_5; + + ThermalV1_4_5 = (EFI_REDFISH_THERMAL_V1_4_5 *)InterpProp; + DestroyThermal_V1_4_5_CS (ThermalV1_4_5->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_4_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_4_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_4_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_4_6/RedfishThermal_V1_4_6_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_4_6/RedfishThermal_V1_4_6_Dxe.inf new file mode 100644 index 00000000000..73c528e1eaf --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_4_6/RedfishThermal_V1_4_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_4_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_4_6_Dxe + FILE_GUID = c2e31bf7-812d-4dff-bf40-0faf19340241 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_4_6EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_4_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_4_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_4_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_4_6/Thermal_V1_4_6_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_4_6/Thermal_V1_4_6_Dxe.c new file mode 100644 index 00000000000..fc9e74615de --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_4_6/Thermal_V1_4_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_4_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_4_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "4", + "6" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_4_6 *ThermalV1_4_6; + EFI_REDFISH_THERMAL_V1_4_6_CS *ThermalV1_4_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_4_6_To_CS (ResoruceRaw, &ThermalV1_4_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_4_6 = (EFI_REDFISH_THERMAL_V1_4_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_4_6)); + if (ThermalV1_4_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_4_6; + ThermalV1_4_6->Thermal = ThermalV1_4_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_4_6_JSON (*((EFI_REDFISH_THERMAL_V1_4_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_4_6 *ThermalV1_4_6; + + ThermalV1_4_6 = (EFI_REDFISH_THERMAL_V1_4_6 *)InterpProp; + DestroyThermal_V1_4_6_CS (ThermalV1_4_6->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_4_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_4_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_4_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_5_0/RedfishThermal_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_5_0/RedfishThermal_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..c274a0ca1e8 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_5_0/RedfishThermal_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_5_0_Dxe + FILE_GUID = 3b19e6a4-6e19-4962-9900-3a33e2506d5c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_5_0/Thermal_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_5_0/Thermal_V1_5_0_Dxe.c new file mode 100644 index 00000000000..702cbf9b057 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_5_0/Thermal_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "5", + "0" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_5_0 *ThermalV1_5_0; + EFI_REDFISH_THERMAL_V1_5_0_CS *ThermalV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_5_0_To_CS (ResoruceRaw, &ThermalV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_5_0 = (EFI_REDFISH_THERMAL_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_5_0)); + if (ThermalV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_5_0; + ThermalV1_5_0->Thermal = ThermalV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_5_0_JSON (*((EFI_REDFISH_THERMAL_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_5_0 *ThermalV1_5_0; + + ThermalV1_5_0 = (EFI_REDFISH_THERMAL_V1_5_0 *)InterpProp; + DestroyThermal_V1_5_0_CS (ThermalV1_5_0->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_5_1/RedfishThermal_V1_5_1_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_5_1/RedfishThermal_V1_5_1_Dxe.inf new file mode 100644 index 00000000000..7d87e9b77af --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_5_1/RedfishThermal_V1_5_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_5_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_5_1_Dxe + FILE_GUID = 5e035a13-d800-4a8c-bd68-1618510b8444 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_5_1EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_5_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_5_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_5_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_5_1/Thermal_V1_5_1_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_5_1/Thermal_V1_5_1_Dxe.c new file mode 100644 index 00000000000..9b7cb9cf2ae --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_5_1/Thermal_V1_5_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_5_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "5", + "1" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_5_1 *ThermalV1_5_1; + EFI_REDFISH_THERMAL_V1_5_1_CS *ThermalV1_5_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_5_1_To_CS (ResoruceRaw, &ThermalV1_5_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_5_1 = (EFI_REDFISH_THERMAL_V1_5_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_5_1)); + if (ThermalV1_5_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_5_1; + ThermalV1_5_1->Thermal = ThermalV1_5_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_5_1_JSON (*((EFI_REDFISH_THERMAL_V1_5_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_5_1 *ThermalV1_5_1; + + ThermalV1_5_1 = (EFI_REDFISH_THERMAL_V1_5_1 *)InterpProp; + DestroyThermal_V1_5_1_CS (ThermalV1_5_1->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_5_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_5_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_5_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_5_2/RedfishThermal_V1_5_2_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_5_2/RedfishThermal_V1_5_2_Dxe.inf new file mode 100644 index 00000000000..acdb68fc1c0 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_5_2/RedfishThermal_V1_5_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_5_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_5_2_Dxe + FILE_GUID = e77f702d-ccb5-4f6b-bc55-caaf6fccc073 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_5_2EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_5_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_5_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_5_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_5_2/Thermal_V1_5_2_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_5_2/Thermal_V1_5_2_Dxe.c new file mode 100644 index 00000000000..95d40a3bfc0 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_5_2/Thermal_V1_5_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_5_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "5", + "2" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_5_2 *ThermalV1_5_2; + EFI_REDFISH_THERMAL_V1_5_2_CS *ThermalV1_5_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_5_2_To_CS (ResoruceRaw, &ThermalV1_5_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_5_2 = (EFI_REDFISH_THERMAL_V1_5_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_5_2)); + if (ThermalV1_5_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_5_2; + ThermalV1_5_2->Thermal = ThermalV1_5_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_5_2_JSON (*((EFI_REDFISH_THERMAL_V1_5_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_5_2 *ThermalV1_5_2; + + ThermalV1_5_2 = (EFI_REDFISH_THERMAL_V1_5_2 *)InterpProp; + DestroyThermal_V1_5_2_CS (ThermalV1_5_2->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_5_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_5_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_5_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_5_3/RedfishThermal_V1_5_3_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_5_3/RedfishThermal_V1_5_3_Dxe.inf new file mode 100644 index 00000000000..9af6b92d856 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_5_3/RedfishThermal_V1_5_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_5_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_5_3_Dxe + FILE_GUID = 96e2fa7a-ae78-43cc-8512-faa64eb2f665 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_5_3EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_5_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_5_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_5_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_5_3/Thermal_V1_5_3_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_5_3/Thermal_V1_5_3_Dxe.c new file mode 100644 index 00000000000..d1b34151b87 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_5_3/Thermal_V1_5_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_5_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "5", + "3" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_5_3 *ThermalV1_5_3; + EFI_REDFISH_THERMAL_V1_5_3_CS *ThermalV1_5_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_5_3_To_CS (ResoruceRaw, &ThermalV1_5_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_5_3 = (EFI_REDFISH_THERMAL_V1_5_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_5_3)); + if (ThermalV1_5_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_5_3; + ThermalV1_5_3->Thermal = ThermalV1_5_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_5_3_JSON (*((EFI_REDFISH_THERMAL_V1_5_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_5_3 *ThermalV1_5_3; + + ThermalV1_5_3 = (EFI_REDFISH_THERMAL_V1_5_3 *)InterpProp; + DestroyThermal_V1_5_3_CS (ThermalV1_5_3->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_5_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_5_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_5_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_5_4/RedfishThermal_V1_5_4_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_5_4/RedfishThermal_V1_5_4_Dxe.inf new file mode 100644 index 00000000000..99ffe4842cb --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_5_4/RedfishThermal_V1_5_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_5_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_5_4_Dxe + FILE_GUID = c4c5f881-6b28-4904-86c1-a99b21e05388 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_5_4EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_5_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_5_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_5_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_5_4/Thermal_V1_5_4_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_5_4/Thermal_V1_5_4_Dxe.c new file mode 100644 index 00000000000..786794ffdf2 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_5_4/Thermal_V1_5_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_5_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "5", + "4" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_5_4 *ThermalV1_5_4; + EFI_REDFISH_THERMAL_V1_5_4_CS *ThermalV1_5_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_5_4_To_CS (ResoruceRaw, &ThermalV1_5_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_5_4 = (EFI_REDFISH_THERMAL_V1_5_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_5_4)); + if (ThermalV1_5_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_5_4; + ThermalV1_5_4->Thermal = ThermalV1_5_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_5_4_JSON (*((EFI_REDFISH_THERMAL_V1_5_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_5_4 *ThermalV1_5_4; + + ThermalV1_5_4 = (EFI_REDFISH_THERMAL_V1_5_4 *)InterpProp; + DestroyThermal_V1_5_4_CS (ThermalV1_5_4->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_5_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_5_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_5_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_5_5/RedfishThermal_V1_5_5_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_5_5/RedfishThermal_V1_5_5_Dxe.inf new file mode 100644 index 00000000000..a0da124e8bc --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_5_5/RedfishThermal_V1_5_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_5_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_5_5_Dxe + FILE_GUID = 17827477-dd49-465c-b4c6-dc7d9b927bba + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_5_5EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_5_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_5_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_5_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_5_5/Thermal_V1_5_5_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_5_5/Thermal_V1_5_5_Dxe.c new file mode 100644 index 00000000000..688dc065616 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_5_5/Thermal_V1_5_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_5_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_5_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "5", + "5" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_5_5 *ThermalV1_5_5; + EFI_REDFISH_THERMAL_V1_5_5_CS *ThermalV1_5_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_5_5_To_CS (ResoruceRaw, &ThermalV1_5_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_5_5 = (EFI_REDFISH_THERMAL_V1_5_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_5_5)); + if (ThermalV1_5_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_5_5; + ThermalV1_5_5->Thermal = ThermalV1_5_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_5_5_JSON (*((EFI_REDFISH_THERMAL_V1_5_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_5_5 *ThermalV1_5_5; + + ThermalV1_5_5 = (EFI_REDFISH_THERMAL_V1_5_5 *)InterpProp; + DestroyThermal_V1_5_5_CS (ThermalV1_5_5->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_5_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_5_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_5_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_6_0/RedfishThermal_V1_6_0_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_6_0/RedfishThermal_V1_6_0_Dxe.inf new file mode 100644 index 00000000000..013ac3248e5 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_6_0/RedfishThermal_V1_6_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_6_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_6_0_Dxe + FILE_GUID = 29254819-0df5-488a-b31f-76451df95483 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_6_0EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_6_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_6_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_6_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_6_0/Thermal_V1_6_0_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_6_0/Thermal_V1_6_0_Dxe.c new file mode 100644 index 00000000000..3b9aecba931 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_6_0/Thermal_V1_6_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_6_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "6", + "0" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_6_0 *ThermalV1_6_0; + EFI_REDFISH_THERMAL_V1_6_0_CS *ThermalV1_6_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_6_0_To_CS (ResoruceRaw, &ThermalV1_6_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_6_0 = (EFI_REDFISH_THERMAL_V1_6_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_6_0)); + if (ThermalV1_6_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_6_0; + ThermalV1_6_0->Thermal = ThermalV1_6_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_6_0_JSON (*((EFI_REDFISH_THERMAL_V1_6_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_6_0 *ThermalV1_6_0; + + ThermalV1_6_0 = (EFI_REDFISH_THERMAL_V1_6_0 *)InterpProp; + DestroyThermal_V1_6_0_CS (ThermalV1_6_0->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_6_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_6_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_6_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_6_1/RedfishThermal_V1_6_1_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_6_1/RedfishThermal_V1_6_1_Dxe.inf new file mode 100644 index 00000000000..1ffe50b6c34 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_6_1/RedfishThermal_V1_6_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_6_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_6_1_Dxe + FILE_GUID = 67cb18eb-310c-4e6d-a3cd-a81742182142 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_6_1EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_6_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_6_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_6_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_6_1/Thermal_V1_6_1_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_6_1/Thermal_V1_6_1_Dxe.c new file mode 100644 index 00000000000..a804a783772 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_6_1/Thermal_V1_6_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_6_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "6", + "1" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_6_1 *ThermalV1_6_1; + EFI_REDFISH_THERMAL_V1_6_1_CS *ThermalV1_6_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_6_1_To_CS (ResoruceRaw, &ThermalV1_6_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_6_1 = (EFI_REDFISH_THERMAL_V1_6_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_6_1)); + if (ThermalV1_6_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_6_1; + ThermalV1_6_1->Thermal = ThermalV1_6_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_6_1_JSON (*((EFI_REDFISH_THERMAL_V1_6_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_6_1 *ThermalV1_6_1; + + ThermalV1_6_1 = (EFI_REDFISH_THERMAL_V1_6_1 *)InterpProp; + DestroyThermal_V1_6_1_CS (ThermalV1_6_1->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_6_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_6_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_6_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_6_2/RedfishThermal_V1_6_2_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_6_2/RedfishThermal_V1_6_2_Dxe.inf new file mode 100644 index 00000000000..20e6ae17220 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_6_2/RedfishThermal_V1_6_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_6_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_6_2_Dxe + FILE_GUID = edc6e243-e834-4e23-9846-22d45463ec8f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_6_2EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_6_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_6_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_6_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_6_2/Thermal_V1_6_2_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_6_2/Thermal_V1_6_2_Dxe.c new file mode 100644 index 00000000000..d48a1803de7 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_6_2/Thermal_V1_6_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_6_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "6", + "2" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_6_2 *ThermalV1_6_2; + EFI_REDFISH_THERMAL_V1_6_2_CS *ThermalV1_6_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_6_2_To_CS (ResoruceRaw, &ThermalV1_6_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_6_2 = (EFI_REDFISH_THERMAL_V1_6_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_6_2)); + if (ThermalV1_6_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_6_2; + ThermalV1_6_2->Thermal = ThermalV1_6_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_6_2_JSON (*((EFI_REDFISH_THERMAL_V1_6_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_6_2 *ThermalV1_6_2; + + ThermalV1_6_2 = (EFI_REDFISH_THERMAL_V1_6_2 *)InterpProp; + DestroyThermal_V1_6_2_CS (ThermalV1_6_2->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_6_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_6_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_6_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Thermal/v1_7_0/RedfishThermal_V1_7_0_Dxe.inf b/RedfishClientPkg/Converter/Thermal/v1_7_0/RedfishThermal_V1_7_0_Dxe.inf new file mode 100644 index 00000000000..d257cc6214c --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_7_0/RedfishThermal_V1_7_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Thermal.v1_7_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermal_V1_7_0_Dxe + FILE_GUID = 72bbef27-2603-4a3c-896f-921a2f1f3f96 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermal_V1_7_0EntryPoint + UNLOAD_IMAGE = RedfishThermal_V1_7_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Thermal_V1_7_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalV1_7_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Thermal/v1_7_0/Thermal_V1_7_0_Dxe.c b/RedfishClientPkg/Converter/Thermal/v1_7_0/Thermal_V1_7_0_Dxe.c new file mode 100644 index 00000000000..6b3748bb5e7 --- /dev/null +++ b/RedfishClientPkg/Converter/Thermal/v1_7_0/Thermal_V1_7_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Thermal.v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Thermal"; +BOOLEAN IsRevisonController = TRUE; + +// Support Thermal V1_7_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Thermal", + "1", + "7", + "0" + }, + "Thermal" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_7_0 *ThermalV1_7_0; + EFI_REDFISH_THERMAL_V1_7_0_CS *ThermalV1_7_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Thermal") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Thermal_V1_7_0_To_CS (ResoruceRaw, &ThermalV1_7_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalV1_7_0 = (EFI_REDFISH_THERMAL_V1_7_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMAL_V1_7_0)); + if (ThermalV1_7_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalV1_7_0; + ThermalV1_7_0->Thermal = ThermalV1_7_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Thermal"), "Thermal"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Thermal")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Thermal"), "Thermal"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Thermal_V1_7_0_JSON (*((EFI_REDFISH_THERMAL_V1_7_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMAL_V1_7_0 *ThermalV1_7_0; + + ThermalV1_7_0 = (EFI_REDFISH_THERMAL_V1_7_0 *)InterpProp; + DestroyThermal_V1_7_0_CS (ThermalV1_7_0->Thermal); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermal_V1_7_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_7_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalToStructWrapper, + ThermalToJson, + ThermalDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermal_V1_7_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ThermalMetrics/v1_0_0/RedfishThermalMetrics_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/ThermalMetrics/v1_0_0/RedfishThermalMetrics_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..1062df122d9 --- /dev/null +++ b/RedfishClientPkg/Converter/ThermalMetrics/v1_0_0/RedfishThermalMetrics_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ThermalMetrics.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermalMetrics_V1_0_0_Dxe + FILE_GUID = 0f2f2433-9b8c-4989-b148-2959ba360aa6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermalMetrics_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishThermalMetrics_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ThermalMetrics_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalMetricsV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ThermalMetrics/v1_0_0/ThermalMetrics_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/ThermalMetrics/v1_0_0/ThermalMetrics_V1_0_0_Dxe.c new file mode 100644 index 00000000000..1547188e1c4 --- /dev/null +++ b/RedfishClientPkg/Converter/ThermalMetrics/v1_0_0/ThermalMetrics_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ThermalMetrics.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ThermalMetrics"; +BOOLEAN IsRevisonController = TRUE; + +// Support ThermalMetrics V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ThermalMetrics", + "1", + "0", + "0" + }, + "ThermalMetrics" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalMetricsToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMALMETRICS_V1_0_0 *ThermalMetricsV1_0_0; + EFI_REDFISH_THERMALMETRICS_V1_0_0_CS *ThermalMetricsV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ThermalMetrics") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ThermalMetrics_V1_0_0_To_CS (ResoruceRaw, &ThermalMetricsV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalMetricsV1_0_0 = (EFI_REDFISH_THERMALMETRICS_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMALMETRICS_V1_0_0)); + if (ThermalMetricsV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalMetricsV1_0_0; + ThermalMetricsV1_0_0->ThermalMetrics = ThermalMetricsV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ThermalMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ThermalMetrics"), "ThermalMetrics"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ThermalMetrics")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ThermalMetrics"), "ThermalMetrics"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalMetricsToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalMetricsToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalMetricsToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalMetricsToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ThermalMetrics_V1_0_0_JSON (*((EFI_REDFISH_THERMALMETRICS_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalMetricsToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalMetricsDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMALMETRICS_V1_0_0 *ThermalMetricsV1_0_0; + + ThermalMetricsV1_0_0 = (EFI_REDFISH_THERMALMETRICS_V1_0_0 *)InterpProp; + DestroyThermalMetrics_V1_0_0_CS (ThermalMetricsV1_0_0->ThermalMetrics); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalMetricsFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalMetricsDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermalMetrics_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermalMetrics_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalMetricsToStructWrapper, + ThermalMetricsToJson, + ThermalMetricsDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermalMetrics_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ThermalSubsystem/v1_0_0/RedfishThermalSubsystem_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/ThermalSubsystem/v1_0_0/RedfishThermalSubsystem_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..374af615d34 --- /dev/null +++ b/RedfishClientPkg/Converter/ThermalSubsystem/v1_0_0/RedfishThermalSubsystem_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ThermalSubsystem.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishThermalSubsystem_V1_0_0_Dxe + FILE_GUID = 14bdf105-b1c6-4488-9899-a9f1a4025ca8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishThermalSubsystem_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishThermalSubsystem_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ThermalSubsystem_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ThermalSubsystemV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ThermalSubsystem/v1_0_0/ThermalSubsystem_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/ThermalSubsystem/v1_0_0/ThermalSubsystem_V1_0_0_Dxe.c new file mode 100644 index 00000000000..aee576585da --- /dev/null +++ b/RedfishClientPkg/Converter/ThermalSubsystem/v1_0_0/ThermalSubsystem_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ThermalSubsystem.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ThermalSubsystem"; +BOOLEAN IsRevisonController = TRUE; + +// Support ThermalSubsystem V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ThermalSubsystem", + "1", + "0", + "0" + }, + "ThermalSubsystem" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalSubsystemToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_THERMALSUBSYSTEM_V1_0_0 *ThermalSubsystemV1_0_0; + EFI_REDFISH_THERMALSUBSYSTEM_V1_0_0_CS *ThermalSubsystemV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ThermalSubsystem") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ThermalSubsystem_V1_0_0_To_CS (ResoruceRaw, &ThermalSubsystemV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ThermalSubsystemV1_0_0 = (EFI_REDFISH_THERMALSUBSYSTEM_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_THERMALSUBSYSTEM_V1_0_0)); + if (ThermalSubsystemV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ThermalSubsystemV1_0_0; + ThermalSubsystemV1_0_0->ThermalSubsystem = ThermalSubsystemV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ThermalSubsystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ThermalSubsystem"), "ThermalSubsystem"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ThermalSubsystem")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ThermalSubsystem"), "ThermalSubsystem"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ThermalSubsystemToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalSubsystemToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ThermalSubsystemToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalSubsystemToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ThermalSubsystem_V1_0_0_JSON (*((EFI_REDFISH_THERMALSUBSYSTEM_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ThermalSubsystemToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalSubsystemDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_THERMALSUBSYSTEM_V1_0_0 *ThermalSubsystemV1_0_0; + + ThermalSubsystemV1_0_0 = (EFI_REDFISH_THERMALSUBSYSTEM_V1_0_0 *)InterpProp; + DestroyThermalSubsystem_V1_0_0_CS (ThermalSubsystemV1_0_0->ThermalSubsystem); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ThermalSubsystemFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ThermalSubsystemDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyThermalSubsystem_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishThermalSubsystem_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ThermalSubsystemToStructWrapper, + ThermalSubsystemToJson, + ThermalSubsystemDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishThermalSubsystem_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Triggers/v1_0_0/RedfishTriggers_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Triggers/v1_0_0/RedfishTriggers_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..ea86fa3b254 --- /dev/null +++ b/RedfishClientPkg/Converter/Triggers/v1_0_0/RedfishTriggers_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Triggers.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTriggers_V1_0_0_Dxe + FILE_GUID = 84067412-1d29-4f6f-bf29-cce508825032 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTriggers_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishTriggers_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Triggers_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TriggersV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Triggers/v1_0_0/Triggers_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Triggers/v1_0_0/Triggers_V1_0_0_Dxe.c new file mode 100644 index 00000000000..7e7fc253b8b --- /dev/null +++ b/RedfishClientPkg/Converter/Triggers/v1_0_0/Triggers_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Triggers.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Triggers"; +BOOLEAN IsRevisonController = TRUE; + +// Support Triggers V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Triggers", + "1", + "0", + "0" + }, + "Triggers" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TRIGGERS_V1_0_0 *TriggersV1_0_0; + EFI_REDFISH_TRIGGERS_V1_0_0_CS *TriggersV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Triggers") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Triggers_V1_0_0_To_CS (ResoruceRaw, &TriggersV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TriggersV1_0_0 = (EFI_REDFISH_TRIGGERS_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TRIGGERS_V1_0_0)); + if (TriggersV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TriggersV1_0_0; + TriggersV1_0_0->Triggers = TriggersV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Triggers")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Triggers"), "Triggers"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Triggers")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Triggers"), "Triggers"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TriggersToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TriggersToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Triggers_V1_0_0_JSON (*((EFI_REDFISH_TRIGGERS_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TriggersToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TRIGGERS_V1_0_0 *TriggersV1_0_0; + + TriggersV1_0_0 = (EFI_REDFISH_TRIGGERS_V1_0_0 *)InterpProp; + DestroyTriggers_V1_0_0_CS (TriggersV1_0_0->Triggers); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TriggersFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTriggers_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTriggers_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TriggersToStructWrapper, + TriggersToJson, + TriggersDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTriggers_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Triggers/v1_0_1/RedfishTriggers_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/Triggers/v1_0_1/RedfishTriggers_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..10aed9fad29 --- /dev/null +++ b/RedfishClientPkg/Converter/Triggers/v1_0_1/RedfishTriggers_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Triggers.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTriggers_V1_0_1_Dxe + FILE_GUID = b7461ce8-a6c4-4eaf-a35a-072cbb75c6b5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTriggers_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishTriggers_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Triggers_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TriggersV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Triggers/v1_0_1/Triggers_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/Triggers/v1_0_1/Triggers_V1_0_1_Dxe.c new file mode 100644 index 00000000000..08c9413709b --- /dev/null +++ b/RedfishClientPkg/Converter/Triggers/v1_0_1/Triggers_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Triggers.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Triggers"; +BOOLEAN IsRevisonController = TRUE; + +// Support Triggers V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Triggers", + "1", + "0", + "1" + }, + "Triggers" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TRIGGERS_V1_0_1 *TriggersV1_0_1; + EFI_REDFISH_TRIGGERS_V1_0_1_CS *TriggersV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Triggers") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Triggers_V1_0_1_To_CS (ResoruceRaw, &TriggersV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TriggersV1_0_1 = (EFI_REDFISH_TRIGGERS_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TRIGGERS_V1_0_1)); + if (TriggersV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TriggersV1_0_1; + TriggersV1_0_1->Triggers = TriggersV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Triggers")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Triggers"), "Triggers"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Triggers")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Triggers"), "Triggers"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TriggersToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TriggersToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Triggers_V1_0_1_JSON (*((EFI_REDFISH_TRIGGERS_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TriggersToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TRIGGERS_V1_0_1 *TriggersV1_0_1; + + TriggersV1_0_1 = (EFI_REDFISH_TRIGGERS_V1_0_1 *)InterpProp; + DestroyTriggers_V1_0_1_CS (TriggersV1_0_1->Triggers); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TriggersFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTriggers_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTriggers_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TriggersToStructWrapper, + TriggersToJson, + TriggersDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTriggers_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Triggers/v1_0_2/RedfishTriggers_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Triggers/v1_0_2/RedfishTriggers_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..a75a13a6e9b --- /dev/null +++ b/RedfishClientPkg/Converter/Triggers/v1_0_2/RedfishTriggers_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Triggers.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTriggers_V1_0_2_Dxe + FILE_GUID = 06e26b76-6454-466b-9014-a9e2a733706f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTriggers_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishTriggers_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Triggers_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TriggersV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Triggers/v1_0_2/Triggers_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Triggers/v1_0_2/Triggers_V1_0_2_Dxe.c new file mode 100644 index 00000000000..0e7e889c2c3 --- /dev/null +++ b/RedfishClientPkg/Converter/Triggers/v1_0_2/Triggers_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Triggers.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Triggers"; +BOOLEAN IsRevisonController = TRUE; + +// Support Triggers V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Triggers", + "1", + "0", + "2" + }, + "Triggers" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TRIGGERS_V1_0_2 *TriggersV1_0_2; + EFI_REDFISH_TRIGGERS_V1_0_2_CS *TriggersV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Triggers") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Triggers_V1_0_2_To_CS (ResoruceRaw, &TriggersV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TriggersV1_0_2 = (EFI_REDFISH_TRIGGERS_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TRIGGERS_V1_0_2)); + if (TriggersV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TriggersV1_0_2; + TriggersV1_0_2->Triggers = TriggersV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Triggers")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Triggers"), "Triggers"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Triggers")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Triggers"), "Triggers"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TriggersToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TriggersToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Triggers_V1_0_2_JSON (*((EFI_REDFISH_TRIGGERS_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TriggersToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TRIGGERS_V1_0_2 *TriggersV1_0_2; + + TriggersV1_0_2 = (EFI_REDFISH_TRIGGERS_V1_0_2 *)InterpProp; + DestroyTriggers_V1_0_2_CS (TriggersV1_0_2->Triggers); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TriggersFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTriggers_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTriggers_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TriggersToStructWrapper, + TriggersToJson, + TriggersDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTriggers_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Triggers/v1_0_3/RedfishTriggers_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/Triggers/v1_0_3/RedfishTriggers_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..4be743ede6e --- /dev/null +++ b/RedfishClientPkg/Converter/Triggers/v1_0_3/RedfishTriggers_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Triggers.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTriggers_V1_0_3_Dxe + FILE_GUID = 6039f8fb-48ba-4663-8fae-756cc5920cc7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTriggers_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishTriggers_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Triggers_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TriggersV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Triggers/v1_0_3/Triggers_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/Triggers/v1_0_3/Triggers_V1_0_3_Dxe.c new file mode 100644 index 00000000000..af9e1b6127c --- /dev/null +++ b/RedfishClientPkg/Converter/Triggers/v1_0_3/Triggers_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Triggers.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Triggers"; +BOOLEAN IsRevisonController = TRUE; + +// Support Triggers V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Triggers", + "1", + "0", + "3" + }, + "Triggers" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TRIGGERS_V1_0_3 *TriggersV1_0_3; + EFI_REDFISH_TRIGGERS_V1_0_3_CS *TriggersV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Triggers") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Triggers_V1_0_3_To_CS (ResoruceRaw, &TriggersV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TriggersV1_0_3 = (EFI_REDFISH_TRIGGERS_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TRIGGERS_V1_0_3)); + if (TriggersV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TriggersV1_0_3; + TriggersV1_0_3->Triggers = TriggersV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Triggers")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Triggers"), "Triggers"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Triggers")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Triggers"), "Triggers"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TriggersToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TriggersToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Triggers_V1_0_3_JSON (*((EFI_REDFISH_TRIGGERS_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TriggersToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TRIGGERS_V1_0_3 *TriggersV1_0_3; + + TriggersV1_0_3 = (EFI_REDFISH_TRIGGERS_V1_0_3 *)InterpProp; + DestroyTriggers_V1_0_3_CS (TriggersV1_0_3->Triggers); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TriggersFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTriggers_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTriggers_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TriggersToStructWrapper, + TriggersToJson, + TriggersDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTriggers_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Triggers/v1_0_4/RedfishTriggers_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/Triggers/v1_0_4/RedfishTriggers_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..e416b149146 --- /dev/null +++ b/RedfishClientPkg/Converter/Triggers/v1_0_4/RedfishTriggers_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Triggers.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTriggers_V1_0_4_Dxe + FILE_GUID = 27d87f04-67c3-4570-8b43-c3e65b3dbbc0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTriggers_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishTriggers_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Triggers_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TriggersV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Triggers/v1_0_4/Triggers_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/Triggers/v1_0_4/Triggers_V1_0_4_Dxe.c new file mode 100644 index 00000000000..197931af29d --- /dev/null +++ b/RedfishClientPkg/Converter/Triggers/v1_0_4/Triggers_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Triggers.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Triggers"; +BOOLEAN IsRevisonController = TRUE; + +// Support Triggers V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Triggers", + "1", + "0", + "4" + }, + "Triggers" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TRIGGERS_V1_0_4 *TriggersV1_0_4; + EFI_REDFISH_TRIGGERS_V1_0_4_CS *TriggersV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Triggers") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Triggers_V1_0_4_To_CS (ResoruceRaw, &TriggersV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TriggersV1_0_4 = (EFI_REDFISH_TRIGGERS_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TRIGGERS_V1_0_4)); + if (TriggersV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TriggersV1_0_4; + TriggersV1_0_4->Triggers = TriggersV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Triggers")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Triggers"), "Triggers"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Triggers")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Triggers"), "Triggers"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TriggersToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TriggersToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Triggers_V1_0_4_JSON (*((EFI_REDFISH_TRIGGERS_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TriggersToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TRIGGERS_V1_0_4 *TriggersV1_0_4; + + TriggersV1_0_4 = (EFI_REDFISH_TRIGGERS_V1_0_4 *)InterpProp; + DestroyTriggers_V1_0_4_CS (TriggersV1_0_4->Triggers); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TriggersFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTriggers_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTriggers_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TriggersToStructWrapper, + TriggersToJson, + TriggersDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTriggers_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Triggers/v1_0_5/RedfishTriggers_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/Triggers/v1_0_5/RedfishTriggers_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..97c15226ad8 --- /dev/null +++ b/RedfishClientPkg/Converter/Triggers/v1_0_5/RedfishTriggers_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Triggers.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTriggers_V1_0_5_Dxe + FILE_GUID = aeb44df0-5bcd-4a49-8e93-faaf89c9d746 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTriggers_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishTriggers_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Triggers_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TriggersV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Triggers/v1_0_5/Triggers_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/Triggers/v1_0_5/Triggers_V1_0_5_Dxe.c new file mode 100644 index 00000000000..9314bb2f6d9 --- /dev/null +++ b/RedfishClientPkg/Converter/Triggers/v1_0_5/Triggers_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Triggers.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Triggers"; +BOOLEAN IsRevisonController = TRUE; + +// Support Triggers V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Triggers", + "1", + "0", + "5" + }, + "Triggers" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TRIGGERS_V1_0_5 *TriggersV1_0_5; + EFI_REDFISH_TRIGGERS_V1_0_5_CS *TriggersV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Triggers") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Triggers_V1_0_5_To_CS (ResoruceRaw, &TriggersV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TriggersV1_0_5 = (EFI_REDFISH_TRIGGERS_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TRIGGERS_V1_0_5)); + if (TriggersV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TriggersV1_0_5; + TriggersV1_0_5->Triggers = TriggersV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Triggers")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Triggers"), "Triggers"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Triggers")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Triggers"), "Triggers"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TriggersToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TriggersToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Triggers_V1_0_5_JSON (*((EFI_REDFISH_TRIGGERS_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TriggersToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TRIGGERS_V1_0_5 *TriggersV1_0_5; + + TriggersV1_0_5 = (EFI_REDFISH_TRIGGERS_V1_0_5 *)InterpProp; + DestroyTriggers_V1_0_5_CS (TriggersV1_0_5->Triggers); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TriggersFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTriggers_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTriggers_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TriggersToStructWrapper, + TriggersToJson, + TriggersDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTriggers_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Triggers/v1_1_0/RedfishTriggers_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/Triggers/v1_1_0/RedfishTriggers_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..e4a79d5174a --- /dev/null +++ b/RedfishClientPkg/Converter/Triggers/v1_1_0/RedfishTriggers_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Triggers.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTriggers_V1_1_0_Dxe + FILE_GUID = aa5b153c-1441-47ee-889b-e74957f57c8b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTriggers_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishTriggers_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Triggers_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TriggersV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Triggers/v1_1_0/Triggers_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/Triggers/v1_1_0/Triggers_V1_1_0_Dxe.c new file mode 100644 index 00000000000..c0023a0c32a --- /dev/null +++ b/RedfishClientPkg/Converter/Triggers/v1_1_0/Triggers_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Triggers.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Triggers"; +BOOLEAN IsRevisonController = TRUE; + +// Support Triggers V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Triggers", + "1", + "1", + "0" + }, + "Triggers" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TRIGGERS_V1_1_0 *TriggersV1_1_0; + EFI_REDFISH_TRIGGERS_V1_1_0_CS *TriggersV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Triggers") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Triggers_V1_1_0_To_CS (ResoruceRaw, &TriggersV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TriggersV1_1_0 = (EFI_REDFISH_TRIGGERS_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TRIGGERS_V1_1_0)); + if (TriggersV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TriggersV1_1_0; + TriggersV1_1_0->Triggers = TriggersV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Triggers")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Triggers"), "Triggers"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Triggers")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Triggers"), "Triggers"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TriggersToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TriggersToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Triggers_V1_1_0_JSON (*((EFI_REDFISH_TRIGGERS_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TriggersToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TRIGGERS_V1_1_0 *TriggersV1_1_0; + + TriggersV1_1_0 = (EFI_REDFISH_TRIGGERS_V1_1_0 *)InterpProp; + DestroyTriggers_V1_1_0_CS (TriggersV1_1_0->Triggers); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TriggersFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTriggers_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTriggers_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TriggersToStructWrapper, + TriggersToJson, + TriggersDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTriggers_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Triggers/v1_1_1/RedfishTriggers_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/Triggers/v1_1_1/RedfishTriggers_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..d8bc6af644c --- /dev/null +++ b/RedfishClientPkg/Converter/Triggers/v1_1_1/RedfishTriggers_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Triggers.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTriggers_V1_1_1_Dxe + FILE_GUID = bdbe04cc-784b-458c-b05d-4a51fb688faf + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTriggers_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishTriggers_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Triggers_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TriggersV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Triggers/v1_1_1/Triggers_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/Triggers/v1_1_1/Triggers_V1_1_1_Dxe.c new file mode 100644 index 00000000000..2e55950f32f --- /dev/null +++ b/RedfishClientPkg/Converter/Triggers/v1_1_1/Triggers_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Triggers.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Triggers"; +BOOLEAN IsRevisonController = TRUE; + +// Support Triggers V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Triggers", + "1", + "1", + "1" + }, + "Triggers" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TRIGGERS_V1_1_1 *TriggersV1_1_1; + EFI_REDFISH_TRIGGERS_V1_1_1_CS *TriggersV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Triggers") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Triggers_V1_1_1_To_CS (ResoruceRaw, &TriggersV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TriggersV1_1_1 = (EFI_REDFISH_TRIGGERS_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TRIGGERS_V1_1_1)); + if (TriggersV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TriggersV1_1_1; + TriggersV1_1_1->Triggers = TriggersV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Triggers")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Triggers"), "Triggers"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Triggers")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Triggers"), "Triggers"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TriggersToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TriggersToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Triggers_V1_1_1_JSON (*((EFI_REDFISH_TRIGGERS_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TriggersToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TRIGGERS_V1_1_1 *TriggersV1_1_1; + + TriggersV1_1_1 = (EFI_REDFISH_TRIGGERS_V1_1_1 *)InterpProp; + DestroyTriggers_V1_1_1_CS (TriggersV1_1_1->Triggers); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TriggersFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTriggers_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTriggers_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TriggersToStructWrapper, + TriggersToJson, + TriggersDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTriggers_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Triggers/v1_1_2/RedfishTriggers_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/Triggers/v1_1_2/RedfishTriggers_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..0355c16652a --- /dev/null +++ b/RedfishClientPkg/Converter/Triggers/v1_1_2/RedfishTriggers_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Triggers.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTriggers_V1_1_2_Dxe + FILE_GUID = a7d7d2cc-7d0f-4f7a-8b89-70904d16b226 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTriggers_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishTriggers_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Triggers_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TriggersV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Triggers/v1_1_2/Triggers_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/Triggers/v1_1_2/Triggers_V1_1_2_Dxe.c new file mode 100644 index 00000000000..e36601bd1e6 --- /dev/null +++ b/RedfishClientPkg/Converter/Triggers/v1_1_2/Triggers_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Triggers.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Triggers"; +BOOLEAN IsRevisonController = TRUE; + +// Support Triggers V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Triggers", + "1", + "1", + "2" + }, + "Triggers" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TRIGGERS_V1_1_2 *TriggersV1_1_2; + EFI_REDFISH_TRIGGERS_V1_1_2_CS *TriggersV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Triggers") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Triggers_V1_1_2_To_CS (ResoruceRaw, &TriggersV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TriggersV1_1_2 = (EFI_REDFISH_TRIGGERS_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TRIGGERS_V1_1_2)); + if (TriggersV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TriggersV1_1_2; + TriggersV1_1_2->Triggers = TriggersV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Triggers")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Triggers"), "Triggers"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Triggers")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Triggers"), "Triggers"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TriggersToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TriggersToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Triggers_V1_1_2_JSON (*((EFI_REDFISH_TRIGGERS_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TriggersToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TRIGGERS_V1_1_2 *TriggersV1_1_2; + + TriggersV1_1_2 = (EFI_REDFISH_TRIGGERS_V1_1_2 *)InterpProp; + DestroyTriggers_V1_1_2_CS (TriggersV1_1_2->Triggers); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TriggersFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTriggers_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTriggers_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TriggersToStructWrapper, + TriggersToJson, + TriggersDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTriggers_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Triggers/v1_1_3/RedfishTriggers_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/Triggers/v1_1_3/RedfishTriggers_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..8205c669d51 --- /dev/null +++ b/RedfishClientPkg/Converter/Triggers/v1_1_3/RedfishTriggers_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Triggers.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTriggers_V1_1_3_Dxe + FILE_GUID = 6ab07f30-a91f-4ef0-9f89-dde5a0e313f0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTriggers_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishTriggers_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Triggers_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TriggersV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Triggers/v1_1_3/Triggers_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/Triggers/v1_1_3/Triggers_V1_1_3_Dxe.c new file mode 100644 index 00000000000..451ed2def94 --- /dev/null +++ b/RedfishClientPkg/Converter/Triggers/v1_1_3/Triggers_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Triggers.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Triggers"; +BOOLEAN IsRevisonController = TRUE; + +// Support Triggers V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Triggers", + "1", + "1", + "3" + }, + "Triggers" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TRIGGERS_V1_1_3 *TriggersV1_1_3; + EFI_REDFISH_TRIGGERS_V1_1_3_CS *TriggersV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Triggers") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Triggers_V1_1_3_To_CS (ResoruceRaw, &TriggersV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + TriggersV1_1_3 = (EFI_REDFISH_TRIGGERS_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TRIGGERS_V1_1_3)); + if (TriggersV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TriggersV1_1_3; + TriggersV1_1_3->Triggers = TriggersV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Triggers")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Triggers"), "Triggers"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Triggers")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Triggers"), "Triggers"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TriggersToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TriggersToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Triggers_V1_1_3_JSON (*((EFI_REDFISH_TRIGGERS_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TriggersToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TRIGGERS_V1_1_3 *TriggersV1_1_3; + + TriggersV1_1_3 = (EFI_REDFISH_TRIGGERS_V1_1_3 *)InterpProp; + DestroyTriggers_V1_1_3_CS (TriggersV1_1_3->Triggers); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TriggersFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTriggers_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTriggers_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TriggersToStructWrapper, + TriggersToJson, + TriggersDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTriggers_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/TriggersCollection/RedfishTriggersCollection_Dxe.inf b/RedfishClientPkg/Converter/TriggersCollection/RedfishTriggersCollection_Dxe.inf new file mode 100644 index 00000000000..a5bba00191c --- /dev/null +++ b/RedfishClientPkg/Converter/TriggersCollection/RedfishTriggersCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of TriggersCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishTriggersCollection_Dxe + FILE_GUID = 939bc560-e698-4229-ac40-f10877a0d4f6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishTriggersCollectionEntryPoint + UNLOAD_IMAGE = RedfishTriggersCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + TriggersCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + TriggersCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/TriggersCollection/TriggersCollection_Dxe.c b/RedfishClientPkg/Converter/TriggersCollection/TriggersCollection_Dxe.c new file mode 100644 index 00000000000..202eb17f82c --- /dev/null +++ b/RedfishClientPkg/Converter/TriggersCollection/TriggersCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - TriggersCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#TriggersCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support TriggersCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "TriggersCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "TriggersCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_TRIGGERSCOLLECTION *TriggersCollection; + EFI_REDFISH_TRIGGERSCOLLECTION_CS *TriggersCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "TriggersCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_TriggersCollection_To_CS (ResoruceRaw, &TriggersCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + TriggersCollection = (EFI_REDFISH_TRIGGERSCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_TRIGGERSCOLLECTION)); + if (TriggersCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)TriggersCollection; + TriggersCollection->TriggersCollection = TriggersCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("TriggersCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("TriggersCollection"), "TriggersCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("TriggersCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("TriggersCollection"), "TriggersCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of TriggersCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return TriggersCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_TriggersCollection_JSON (*((EFI_REDFISH_TRIGGERSCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in TriggersCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_TRIGGERSCOLLECTION *TriggersCollection; + + TriggersCollection = (EFI_REDFISH_TRIGGERSCOLLECTION *)InterpProp; + DestroyTriggersCollection_CS (TriggersCollection->TriggersCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from TriggersCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +TriggersCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyTriggersCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishTriggersCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + TriggersCollectionToStructWrapper, + TriggersCollectionToJson, + TriggersCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishTriggersCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_0_0/RedfishUpdateService_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_0_0/RedfishUpdateService_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..18d6f06fb02 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_0_0/RedfishUpdateService_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_0_0_Dxe + FILE_GUID = 39bc7751-e660-46e4-ada1-c4902eea1fc2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_0_0/UpdateService_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_0_0/UpdateService_V1_0_0_Dxe.c new file mode 100644 index 00000000000..3d1bafb9648 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_0_0/UpdateService_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "0", + "0" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_0_0 *UpdateServiceV1_0_0; + EFI_REDFISH_UPDATESERVICE_V1_0_0_CS *UpdateServiceV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_0_0_To_CS (ResoruceRaw, &UpdateServiceV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_0_0 = (EFI_REDFISH_UPDATESERVICE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_0_0)); + if (UpdateServiceV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_0_0; + UpdateServiceV1_0_0->UpdateService = UpdateServiceV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_0_0_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_0_0 *UpdateServiceV1_0_0; + + UpdateServiceV1_0_0 = (EFI_REDFISH_UPDATESERVICE_V1_0_0 *)InterpProp; + DestroyUpdateService_V1_0_0_CS (UpdateServiceV1_0_0->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_0_1/RedfishUpdateService_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_0_1/RedfishUpdateService_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..cdc04a7cafe --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_0_1/RedfishUpdateService_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_0_1_Dxe + FILE_GUID = 40382e0b-8553-4062-acf8-84d26a43abc4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_0_1/UpdateService_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_0_1/UpdateService_V1_0_1_Dxe.c new file mode 100644 index 00000000000..5e20d0b6e7e --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_0_1/UpdateService_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "0", + "1" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_0_1 *UpdateServiceV1_0_1; + EFI_REDFISH_UPDATESERVICE_V1_0_1_CS *UpdateServiceV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_0_1_To_CS (ResoruceRaw, &UpdateServiceV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_0_1 = (EFI_REDFISH_UPDATESERVICE_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_0_1)); + if (UpdateServiceV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_0_1; + UpdateServiceV1_0_1->UpdateService = UpdateServiceV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_0_1_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_0_1 *UpdateServiceV1_0_1; + + UpdateServiceV1_0_1 = (EFI_REDFISH_UPDATESERVICE_V1_0_1 *)InterpProp; + DestroyUpdateService_V1_0_1_CS (UpdateServiceV1_0_1->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_0_10/RedfishUpdateService_V1_0_10_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_0_10/RedfishUpdateService_V1_0_10_Dxe.inf new file mode 100644 index 00000000000..8dc324561af --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_0_10/RedfishUpdateService_V1_0_10_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_0_10 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_0_10_Dxe + FILE_GUID = 0cb443fd-828c-4c06-aad0-e02892ff3118 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_0_10EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_0_10Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_0_10_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_0_10Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_0_10/UpdateService_V1_0_10_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_0_10/UpdateService_V1_0_10_Dxe.c new file mode 100644 index 00000000000..8e2ebb4d53d --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_0_10/UpdateService_V1_0_10_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_0_10 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "0", + "10" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_0_10 *UpdateServiceV1_0_10; + EFI_REDFISH_UPDATESERVICE_V1_0_10_CS *UpdateServiceV1_0_10Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "10") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_0_10_To_CS (ResoruceRaw, &UpdateServiceV1_0_10Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_0_10 = (EFI_REDFISH_UPDATESERVICE_V1_0_10 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_0_10)); + if (UpdateServiceV1_0_10 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_0_10; + UpdateServiceV1_0_10->UpdateService = UpdateServiceV1_0_10Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "10"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_0_10_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_0_10_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_0_10 *UpdateServiceV1_0_10; + + UpdateServiceV1_0_10 = (EFI_REDFISH_UPDATESERVICE_V1_0_10 *)InterpProp; + DestroyUpdateService_V1_0_10_CS (UpdateServiceV1_0_10->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_0_10_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_0_10EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_0_10Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_0_2/RedfishUpdateService_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_0_2/RedfishUpdateService_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..5ad606652bd --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_0_2/RedfishUpdateService_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_0_2_Dxe + FILE_GUID = b3ad1980-436a-44ed-8ee2-51dd091f3c40 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_0_2/UpdateService_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_0_2/UpdateService_V1_0_2_Dxe.c new file mode 100644 index 00000000000..7e904de9495 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_0_2/UpdateService_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "0", + "2" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_0_2 *UpdateServiceV1_0_2; + EFI_REDFISH_UPDATESERVICE_V1_0_2_CS *UpdateServiceV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_0_2_To_CS (ResoruceRaw, &UpdateServiceV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_0_2 = (EFI_REDFISH_UPDATESERVICE_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_0_2)); + if (UpdateServiceV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_0_2; + UpdateServiceV1_0_2->UpdateService = UpdateServiceV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_0_2_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_0_2 *UpdateServiceV1_0_2; + + UpdateServiceV1_0_2 = (EFI_REDFISH_UPDATESERVICE_V1_0_2 *)InterpProp; + DestroyUpdateService_V1_0_2_CS (UpdateServiceV1_0_2->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_0_3/RedfishUpdateService_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_0_3/RedfishUpdateService_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..bf2d13bb8a5 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_0_3/RedfishUpdateService_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_0_3_Dxe + FILE_GUID = 45b1a570-4037-4420-af6f-a81e215870b1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_0_3/UpdateService_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_0_3/UpdateService_V1_0_3_Dxe.c new file mode 100644 index 00000000000..1b37c132688 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_0_3/UpdateService_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "0", + "3" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_0_3 *UpdateServiceV1_0_3; + EFI_REDFISH_UPDATESERVICE_V1_0_3_CS *UpdateServiceV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_0_3_To_CS (ResoruceRaw, &UpdateServiceV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_0_3 = (EFI_REDFISH_UPDATESERVICE_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_0_3)); + if (UpdateServiceV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_0_3; + UpdateServiceV1_0_3->UpdateService = UpdateServiceV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_0_3_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_0_3 *UpdateServiceV1_0_3; + + UpdateServiceV1_0_3 = (EFI_REDFISH_UPDATESERVICE_V1_0_3 *)InterpProp; + DestroyUpdateService_V1_0_3_CS (UpdateServiceV1_0_3->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_0_4/RedfishUpdateService_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_0_4/RedfishUpdateService_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..51a402010e3 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_0_4/RedfishUpdateService_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_0_4_Dxe + FILE_GUID = 0991f4ad-9892-47e0-b33d-91cf677de69d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_0_4/UpdateService_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_0_4/UpdateService_V1_0_4_Dxe.c new file mode 100644 index 00000000000..02c697c7e67 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_0_4/UpdateService_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "0", + "4" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_0_4 *UpdateServiceV1_0_4; + EFI_REDFISH_UPDATESERVICE_V1_0_4_CS *UpdateServiceV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_0_4_To_CS (ResoruceRaw, &UpdateServiceV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_0_4 = (EFI_REDFISH_UPDATESERVICE_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_0_4)); + if (UpdateServiceV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_0_4; + UpdateServiceV1_0_4->UpdateService = UpdateServiceV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_0_4_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_0_4 *UpdateServiceV1_0_4; + + UpdateServiceV1_0_4 = (EFI_REDFISH_UPDATESERVICE_V1_0_4 *)InterpProp; + DestroyUpdateService_V1_0_4_CS (UpdateServiceV1_0_4->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_0_5/RedfishUpdateService_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_0_5/RedfishUpdateService_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..0aab61515a1 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_0_5/RedfishUpdateService_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_0_5_Dxe + FILE_GUID = b11b3ef5-2948-44f1-9fab-91b12d30829d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_0_5/UpdateService_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_0_5/UpdateService_V1_0_5_Dxe.c new file mode 100644 index 00000000000..f0b824a11ea --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_0_5/UpdateService_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "0", + "5" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_0_5 *UpdateServiceV1_0_5; + EFI_REDFISH_UPDATESERVICE_V1_0_5_CS *UpdateServiceV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_0_5_To_CS (ResoruceRaw, &UpdateServiceV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_0_5 = (EFI_REDFISH_UPDATESERVICE_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_0_5)); + if (UpdateServiceV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_0_5; + UpdateServiceV1_0_5->UpdateService = UpdateServiceV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_0_5_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_0_5 *UpdateServiceV1_0_5; + + UpdateServiceV1_0_5 = (EFI_REDFISH_UPDATESERVICE_V1_0_5 *)InterpProp; + DestroyUpdateService_V1_0_5_CS (UpdateServiceV1_0_5->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_0_6/RedfishUpdateService_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_0_6/RedfishUpdateService_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..84b9bc43715 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_0_6/RedfishUpdateService_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_0_6_Dxe + FILE_GUID = e28bdf40-4fc0-4e3c-affe-5d5879d8eb2f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_0_6/UpdateService_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_0_6/UpdateService_V1_0_6_Dxe.c new file mode 100644 index 00000000000..0a76afbf871 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_0_6/UpdateService_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "0", + "6" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_0_6 *UpdateServiceV1_0_6; + EFI_REDFISH_UPDATESERVICE_V1_0_6_CS *UpdateServiceV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_0_6_To_CS (ResoruceRaw, &UpdateServiceV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_0_6 = (EFI_REDFISH_UPDATESERVICE_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_0_6)); + if (UpdateServiceV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_0_6; + UpdateServiceV1_0_6->UpdateService = UpdateServiceV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_0_6_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_0_6 *UpdateServiceV1_0_6; + + UpdateServiceV1_0_6 = (EFI_REDFISH_UPDATESERVICE_V1_0_6 *)InterpProp; + DestroyUpdateService_V1_0_6_CS (UpdateServiceV1_0_6->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_0_7/RedfishUpdateService_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_0_7/RedfishUpdateService_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..afba432f329 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_0_7/RedfishUpdateService_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_0_7_Dxe + FILE_GUID = 3774fbee-b6b5-4ae7-adaa-754a223e4f6a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_0_7/UpdateService_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_0_7/UpdateService_V1_0_7_Dxe.c new file mode 100644 index 00000000000..be570b6b085 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_0_7/UpdateService_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "0", + "7" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_0_7 *UpdateServiceV1_0_7; + EFI_REDFISH_UPDATESERVICE_V1_0_7_CS *UpdateServiceV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_0_7_To_CS (ResoruceRaw, &UpdateServiceV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_0_7 = (EFI_REDFISH_UPDATESERVICE_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_0_7)); + if (UpdateServiceV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_0_7; + UpdateServiceV1_0_7->UpdateService = UpdateServiceV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_0_7_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_0_7 *UpdateServiceV1_0_7; + + UpdateServiceV1_0_7 = (EFI_REDFISH_UPDATESERVICE_V1_0_7 *)InterpProp; + DestroyUpdateService_V1_0_7_CS (UpdateServiceV1_0_7->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_0_8/RedfishUpdateService_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_0_8/RedfishUpdateService_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..a9618397f74 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_0_8/RedfishUpdateService_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_0_8_Dxe + FILE_GUID = 49866397-fe47-438f-9017-e12f5829db07 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_0_8/UpdateService_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_0_8/UpdateService_V1_0_8_Dxe.c new file mode 100644 index 00000000000..0746dd6de02 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_0_8/UpdateService_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "0", + "8" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_0_8 *UpdateServiceV1_0_8; + EFI_REDFISH_UPDATESERVICE_V1_0_8_CS *UpdateServiceV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_0_8_To_CS (ResoruceRaw, &UpdateServiceV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_0_8 = (EFI_REDFISH_UPDATESERVICE_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_0_8)); + if (UpdateServiceV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_0_8; + UpdateServiceV1_0_8->UpdateService = UpdateServiceV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_0_8_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_0_8 *UpdateServiceV1_0_8; + + UpdateServiceV1_0_8 = (EFI_REDFISH_UPDATESERVICE_V1_0_8 *)InterpProp; + DestroyUpdateService_V1_0_8_CS (UpdateServiceV1_0_8->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_0_9/RedfishUpdateService_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_0_9/RedfishUpdateService_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..26990a61273 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_0_9/RedfishUpdateService_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_0_9_Dxe + FILE_GUID = 7874f731-00d1-4449-9f66-5d8eceef3af2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_0_9/UpdateService_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_0_9/UpdateService_V1_0_9_Dxe.c new file mode 100644 index 00000000000..d79460a5e7f --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_0_9/UpdateService_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "0", + "9" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_0_9 *UpdateServiceV1_0_9; + EFI_REDFISH_UPDATESERVICE_V1_0_9_CS *UpdateServiceV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_0_9_To_CS (ResoruceRaw, &UpdateServiceV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_0_9 = (EFI_REDFISH_UPDATESERVICE_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_0_9)); + if (UpdateServiceV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_0_9; + UpdateServiceV1_0_9->UpdateService = UpdateServiceV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_0_9_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_0_9 *UpdateServiceV1_0_9; + + UpdateServiceV1_0_9 = (EFI_REDFISH_UPDATESERVICE_V1_0_9 *)InterpProp; + DestroyUpdateService_V1_0_9_CS (UpdateServiceV1_0_9->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_1_0/RedfishUpdateService_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_1_0/RedfishUpdateService_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..d6043fcfa43 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_1_0/RedfishUpdateService_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_1_0_Dxe + FILE_GUID = 270ca34a-4401-4d48-ba6a-77239b8bf064 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_1_0/UpdateService_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_1_0/UpdateService_V1_1_0_Dxe.c new file mode 100644 index 00000000000..0e13c8dbc2e --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_1_0/UpdateService_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "1", + "0" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_1_0 *UpdateServiceV1_1_0; + EFI_REDFISH_UPDATESERVICE_V1_1_0_CS *UpdateServiceV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_1_0_To_CS (ResoruceRaw, &UpdateServiceV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_1_0 = (EFI_REDFISH_UPDATESERVICE_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_1_0)); + if (UpdateServiceV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_1_0; + UpdateServiceV1_1_0->UpdateService = UpdateServiceV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_1_0_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_1_0 *UpdateServiceV1_1_0; + + UpdateServiceV1_1_0 = (EFI_REDFISH_UPDATESERVICE_V1_1_0 *)InterpProp; + DestroyUpdateService_V1_1_0_CS (UpdateServiceV1_1_0->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_1_1/RedfishUpdateService_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_1_1/RedfishUpdateService_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..1c74f44003e --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_1_1/RedfishUpdateService_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_1_1_Dxe + FILE_GUID = f6f9d8fa-429f-4a90-81a0-a3857db5b917 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_1_1/UpdateService_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_1_1/UpdateService_V1_1_1_Dxe.c new file mode 100644 index 00000000000..b36a41f541e --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_1_1/UpdateService_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "1", + "1" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_1_1 *UpdateServiceV1_1_1; + EFI_REDFISH_UPDATESERVICE_V1_1_1_CS *UpdateServiceV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_1_1_To_CS (ResoruceRaw, &UpdateServiceV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_1_1 = (EFI_REDFISH_UPDATESERVICE_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_1_1)); + if (UpdateServiceV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_1_1; + UpdateServiceV1_1_1->UpdateService = UpdateServiceV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_1_1_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_1_1 *UpdateServiceV1_1_1; + + UpdateServiceV1_1_1 = (EFI_REDFISH_UPDATESERVICE_V1_1_1 *)InterpProp; + DestroyUpdateService_V1_1_1_CS (UpdateServiceV1_1_1->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_1_2/RedfishUpdateService_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_1_2/RedfishUpdateService_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..03ca4f0899d --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_1_2/RedfishUpdateService_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_1_2_Dxe + FILE_GUID = 1ae4e2e6-0e36-414c-a6c9-6ab167616bd6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_1_2/UpdateService_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_1_2/UpdateService_V1_1_2_Dxe.c new file mode 100644 index 00000000000..c5ef9c5b390 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_1_2/UpdateService_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "1", + "2" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_1_2 *UpdateServiceV1_1_2; + EFI_REDFISH_UPDATESERVICE_V1_1_2_CS *UpdateServiceV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_1_2_To_CS (ResoruceRaw, &UpdateServiceV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_1_2 = (EFI_REDFISH_UPDATESERVICE_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_1_2)); + if (UpdateServiceV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_1_2; + UpdateServiceV1_1_2->UpdateService = UpdateServiceV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_1_2_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_1_2 *UpdateServiceV1_1_2; + + UpdateServiceV1_1_2 = (EFI_REDFISH_UPDATESERVICE_V1_1_2 *)InterpProp; + DestroyUpdateService_V1_1_2_CS (UpdateServiceV1_1_2->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_1_3/RedfishUpdateService_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_1_3/RedfishUpdateService_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..367fdd2cc55 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_1_3/RedfishUpdateService_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_1_3_Dxe + FILE_GUID = 063c6180-f587-4b98-b02b-9a520de522e0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_1_3/UpdateService_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_1_3/UpdateService_V1_1_3_Dxe.c new file mode 100644 index 00000000000..2727ef45ddd --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_1_3/UpdateService_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "1", + "3" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_1_3 *UpdateServiceV1_1_3; + EFI_REDFISH_UPDATESERVICE_V1_1_3_CS *UpdateServiceV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_1_3_To_CS (ResoruceRaw, &UpdateServiceV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_1_3 = (EFI_REDFISH_UPDATESERVICE_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_1_3)); + if (UpdateServiceV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_1_3; + UpdateServiceV1_1_3->UpdateService = UpdateServiceV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_1_3_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_1_3 *UpdateServiceV1_1_3; + + UpdateServiceV1_1_3 = (EFI_REDFISH_UPDATESERVICE_V1_1_3 *)InterpProp; + DestroyUpdateService_V1_1_3_CS (UpdateServiceV1_1_3->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_1_4/RedfishUpdateService_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_1_4/RedfishUpdateService_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..2d8fd991d2d --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_1_4/RedfishUpdateService_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_1_4_Dxe + FILE_GUID = 33add32b-b040-46e0-9422-5270bc83cdbc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_1_4/UpdateService_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_1_4/UpdateService_V1_1_4_Dxe.c new file mode 100644 index 00000000000..3d0f2e8a466 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_1_4/UpdateService_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "1", + "4" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_1_4 *UpdateServiceV1_1_4; + EFI_REDFISH_UPDATESERVICE_V1_1_4_CS *UpdateServiceV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_1_4_To_CS (ResoruceRaw, &UpdateServiceV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_1_4 = (EFI_REDFISH_UPDATESERVICE_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_1_4)); + if (UpdateServiceV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_1_4; + UpdateServiceV1_1_4->UpdateService = UpdateServiceV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_1_4_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_1_4 *UpdateServiceV1_1_4; + + UpdateServiceV1_1_4 = (EFI_REDFISH_UPDATESERVICE_V1_1_4 *)InterpProp; + DestroyUpdateService_V1_1_4_CS (UpdateServiceV1_1_4->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_1_5/RedfishUpdateService_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_1_5/RedfishUpdateService_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..aab56dfa6e5 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_1_5/RedfishUpdateService_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_1_5_Dxe + FILE_GUID = a1a650c7-861a-42d9-bedb-ab71c954bece + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_1_5/UpdateService_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_1_5/UpdateService_V1_1_5_Dxe.c new file mode 100644 index 00000000000..08c1dbc1799 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_1_5/UpdateService_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "1", + "5" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_1_5 *UpdateServiceV1_1_5; + EFI_REDFISH_UPDATESERVICE_V1_1_5_CS *UpdateServiceV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_1_5_To_CS (ResoruceRaw, &UpdateServiceV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_1_5 = (EFI_REDFISH_UPDATESERVICE_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_1_5)); + if (UpdateServiceV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_1_5; + UpdateServiceV1_1_5->UpdateService = UpdateServiceV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_1_5_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_1_5 *UpdateServiceV1_1_5; + + UpdateServiceV1_1_5 = (EFI_REDFISH_UPDATESERVICE_V1_1_5 *)InterpProp; + DestroyUpdateService_V1_1_5_CS (UpdateServiceV1_1_5->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_1_6/RedfishUpdateService_V1_1_6_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_1_6/RedfishUpdateService_V1_1_6_Dxe.inf new file mode 100644 index 00000000000..4f74c2b3ef1 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_1_6/RedfishUpdateService_V1_1_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_1_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_1_6_Dxe + FILE_GUID = e0389776-1237-4d9d-9364-41b0afff752c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_1_6EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_1_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_1_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_1_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_1_6/UpdateService_V1_1_6_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_1_6/UpdateService_V1_1_6_Dxe.c new file mode 100644 index 00000000000..5491ba1afb2 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_1_6/UpdateService_V1_1_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_1_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "1", + "6" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_1_6 *UpdateServiceV1_1_6; + EFI_REDFISH_UPDATESERVICE_V1_1_6_CS *UpdateServiceV1_1_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_1_6_To_CS (ResoruceRaw, &UpdateServiceV1_1_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_1_6 = (EFI_REDFISH_UPDATESERVICE_V1_1_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_1_6)); + if (UpdateServiceV1_1_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_1_6; + UpdateServiceV1_1_6->UpdateService = UpdateServiceV1_1_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_1_6_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_1_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_1_6 *UpdateServiceV1_1_6; + + UpdateServiceV1_1_6 = (EFI_REDFISH_UPDATESERVICE_V1_1_6 *)InterpProp; + DestroyUpdateService_V1_1_6_CS (UpdateServiceV1_1_6->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_1_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_1_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_1_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_1_7/RedfishUpdateService_V1_1_7_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_1_7/RedfishUpdateService_V1_1_7_Dxe.inf new file mode 100644 index 00000000000..78fdc8499d9 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_1_7/RedfishUpdateService_V1_1_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_1_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_1_7_Dxe + FILE_GUID = 48952ba5-60e0-4c09-9193-4013740e8a38 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_1_7EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_1_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_1_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_1_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_1_7/UpdateService_V1_1_7_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_1_7/UpdateService_V1_1_7_Dxe.c new file mode 100644 index 00000000000..7cc5623f383 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_1_7/UpdateService_V1_1_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_1_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "1", + "7" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_1_7 *UpdateServiceV1_1_7; + EFI_REDFISH_UPDATESERVICE_V1_1_7_CS *UpdateServiceV1_1_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_1_7_To_CS (ResoruceRaw, &UpdateServiceV1_1_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_1_7 = (EFI_REDFISH_UPDATESERVICE_V1_1_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_1_7)); + if (UpdateServiceV1_1_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_1_7; + UpdateServiceV1_1_7->UpdateService = UpdateServiceV1_1_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_1_7_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_1_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_1_7 *UpdateServiceV1_1_7; + + UpdateServiceV1_1_7 = (EFI_REDFISH_UPDATESERVICE_V1_1_7 *)InterpProp; + DestroyUpdateService_V1_1_7_CS (UpdateServiceV1_1_7->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_1_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_1_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_1_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_1_8/RedfishUpdateService_V1_1_8_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_1_8/RedfishUpdateService_V1_1_8_Dxe.inf new file mode 100644 index 00000000000..b781b0d9966 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_1_8/RedfishUpdateService_V1_1_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_1_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_1_8_Dxe + FILE_GUID = 6298fb3b-ca95-4c08-8f2a-970ff7079581 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_1_8EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_1_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_1_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_1_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_1_8/UpdateService_V1_1_8_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_1_8/UpdateService_V1_1_8_Dxe.c new file mode 100644 index 00000000000..26576d984a2 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_1_8/UpdateService_V1_1_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_1_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "1", + "8" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_1_8 *UpdateServiceV1_1_8; + EFI_REDFISH_UPDATESERVICE_V1_1_8_CS *UpdateServiceV1_1_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_1_8_To_CS (ResoruceRaw, &UpdateServiceV1_1_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_1_8 = (EFI_REDFISH_UPDATESERVICE_V1_1_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_1_8)); + if (UpdateServiceV1_1_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_1_8; + UpdateServiceV1_1_8->UpdateService = UpdateServiceV1_1_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_1_8_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_1_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_1_8 *UpdateServiceV1_1_8; + + UpdateServiceV1_1_8 = (EFI_REDFISH_UPDATESERVICE_V1_1_8 *)InterpProp; + DestroyUpdateService_V1_1_8_CS (UpdateServiceV1_1_8->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_1_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_1_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_1_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_1_9/RedfishUpdateService_V1_1_9_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_1_9/RedfishUpdateService_V1_1_9_Dxe.inf new file mode 100644 index 00000000000..838cd987d1f --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_1_9/RedfishUpdateService_V1_1_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_1_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_1_9_Dxe + FILE_GUID = b720fb9e-6b3d-48bb-94c2-aa32d2903002 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_1_9EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_1_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_1_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_1_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_1_9/UpdateService_V1_1_9_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_1_9/UpdateService_V1_1_9_Dxe.c new file mode 100644 index 00000000000..cdc5bbee239 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_1_9/UpdateService_V1_1_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_1_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "1", + "9" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_1_9 *UpdateServiceV1_1_9; + EFI_REDFISH_UPDATESERVICE_V1_1_9_CS *UpdateServiceV1_1_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_1_9_To_CS (ResoruceRaw, &UpdateServiceV1_1_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_1_9 = (EFI_REDFISH_UPDATESERVICE_V1_1_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_1_9)); + if (UpdateServiceV1_1_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_1_9; + UpdateServiceV1_1_9->UpdateService = UpdateServiceV1_1_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_1_9_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_1_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_1_9 *UpdateServiceV1_1_9; + + UpdateServiceV1_1_9 = (EFI_REDFISH_UPDATESERVICE_V1_1_9 *)InterpProp; + DestroyUpdateService_V1_1_9_CS (UpdateServiceV1_1_9->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_1_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_1_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_1_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_2_0/RedfishUpdateService_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_2_0/RedfishUpdateService_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..22959f129c7 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_2_0/RedfishUpdateService_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_2_0_Dxe + FILE_GUID = d270d81f-b7f7-49e8-a0b6-07d8e2e66b5d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_2_0/UpdateService_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_2_0/UpdateService_V1_2_0_Dxe.c new file mode 100644 index 00000000000..7f17216512a --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_2_0/UpdateService_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "2", + "0" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_2_0 *UpdateServiceV1_2_0; + EFI_REDFISH_UPDATESERVICE_V1_2_0_CS *UpdateServiceV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_2_0_To_CS (ResoruceRaw, &UpdateServiceV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_2_0 = (EFI_REDFISH_UPDATESERVICE_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_2_0)); + if (UpdateServiceV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_2_0; + UpdateServiceV1_2_0->UpdateService = UpdateServiceV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_2_0_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_2_0 *UpdateServiceV1_2_0; + + UpdateServiceV1_2_0 = (EFI_REDFISH_UPDATESERVICE_V1_2_0 *)InterpProp; + DestroyUpdateService_V1_2_0_CS (UpdateServiceV1_2_0->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_2_1/RedfishUpdateService_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_2_1/RedfishUpdateService_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..afaa19c4ad6 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_2_1/RedfishUpdateService_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_2_1_Dxe + FILE_GUID = 108e5d5f-555b-4e69-8e1d-afe346b1929a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_2_1/UpdateService_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_2_1/UpdateService_V1_2_1_Dxe.c new file mode 100644 index 00000000000..0b3c97c3b0b --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_2_1/UpdateService_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "2", + "1" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_2_1 *UpdateServiceV1_2_1; + EFI_REDFISH_UPDATESERVICE_V1_2_1_CS *UpdateServiceV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_2_1_To_CS (ResoruceRaw, &UpdateServiceV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_2_1 = (EFI_REDFISH_UPDATESERVICE_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_2_1)); + if (UpdateServiceV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_2_1; + UpdateServiceV1_2_1->UpdateService = UpdateServiceV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_2_1_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_2_1 *UpdateServiceV1_2_1; + + UpdateServiceV1_2_1 = (EFI_REDFISH_UPDATESERVICE_V1_2_1 *)InterpProp; + DestroyUpdateService_V1_2_1_CS (UpdateServiceV1_2_1->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_2_2/RedfishUpdateService_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_2_2/RedfishUpdateService_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..7a9bff26e63 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_2_2/RedfishUpdateService_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_2_2_Dxe + FILE_GUID = cfd7f5f6-27c5-4a96-a078-2b093b12567d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_2_2/UpdateService_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_2_2/UpdateService_V1_2_2_Dxe.c new file mode 100644 index 00000000000..1cb13b5f1a1 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_2_2/UpdateService_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "2", + "2" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_2_2 *UpdateServiceV1_2_2; + EFI_REDFISH_UPDATESERVICE_V1_2_2_CS *UpdateServiceV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_2_2_To_CS (ResoruceRaw, &UpdateServiceV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_2_2 = (EFI_REDFISH_UPDATESERVICE_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_2_2)); + if (UpdateServiceV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_2_2; + UpdateServiceV1_2_2->UpdateService = UpdateServiceV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_2_2_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_2_2 *UpdateServiceV1_2_2; + + UpdateServiceV1_2_2 = (EFI_REDFISH_UPDATESERVICE_V1_2_2 *)InterpProp; + DestroyUpdateService_V1_2_2_CS (UpdateServiceV1_2_2->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_2_3/RedfishUpdateService_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_2_3/RedfishUpdateService_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..eb199e3f38b --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_2_3/RedfishUpdateService_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_2_3_Dxe + FILE_GUID = f8acd2a4-31af-41bd-824c-067de6377718 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_2_3/UpdateService_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_2_3/UpdateService_V1_2_3_Dxe.c new file mode 100644 index 00000000000..10a884fdcab --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_2_3/UpdateService_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "2", + "3" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_2_3 *UpdateServiceV1_2_3; + EFI_REDFISH_UPDATESERVICE_V1_2_3_CS *UpdateServiceV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_2_3_To_CS (ResoruceRaw, &UpdateServiceV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_2_3 = (EFI_REDFISH_UPDATESERVICE_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_2_3)); + if (UpdateServiceV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_2_3; + UpdateServiceV1_2_3->UpdateService = UpdateServiceV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_2_3_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_2_3 *UpdateServiceV1_2_3; + + UpdateServiceV1_2_3 = (EFI_REDFISH_UPDATESERVICE_V1_2_3 *)InterpProp; + DestroyUpdateService_V1_2_3_CS (UpdateServiceV1_2_3->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_2_4/RedfishUpdateService_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_2_4/RedfishUpdateService_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..ba7f41eef6c --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_2_4/RedfishUpdateService_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_2_4_Dxe + FILE_GUID = 88945792-f768-45d8-b816-3a40b1dda0ef + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_2_4/UpdateService_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_2_4/UpdateService_V1_2_4_Dxe.c new file mode 100644 index 00000000000..bdf1983b865 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_2_4/UpdateService_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "2", + "4" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_2_4 *UpdateServiceV1_2_4; + EFI_REDFISH_UPDATESERVICE_V1_2_4_CS *UpdateServiceV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_2_4_To_CS (ResoruceRaw, &UpdateServiceV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_2_4 = (EFI_REDFISH_UPDATESERVICE_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_2_4)); + if (UpdateServiceV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_2_4; + UpdateServiceV1_2_4->UpdateService = UpdateServiceV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_2_4_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_2_4 *UpdateServiceV1_2_4; + + UpdateServiceV1_2_4 = (EFI_REDFISH_UPDATESERVICE_V1_2_4 *)InterpProp; + DestroyUpdateService_V1_2_4_CS (UpdateServiceV1_2_4->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_2_5/RedfishUpdateService_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_2_5/RedfishUpdateService_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..c042ba5e0c5 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_2_5/RedfishUpdateService_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_2_5_Dxe + FILE_GUID = 0116a25f-9f6c-4ca3-aaeb-1a33c63b2722 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_2_5/UpdateService_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_2_5/UpdateService_V1_2_5_Dxe.c new file mode 100644 index 00000000000..63aa328a378 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_2_5/UpdateService_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "2", + "5" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_2_5 *UpdateServiceV1_2_5; + EFI_REDFISH_UPDATESERVICE_V1_2_5_CS *UpdateServiceV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_2_5_To_CS (ResoruceRaw, &UpdateServiceV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_2_5 = (EFI_REDFISH_UPDATESERVICE_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_2_5)); + if (UpdateServiceV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_2_5; + UpdateServiceV1_2_5->UpdateService = UpdateServiceV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_2_5_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_2_5 *UpdateServiceV1_2_5; + + UpdateServiceV1_2_5 = (EFI_REDFISH_UPDATESERVICE_V1_2_5 *)InterpProp; + DestroyUpdateService_V1_2_5_CS (UpdateServiceV1_2_5->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_2_6/RedfishUpdateService_V1_2_6_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_2_6/RedfishUpdateService_V1_2_6_Dxe.inf new file mode 100644 index 00000000000..35f2b6aa50c --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_2_6/RedfishUpdateService_V1_2_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_2_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_2_6_Dxe + FILE_GUID = 907e189c-74e7-4649-ae30-3638ddb78f7e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_2_6EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_2_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_2_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_2_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_2_6/UpdateService_V1_2_6_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_2_6/UpdateService_V1_2_6_Dxe.c new file mode 100644 index 00000000000..5855b1d623b --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_2_6/UpdateService_V1_2_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_2_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "2", + "6" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_2_6 *UpdateServiceV1_2_6; + EFI_REDFISH_UPDATESERVICE_V1_2_6_CS *UpdateServiceV1_2_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_2_6_To_CS (ResoruceRaw, &UpdateServiceV1_2_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_2_6 = (EFI_REDFISH_UPDATESERVICE_V1_2_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_2_6)); + if (UpdateServiceV1_2_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_2_6; + UpdateServiceV1_2_6->UpdateService = UpdateServiceV1_2_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_2_6_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_2_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_2_6 *UpdateServiceV1_2_6; + + UpdateServiceV1_2_6 = (EFI_REDFISH_UPDATESERVICE_V1_2_6 *)InterpProp; + DestroyUpdateService_V1_2_6_CS (UpdateServiceV1_2_6->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_2_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_2_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_2_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_2_7/RedfishUpdateService_V1_2_7_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_2_7/RedfishUpdateService_V1_2_7_Dxe.inf new file mode 100644 index 00000000000..8911bc81a39 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_2_7/RedfishUpdateService_V1_2_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_2_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_2_7_Dxe + FILE_GUID = 49f93878-e9a6-4c30-ad64-1c6b28c08251 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_2_7EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_2_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_2_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_2_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_2_7/UpdateService_V1_2_7_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_2_7/UpdateService_V1_2_7_Dxe.c new file mode 100644 index 00000000000..7e3db0d12d3 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_2_7/UpdateService_V1_2_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_2_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "2", + "7" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_2_7 *UpdateServiceV1_2_7; + EFI_REDFISH_UPDATESERVICE_V1_2_7_CS *UpdateServiceV1_2_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_2_7_To_CS (ResoruceRaw, &UpdateServiceV1_2_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_2_7 = (EFI_REDFISH_UPDATESERVICE_V1_2_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_2_7)); + if (UpdateServiceV1_2_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_2_7; + UpdateServiceV1_2_7->UpdateService = UpdateServiceV1_2_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_2_7_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_2_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_2_7 *UpdateServiceV1_2_7; + + UpdateServiceV1_2_7 = (EFI_REDFISH_UPDATESERVICE_V1_2_7 *)InterpProp; + DestroyUpdateService_V1_2_7_CS (UpdateServiceV1_2_7->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_2_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_2_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_2_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_2_8/RedfishUpdateService_V1_2_8_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_2_8/RedfishUpdateService_V1_2_8_Dxe.inf new file mode 100644 index 00000000000..ebe7096f908 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_2_8/RedfishUpdateService_V1_2_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_2_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_2_8_Dxe + FILE_GUID = 8372d8ee-ff32-46bd-bdae-b0e8b93f6eb9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_2_8EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_2_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_2_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_2_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_2_8/UpdateService_V1_2_8_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_2_8/UpdateService_V1_2_8_Dxe.c new file mode 100644 index 00000000000..bfb95b24554 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_2_8/UpdateService_V1_2_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_2_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "2", + "8" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_2_8 *UpdateServiceV1_2_8; + EFI_REDFISH_UPDATESERVICE_V1_2_8_CS *UpdateServiceV1_2_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_2_8_To_CS (ResoruceRaw, &UpdateServiceV1_2_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_2_8 = (EFI_REDFISH_UPDATESERVICE_V1_2_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_2_8)); + if (UpdateServiceV1_2_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_2_8; + UpdateServiceV1_2_8->UpdateService = UpdateServiceV1_2_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_2_8_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_2_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_2_8 *UpdateServiceV1_2_8; + + UpdateServiceV1_2_8 = (EFI_REDFISH_UPDATESERVICE_V1_2_8 *)InterpProp; + DestroyUpdateService_V1_2_8_CS (UpdateServiceV1_2_8->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_2_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_2_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_2_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_3_0/RedfishUpdateService_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_3_0/RedfishUpdateService_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..00416836f3d --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_3_0/RedfishUpdateService_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_3_0_Dxe + FILE_GUID = e5cda000-fb59-414b-abcd-fbee06214e5f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_3_0/UpdateService_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_3_0/UpdateService_V1_3_0_Dxe.c new file mode 100644 index 00000000000..70062c1f605 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_3_0/UpdateService_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "3", + "0" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_3_0 *UpdateServiceV1_3_0; + EFI_REDFISH_UPDATESERVICE_V1_3_0_CS *UpdateServiceV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_3_0_To_CS (ResoruceRaw, &UpdateServiceV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_3_0 = (EFI_REDFISH_UPDATESERVICE_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_3_0)); + if (UpdateServiceV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_3_0; + UpdateServiceV1_3_0->UpdateService = UpdateServiceV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_3_0_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_3_0 *UpdateServiceV1_3_0; + + UpdateServiceV1_3_0 = (EFI_REDFISH_UPDATESERVICE_V1_3_0 *)InterpProp; + DestroyUpdateService_V1_3_0_CS (UpdateServiceV1_3_0->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_3_1/RedfishUpdateService_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_3_1/RedfishUpdateService_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..27375bce3e7 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_3_1/RedfishUpdateService_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_3_1_Dxe + FILE_GUID = bbb3dccd-f9e9-43dd-80c3-93499c83a04e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_3_1/UpdateService_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_3_1/UpdateService_V1_3_1_Dxe.c new file mode 100644 index 00000000000..f989601d0bf --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_3_1/UpdateService_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "3", + "1" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_3_1 *UpdateServiceV1_3_1; + EFI_REDFISH_UPDATESERVICE_V1_3_1_CS *UpdateServiceV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_3_1_To_CS (ResoruceRaw, &UpdateServiceV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_3_1 = (EFI_REDFISH_UPDATESERVICE_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_3_1)); + if (UpdateServiceV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_3_1; + UpdateServiceV1_3_1->UpdateService = UpdateServiceV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_3_1_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_3_1 *UpdateServiceV1_3_1; + + UpdateServiceV1_3_1 = (EFI_REDFISH_UPDATESERVICE_V1_3_1 *)InterpProp; + DestroyUpdateService_V1_3_1_CS (UpdateServiceV1_3_1->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_3_2/RedfishUpdateService_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_3_2/RedfishUpdateService_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..4ac3c69f14c --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_3_2/RedfishUpdateService_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_3_2_Dxe + FILE_GUID = 028cca7e-4b0c-43e8-833c-61cea51ea295 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_3_2/UpdateService_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_3_2/UpdateService_V1_3_2_Dxe.c new file mode 100644 index 00000000000..f9d0c4ca534 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_3_2/UpdateService_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "3", + "2" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_3_2 *UpdateServiceV1_3_2; + EFI_REDFISH_UPDATESERVICE_V1_3_2_CS *UpdateServiceV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_3_2_To_CS (ResoruceRaw, &UpdateServiceV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_3_2 = (EFI_REDFISH_UPDATESERVICE_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_3_2)); + if (UpdateServiceV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_3_2; + UpdateServiceV1_3_2->UpdateService = UpdateServiceV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_3_2_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_3_2 *UpdateServiceV1_3_2; + + UpdateServiceV1_3_2 = (EFI_REDFISH_UPDATESERVICE_V1_3_2 *)InterpProp; + DestroyUpdateService_V1_3_2_CS (UpdateServiceV1_3_2->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_3_3/RedfishUpdateService_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_3_3/RedfishUpdateService_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..922db658359 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_3_3/RedfishUpdateService_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_3_3_Dxe + FILE_GUID = f8016460-b061-40cd-b6e9-163eed7660c4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_3_3/UpdateService_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_3_3/UpdateService_V1_3_3_Dxe.c new file mode 100644 index 00000000000..7ad4adaabd0 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_3_3/UpdateService_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "3", + "3" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_3_3 *UpdateServiceV1_3_3; + EFI_REDFISH_UPDATESERVICE_V1_3_3_CS *UpdateServiceV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_3_3_To_CS (ResoruceRaw, &UpdateServiceV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_3_3 = (EFI_REDFISH_UPDATESERVICE_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_3_3)); + if (UpdateServiceV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_3_3; + UpdateServiceV1_3_3->UpdateService = UpdateServiceV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_3_3_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_3_3 *UpdateServiceV1_3_3; + + UpdateServiceV1_3_3 = (EFI_REDFISH_UPDATESERVICE_V1_3_3 *)InterpProp; + DestroyUpdateService_V1_3_3_CS (UpdateServiceV1_3_3->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_3_4/RedfishUpdateService_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_3_4/RedfishUpdateService_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..8d84ab48ed3 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_3_4/RedfishUpdateService_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_3_4_Dxe + FILE_GUID = 01dfd60e-1b68-457c-b547-26abc6a002a8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_3_4/UpdateService_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_3_4/UpdateService_V1_3_4_Dxe.c new file mode 100644 index 00000000000..c6c470910ae --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_3_4/UpdateService_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "3", + "4" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_3_4 *UpdateServiceV1_3_4; + EFI_REDFISH_UPDATESERVICE_V1_3_4_CS *UpdateServiceV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_3_4_To_CS (ResoruceRaw, &UpdateServiceV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_3_4 = (EFI_REDFISH_UPDATESERVICE_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_3_4)); + if (UpdateServiceV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_3_4; + UpdateServiceV1_3_4->UpdateService = UpdateServiceV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_3_4_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_3_4 *UpdateServiceV1_3_4; + + UpdateServiceV1_3_4 = (EFI_REDFISH_UPDATESERVICE_V1_3_4 *)InterpProp; + DestroyUpdateService_V1_3_4_CS (UpdateServiceV1_3_4->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_3_5/RedfishUpdateService_V1_3_5_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_3_5/RedfishUpdateService_V1_3_5_Dxe.inf new file mode 100644 index 00000000000..32f3e768fb1 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_3_5/RedfishUpdateService_V1_3_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_3_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_3_5_Dxe + FILE_GUID = 30a7787a-ab9d-4ff6-90c4-0379d5ce1e98 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_3_5EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_3_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_3_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_3_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_3_5/UpdateService_V1_3_5_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_3_5/UpdateService_V1_3_5_Dxe.c new file mode 100644 index 00000000000..48260330fb7 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_3_5/UpdateService_V1_3_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_3_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "3", + "5" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_3_5 *UpdateServiceV1_3_5; + EFI_REDFISH_UPDATESERVICE_V1_3_5_CS *UpdateServiceV1_3_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_3_5_To_CS (ResoruceRaw, &UpdateServiceV1_3_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_3_5 = (EFI_REDFISH_UPDATESERVICE_V1_3_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_3_5)); + if (UpdateServiceV1_3_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_3_5; + UpdateServiceV1_3_5->UpdateService = UpdateServiceV1_3_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_3_5_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_3_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_3_5 *UpdateServiceV1_3_5; + + UpdateServiceV1_3_5 = (EFI_REDFISH_UPDATESERVICE_V1_3_5 *)InterpProp; + DestroyUpdateService_V1_3_5_CS (UpdateServiceV1_3_5->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_3_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_3_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_3_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_3_6/RedfishUpdateService_V1_3_6_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_3_6/RedfishUpdateService_V1_3_6_Dxe.inf new file mode 100644 index 00000000000..1d1ac649efb --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_3_6/RedfishUpdateService_V1_3_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_3_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_3_6_Dxe + FILE_GUID = dc0604f8-1563-4e8a-8980-f4f50c6b9ccf + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_3_6EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_3_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_3_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_3_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_3_6/UpdateService_V1_3_6_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_3_6/UpdateService_V1_3_6_Dxe.c new file mode 100644 index 00000000000..8df566c4a3b --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_3_6/UpdateService_V1_3_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_3_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "3", + "6" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_3_6 *UpdateServiceV1_3_6; + EFI_REDFISH_UPDATESERVICE_V1_3_6_CS *UpdateServiceV1_3_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_3_6_To_CS (ResoruceRaw, &UpdateServiceV1_3_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_3_6 = (EFI_REDFISH_UPDATESERVICE_V1_3_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_3_6)); + if (UpdateServiceV1_3_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_3_6; + UpdateServiceV1_3_6->UpdateService = UpdateServiceV1_3_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_3_6_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_3_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_3_6 *UpdateServiceV1_3_6; + + UpdateServiceV1_3_6 = (EFI_REDFISH_UPDATESERVICE_V1_3_6 *)InterpProp; + DestroyUpdateService_V1_3_6_CS (UpdateServiceV1_3_6->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_3_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_3_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_3_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_4_0/RedfishUpdateService_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_4_0/RedfishUpdateService_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..3cf6ccd7ddc --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_4_0/RedfishUpdateService_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_4_0_Dxe + FILE_GUID = ad91b0c2-6f43-4cb7-9725-f76f7401a497 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_4_0/UpdateService_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_4_0/UpdateService_V1_4_0_Dxe.c new file mode 100644 index 00000000000..9e5a9f49020 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_4_0/UpdateService_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "4", + "0" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_4_0 *UpdateServiceV1_4_0; + EFI_REDFISH_UPDATESERVICE_V1_4_0_CS *UpdateServiceV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_4_0_To_CS (ResoruceRaw, &UpdateServiceV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_4_0 = (EFI_REDFISH_UPDATESERVICE_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_4_0)); + if (UpdateServiceV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_4_0; + UpdateServiceV1_4_0->UpdateService = UpdateServiceV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_4_0_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_4_0 *UpdateServiceV1_4_0; + + UpdateServiceV1_4_0 = (EFI_REDFISH_UPDATESERVICE_V1_4_0 *)InterpProp; + DestroyUpdateService_V1_4_0_CS (UpdateServiceV1_4_0->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_4_1/RedfishUpdateService_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_4_1/RedfishUpdateService_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..24a96ab7607 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_4_1/RedfishUpdateService_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_4_1_Dxe + FILE_GUID = 1c7ae6e3-bce5-4b81-9a1e-0290ebb90ea3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_4_1/UpdateService_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_4_1/UpdateService_V1_4_1_Dxe.c new file mode 100644 index 00000000000..7d3f0b94df2 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_4_1/UpdateService_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "4", + "1" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_4_1 *UpdateServiceV1_4_1; + EFI_REDFISH_UPDATESERVICE_V1_4_1_CS *UpdateServiceV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_4_1_To_CS (ResoruceRaw, &UpdateServiceV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_4_1 = (EFI_REDFISH_UPDATESERVICE_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_4_1)); + if (UpdateServiceV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_4_1; + UpdateServiceV1_4_1->UpdateService = UpdateServiceV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_4_1_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_4_1 *UpdateServiceV1_4_1; + + UpdateServiceV1_4_1 = (EFI_REDFISH_UPDATESERVICE_V1_4_1 *)InterpProp; + DestroyUpdateService_V1_4_1_CS (UpdateServiceV1_4_1->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_4_2/RedfishUpdateService_V1_4_2_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_4_2/RedfishUpdateService_V1_4_2_Dxe.inf new file mode 100644 index 00000000000..bc5b07d6338 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_4_2/RedfishUpdateService_V1_4_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_4_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_4_2_Dxe + FILE_GUID = 4fc2234d-3fa1-4a39-a8d1-5f98b273d92c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_4_2EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_4_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_4_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_4_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_4_2/UpdateService_V1_4_2_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_4_2/UpdateService_V1_4_2_Dxe.c new file mode 100644 index 00000000000..33f538c2695 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_4_2/UpdateService_V1_4_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_4_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "4", + "2" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_4_2 *UpdateServiceV1_4_2; + EFI_REDFISH_UPDATESERVICE_V1_4_2_CS *UpdateServiceV1_4_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_4_2_To_CS (ResoruceRaw, &UpdateServiceV1_4_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_4_2 = (EFI_REDFISH_UPDATESERVICE_V1_4_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_4_2)); + if (UpdateServiceV1_4_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_4_2; + UpdateServiceV1_4_2->UpdateService = UpdateServiceV1_4_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_4_2_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_4_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_4_2 *UpdateServiceV1_4_2; + + UpdateServiceV1_4_2 = (EFI_REDFISH_UPDATESERVICE_V1_4_2 *)InterpProp; + DestroyUpdateService_V1_4_2_CS (UpdateServiceV1_4_2->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_4_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_4_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_4_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_4_3/RedfishUpdateService_V1_4_3_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_4_3/RedfishUpdateService_V1_4_3_Dxe.inf new file mode 100644 index 00000000000..c99685c636a --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_4_3/RedfishUpdateService_V1_4_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_4_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_4_3_Dxe + FILE_GUID = fcd28957-f6bc-425a-a624-08c67d830918 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_4_3EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_4_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_4_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_4_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_4_3/UpdateService_V1_4_3_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_4_3/UpdateService_V1_4_3_Dxe.c new file mode 100644 index 00000000000..eec26f0ded2 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_4_3/UpdateService_V1_4_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_4_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "4", + "3" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_4_3 *UpdateServiceV1_4_3; + EFI_REDFISH_UPDATESERVICE_V1_4_3_CS *UpdateServiceV1_4_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_4_3_To_CS (ResoruceRaw, &UpdateServiceV1_4_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_4_3 = (EFI_REDFISH_UPDATESERVICE_V1_4_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_4_3)); + if (UpdateServiceV1_4_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_4_3; + UpdateServiceV1_4_3->UpdateService = UpdateServiceV1_4_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_4_3_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_4_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_4_3 *UpdateServiceV1_4_3; + + UpdateServiceV1_4_3 = (EFI_REDFISH_UPDATESERVICE_V1_4_3 *)InterpProp; + DestroyUpdateService_V1_4_3_CS (UpdateServiceV1_4_3->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_4_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_4_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_4_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_4_4/RedfishUpdateService_V1_4_4_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_4_4/RedfishUpdateService_V1_4_4_Dxe.inf new file mode 100644 index 00000000000..7f2f1819e38 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_4_4/RedfishUpdateService_V1_4_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_4_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_4_4_Dxe + FILE_GUID = cf7f7224-9ed4-49b9-b2ab-fa4f565741ee + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_4_4EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_4_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_4_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_4_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_4_4/UpdateService_V1_4_4_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_4_4/UpdateService_V1_4_4_Dxe.c new file mode 100644 index 00000000000..1d036417ac5 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_4_4/UpdateService_V1_4_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_4_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "4", + "4" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_4_4 *UpdateServiceV1_4_4; + EFI_REDFISH_UPDATESERVICE_V1_4_4_CS *UpdateServiceV1_4_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_4_4_To_CS (ResoruceRaw, &UpdateServiceV1_4_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_4_4 = (EFI_REDFISH_UPDATESERVICE_V1_4_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_4_4)); + if (UpdateServiceV1_4_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_4_4; + UpdateServiceV1_4_4->UpdateService = UpdateServiceV1_4_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_4_4_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_4_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_4_4 *UpdateServiceV1_4_4; + + UpdateServiceV1_4_4 = (EFI_REDFISH_UPDATESERVICE_V1_4_4 *)InterpProp; + DestroyUpdateService_V1_4_4_CS (UpdateServiceV1_4_4->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_4_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_4_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_4_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_4_5/RedfishUpdateService_V1_4_5_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_4_5/RedfishUpdateService_V1_4_5_Dxe.inf new file mode 100644 index 00000000000..d6ad8988e35 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_4_5/RedfishUpdateService_V1_4_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_4_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_4_5_Dxe + FILE_GUID = 92cb5ef3-6a23-490f-9c37-fbcd985ef255 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_4_5EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_4_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_4_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_4_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_4_5/UpdateService_V1_4_5_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_4_5/UpdateService_V1_4_5_Dxe.c new file mode 100644 index 00000000000..f218bf87571 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_4_5/UpdateService_V1_4_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_4_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "4", + "5" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_4_5 *UpdateServiceV1_4_5; + EFI_REDFISH_UPDATESERVICE_V1_4_5_CS *UpdateServiceV1_4_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_4_5_To_CS (ResoruceRaw, &UpdateServiceV1_4_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_4_5 = (EFI_REDFISH_UPDATESERVICE_V1_4_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_4_5)); + if (UpdateServiceV1_4_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_4_5; + UpdateServiceV1_4_5->UpdateService = UpdateServiceV1_4_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_4_5_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_4_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_4_5 *UpdateServiceV1_4_5; + + UpdateServiceV1_4_5 = (EFI_REDFISH_UPDATESERVICE_V1_4_5 *)InterpProp; + DestroyUpdateService_V1_4_5_CS (UpdateServiceV1_4_5->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_4_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_4_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_4_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_5_0/RedfishUpdateService_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_5_0/RedfishUpdateService_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..c7e9c9f5e39 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_5_0/RedfishUpdateService_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_5_0_Dxe + FILE_GUID = 12a3d62e-a1ae-42fe-a23c-5988ed17d3eb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_5_0/UpdateService_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_5_0/UpdateService_V1_5_0_Dxe.c new file mode 100644 index 00000000000..fdc55f5de35 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_5_0/UpdateService_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "5", + "0" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_5_0 *UpdateServiceV1_5_0; + EFI_REDFISH_UPDATESERVICE_V1_5_0_CS *UpdateServiceV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_5_0_To_CS (ResoruceRaw, &UpdateServiceV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_5_0 = (EFI_REDFISH_UPDATESERVICE_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_5_0)); + if (UpdateServiceV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_5_0; + UpdateServiceV1_5_0->UpdateService = UpdateServiceV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_5_0_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_5_0 *UpdateServiceV1_5_0; + + UpdateServiceV1_5_0 = (EFI_REDFISH_UPDATESERVICE_V1_5_0 *)InterpProp; + DestroyUpdateService_V1_5_0_CS (UpdateServiceV1_5_0->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_5_1/RedfishUpdateService_V1_5_1_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_5_1/RedfishUpdateService_V1_5_1_Dxe.inf new file mode 100644 index 00000000000..33de3d96516 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_5_1/RedfishUpdateService_V1_5_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_5_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_5_1_Dxe + FILE_GUID = d5144595-0fc0-4825-9f7c-ec56593b85a3 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_5_1EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_5_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_5_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_5_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_5_1/UpdateService_V1_5_1_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_5_1/UpdateService_V1_5_1_Dxe.c new file mode 100644 index 00000000000..660223668da --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_5_1/UpdateService_V1_5_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_5_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "5", + "1" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_5_1 *UpdateServiceV1_5_1; + EFI_REDFISH_UPDATESERVICE_V1_5_1_CS *UpdateServiceV1_5_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_5_1_To_CS (ResoruceRaw, &UpdateServiceV1_5_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_5_1 = (EFI_REDFISH_UPDATESERVICE_V1_5_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_5_1)); + if (UpdateServiceV1_5_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_5_1; + UpdateServiceV1_5_1->UpdateService = UpdateServiceV1_5_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_5_1_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_5_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_5_1 *UpdateServiceV1_5_1; + + UpdateServiceV1_5_1 = (EFI_REDFISH_UPDATESERVICE_V1_5_1 *)InterpProp; + DestroyUpdateService_V1_5_1_CS (UpdateServiceV1_5_1->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_5_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_5_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_5_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_5_2/RedfishUpdateService_V1_5_2_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_5_2/RedfishUpdateService_V1_5_2_Dxe.inf new file mode 100644 index 00000000000..b21c60eb3d7 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_5_2/RedfishUpdateService_V1_5_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_5_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_5_2_Dxe + FILE_GUID = 9dc8956a-daad-454d-87d0-9ace991bb3b5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_5_2EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_5_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_5_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_5_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_5_2/UpdateService_V1_5_2_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_5_2/UpdateService_V1_5_2_Dxe.c new file mode 100644 index 00000000000..9ab09233af5 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_5_2/UpdateService_V1_5_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_5_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "5", + "2" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_5_2 *UpdateServiceV1_5_2; + EFI_REDFISH_UPDATESERVICE_V1_5_2_CS *UpdateServiceV1_5_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_5_2_To_CS (ResoruceRaw, &UpdateServiceV1_5_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_5_2 = (EFI_REDFISH_UPDATESERVICE_V1_5_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_5_2)); + if (UpdateServiceV1_5_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_5_2; + UpdateServiceV1_5_2->UpdateService = UpdateServiceV1_5_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_5_2_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_5_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_5_2 *UpdateServiceV1_5_2; + + UpdateServiceV1_5_2 = (EFI_REDFISH_UPDATESERVICE_V1_5_2 *)InterpProp; + DestroyUpdateService_V1_5_2_CS (UpdateServiceV1_5_2->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_5_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_5_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_5_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_5_3/RedfishUpdateService_V1_5_3_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_5_3/RedfishUpdateService_V1_5_3_Dxe.inf new file mode 100644 index 00000000000..22160954968 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_5_3/RedfishUpdateService_V1_5_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_5_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_5_3_Dxe + FILE_GUID = 6c92e107-4ca7-4991-a28c-8528d5b588d0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_5_3EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_5_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_5_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_5_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_5_3/UpdateService_V1_5_3_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_5_3/UpdateService_V1_5_3_Dxe.c new file mode 100644 index 00000000000..7ccbffafb5f --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_5_3/UpdateService_V1_5_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_5_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "5", + "3" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_5_3 *UpdateServiceV1_5_3; + EFI_REDFISH_UPDATESERVICE_V1_5_3_CS *UpdateServiceV1_5_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_5_3_To_CS (ResoruceRaw, &UpdateServiceV1_5_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_5_3 = (EFI_REDFISH_UPDATESERVICE_V1_5_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_5_3)); + if (UpdateServiceV1_5_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_5_3; + UpdateServiceV1_5_3->UpdateService = UpdateServiceV1_5_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_5_3_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_5_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_5_3 *UpdateServiceV1_5_3; + + UpdateServiceV1_5_3 = (EFI_REDFISH_UPDATESERVICE_V1_5_3 *)InterpProp; + DestroyUpdateService_V1_5_3_CS (UpdateServiceV1_5_3->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_5_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_5_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_5_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_5_4/RedfishUpdateService_V1_5_4_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_5_4/RedfishUpdateService_V1_5_4_Dxe.inf new file mode 100644 index 00000000000..2aca9984fce --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_5_4/RedfishUpdateService_V1_5_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_5_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_5_4_Dxe + FILE_GUID = 0163d70d-42bb-4636-82eb-0c4b3df98f23 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_5_4EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_5_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_5_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_5_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_5_4/UpdateService_V1_5_4_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_5_4/UpdateService_V1_5_4_Dxe.c new file mode 100644 index 00000000000..e317204b3f5 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_5_4/UpdateService_V1_5_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_5_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "5", + "4" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_5_4 *UpdateServiceV1_5_4; + EFI_REDFISH_UPDATESERVICE_V1_5_4_CS *UpdateServiceV1_5_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_5_4_To_CS (ResoruceRaw, &UpdateServiceV1_5_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_5_4 = (EFI_REDFISH_UPDATESERVICE_V1_5_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_5_4)); + if (UpdateServiceV1_5_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_5_4; + UpdateServiceV1_5_4->UpdateService = UpdateServiceV1_5_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_5_4_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_5_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_5_4 *UpdateServiceV1_5_4; + + UpdateServiceV1_5_4 = (EFI_REDFISH_UPDATESERVICE_V1_5_4 *)InterpProp; + DestroyUpdateService_V1_5_4_CS (UpdateServiceV1_5_4->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_5_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_5_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_5_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_6_0/RedfishUpdateService_V1_6_0_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_6_0/RedfishUpdateService_V1_6_0_Dxe.inf new file mode 100644 index 00000000000..1c166fa0308 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_6_0/RedfishUpdateService_V1_6_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_6_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_6_0_Dxe + FILE_GUID = b6264e7a-7c97-4bb7-8dbb-40167327c9e4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_6_0EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_6_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_6_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_6_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_6_0/UpdateService_V1_6_0_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_6_0/UpdateService_V1_6_0_Dxe.c new file mode 100644 index 00000000000..8afec1a66a1 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_6_0/UpdateService_V1_6_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_6_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "6", + "0" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_6_0 *UpdateServiceV1_6_0; + EFI_REDFISH_UPDATESERVICE_V1_6_0_CS *UpdateServiceV1_6_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_6_0_To_CS (ResoruceRaw, &UpdateServiceV1_6_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_6_0 = (EFI_REDFISH_UPDATESERVICE_V1_6_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_6_0)); + if (UpdateServiceV1_6_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_6_0; + UpdateServiceV1_6_0->UpdateService = UpdateServiceV1_6_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_6_0_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_6_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_6_0 *UpdateServiceV1_6_0; + + UpdateServiceV1_6_0 = (EFI_REDFISH_UPDATESERVICE_V1_6_0 *)InterpProp; + DestroyUpdateService_V1_6_0_CS (UpdateServiceV1_6_0->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_6_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_6_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_6_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_6_1/RedfishUpdateService_V1_6_1_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_6_1/RedfishUpdateService_V1_6_1_Dxe.inf new file mode 100644 index 00000000000..d91252fd98b --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_6_1/RedfishUpdateService_V1_6_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_6_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_6_1_Dxe + FILE_GUID = 668ad5e7-3d8c-4cf3-b78c-016426a06616 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_6_1EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_6_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_6_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_6_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_6_1/UpdateService_V1_6_1_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_6_1/UpdateService_V1_6_1_Dxe.c new file mode 100644 index 00000000000..41ee05fc2d8 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_6_1/UpdateService_V1_6_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_6_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "6", + "1" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_6_1 *UpdateServiceV1_6_1; + EFI_REDFISH_UPDATESERVICE_V1_6_1_CS *UpdateServiceV1_6_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_6_1_To_CS (ResoruceRaw, &UpdateServiceV1_6_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_6_1 = (EFI_REDFISH_UPDATESERVICE_V1_6_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_6_1)); + if (UpdateServiceV1_6_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_6_1; + UpdateServiceV1_6_1->UpdateService = UpdateServiceV1_6_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_6_1_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_6_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_6_1 *UpdateServiceV1_6_1; + + UpdateServiceV1_6_1 = (EFI_REDFISH_UPDATESERVICE_V1_6_1 *)InterpProp; + DestroyUpdateService_V1_6_1_CS (UpdateServiceV1_6_1->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_6_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_6_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_6_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_6_2/RedfishUpdateService_V1_6_2_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_6_2/RedfishUpdateService_V1_6_2_Dxe.inf new file mode 100644 index 00000000000..b9d51c95fb9 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_6_2/RedfishUpdateService_V1_6_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_6_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_6_2_Dxe + FILE_GUID = 31004243-c273-4acf-85ee-c016c93861af + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_6_2EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_6_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_6_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_6_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_6_2/UpdateService_V1_6_2_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_6_2/UpdateService_V1_6_2_Dxe.c new file mode 100644 index 00000000000..f9227c3eca4 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_6_2/UpdateService_V1_6_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_6_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "6", + "2" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_6_2 *UpdateServiceV1_6_2; + EFI_REDFISH_UPDATESERVICE_V1_6_2_CS *UpdateServiceV1_6_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_6_2_To_CS (ResoruceRaw, &UpdateServiceV1_6_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_6_2 = (EFI_REDFISH_UPDATESERVICE_V1_6_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_6_2)); + if (UpdateServiceV1_6_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_6_2; + UpdateServiceV1_6_2->UpdateService = UpdateServiceV1_6_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_6_2_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_6_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_6_2 *UpdateServiceV1_6_2; + + UpdateServiceV1_6_2 = (EFI_REDFISH_UPDATESERVICE_V1_6_2 *)InterpProp; + DestroyUpdateService_V1_6_2_CS (UpdateServiceV1_6_2->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_6_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_6_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_6_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_6_3/RedfishUpdateService_V1_6_3_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_6_3/RedfishUpdateService_V1_6_3_Dxe.inf new file mode 100644 index 00000000000..063e43f784f --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_6_3/RedfishUpdateService_V1_6_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_6_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_6_3_Dxe + FILE_GUID = 07372d71-9a8c-4de5-99af-8d2f48ffbd20 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_6_3EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_6_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_6_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_6_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_6_3/UpdateService_V1_6_3_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_6_3/UpdateService_V1_6_3_Dxe.c new file mode 100644 index 00000000000..76150d16fe9 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_6_3/UpdateService_V1_6_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_6_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_6_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "6", + "3" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_6_3 *UpdateServiceV1_6_3; + EFI_REDFISH_UPDATESERVICE_V1_6_3_CS *UpdateServiceV1_6_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_6_3_To_CS (ResoruceRaw, &UpdateServiceV1_6_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_6_3 = (EFI_REDFISH_UPDATESERVICE_V1_6_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_6_3)); + if (UpdateServiceV1_6_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_6_3; + UpdateServiceV1_6_3->UpdateService = UpdateServiceV1_6_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_6_3_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_6_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_6_3 *UpdateServiceV1_6_3; + + UpdateServiceV1_6_3 = (EFI_REDFISH_UPDATESERVICE_V1_6_3 *)InterpProp; + DestroyUpdateService_V1_6_3_CS (UpdateServiceV1_6_3->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_6_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_6_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_6_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_7_0/RedfishUpdateService_V1_7_0_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_7_0/RedfishUpdateService_V1_7_0_Dxe.inf new file mode 100644 index 00000000000..806a617edb3 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_7_0/RedfishUpdateService_V1_7_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_7_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_7_0_Dxe + FILE_GUID = 314446a4-c94c-4771-b8bf-3abe00023839 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_7_0EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_7_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_7_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_7_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_7_0/UpdateService_V1_7_0_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_7_0/UpdateService_V1_7_0_Dxe.c new file mode 100644 index 00000000000..26bf59769e1 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_7_0/UpdateService_V1_7_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_7_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "7", + "0" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_7_0 *UpdateServiceV1_7_0; + EFI_REDFISH_UPDATESERVICE_V1_7_0_CS *UpdateServiceV1_7_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_7_0_To_CS (ResoruceRaw, &UpdateServiceV1_7_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_7_0 = (EFI_REDFISH_UPDATESERVICE_V1_7_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_7_0)); + if (UpdateServiceV1_7_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_7_0; + UpdateServiceV1_7_0->UpdateService = UpdateServiceV1_7_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_7_0_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_7_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_7_0 *UpdateServiceV1_7_0; + + UpdateServiceV1_7_0 = (EFI_REDFISH_UPDATESERVICE_V1_7_0 *)InterpProp; + DestroyUpdateService_V1_7_0_CS (UpdateServiceV1_7_0->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_7_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_7_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_7_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_7_1/RedfishUpdateService_V1_7_1_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_7_1/RedfishUpdateService_V1_7_1_Dxe.inf new file mode 100644 index 00000000000..de280f69b6f --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_7_1/RedfishUpdateService_V1_7_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_7_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_7_1_Dxe + FILE_GUID = ed2ca53b-b318-445f-9f8e-c57d9d1b219a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_7_1EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_7_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_7_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_7_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_7_1/UpdateService_V1_7_1_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_7_1/UpdateService_V1_7_1_Dxe.c new file mode 100644 index 00000000000..b9d60b86820 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_7_1/UpdateService_V1_7_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_7_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_7_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "7", + "1" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_7_1 *UpdateServiceV1_7_1; + EFI_REDFISH_UPDATESERVICE_V1_7_1_CS *UpdateServiceV1_7_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_7_1_To_CS (ResoruceRaw, &UpdateServiceV1_7_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_7_1 = (EFI_REDFISH_UPDATESERVICE_V1_7_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_7_1)); + if (UpdateServiceV1_7_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_7_1; + UpdateServiceV1_7_1->UpdateService = UpdateServiceV1_7_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_7_1_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_7_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_7_1 *UpdateServiceV1_7_1; + + UpdateServiceV1_7_1 = (EFI_REDFISH_UPDATESERVICE_V1_7_1 *)InterpProp; + DestroyUpdateService_V1_7_1_CS (UpdateServiceV1_7_1->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_7_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_7_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_7_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_7_2/RedfishUpdateService_V1_7_2_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_7_2/RedfishUpdateService_V1_7_2_Dxe.inf new file mode 100644 index 00000000000..5db040a4828 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_7_2/RedfishUpdateService_V1_7_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_7_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_7_2_Dxe + FILE_GUID = 1e630679-ea89-420e-ad37-dcc9dc769d47 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_7_2EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_7_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_7_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_7_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_7_2/UpdateService_V1_7_2_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_7_2/UpdateService_V1_7_2_Dxe.c new file mode 100644 index 00000000000..7bf194822f9 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_7_2/UpdateService_V1_7_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_7_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_7_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "7", + "2" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_7_2 *UpdateServiceV1_7_2; + EFI_REDFISH_UPDATESERVICE_V1_7_2_CS *UpdateServiceV1_7_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_7_2_To_CS (ResoruceRaw, &UpdateServiceV1_7_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_7_2 = (EFI_REDFISH_UPDATESERVICE_V1_7_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_7_2)); + if (UpdateServiceV1_7_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_7_2; + UpdateServiceV1_7_2->UpdateService = UpdateServiceV1_7_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_7_2_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_7_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_7_2 *UpdateServiceV1_7_2; + + UpdateServiceV1_7_2 = (EFI_REDFISH_UPDATESERVICE_V1_7_2 *)InterpProp; + DestroyUpdateService_V1_7_2_CS (UpdateServiceV1_7_2->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_7_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_7_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_7_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_7_3/RedfishUpdateService_V1_7_3_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_7_3/RedfishUpdateService_V1_7_3_Dxe.inf new file mode 100644 index 00000000000..630234237ec --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_7_3/RedfishUpdateService_V1_7_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_7_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_7_3_Dxe + FILE_GUID = 0ae8af3c-6c66-4f34-bdeb-1b7821e8a76d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_7_3EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_7_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_7_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_7_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_7_3/UpdateService_V1_7_3_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_7_3/UpdateService_V1_7_3_Dxe.c new file mode 100644 index 00000000000..7120aa63e8b --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_7_3/UpdateService_V1_7_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_7_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_7_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "7", + "3" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_7_3 *UpdateServiceV1_7_3; + EFI_REDFISH_UPDATESERVICE_V1_7_3_CS *UpdateServiceV1_7_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_7_3_To_CS (ResoruceRaw, &UpdateServiceV1_7_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_7_3 = (EFI_REDFISH_UPDATESERVICE_V1_7_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_7_3)); + if (UpdateServiceV1_7_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_7_3; + UpdateServiceV1_7_3->UpdateService = UpdateServiceV1_7_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "7"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_7_3_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_7_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_7_3 *UpdateServiceV1_7_3; + + UpdateServiceV1_7_3 = (EFI_REDFISH_UPDATESERVICE_V1_7_3 *)InterpProp; + DestroyUpdateService_V1_7_3_CS (UpdateServiceV1_7_3->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_7_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_7_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_7_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_8_0/RedfishUpdateService_V1_8_0_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_8_0/RedfishUpdateService_V1_8_0_Dxe.inf new file mode 100644 index 00000000000..9b30dc7acf6 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_8_0/RedfishUpdateService_V1_8_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_8_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_8_0_Dxe + FILE_GUID = 26f33aed-4293-4cc0-87ae-2bdd60516c6f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_8_0EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_8_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_8_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_8_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_8_0/UpdateService_V1_8_0_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_8_0/UpdateService_V1_8_0_Dxe.c new file mode 100644 index 00000000000..c443f55ed6c --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_8_0/UpdateService_V1_8_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_8_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_8_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "8", + "0" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_8_0 *UpdateServiceV1_8_0; + EFI_REDFISH_UPDATESERVICE_V1_8_0_CS *UpdateServiceV1_8_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_8_0_To_CS (ResoruceRaw, &UpdateServiceV1_8_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_8_0 = (EFI_REDFISH_UPDATESERVICE_V1_8_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_8_0)); + if (UpdateServiceV1_8_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_8_0; + UpdateServiceV1_8_0->UpdateService = UpdateServiceV1_8_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_8_0_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_8_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_8_0 *UpdateServiceV1_8_0; + + UpdateServiceV1_8_0 = (EFI_REDFISH_UPDATESERVICE_V1_8_0 *)InterpProp; + DestroyUpdateService_V1_8_0_CS (UpdateServiceV1_8_0->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_8_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_8_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_8_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_8_1/RedfishUpdateService_V1_8_1_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_8_1/RedfishUpdateService_V1_8_1_Dxe.inf new file mode 100644 index 00000000000..c268865caa5 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_8_1/RedfishUpdateService_V1_8_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_8_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_8_1_Dxe + FILE_GUID = 3f6939e1-4fe0-4a31-b437-b49338b8751a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_8_1EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_8_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_8_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_8_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_8_1/UpdateService_V1_8_1_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_8_1/UpdateService_V1_8_1_Dxe.c new file mode 100644 index 00000000000..8a296d777e7 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_8_1/UpdateService_V1_8_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_8_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_8_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "8", + "1" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_8_1 *UpdateServiceV1_8_1; + EFI_REDFISH_UPDATESERVICE_V1_8_1_CS *UpdateServiceV1_8_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_8_1_To_CS (ResoruceRaw, &UpdateServiceV1_8_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_8_1 = (EFI_REDFISH_UPDATESERVICE_V1_8_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_8_1)); + if (UpdateServiceV1_8_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_8_1; + UpdateServiceV1_8_1->UpdateService = UpdateServiceV1_8_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_8_1_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_8_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_8_1 *UpdateServiceV1_8_1; + + UpdateServiceV1_8_1 = (EFI_REDFISH_UPDATESERVICE_V1_8_1 *)InterpProp; + DestroyUpdateService_V1_8_1_CS (UpdateServiceV1_8_1->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_8_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_8_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_8_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_8_2/RedfishUpdateService_V1_8_2_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_8_2/RedfishUpdateService_V1_8_2_Dxe.inf new file mode 100644 index 00000000000..80e8b926352 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_8_2/RedfishUpdateService_V1_8_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_8_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_8_2_Dxe + FILE_GUID = ee5b134e-0368-4599-af05-a0b597f0f7b8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_8_2EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_8_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_8_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_8_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_8_2/UpdateService_V1_8_2_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_8_2/UpdateService_V1_8_2_Dxe.c new file mode 100644 index 00000000000..21483818460 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_8_2/UpdateService_V1_8_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_8_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_8_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "8", + "2" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_8_2 *UpdateServiceV1_8_2; + EFI_REDFISH_UPDATESERVICE_V1_8_2_CS *UpdateServiceV1_8_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_8_2_To_CS (ResoruceRaw, &UpdateServiceV1_8_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_8_2 = (EFI_REDFISH_UPDATESERVICE_V1_8_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_8_2)); + if (UpdateServiceV1_8_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_8_2; + UpdateServiceV1_8_2->UpdateService = UpdateServiceV1_8_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_8_2_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_8_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_8_2 *UpdateServiceV1_8_2; + + UpdateServiceV1_8_2 = (EFI_REDFISH_UPDATESERVICE_V1_8_2 *)InterpProp; + DestroyUpdateService_V1_8_2_CS (UpdateServiceV1_8_2->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_8_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_8_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_8_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/UpdateService/v1_8_3/RedfishUpdateService_V1_8_3_Dxe.inf b/RedfishClientPkg/Converter/UpdateService/v1_8_3/RedfishUpdateService_V1_8_3_Dxe.inf new file mode 100644 index 00000000000..1bb46bb39f4 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_8_3/RedfishUpdateService_V1_8_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of UpdateService.v1_8_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishUpdateService_V1_8_3_Dxe + FILE_GUID = a998ddc9-313f-48a7-8c97-fb109206807d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishUpdateService_V1_8_3EntryPoint + UNLOAD_IMAGE = RedfishUpdateService_V1_8_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + UpdateService_V1_8_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + UpdateServiceV1_8_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/UpdateService/v1_8_3/UpdateService_V1_8_3_Dxe.c b/RedfishClientPkg/Converter/UpdateService/v1_8_3/UpdateService_V1_8_3_Dxe.c new file mode 100644 index 00000000000..2f2363c41a7 --- /dev/null +++ b/RedfishClientPkg/Converter/UpdateService/v1_8_3/UpdateService_V1_8_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - UpdateService.v1_8_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#UpdateService"; +BOOLEAN IsRevisonController = TRUE; + +// Support UpdateService V1_8_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "UpdateService", + "1", + "8", + "3" + }, + "UpdateService" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_8_3 *UpdateServiceV1_8_3; + EFI_REDFISH_UPDATESERVICE_V1_8_3_CS *UpdateServiceV1_8_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "UpdateService") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_UpdateService_V1_8_3_To_CS (ResoruceRaw, &UpdateServiceV1_8_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + UpdateServiceV1_8_3 = (EFI_REDFISH_UPDATESERVICE_V1_8_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_UPDATESERVICE_V1_8_3)); + if (UpdateServiceV1_8_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)UpdateServiceV1_8_3; + UpdateServiceV1_8_3->UpdateService = UpdateServiceV1_8_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "8"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("UpdateService"), "UpdateService"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("UpdateService")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("UpdateService"), "UpdateService"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of UpdateServiceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return UpdateServiceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_UpdateService_V1_8_3_JSON (*((EFI_REDFISH_UPDATESERVICE_V1_8_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in UpdateServiceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_UPDATESERVICE_V1_8_3 *UpdateServiceV1_8_3; + + UpdateServiceV1_8_3 = (EFI_REDFISH_UPDATESERVICE_V1_8_3 *)InterpProp; + DestroyUpdateService_V1_8_3_CS (UpdateServiceV1_8_3->UpdateService); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from UpdateServiceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +UpdateServiceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyUpdateService_V1_8_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_8_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + UpdateServiceToStructWrapper, + UpdateServiceToJson, + UpdateServiceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishUpdateService_V1_8_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VCATEntry/v1_0_0/RedfishVCATEntry_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/VCATEntry/v1_0_0/RedfishVCATEntry_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..3fb038ca847 --- /dev/null +++ b/RedfishClientPkg/Converter/VCATEntry/v1_0_0/RedfishVCATEntry_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VCATEntry.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVCATEntry_V1_0_0_Dxe + FILE_GUID = 734cfdfc-666e-4e81-b726-2f06ad2fe5df + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVCATEntry_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishVCATEntry_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VCATEntry_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VCATEntryV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VCATEntry/v1_0_0/VCATEntry_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/VCATEntry/v1_0_0/VCATEntry_V1_0_0_Dxe.c new file mode 100644 index 00000000000..30880786d62 --- /dev/null +++ b/RedfishClientPkg/Converter/VCATEntry/v1_0_0/VCATEntry_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VCATEntry.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VCATEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support VCATEntry V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VCATEntry", + "1", + "0", + "0" + }, + "VCATEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VCATEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VCATENTRY_V1_0_0 *VCATEntryV1_0_0; + EFI_REDFISH_VCATENTRY_V1_0_0_CS *VCATEntryV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VCATEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VCATEntry_V1_0_0_To_CS (ResoruceRaw, &VCATEntryV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VCATEntryV1_0_0 = (EFI_REDFISH_VCATENTRY_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VCATENTRY_V1_0_0)); + if (VCATEntryV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VCATEntryV1_0_0; + VCATEntryV1_0_0->VCATEntry = VCATEntryV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VCATEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VCATEntry"), "VCATEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VCATEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VCATEntry"), "VCATEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VCATEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VCATEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VCATEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VCATEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VCATEntry_V1_0_0_JSON (*((EFI_REDFISH_VCATENTRY_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VCATEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VCATEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VCATENTRY_V1_0_0 *VCATEntryV1_0_0; + + VCATEntryV1_0_0 = (EFI_REDFISH_VCATENTRY_V1_0_0 *)InterpProp; + DestroyVCATEntry_V1_0_0_CS (VCATEntryV1_0_0->VCATEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VCATEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VCATEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVCATEntry_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVCATEntry_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VCATEntryToStructWrapper, + VCATEntryToJson, + VCATEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVCATEntry_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VCATEntry/v1_0_1/RedfishVCATEntry_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/VCATEntry/v1_0_1/RedfishVCATEntry_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..f449f471878 --- /dev/null +++ b/RedfishClientPkg/Converter/VCATEntry/v1_0_1/RedfishVCATEntry_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VCATEntry.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVCATEntry_V1_0_1_Dxe + FILE_GUID = 8d5558c5-2f11-44c9-bd38-3cc14ab51def + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVCATEntry_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishVCATEntry_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VCATEntry_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VCATEntryV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VCATEntry/v1_0_1/VCATEntry_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/VCATEntry/v1_0_1/VCATEntry_V1_0_1_Dxe.c new file mode 100644 index 00000000000..ef6dd80c0a3 --- /dev/null +++ b/RedfishClientPkg/Converter/VCATEntry/v1_0_1/VCATEntry_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VCATEntry.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VCATEntry"; +BOOLEAN IsRevisonController = TRUE; + +// Support VCATEntry V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VCATEntry", + "1", + "0", + "1" + }, + "VCATEntry" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VCATEntryToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VCATENTRY_V1_0_1 *VCATEntryV1_0_1; + EFI_REDFISH_VCATENTRY_V1_0_1_CS *VCATEntryV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VCATEntry") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VCATEntry_V1_0_1_To_CS (ResoruceRaw, &VCATEntryV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VCATEntryV1_0_1 = (EFI_REDFISH_VCATENTRY_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VCATENTRY_V1_0_1)); + if (VCATEntryV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VCATEntryV1_0_1; + VCATEntryV1_0_1->VCATEntry = VCATEntryV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VCATEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VCATEntry"), "VCATEntry"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VCATEntry")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VCATEntry"), "VCATEntry"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VCATEntryToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VCATEntryToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VCATEntryToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VCATEntryToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VCATEntry_V1_0_1_JSON (*((EFI_REDFISH_VCATENTRY_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VCATEntryToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VCATEntryDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VCATENTRY_V1_0_1 *VCATEntryV1_0_1; + + VCATEntryV1_0_1 = (EFI_REDFISH_VCATENTRY_V1_0_1 *)InterpProp; + DestroyVCATEntry_V1_0_1_CS (VCATEntryV1_0_1->VCATEntry); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VCATEntryFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VCATEntryDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVCATEntry_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVCATEntry_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VCATEntryToStructWrapper, + VCATEntryToJson, + VCATEntryDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVCATEntry_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VCATEntryCollection/RedfishVCATEntryCollection_Dxe.inf b/RedfishClientPkg/Converter/VCATEntryCollection/RedfishVCATEntryCollection_Dxe.inf new file mode 100644 index 00000000000..98b7d89579f --- /dev/null +++ b/RedfishClientPkg/Converter/VCATEntryCollection/RedfishVCATEntryCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VCATEntryCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVCATEntryCollection_Dxe + FILE_GUID = 31dc5ec4-f5b8-4407-9306-defc76127249 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVCATEntryCollectionEntryPoint + UNLOAD_IMAGE = RedfishVCATEntryCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VCATEntryCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VCATEntryCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VCATEntryCollection/VCATEntryCollection_Dxe.c b/RedfishClientPkg/Converter/VCATEntryCollection/VCATEntryCollection_Dxe.c new file mode 100644 index 00000000000..7a0fb19a971 --- /dev/null +++ b/RedfishClientPkg/Converter/VCATEntryCollection/VCATEntryCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VCATEntryCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VCATEntryCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support VCATEntryCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VCATEntryCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "VCATEntryCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VCATEntryCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VCATENTRYCOLLECTION *VCATEntryCollection; + EFI_REDFISH_VCATENTRYCOLLECTION_CS *VCATEntryCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VCATEntryCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VCATEntryCollection_To_CS (ResoruceRaw, &VCATEntryCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + VCATEntryCollection = (EFI_REDFISH_VCATENTRYCOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VCATENTRYCOLLECTION)); + if (VCATEntryCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VCATEntryCollection; + VCATEntryCollection->VCATEntryCollection = VCATEntryCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VCATEntryCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VCATEntryCollection"), "VCATEntryCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VCATEntryCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VCATEntryCollection"), "VCATEntryCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VCATEntryCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VCATEntryCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VCATEntryCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VCATEntryCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VCATEntryCollection_JSON (*((EFI_REDFISH_VCATENTRYCOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VCATEntryCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VCATEntryCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VCATENTRYCOLLECTION *VCATEntryCollection; + + VCATEntryCollection = (EFI_REDFISH_VCATENTRYCOLLECTION *)InterpProp; + DestroyVCATEntryCollection_CS (VCATEntryCollection->VCATEntryCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VCATEntryCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VCATEntryCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVCATEntryCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVCATEntryCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VCATEntryCollectionToStructWrapper, + VCATEntryCollectionToJson, + VCATEntryCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVCATEntryCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_0/RedfishVLanNetworkInterface_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_0/RedfishVLanNetworkInterface_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..15149493878 --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_0/RedfishVLanNetworkInterface_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VLanNetworkInterface.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVLanNetworkInterface_V1_0_0_Dxe + FILE_GUID = c63fa3d6-15d7-4c1d-92dd-912d3a672f2c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVLanNetworkInterface_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishVLanNetworkInterface_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VLanNetworkInterface_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VLanNetworkInterfaceV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_0/VLanNetworkInterface_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_0/VLanNetworkInterface_V1_0_0_Dxe.c new file mode 100644 index 00000000000..39a81ba78d6 --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_0/VLanNetworkInterface_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VLanNetworkInterface.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VLanNetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support VLanNetworkInterface V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VLanNetworkInterface", + "1", + "0", + "0" + }, + "VLanNetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_0 *VLanNetworkInterfaceV1_0_0; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_0_CS *VLanNetworkInterfaceV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VLanNetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VLanNetworkInterface_V1_0_0_To_CS (ResoruceRaw, &VLanNetworkInterfaceV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VLanNetworkInterfaceV1_0_0 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_0)); + if (VLanNetworkInterfaceV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VLanNetworkInterfaceV1_0_0; + VLanNetworkInterfaceV1_0_0->VLanNetworkInterface = VLanNetworkInterfaceV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VLanNetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VLanNetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VLanNetworkInterface_V1_0_0_JSON (*((EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VLanNetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_0 *VLanNetworkInterfaceV1_0_0; + + VLanNetworkInterfaceV1_0_0 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_0 *)InterpProp; + DestroyVLanNetworkInterface_V1_0_0_CS (VLanNetworkInterfaceV1_0_0->VLanNetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VLanNetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVLanNetworkInterface_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VLanNetworkInterfaceToStructWrapper, + VLanNetworkInterfaceToJson, + VLanNetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_1/RedfishVLanNetworkInterface_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_1/RedfishVLanNetworkInterface_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..25ea1a8d9aa --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_1/RedfishVLanNetworkInterface_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VLanNetworkInterface.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVLanNetworkInterface_V1_0_1_Dxe + FILE_GUID = 8fb04ade-212e-41c8-ad03-cd3614ce4efb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVLanNetworkInterface_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishVLanNetworkInterface_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VLanNetworkInterface_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VLanNetworkInterfaceV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_1/VLanNetworkInterface_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_1/VLanNetworkInterface_V1_0_1_Dxe.c new file mode 100644 index 00000000000..ac4a965a43c --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_1/VLanNetworkInterface_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VLanNetworkInterface.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VLanNetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support VLanNetworkInterface V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VLanNetworkInterface", + "1", + "0", + "1" + }, + "VLanNetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_1 *VLanNetworkInterfaceV1_0_1; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_1_CS *VLanNetworkInterfaceV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VLanNetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VLanNetworkInterface_V1_0_1_To_CS (ResoruceRaw, &VLanNetworkInterfaceV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VLanNetworkInterfaceV1_0_1 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_1)); + if (VLanNetworkInterfaceV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VLanNetworkInterfaceV1_0_1; + VLanNetworkInterfaceV1_0_1->VLanNetworkInterface = VLanNetworkInterfaceV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VLanNetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VLanNetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VLanNetworkInterface_V1_0_1_JSON (*((EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VLanNetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_1 *VLanNetworkInterfaceV1_0_1; + + VLanNetworkInterfaceV1_0_1 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_1 *)InterpProp; + DestroyVLanNetworkInterface_V1_0_1_CS (VLanNetworkInterfaceV1_0_1->VLanNetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VLanNetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVLanNetworkInterface_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VLanNetworkInterfaceToStructWrapper, + VLanNetworkInterfaceToJson, + VLanNetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_2/RedfishVLanNetworkInterface_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_2/RedfishVLanNetworkInterface_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..fc7acfa2449 --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_2/RedfishVLanNetworkInterface_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VLanNetworkInterface.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVLanNetworkInterface_V1_0_2_Dxe + FILE_GUID = 01aa2656-5ea7-4190-9ed5-8dffe3a62664 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVLanNetworkInterface_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishVLanNetworkInterface_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VLanNetworkInterface_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VLanNetworkInterfaceV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_2/VLanNetworkInterface_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_2/VLanNetworkInterface_V1_0_2_Dxe.c new file mode 100644 index 00000000000..5ac6d02fc1d --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_2/VLanNetworkInterface_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VLanNetworkInterface.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VLanNetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support VLanNetworkInterface V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VLanNetworkInterface", + "1", + "0", + "2" + }, + "VLanNetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_2 *VLanNetworkInterfaceV1_0_2; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_2_CS *VLanNetworkInterfaceV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VLanNetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VLanNetworkInterface_V1_0_2_To_CS (ResoruceRaw, &VLanNetworkInterfaceV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VLanNetworkInterfaceV1_0_2 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_2)); + if (VLanNetworkInterfaceV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VLanNetworkInterfaceV1_0_2; + VLanNetworkInterfaceV1_0_2->VLanNetworkInterface = VLanNetworkInterfaceV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VLanNetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VLanNetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VLanNetworkInterface_V1_0_2_JSON (*((EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VLanNetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_2 *VLanNetworkInterfaceV1_0_2; + + VLanNetworkInterfaceV1_0_2 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_2 *)InterpProp; + DestroyVLanNetworkInterface_V1_0_2_CS (VLanNetworkInterfaceV1_0_2->VLanNetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VLanNetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVLanNetworkInterface_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VLanNetworkInterfaceToStructWrapper, + VLanNetworkInterfaceToJson, + VLanNetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_3/RedfishVLanNetworkInterface_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_3/RedfishVLanNetworkInterface_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..b68a8f96711 --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_3/RedfishVLanNetworkInterface_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VLanNetworkInterface.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVLanNetworkInterface_V1_0_3_Dxe + FILE_GUID = d3bffc67-6c8b-4b60-adee-00be35bebb9d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVLanNetworkInterface_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishVLanNetworkInterface_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VLanNetworkInterface_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VLanNetworkInterfaceV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_3/VLanNetworkInterface_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_3/VLanNetworkInterface_V1_0_3_Dxe.c new file mode 100644 index 00000000000..e23c0b70072 --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_3/VLanNetworkInterface_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VLanNetworkInterface.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VLanNetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support VLanNetworkInterface V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VLanNetworkInterface", + "1", + "0", + "3" + }, + "VLanNetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_3 *VLanNetworkInterfaceV1_0_3; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_3_CS *VLanNetworkInterfaceV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VLanNetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VLanNetworkInterface_V1_0_3_To_CS (ResoruceRaw, &VLanNetworkInterfaceV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VLanNetworkInterfaceV1_0_3 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_3)); + if (VLanNetworkInterfaceV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VLanNetworkInterfaceV1_0_3; + VLanNetworkInterfaceV1_0_3->VLanNetworkInterface = VLanNetworkInterfaceV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VLanNetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VLanNetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VLanNetworkInterface_V1_0_3_JSON (*((EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VLanNetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_3 *VLanNetworkInterfaceV1_0_3; + + VLanNetworkInterfaceV1_0_3 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_3 *)InterpProp; + DestroyVLanNetworkInterface_V1_0_3_CS (VLanNetworkInterfaceV1_0_3->VLanNetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VLanNetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVLanNetworkInterface_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VLanNetworkInterfaceToStructWrapper, + VLanNetworkInterfaceToJson, + VLanNetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_4/RedfishVLanNetworkInterface_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_4/RedfishVLanNetworkInterface_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..6ea93048df6 --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_4/RedfishVLanNetworkInterface_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VLanNetworkInterface.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVLanNetworkInterface_V1_0_4_Dxe + FILE_GUID = cacf93db-8794-4262-b903-d3cf1785e4c0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVLanNetworkInterface_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishVLanNetworkInterface_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VLanNetworkInterface_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VLanNetworkInterfaceV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_4/VLanNetworkInterface_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_4/VLanNetworkInterface_V1_0_4_Dxe.c new file mode 100644 index 00000000000..f519b494938 --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_4/VLanNetworkInterface_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VLanNetworkInterface.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VLanNetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support VLanNetworkInterface V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VLanNetworkInterface", + "1", + "0", + "4" + }, + "VLanNetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_4 *VLanNetworkInterfaceV1_0_4; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_4_CS *VLanNetworkInterfaceV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VLanNetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VLanNetworkInterface_V1_0_4_To_CS (ResoruceRaw, &VLanNetworkInterfaceV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VLanNetworkInterfaceV1_0_4 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_4)); + if (VLanNetworkInterfaceV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VLanNetworkInterfaceV1_0_4; + VLanNetworkInterfaceV1_0_4->VLanNetworkInterface = VLanNetworkInterfaceV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VLanNetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VLanNetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VLanNetworkInterface_V1_0_4_JSON (*((EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VLanNetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_4 *VLanNetworkInterfaceV1_0_4; + + VLanNetworkInterfaceV1_0_4 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_4 *)InterpProp; + DestroyVLanNetworkInterface_V1_0_4_CS (VLanNetworkInterfaceV1_0_4->VLanNetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VLanNetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVLanNetworkInterface_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VLanNetworkInterfaceToStructWrapper, + VLanNetworkInterfaceToJson, + VLanNetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_5/RedfishVLanNetworkInterface_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_5/RedfishVLanNetworkInterface_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..7f79552622e --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_5/RedfishVLanNetworkInterface_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VLanNetworkInterface.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVLanNetworkInterface_V1_0_5_Dxe + FILE_GUID = 0464401f-612a-4600-a007-b409d5973bed + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVLanNetworkInterface_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishVLanNetworkInterface_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VLanNetworkInterface_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VLanNetworkInterfaceV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_5/VLanNetworkInterface_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_5/VLanNetworkInterface_V1_0_5_Dxe.c new file mode 100644 index 00000000000..af457789eb8 --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_5/VLanNetworkInterface_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VLanNetworkInterface.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VLanNetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support VLanNetworkInterface V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VLanNetworkInterface", + "1", + "0", + "5" + }, + "VLanNetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_5 *VLanNetworkInterfaceV1_0_5; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_5_CS *VLanNetworkInterfaceV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VLanNetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VLanNetworkInterface_V1_0_5_To_CS (ResoruceRaw, &VLanNetworkInterfaceV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VLanNetworkInterfaceV1_0_5 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_5)); + if (VLanNetworkInterfaceV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VLanNetworkInterfaceV1_0_5; + VLanNetworkInterfaceV1_0_5->VLanNetworkInterface = VLanNetworkInterfaceV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VLanNetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VLanNetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VLanNetworkInterface_V1_0_5_JSON (*((EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VLanNetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_5 *VLanNetworkInterfaceV1_0_5; + + VLanNetworkInterfaceV1_0_5 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_5 *)InterpProp; + DestroyVLanNetworkInterface_V1_0_5_CS (VLanNetworkInterfaceV1_0_5->VLanNetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VLanNetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVLanNetworkInterface_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VLanNetworkInterfaceToStructWrapper, + VLanNetworkInterfaceToJson, + VLanNetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_6/RedfishVLanNetworkInterface_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_6/RedfishVLanNetworkInterface_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..69ff62d55e3 --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_6/RedfishVLanNetworkInterface_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VLanNetworkInterface.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVLanNetworkInterface_V1_0_6_Dxe + FILE_GUID = 8d4b9ce2-c52a-476e-9e7f-68176f90aa8a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVLanNetworkInterface_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishVLanNetworkInterface_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VLanNetworkInterface_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VLanNetworkInterfaceV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_6/VLanNetworkInterface_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_6/VLanNetworkInterface_V1_0_6_Dxe.c new file mode 100644 index 00000000000..f1617c19bfd --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_6/VLanNetworkInterface_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VLanNetworkInterface.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VLanNetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support VLanNetworkInterface V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VLanNetworkInterface", + "1", + "0", + "6" + }, + "VLanNetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_6 *VLanNetworkInterfaceV1_0_6; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_6_CS *VLanNetworkInterfaceV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VLanNetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VLanNetworkInterface_V1_0_6_To_CS (ResoruceRaw, &VLanNetworkInterfaceV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VLanNetworkInterfaceV1_0_6 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_6)); + if (VLanNetworkInterfaceV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VLanNetworkInterfaceV1_0_6; + VLanNetworkInterfaceV1_0_6->VLanNetworkInterface = VLanNetworkInterfaceV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VLanNetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VLanNetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VLanNetworkInterface_V1_0_6_JSON (*((EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VLanNetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_6 *VLanNetworkInterfaceV1_0_6; + + VLanNetworkInterfaceV1_0_6 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_6 *)InterpProp; + DestroyVLanNetworkInterface_V1_0_6_CS (VLanNetworkInterfaceV1_0_6->VLanNetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VLanNetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVLanNetworkInterface_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VLanNetworkInterfaceToStructWrapper, + VLanNetworkInterfaceToJson, + VLanNetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_7/RedfishVLanNetworkInterface_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_7/RedfishVLanNetworkInterface_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..58ab35adce2 --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_7/RedfishVLanNetworkInterface_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VLanNetworkInterface.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVLanNetworkInterface_V1_0_7_Dxe + FILE_GUID = 8c876e79-414a-42eb-966e-02f532b8a583 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVLanNetworkInterface_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishVLanNetworkInterface_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VLanNetworkInterface_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VLanNetworkInterfaceV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_7/VLanNetworkInterface_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_7/VLanNetworkInterface_V1_0_7_Dxe.c new file mode 100644 index 00000000000..05e982b4e1a --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_7/VLanNetworkInterface_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VLanNetworkInterface.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VLanNetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support VLanNetworkInterface V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VLanNetworkInterface", + "1", + "0", + "7" + }, + "VLanNetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_7 *VLanNetworkInterfaceV1_0_7; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_7_CS *VLanNetworkInterfaceV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VLanNetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VLanNetworkInterface_V1_0_7_To_CS (ResoruceRaw, &VLanNetworkInterfaceV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VLanNetworkInterfaceV1_0_7 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_7)); + if (VLanNetworkInterfaceV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VLanNetworkInterfaceV1_0_7; + VLanNetworkInterfaceV1_0_7->VLanNetworkInterface = VLanNetworkInterfaceV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VLanNetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VLanNetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VLanNetworkInterface_V1_0_7_JSON (*((EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VLanNetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_7 *VLanNetworkInterfaceV1_0_7; + + VLanNetworkInterfaceV1_0_7 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_7 *)InterpProp; + DestroyVLanNetworkInterface_V1_0_7_CS (VLanNetworkInterfaceV1_0_7->VLanNetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VLanNetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVLanNetworkInterface_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VLanNetworkInterfaceToStructWrapper, + VLanNetworkInterfaceToJson, + VLanNetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_8/RedfishVLanNetworkInterface_V1_0_8_Dxe.inf b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_8/RedfishVLanNetworkInterface_V1_0_8_Dxe.inf new file mode 100644 index 00000000000..341675d89b1 --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_8/RedfishVLanNetworkInterface_V1_0_8_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VLanNetworkInterface.v1_0_8 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVLanNetworkInterface_V1_0_8_Dxe + FILE_GUID = 42870183-51c3-4920-8f7f-939a0b347e76 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVLanNetworkInterface_V1_0_8EntryPoint + UNLOAD_IMAGE = RedfishVLanNetworkInterface_V1_0_8Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VLanNetworkInterface_V1_0_8_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VLanNetworkInterfaceV1_0_8Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_8/VLanNetworkInterface_V1_0_8_Dxe.c b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_8/VLanNetworkInterface_V1_0_8_Dxe.c new file mode 100644 index 00000000000..060e84b36bc --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_8/VLanNetworkInterface_V1_0_8_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VLanNetworkInterface.v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VLanNetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support VLanNetworkInterface V1_0_8 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VLanNetworkInterface", + "1", + "0", + "8" + }, + "VLanNetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_8 *VLanNetworkInterfaceV1_0_8; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_8_CS *VLanNetworkInterfaceV1_0_8Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "8") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VLanNetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VLanNetworkInterface_V1_0_8_To_CS (ResoruceRaw, &VLanNetworkInterfaceV1_0_8Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VLanNetworkInterfaceV1_0_8 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_8 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_8)); + if (VLanNetworkInterfaceV1_0_8 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VLanNetworkInterfaceV1_0_8; + VLanNetworkInterfaceV1_0_8->VLanNetworkInterface = VLanNetworkInterfaceV1_0_8Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "8"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VLanNetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VLanNetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VLanNetworkInterface_V1_0_8_JSON (*((EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_8_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VLanNetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_8 *VLanNetworkInterfaceV1_0_8; + + VLanNetworkInterfaceV1_0_8 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_8 *)InterpProp; + DestroyVLanNetworkInterface_V1_0_8_CS (VLanNetworkInterfaceV1_0_8->VLanNetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VLanNetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVLanNetworkInterface_V1_0_8_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_0_8EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VLanNetworkInterfaceToStructWrapper, + VLanNetworkInterfaceToJson, + VLanNetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_0_8Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_9/RedfishVLanNetworkInterface_V1_0_9_Dxe.inf b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_9/RedfishVLanNetworkInterface_V1_0_9_Dxe.inf new file mode 100644 index 00000000000..80dde91cbda --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_9/RedfishVLanNetworkInterface_V1_0_9_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VLanNetworkInterface.v1_0_9 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVLanNetworkInterface_V1_0_9_Dxe + FILE_GUID = d585ba31-c628-4b37-96a8-61478ee3aecc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVLanNetworkInterface_V1_0_9EntryPoint + UNLOAD_IMAGE = RedfishVLanNetworkInterface_V1_0_9Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VLanNetworkInterface_V1_0_9_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VLanNetworkInterfaceV1_0_9Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_9/VLanNetworkInterface_V1_0_9_Dxe.c b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_9/VLanNetworkInterface_V1_0_9_Dxe.c new file mode 100644 index 00000000000..ff2d7c1fa78 --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_0_9/VLanNetworkInterface_V1_0_9_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VLanNetworkInterface.v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VLanNetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support VLanNetworkInterface V1_0_9 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VLanNetworkInterface", + "1", + "0", + "9" + }, + "VLanNetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_9 *VLanNetworkInterfaceV1_0_9; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_9_CS *VLanNetworkInterfaceV1_0_9Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "9") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VLanNetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VLanNetworkInterface_V1_0_9_To_CS (ResoruceRaw, &VLanNetworkInterfaceV1_0_9Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VLanNetworkInterfaceV1_0_9 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_9 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_9)); + if (VLanNetworkInterfaceV1_0_9 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VLanNetworkInterfaceV1_0_9; + VLanNetworkInterfaceV1_0_9->VLanNetworkInterface = VLanNetworkInterfaceV1_0_9Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "9"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VLanNetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VLanNetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VLanNetworkInterface_V1_0_9_JSON (*((EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_9_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VLanNetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_9 *VLanNetworkInterfaceV1_0_9; + + VLanNetworkInterfaceV1_0_9 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_9 *)InterpProp; + DestroyVLanNetworkInterface_V1_0_9_CS (VLanNetworkInterfaceV1_0_9->VLanNetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VLanNetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVLanNetworkInterface_V1_0_9_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_0_9EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VLanNetworkInterfaceToStructWrapper, + VLanNetworkInterfaceToJson, + VLanNetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_0_9Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_0/RedfishVLanNetworkInterface_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_0/RedfishVLanNetworkInterface_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..8c53fefa844 --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_0/RedfishVLanNetworkInterface_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VLanNetworkInterface.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVLanNetworkInterface_V1_1_0_Dxe + FILE_GUID = 77e382ee-70ea-4e9b-b29c-9c03ae4843ec + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVLanNetworkInterface_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishVLanNetworkInterface_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VLanNetworkInterface_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VLanNetworkInterfaceV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_0/VLanNetworkInterface_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_0/VLanNetworkInterface_V1_1_0_Dxe.c new file mode 100644 index 00000000000..672b26bfd8d --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_0/VLanNetworkInterface_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VLanNetworkInterface.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VLanNetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support VLanNetworkInterface V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VLanNetworkInterface", + "1", + "1", + "0" + }, + "VLanNetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_0 *VLanNetworkInterfaceV1_1_0; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_0_CS *VLanNetworkInterfaceV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VLanNetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VLanNetworkInterface_V1_1_0_To_CS (ResoruceRaw, &VLanNetworkInterfaceV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VLanNetworkInterfaceV1_1_0 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_0)); + if (VLanNetworkInterfaceV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VLanNetworkInterfaceV1_1_0; + VLanNetworkInterfaceV1_1_0->VLanNetworkInterface = VLanNetworkInterfaceV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VLanNetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VLanNetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VLanNetworkInterface_V1_1_0_JSON (*((EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VLanNetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_0 *VLanNetworkInterfaceV1_1_0; + + VLanNetworkInterfaceV1_1_0 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_0 *)InterpProp; + DestroyVLanNetworkInterface_V1_1_0_CS (VLanNetworkInterfaceV1_1_0->VLanNetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VLanNetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVLanNetworkInterface_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VLanNetworkInterfaceToStructWrapper, + VLanNetworkInterfaceToJson, + VLanNetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_1/RedfishVLanNetworkInterface_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_1/RedfishVLanNetworkInterface_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..4a88645e1f1 --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_1/RedfishVLanNetworkInterface_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VLanNetworkInterface.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVLanNetworkInterface_V1_1_1_Dxe + FILE_GUID = 7b7ab333-a663-4ed6-9553-eccd91a37a20 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVLanNetworkInterface_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishVLanNetworkInterface_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VLanNetworkInterface_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VLanNetworkInterfaceV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_1/VLanNetworkInterface_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_1/VLanNetworkInterface_V1_1_1_Dxe.c new file mode 100644 index 00000000000..6d5b10ab092 --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_1/VLanNetworkInterface_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VLanNetworkInterface.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VLanNetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support VLanNetworkInterface V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VLanNetworkInterface", + "1", + "1", + "1" + }, + "VLanNetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_1 *VLanNetworkInterfaceV1_1_1; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_1_CS *VLanNetworkInterfaceV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VLanNetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VLanNetworkInterface_V1_1_1_To_CS (ResoruceRaw, &VLanNetworkInterfaceV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VLanNetworkInterfaceV1_1_1 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_1)); + if (VLanNetworkInterfaceV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VLanNetworkInterfaceV1_1_1; + VLanNetworkInterfaceV1_1_1->VLanNetworkInterface = VLanNetworkInterfaceV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VLanNetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VLanNetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VLanNetworkInterface_V1_1_1_JSON (*((EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VLanNetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_1 *VLanNetworkInterfaceV1_1_1; + + VLanNetworkInterfaceV1_1_1 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_1 *)InterpProp; + DestroyVLanNetworkInterface_V1_1_1_CS (VLanNetworkInterfaceV1_1_1->VLanNetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VLanNetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVLanNetworkInterface_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VLanNetworkInterfaceToStructWrapper, + VLanNetworkInterfaceToJson, + VLanNetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_2/RedfishVLanNetworkInterface_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_2/RedfishVLanNetworkInterface_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..22918f5d0f1 --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_2/RedfishVLanNetworkInterface_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VLanNetworkInterface.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVLanNetworkInterface_V1_1_2_Dxe + FILE_GUID = d243217d-bede-41e2-8afd-6dd6f9067d46 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVLanNetworkInterface_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishVLanNetworkInterface_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VLanNetworkInterface_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VLanNetworkInterfaceV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_2/VLanNetworkInterface_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_2/VLanNetworkInterface_V1_1_2_Dxe.c new file mode 100644 index 00000000000..4bbabc1ffec --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_2/VLanNetworkInterface_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VLanNetworkInterface.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VLanNetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support VLanNetworkInterface V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VLanNetworkInterface", + "1", + "1", + "2" + }, + "VLanNetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_2 *VLanNetworkInterfaceV1_1_2; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_2_CS *VLanNetworkInterfaceV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VLanNetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VLanNetworkInterface_V1_1_2_To_CS (ResoruceRaw, &VLanNetworkInterfaceV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VLanNetworkInterfaceV1_1_2 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_2)); + if (VLanNetworkInterfaceV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VLanNetworkInterfaceV1_1_2; + VLanNetworkInterfaceV1_1_2->VLanNetworkInterface = VLanNetworkInterfaceV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VLanNetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VLanNetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VLanNetworkInterface_V1_1_2_JSON (*((EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VLanNetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_2 *VLanNetworkInterfaceV1_1_2; + + VLanNetworkInterfaceV1_1_2 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_2 *)InterpProp; + DestroyVLanNetworkInterface_V1_1_2_CS (VLanNetworkInterfaceV1_1_2->VLanNetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VLanNetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVLanNetworkInterface_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VLanNetworkInterfaceToStructWrapper, + VLanNetworkInterfaceToJson, + VLanNetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_3/RedfishVLanNetworkInterface_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_3/RedfishVLanNetworkInterface_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..8332f15f40f --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_3/RedfishVLanNetworkInterface_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VLanNetworkInterface.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVLanNetworkInterface_V1_1_3_Dxe + FILE_GUID = 523523b7-d774-4a2b-bcab-51f67dc8c4c6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVLanNetworkInterface_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishVLanNetworkInterface_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VLanNetworkInterface_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VLanNetworkInterfaceV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_3/VLanNetworkInterface_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_3/VLanNetworkInterface_V1_1_3_Dxe.c new file mode 100644 index 00000000000..8d3638eabd6 --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_3/VLanNetworkInterface_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VLanNetworkInterface.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VLanNetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support VLanNetworkInterface V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VLanNetworkInterface", + "1", + "1", + "3" + }, + "VLanNetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_3 *VLanNetworkInterfaceV1_1_3; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_3_CS *VLanNetworkInterfaceV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VLanNetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VLanNetworkInterface_V1_1_3_To_CS (ResoruceRaw, &VLanNetworkInterfaceV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VLanNetworkInterfaceV1_1_3 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_3)); + if (VLanNetworkInterfaceV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VLanNetworkInterfaceV1_1_3; + VLanNetworkInterfaceV1_1_3->VLanNetworkInterface = VLanNetworkInterfaceV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VLanNetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VLanNetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VLanNetworkInterface_V1_1_3_JSON (*((EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VLanNetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_3 *VLanNetworkInterfaceV1_1_3; + + VLanNetworkInterfaceV1_1_3 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_3 *)InterpProp; + DestroyVLanNetworkInterface_V1_1_3_CS (VLanNetworkInterfaceV1_1_3->VLanNetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VLanNetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVLanNetworkInterface_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VLanNetworkInterfaceToStructWrapper, + VLanNetworkInterfaceToJson, + VLanNetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_4/RedfishVLanNetworkInterface_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_4/RedfishVLanNetworkInterface_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..88cd22a4017 --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_4/RedfishVLanNetworkInterface_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VLanNetworkInterface.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVLanNetworkInterface_V1_1_4_Dxe + FILE_GUID = 070e3d39-3942-4e30-b22c-00249ffc69d1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVLanNetworkInterface_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishVLanNetworkInterface_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VLanNetworkInterface_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VLanNetworkInterfaceV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_4/VLanNetworkInterface_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_4/VLanNetworkInterface_V1_1_4_Dxe.c new file mode 100644 index 00000000000..6082bf85108 --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_4/VLanNetworkInterface_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VLanNetworkInterface.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VLanNetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support VLanNetworkInterface V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VLanNetworkInterface", + "1", + "1", + "4" + }, + "VLanNetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_4 *VLanNetworkInterfaceV1_1_4; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_4_CS *VLanNetworkInterfaceV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VLanNetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VLanNetworkInterface_V1_1_4_To_CS (ResoruceRaw, &VLanNetworkInterfaceV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VLanNetworkInterfaceV1_1_4 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_4)); + if (VLanNetworkInterfaceV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VLanNetworkInterfaceV1_1_4; + VLanNetworkInterfaceV1_1_4->VLanNetworkInterface = VLanNetworkInterfaceV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VLanNetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VLanNetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VLanNetworkInterface_V1_1_4_JSON (*((EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VLanNetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_4 *VLanNetworkInterfaceV1_1_4; + + VLanNetworkInterfaceV1_1_4 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_4 *)InterpProp; + DestroyVLanNetworkInterface_V1_1_4_CS (VLanNetworkInterfaceV1_1_4->VLanNetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VLanNetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVLanNetworkInterface_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VLanNetworkInterfaceToStructWrapper, + VLanNetworkInterfaceToJson, + VLanNetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_5/RedfishVLanNetworkInterface_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_5/RedfishVLanNetworkInterface_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..64d63e9be45 --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_5/RedfishVLanNetworkInterface_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VLanNetworkInterface.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVLanNetworkInterface_V1_1_5_Dxe + FILE_GUID = 760d81a2-a94f-4b0f-bbec-ceaacc19c641 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVLanNetworkInterface_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishVLanNetworkInterface_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VLanNetworkInterface_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VLanNetworkInterfaceV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_5/VLanNetworkInterface_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_5/VLanNetworkInterface_V1_1_5_Dxe.c new file mode 100644 index 00000000000..1a8617e1fda --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_1_5/VLanNetworkInterface_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VLanNetworkInterface.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VLanNetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support VLanNetworkInterface V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VLanNetworkInterface", + "1", + "1", + "5" + }, + "VLanNetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_5 *VLanNetworkInterfaceV1_1_5; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_5_CS *VLanNetworkInterfaceV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VLanNetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VLanNetworkInterface_V1_1_5_To_CS (ResoruceRaw, &VLanNetworkInterfaceV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VLanNetworkInterfaceV1_1_5 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_5)); + if (VLanNetworkInterfaceV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VLanNetworkInterfaceV1_1_5; + VLanNetworkInterfaceV1_1_5->VLanNetworkInterface = VLanNetworkInterfaceV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VLanNetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VLanNetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VLanNetworkInterface_V1_1_5_JSON (*((EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VLanNetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_5 *VLanNetworkInterfaceV1_1_5; + + VLanNetworkInterfaceV1_1_5 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_5 *)InterpProp; + DestroyVLanNetworkInterface_V1_1_5_CS (VLanNetworkInterfaceV1_1_5->VLanNetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VLanNetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVLanNetworkInterface_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VLanNetworkInterfaceToStructWrapper, + VLanNetworkInterfaceToJson, + VLanNetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_2_0/RedfishVLanNetworkInterface_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_2_0/RedfishVLanNetworkInterface_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..5028d73a189 --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_2_0/RedfishVLanNetworkInterface_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VLanNetworkInterface.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVLanNetworkInterface_V1_2_0_Dxe + FILE_GUID = 849f17f2-c447-4176-a420-c8a09b69bde6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVLanNetworkInterface_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishVLanNetworkInterface_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VLanNetworkInterface_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VLanNetworkInterfaceV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VLanNetworkInterface/v1_2_0/VLanNetworkInterface_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_2_0/VLanNetworkInterface_V1_2_0_Dxe.c new file mode 100644 index 00000000000..c6d344f7ab2 --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterface/v1_2_0/VLanNetworkInterface_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VLanNetworkInterface.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VLanNetworkInterface"; +BOOLEAN IsRevisonController = TRUE; + +// Support VLanNetworkInterface V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VLanNetworkInterface", + "1", + "2", + "0" + }, + "VLanNetworkInterface" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_2_0 *VLanNetworkInterfaceV1_2_0; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_2_0_CS *VLanNetworkInterfaceV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VLanNetworkInterface") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VLanNetworkInterface_V1_2_0_To_CS (ResoruceRaw, &VLanNetworkInterfaceV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VLanNetworkInterfaceV1_2_0 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VLANNETWORKINTERFACE_V1_2_0)); + if (VLanNetworkInterfaceV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VLanNetworkInterfaceV1_2_0; + VLanNetworkInterfaceV1_2_0->VLanNetworkInterface = VLanNetworkInterfaceV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterface")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VLanNetworkInterface"), "VLanNetworkInterface"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VLanNetworkInterfaceToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VLanNetworkInterfaceToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VLanNetworkInterface_V1_2_0_JSON (*((EFI_REDFISH_VLANNETWORKINTERFACE_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VLanNetworkInterfaceToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACE_V1_2_0 *VLanNetworkInterfaceV1_2_0; + + VLanNetworkInterfaceV1_2_0 = (EFI_REDFISH_VLANNETWORKINTERFACE_V1_2_0 *)InterpProp; + DestroyVLanNetworkInterface_V1_2_0_CS (VLanNetworkInterfaceV1_2_0->VLanNetworkInterface); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VLanNetworkInterfaceFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVLanNetworkInterface_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VLanNetworkInterfaceToStructWrapper, + VLanNetworkInterfaceToJson, + VLanNetworkInterfaceDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterface_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VLanNetworkInterfaceCollection/RedfishVLanNetworkInterfaceCollection_Dxe.inf b/RedfishClientPkg/Converter/VLanNetworkInterfaceCollection/RedfishVLanNetworkInterfaceCollection_Dxe.inf new file mode 100644 index 00000000000..a1f684a67a3 --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterfaceCollection/RedfishVLanNetworkInterfaceCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VLanNetworkInterfaceCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVLanNetworkInterfaceCollection_Dxe + FILE_GUID = b5ce03eb-4fc7-4c96-8ff3-5fe259d3d997 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVLanNetworkInterfaceCollectionEntryPoint + UNLOAD_IMAGE = RedfishVLanNetworkInterfaceCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VLanNetworkInterfaceCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VLanNetworkInterfaceCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VLanNetworkInterfaceCollection/VLanNetworkInterfaceCollection_Dxe.c b/RedfishClientPkg/Converter/VLanNetworkInterfaceCollection/VLanNetworkInterfaceCollection_Dxe.c new file mode 100644 index 00000000000..7904d628002 --- /dev/null +++ b/RedfishClientPkg/Converter/VLanNetworkInterfaceCollection/VLanNetworkInterfaceCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VLanNetworkInterfaceCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VLanNetworkInterfaceCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support VLanNetworkInterfaceCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VLanNetworkInterfaceCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "VLanNetworkInterfaceCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACECOLLECTION *VLanNetworkInterfaceCollection; + EFI_REDFISH_VLANNETWORKINTERFACECOLLECTION_CS *VLanNetworkInterfaceCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VLanNetworkInterfaceCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VLanNetworkInterfaceCollection_To_CS (ResoruceRaw, &VLanNetworkInterfaceCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + VLanNetworkInterfaceCollection = (EFI_REDFISH_VLANNETWORKINTERFACECOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VLANNETWORKINTERFACECOLLECTION)); + if (VLanNetworkInterfaceCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VLanNetworkInterfaceCollection; + VLanNetworkInterfaceCollection->VLanNetworkInterfaceCollection = VLanNetworkInterfaceCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterfaceCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VLanNetworkInterfaceCollection"), "VLanNetworkInterfaceCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VLanNetworkInterfaceCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VLanNetworkInterfaceCollection"), "VLanNetworkInterfaceCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VLanNetworkInterfaceCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VLanNetworkInterfaceCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VLanNetworkInterfaceCollection_JSON (*((EFI_REDFISH_VLANNETWORKINTERFACECOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VLanNetworkInterfaceCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VLANNETWORKINTERFACECOLLECTION *VLanNetworkInterfaceCollection; + + VLanNetworkInterfaceCollection = (EFI_REDFISH_VLANNETWORKINTERFACECOLLECTION *)InterpProp; + DestroyVLanNetworkInterfaceCollection_CS (VLanNetworkInterfaceCollection->VLanNetworkInterfaceCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VLanNetworkInterfaceCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VLanNetworkInterfaceCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVLanNetworkInterfaceCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterfaceCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VLanNetworkInterfaceCollectionToStructWrapper, + VLanNetworkInterfaceCollectionToJson, + VLanNetworkInterfaceCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVLanNetworkInterfaceCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_0_0/RedfishVirtualMedia_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/VirtualMedia/v1_0_0/RedfishVirtualMedia_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..a2cbc9f0d59 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_0_0/RedfishVirtualMedia_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VirtualMedia.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVirtualMedia_V1_0_0_Dxe + FILE_GUID = 23f16781-5378-43f6-a1fb-2a1157edd0cc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVirtualMedia_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishVirtualMedia_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VirtualMedia_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VirtualMediaV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_0_0/VirtualMedia_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/VirtualMedia/v1_0_0/VirtualMedia_V1_0_0_Dxe.c new file mode 100644 index 00000000000..ba1f6c3c4ae --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_0_0/VirtualMedia_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VirtualMedia.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VirtualMedia"; +BOOLEAN IsRevisonController = TRUE; + +// Support VirtualMedia V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VirtualMedia", + "1", + "0", + "0" + }, + "VirtualMedia" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_0_0 *VirtualMediaV1_0_0; + EFI_REDFISH_VIRTUALMEDIA_V1_0_0_CS *VirtualMediaV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VirtualMedia") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VirtualMedia_V1_0_0_To_CS (ResoruceRaw, &VirtualMediaV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VirtualMediaV1_0_0 = (EFI_REDFISH_VIRTUALMEDIA_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VIRTUALMEDIA_V1_0_0)); + if (VirtualMediaV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VirtualMediaV1_0_0; + VirtualMediaV1_0_0->VirtualMedia = VirtualMediaV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VirtualMediaToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VirtualMediaToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VirtualMedia_V1_0_0_JSON (*((EFI_REDFISH_VIRTUALMEDIA_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VirtualMediaToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_0_0 *VirtualMediaV1_0_0; + + VirtualMediaV1_0_0 = (EFI_REDFISH_VIRTUALMEDIA_V1_0_0 *)InterpProp; + DestroyVirtualMedia_V1_0_0_CS (VirtualMediaV1_0_0->VirtualMedia); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VirtualMediaFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVirtualMedia_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VirtualMediaToStructWrapper, + VirtualMediaToJson, + VirtualMediaDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_0_2/RedfishVirtualMedia_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/VirtualMedia/v1_0_2/RedfishVirtualMedia_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..a2272dc6c14 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_0_2/RedfishVirtualMedia_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VirtualMedia.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVirtualMedia_V1_0_2_Dxe + FILE_GUID = f2b6ac68-da90-4e4c-944d-3ecd3c6dd0fa + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVirtualMedia_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishVirtualMedia_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VirtualMedia_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VirtualMediaV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_0_2/VirtualMedia_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/VirtualMedia/v1_0_2/VirtualMedia_V1_0_2_Dxe.c new file mode 100644 index 00000000000..78529f24319 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_0_2/VirtualMedia_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VirtualMedia.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VirtualMedia"; +BOOLEAN IsRevisonController = TRUE; + +// Support VirtualMedia V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VirtualMedia", + "1", + "0", + "2" + }, + "VirtualMedia" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_0_2 *VirtualMediaV1_0_2; + EFI_REDFISH_VIRTUALMEDIA_V1_0_2_CS *VirtualMediaV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VirtualMedia") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VirtualMedia_V1_0_2_To_CS (ResoruceRaw, &VirtualMediaV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VirtualMediaV1_0_2 = (EFI_REDFISH_VIRTUALMEDIA_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VIRTUALMEDIA_V1_0_2)); + if (VirtualMediaV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VirtualMediaV1_0_2; + VirtualMediaV1_0_2->VirtualMedia = VirtualMediaV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VirtualMediaToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VirtualMediaToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VirtualMedia_V1_0_2_JSON (*((EFI_REDFISH_VIRTUALMEDIA_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VirtualMediaToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_0_2 *VirtualMediaV1_0_2; + + VirtualMediaV1_0_2 = (EFI_REDFISH_VIRTUALMEDIA_V1_0_2 *)InterpProp; + DestroyVirtualMedia_V1_0_2_CS (VirtualMediaV1_0_2->VirtualMedia); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VirtualMediaFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVirtualMedia_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VirtualMediaToStructWrapper, + VirtualMediaToJson, + VirtualMediaDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_0_3/RedfishVirtualMedia_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/VirtualMedia/v1_0_3/RedfishVirtualMedia_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..eb540fe8114 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_0_3/RedfishVirtualMedia_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VirtualMedia.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVirtualMedia_V1_0_3_Dxe + FILE_GUID = 2a418c57-999a-49d3-a293-733dd6e36af7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVirtualMedia_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishVirtualMedia_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VirtualMedia_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VirtualMediaV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_0_3/VirtualMedia_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/VirtualMedia/v1_0_3/VirtualMedia_V1_0_3_Dxe.c new file mode 100644 index 00000000000..7ed988c83e7 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_0_3/VirtualMedia_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VirtualMedia.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VirtualMedia"; +BOOLEAN IsRevisonController = TRUE; + +// Support VirtualMedia V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VirtualMedia", + "1", + "0", + "3" + }, + "VirtualMedia" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_0_3 *VirtualMediaV1_0_3; + EFI_REDFISH_VIRTUALMEDIA_V1_0_3_CS *VirtualMediaV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VirtualMedia") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VirtualMedia_V1_0_3_To_CS (ResoruceRaw, &VirtualMediaV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VirtualMediaV1_0_3 = (EFI_REDFISH_VIRTUALMEDIA_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VIRTUALMEDIA_V1_0_3)); + if (VirtualMediaV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VirtualMediaV1_0_3; + VirtualMediaV1_0_3->VirtualMedia = VirtualMediaV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VirtualMediaToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VirtualMediaToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VirtualMedia_V1_0_3_JSON (*((EFI_REDFISH_VIRTUALMEDIA_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VirtualMediaToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_0_3 *VirtualMediaV1_0_3; + + VirtualMediaV1_0_3 = (EFI_REDFISH_VIRTUALMEDIA_V1_0_3 *)InterpProp; + DestroyVirtualMedia_V1_0_3_CS (VirtualMediaV1_0_3->VirtualMedia); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VirtualMediaFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVirtualMedia_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VirtualMediaToStructWrapper, + VirtualMediaToJson, + VirtualMediaDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_0_4/RedfishVirtualMedia_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/VirtualMedia/v1_0_4/RedfishVirtualMedia_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..54472521bc1 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_0_4/RedfishVirtualMedia_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VirtualMedia.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVirtualMedia_V1_0_4_Dxe + FILE_GUID = 3ee35c06-b068-45fc-9881-b6283349dbc2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVirtualMedia_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishVirtualMedia_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VirtualMedia_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VirtualMediaV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_0_4/VirtualMedia_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/VirtualMedia/v1_0_4/VirtualMedia_V1_0_4_Dxe.c new file mode 100644 index 00000000000..bd720acd4a0 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_0_4/VirtualMedia_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VirtualMedia.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VirtualMedia"; +BOOLEAN IsRevisonController = TRUE; + +// Support VirtualMedia V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VirtualMedia", + "1", + "0", + "4" + }, + "VirtualMedia" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_0_4 *VirtualMediaV1_0_4; + EFI_REDFISH_VIRTUALMEDIA_V1_0_4_CS *VirtualMediaV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VirtualMedia") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VirtualMedia_V1_0_4_To_CS (ResoruceRaw, &VirtualMediaV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VirtualMediaV1_0_4 = (EFI_REDFISH_VIRTUALMEDIA_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VIRTUALMEDIA_V1_0_4)); + if (VirtualMediaV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VirtualMediaV1_0_4; + VirtualMediaV1_0_4->VirtualMedia = VirtualMediaV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VirtualMediaToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VirtualMediaToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VirtualMedia_V1_0_4_JSON (*((EFI_REDFISH_VIRTUALMEDIA_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VirtualMediaToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_0_4 *VirtualMediaV1_0_4; + + VirtualMediaV1_0_4 = (EFI_REDFISH_VIRTUALMEDIA_V1_0_4 *)InterpProp; + DestroyVirtualMedia_V1_0_4_CS (VirtualMediaV1_0_4->VirtualMedia); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VirtualMediaFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVirtualMedia_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VirtualMediaToStructWrapper, + VirtualMediaToJson, + VirtualMediaDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_0_5/RedfishVirtualMedia_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/VirtualMedia/v1_0_5/RedfishVirtualMedia_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..1edb8c9f7cb --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_0_5/RedfishVirtualMedia_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VirtualMedia.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVirtualMedia_V1_0_5_Dxe + FILE_GUID = 132caf28-97ce-4989-8546-c28ea92dcbd8 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVirtualMedia_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishVirtualMedia_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VirtualMedia_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VirtualMediaV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_0_5/VirtualMedia_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/VirtualMedia/v1_0_5/VirtualMedia_V1_0_5_Dxe.c new file mode 100644 index 00000000000..67fbe3343ad --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_0_5/VirtualMedia_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VirtualMedia.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VirtualMedia"; +BOOLEAN IsRevisonController = TRUE; + +// Support VirtualMedia V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VirtualMedia", + "1", + "0", + "5" + }, + "VirtualMedia" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_0_5 *VirtualMediaV1_0_5; + EFI_REDFISH_VIRTUALMEDIA_V1_0_5_CS *VirtualMediaV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VirtualMedia") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VirtualMedia_V1_0_5_To_CS (ResoruceRaw, &VirtualMediaV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VirtualMediaV1_0_5 = (EFI_REDFISH_VIRTUALMEDIA_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VIRTUALMEDIA_V1_0_5)); + if (VirtualMediaV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VirtualMediaV1_0_5; + VirtualMediaV1_0_5->VirtualMedia = VirtualMediaV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VirtualMediaToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VirtualMediaToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VirtualMedia_V1_0_5_JSON (*((EFI_REDFISH_VIRTUALMEDIA_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VirtualMediaToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_0_5 *VirtualMediaV1_0_5; + + VirtualMediaV1_0_5 = (EFI_REDFISH_VIRTUALMEDIA_V1_0_5 *)InterpProp; + DestroyVirtualMedia_V1_0_5_CS (VirtualMediaV1_0_5->VirtualMedia); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VirtualMediaFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVirtualMedia_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VirtualMediaToStructWrapper, + VirtualMediaToJson, + VirtualMediaDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_0_6/RedfishVirtualMedia_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/VirtualMedia/v1_0_6/RedfishVirtualMedia_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..924b76d26aa --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_0_6/RedfishVirtualMedia_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VirtualMedia.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVirtualMedia_V1_0_6_Dxe + FILE_GUID = d2a681e0-0dc6-486b-b03b-66b4da210823 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVirtualMedia_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishVirtualMedia_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VirtualMedia_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VirtualMediaV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_0_6/VirtualMedia_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/VirtualMedia/v1_0_6/VirtualMedia_V1_0_6_Dxe.c new file mode 100644 index 00000000000..663f376168d --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_0_6/VirtualMedia_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VirtualMedia.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VirtualMedia"; +BOOLEAN IsRevisonController = TRUE; + +// Support VirtualMedia V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VirtualMedia", + "1", + "0", + "6" + }, + "VirtualMedia" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_0_6 *VirtualMediaV1_0_6; + EFI_REDFISH_VIRTUALMEDIA_V1_0_6_CS *VirtualMediaV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VirtualMedia") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VirtualMedia_V1_0_6_To_CS (ResoruceRaw, &VirtualMediaV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VirtualMediaV1_0_6 = (EFI_REDFISH_VIRTUALMEDIA_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VIRTUALMEDIA_V1_0_6)); + if (VirtualMediaV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VirtualMediaV1_0_6; + VirtualMediaV1_0_6->VirtualMedia = VirtualMediaV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VirtualMediaToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VirtualMediaToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VirtualMedia_V1_0_6_JSON (*((EFI_REDFISH_VIRTUALMEDIA_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VirtualMediaToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_0_6 *VirtualMediaV1_0_6; + + VirtualMediaV1_0_6 = (EFI_REDFISH_VIRTUALMEDIA_V1_0_6 *)InterpProp; + DestroyVirtualMedia_V1_0_6_CS (VirtualMediaV1_0_6->VirtualMedia); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VirtualMediaFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVirtualMedia_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VirtualMediaToStructWrapper, + VirtualMediaToJson, + VirtualMediaDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_0_7/RedfishVirtualMedia_V1_0_7_Dxe.inf b/RedfishClientPkg/Converter/VirtualMedia/v1_0_7/RedfishVirtualMedia_V1_0_7_Dxe.inf new file mode 100644 index 00000000000..7dac8d30875 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_0_7/RedfishVirtualMedia_V1_0_7_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VirtualMedia.v1_0_7 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVirtualMedia_V1_0_7_Dxe + FILE_GUID = c1adaef8-7639-4fb9-9615-f1e3eab9ff37 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVirtualMedia_V1_0_7EntryPoint + UNLOAD_IMAGE = RedfishVirtualMedia_V1_0_7Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VirtualMedia_V1_0_7_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VirtualMediaV1_0_7Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_0_7/VirtualMedia_V1_0_7_Dxe.c b/RedfishClientPkg/Converter/VirtualMedia/v1_0_7/VirtualMedia_V1_0_7_Dxe.c new file mode 100644 index 00000000000..790ed421748 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_0_7/VirtualMedia_V1_0_7_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VirtualMedia.v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VirtualMedia"; +BOOLEAN IsRevisonController = TRUE; + +// Support VirtualMedia V1_0_7 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VirtualMedia", + "1", + "0", + "7" + }, + "VirtualMedia" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_0_7 *VirtualMediaV1_0_7; + EFI_REDFISH_VIRTUALMEDIA_V1_0_7_CS *VirtualMediaV1_0_7Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "7") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VirtualMedia") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VirtualMedia_V1_0_7_To_CS (ResoruceRaw, &VirtualMediaV1_0_7Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VirtualMediaV1_0_7 = (EFI_REDFISH_VIRTUALMEDIA_V1_0_7 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VIRTUALMEDIA_V1_0_7)); + if (VirtualMediaV1_0_7 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VirtualMediaV1_0_7; + VirtualMediaV1_0_7->VirtualMedia = VirtualMediaV1_0_7Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "7"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VirtualMediaToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VirtualMediaToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VirtualMedia_V1_0_7_JSON (*((EFI_REDFISH_VIRTUALMEDIA_V1_0_7_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VirtualMediaToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_0_7 *VirtualMediaV1_0_7; + + VirtualMediaV1_0_7 = (EFI_REDFISH_VIRTUALMEDIA_V1_0_7 *)InterpProp; + DestroyVirtualMedia_V1_0_7_CS (VirtualMediaV1_0_7->VirtualMedia); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VirtualMediaFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVirtualMedia_V1_0_7_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_0_7EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VirtualMediaToStructWrapper, + VirtualMediaToJson, + VirtualMediaDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_0_7Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_1_0/RedfishVirtualMedia_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/VirtualMedia/v1_1_0/RedfishVirtualMedia_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..ac7d1a5f8de --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_1_0/RedfishVirtualMedia_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VirtualMedia.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVirtualMedia_V1_1_0_Dxe + FILE_GUID = 1d108b81-0818-4319-80c0-d947bd545c5e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVirtualMedia_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishVirtualMedia_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VirtualMedia_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VirtualMediaV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_1_0/VirtualMedia_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/VirtualMedia/v1_1_0/VirtualMedia_V1_1_0_Dxe.c new file mode 100644 index 00000000000..a3a87b2d9ee --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_1_0/VirtualMedia_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VirtualMedia.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VirtualMedia"; +BOOLEAN IsRevisonController = TRUE; + +// Support VirtualMedia V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VirtualMedia", + "1", + "1", + "0" + }, + "VirtualMedia" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_1_0 *VirtualMediaV1_1_0; + EFI_REDFISH_VIRTUALMEDIA_V1_1_0_CS *VirtualMediaV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VirtualMedia") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VirtualMedia_V1_1_0_To_CS (ResoruceRaw, &VirtualMediaV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VirtualMediaV1_1_0 = (EFI_REDFISH_VIRTUALMEDIA_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VIRTUALMEDIA_V1_1_0)); + if (VirtualMediaV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VirtualMediaV1_1_0; + VirtualMediaV1_1_0->VirtualMedia = VirtualMediaV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VirtualMediaToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VirtualMediaToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VirtualMedia_V1_1_0_JSON (*((EFI_REDFISH_VIRTUALMEDIA_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VirtualMediaToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_1_0 *VirtualMediaV1_1_0; + + VirtualMediaV1_1_0 = (EFI_REDFISH_VIRTUALMEDIA_V1_1_0 *)InterpProp; + DestroyVirtualMedia_V1_1_0_CS (VirtualMediaV1_1_0->VirtualMedia); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VirtualMediaFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVirtualMedia_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VirtualMediaToStructWrapper, + VirtualMediaToJson, + VirtualMediaDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_1_1/RedfishVirtualMedia_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/VirtualMedia/v1_1_1/RedfishVirtualMedia_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..4bfbe755f67 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_1_1/RedfishVirtualMedia_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VirtualMedia.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVirtualMedia_V1_1_1_Dxe + FILE_GUID = c4e9d61e-614c-4f7f-8326-d70dbb34cbcb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVirtualMedia_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishVirtualMedia_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VirtualMedia_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VirtualMediaV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_1_1/VirtualMedia_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/VirtualMedia/v1_1_1/VirtualMedia_V1_1_1_Dxe.c new file mode 100644 index 00000000000..b2ee874bfd0 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_1_1/VirtualMedia_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VirtualMedia.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VirtualMedia"; +BOOLEAN IsRevisonController = TRUE; + +// Support VirtualMedia V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VirtualMedia", + "1", + "1", + "1" + }, + "VirtualMedia" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_1_1 *VirtualMediaV1_1_1; + EFI_REDFISH_VIRTUALMEDIA_V1_1_1_CS *VirtualMediaV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VirtualMedia") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VirtualMedia_V1_1_1_To_CS (ResoruceRaw, &VirtualMediaV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VirtualMediaV1_1_1 = (EFI_REDFISH_VIRTUALMEDIA_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VIRTUALMEDIA_V1_1_1)); + if (VirtualMediaV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VirtualMediaV1_1_1; + VirtualMediaV1_1_1->VirtualMedia = VirtualMediaV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VirtualMediaToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VirtualMediaToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VirtualMedia_V1_1_1_JSON (*((EFI_REDFISH_VIRTUALMEDIA_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VirtualMediaToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_1_1 *VirtualMediaV1_1_1; + + VirtualMediaV1_1_1 = (EFI_REDFISH_VIRTUALMEDIA_V1_1_1 *)InterpProp; + DestroyVirtualMedia_V1_1_1_CS (VirtualMediaV1_1_1->VirtualMedia); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VirtualMediaFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVirtualMedia_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VirtualMediaToStructWrapper, + VirtualMediaToJson, + VirtualMediaDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_1_2/RedfishVirtualMedia_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/VirtualMedia/v1_1_2/RedfishVirtualMedia_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..d27e3998594 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_1_2/RedfishVirtualMedia_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VirtualMedia.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVirtualMedia_V1_1_2_Dxe + FILE_GUID = 3a2569c6-3b7a-492d-83a6-310a9ce52973 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVirtualMedia_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishVirtualMedia_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VirtualMedia_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VirtualMediaV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_1_2/VirtualMedia_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/VirtualMedia/v1_1_2/VirtualMedia_V1_1_2_Dxe.c new file mode 100644 index 00000000000..45a8b279766 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_1_2/VirtualMedia_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VirtualMedia.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VirtualMedia"; +BOOLEAN IsRevisonController = TRUE; + +// Support VirtualMedia V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VirtualMedia", + "1", + "1", + "2" + }, + "VirtualMedia" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_1_2 *VirtualMediaV1_1_2; + EFI_REDFISH_VIRTUALMEDIA_V1_1_2_CS *VirtualMediaV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VirtualMedia") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VirtualMedia_V1_1_2_To_CS (ResoruceRaw, &VirtualMediaV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VirtualMediaV1_1_2 = (EFI_REDFISH_VIRTUALMEDIA_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VIRTUALMEDIA_V1_1_2)); + if (VirtualMediaV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VirtualMediaV1_1_2; + VirtualMediaV1_1_2->VirtualMedia = VirtualMediaV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VirtualMediaToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VirtualMediaToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VirtualMedia_V1_1_2_JSON (*((EFI_REDFISH_VIRTUALMEDIA_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VirtualMediaToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_1_2 *VirtualMediaV1_1_2; + + VirtualMediaV1_1_2 = (EFI_REDFISH_VIRTUALMEDIA_V1_1_2 *)InterpProp; + DestroyVirtualMedia_V1_1_2_CS (VirtualMediaV1_1_2->VirtualMedia); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VirtualMediaFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVirtualMedia_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VirtualMediaToStructWrapper, + VirtualMediaToJson, + VirtualMediaDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_1_3/RedfishVirtualMedia_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/VirtualMedia/v1_1_3/RedfishVirtualMedia_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..6b80a500742 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_1_3/RedfishVirtualMedia_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VirtualMedia.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVirtualMedia_V1_1_3_Dxe + FILE_GUID = 3b9a8a78-2ca2-4970-a6cc-21bc2192c0fa + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVirtualMedia_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishVirtualMedia_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VirtualMedia_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VirtualMediaV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_1_3/VirtualMedia_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/VirtualMedia/v1_1_3/VirtualMedia_V1_1_3_Dxe.c new file mode 100644 index 00000000000..debcf920548 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_1_3/VirtualMedia_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VirtualMedia.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VirtualMedia"; +BOOLEAN IsRevisonController = TRUE; + +// Support VirtualMedia V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VirtualMedia", + "1", + "1", + "3" + }, + "VirtualMedia" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_1_3 *VirtualMediaV1_1_3; + EFI_REDFISH_VIRTUALMEDIA_V1_1_3_CS *VirtualMediaV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VirtualMedia") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VirtualMedia_V1_1_3_To_CS (ResoruceRaw, &VirtualMediaV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VirtualMediaV1_1_3 = (EFI_REDFISH_VIRTUALMEDIA_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VIRTUALMEDIA_V1_1_3)); + if (VirtualMediaV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VirtualMediaV1_1_3; + VirtualMediaV1_1_3->VirtualMedia = VirtualMediaV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VirtualMediaToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VirtualMediaToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VirtualMedia_V1_1_3_JSON (*((EFI_REDFISH_VIRTUALMEDIA_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VirtualMediaToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_1_3 *VirtualMediaV1_1_3; + + VirtualMediaV1_1_3 = (EFI_REDFISH_VIRTUALMEDIA_V1_1_3 *)InterpProp; + DestroyVirtualMedia_V1_1_3_CS (VirtualMediaV1_1_3->VirtualMedia); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VirtualMediaFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVirtualMedia_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VirtualMediaToStructWrapper, + VirtualMediaToJson, + VirtualMediaDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_1_4/RedfishVirtualMedia_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/VirtualMedia/v1_1_4/RedfishVirtualMedia_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..2cc75193de3 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_1_4/RedfishVirtualMedia_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VirtualMedia.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVirtualMedia_V1_1_4_Dxe + FILE_GUID = 6b3b6f67-4122-490c-bedd-98b279b0808d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVirtualMedia_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishVirtualMedia_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VirtualMedia_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VirtualMediaV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_1_4/VirtualMedia_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/VirtualMedia/v1_1_4/VirtualMedia_V1_1_4_Dxe.c new file mode 100644 index 00000000000..461f3f3efcf --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_1_4/VirtualMedia_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VirtualMedia.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VirtualMedia"; +BOOLEAN IsRevisonController = TRUE; + +// Support VirtualMedia V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VirtualMedia", + "1", + "1", + "4" + }, + "VirtualMedia" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_1_4 *VirtualMediaV1_1_4; + EFI_REDFISH_VIRTUALMEDIA_V1_1_4_CS *VirtualMediaV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VirtualMedia") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VirtualMedia_V1_1_4_To_CS (ResoruceRaw, &VirtualMediaV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VirtualMediaV1_1_4 = (EFI_REDFISH_VIRTUALMEDIA_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VIRTUALMEDIA_V1_1_4)); + if (VirtualMediaV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VirtualMediaV1_1_4; + VirtualMediaV1_1_4->VirtualMedia = VirtualMediaV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VirtualMediaToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VirtualMediaToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VirtualMedia_V1_1_4_JSON (*((EFI_REDFISH_VIRTUALMEDIA_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VirtualMediaToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_1_4 *VirtualMediaV1_1_4; + + VirtualMediaV1_1_4 = (EFI_REDFISH_VIRTUALMEDIA_V1_1_4 *)InterpProp; + DestroyVirtualMedia_V1_1_4_CS (VirtualMediaV1_1_4->VirtualMedia); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VirtualMediaFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVirtualMedia_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VirtualMediaToStructWrapper, + VirtualMediaToJson, + VirtualMediaDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_1_5/RedfishVirtualMedia_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/VirtualMedia/v1_1_5/RedfishVirtualMedia_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..99779aa2cb4 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_1_5/RedfishVirtualMedia_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VirtualMedia.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVirtualMedia_V1_1_5_Dxe + FILE_GUID = 6805160c-6420-4eef-bab0-ebbf1e3fe38f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVirtualMedia_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishVirtualMedia_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VirtualMedia_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VirtualMediaV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_1_5/VirtualMedia_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/VirtualMedia/v1_1_5/VirtualMedia_V1_1_5_Dxe.c new file mode 100644 index 00000000000..32d673b2e30 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_1_5/VirtualMedia_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VirtualMedia.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VirtualMedia"; +BOOLEAN IsRevisonController = TRUE; + +// Support VirtualMedia V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VirtualMedia", + "1", + "1", + "5" + }, + "VirtualMedia" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_1_5 *VirtualMediaV1_1_5; + EFI_REDFISH_VIRTUALMEDIA_V1_1_5_CS *VirtualMediaV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VirtualMedia") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VirtualMedia_V1_1_5_To_CS (ResoruceRaw, &VirtualMediaV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VirtualMediaV1_1_5 = (EFI_REDFISH_VIRTUALMEDIA_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VIRTUALMEDIA_V1_1_5)); + if (VirtualMediaV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VirtualMediaV1_1_5; + VirtualMediaV1_1_5->VirtualMedia = VirtualMediaV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VirtualMediaToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VirtualMediaToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VirtualMedia_V1_1_5_JSON (*((EFI_REDFISH_VIRTUALMEDIA_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VirtualMediaToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_1_5 *VirtualMediaV1_1_5; + + VirtualMediaV1_1_5 = (EFI_REDFISH_VIRTUALMEDIA_V1_1_5 *)InterpProp; + DestroyVirtualMedia_V1_1_5_CS (VirtualMediaV1_1_5->VirtualMedia); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VirtualMediaFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVirtualMedia_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VirtualMediaToStructWrapper, + VirtualMediaToJson, + VirtualMediaDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_2_0/RedfishVirtualMedia_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/VirtualMedia/v1_2_0/RedfishVirtualMedia_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..da444e4e8eb --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_2_0/RedfishVirtualMedia_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VirtualMedia.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVirtualMedia_V1_2_0_Dxe + FILE_GUID = 8755c35a-ae05-4432-84af-29270ab97d18 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVirtualMedia_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishVirtualMedia_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VirtualMedia_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VirtualMediaV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_2_0/VirtualMedia_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/VirtualMedia/v1_2_0/VirtualMedia_V1_2_0_Dxe.c new file mode 100644 index 00000000000..9ecabed924b --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_2_0/VirtualMedia_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VirtualMedia.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VirtualMedia"; +BOOLEAN IsRevisonController = TRUE; + +// Support VirtualMedia V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VirtualMedia", + "1", + "2", + "0" + }, + "VirtualMedia" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_2_0 *VirtualMediaV1_2_0; + EFI_REDFISH_VIRTUALMEDIA_V1_2_0_CS *VirtualMediaV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VirtualMedia") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VirtualMedia_V1_2_0_To_CS (ResoruceRaw, &VirtualMediaV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VirtualMediaV1_2_0 = (EFI_REDFISH_VIRTUALMEDIA_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VIRTUALMEDIA_V1_2_0)); + if (VirtualMediaV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VirtualMediaV1_2_0; + VirtualMediaV1_2_0->VirtualMedia = VirtualMediaV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VirtualMediaToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VirtualMediaToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VirtualMedia_V1_2_0_JSON (*((EFI_REDFISH_VIRTUALMEDIA_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VirtualMediaToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_2_0 *VirtualMediaV1_2_0; + + VirtualMediaV1_2_0 = (EFI_REDFISH_VIRTUALMEDIA_V1_2_0 *)InterpProp; + DestroyVirtualMedia_V1_2_0_CS (VirtualMediaV1_2_0->VirtualMedia); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VirtualMediaFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVirtualMedia_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VirtualMediaToStructWrapper, + VirtualMediaToJson, + VirtualMediaDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_2_1/RedfishVirtualMedia_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/VirtualMedia/v1_2_1/RedfishVirtualMedia_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..dee1c24c5b9 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_2_1/RedfishVirtualMedia_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VirtualMedia.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVirtualMedia_V1_2_1_Dxe + FILE_GUID = fa4221ca-4afd-4188-a02f-363b591fbd0b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVirtualMedia_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishVirtualMedia_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VirtualMedia_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VirtualMediaV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_2_1/VirtualMedia_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/VirtualMedia/v1_2_1/VirtualMedia_V1_2_1_Dxe.c new file mode 100644 index 00000000000..8af72bf1a68 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_2_1/VirtualMedia_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VirtualMedia.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VirtualMedia"; +BOOLEAN IsRevisonController = TRUE; + +// Support VirtualMedia V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VirtualMedia", + "1", + "2", + "1" + }, + "VirtualMedia" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_2_1 *VirtualMediaV1_2_1; + EFI_REDFISH_VIRTUALMEDIA_V1_2_1_CS *VirtualMediaV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VirtualMedia") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VirtualMedia_V1_2_1_To_CS (ResoruceRaw, &VirtualMediaV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VirtualMediaV1_2_1 = (EFI_REDFISH_VIRTUALMEDIA_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VIRTUALMEDIA_V1_2_1)); + if (VirtualMediaV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VirtualMediaV1_2_1; + VirtualMediaV1_2_1->VirtualMedia = VirtualMediaV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VirtualMediaToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VirtualMediaToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VirtualMedia_V1_2_1_JSON (*((EFI_REDFISH_VIRTUALMEDIA_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VirtualMediaToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_2_1 *VirtualMediaV1_2_1; + + VirtualMediaV1_2_1 = (EFI_REDFISH_VIRTUALMEDIA_V1_2_1 *)InterpProp; + DestroyVirtualMedia_V1_2_1_CS (VirtualMediaV1_2_1->VirtualMedia); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VirtualMediaFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVirtualMedia_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VirtualMediaToStructWrapper, + VirtualMediaToJson, + VirtualMediaDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_2_2/RedfishVirtualMedia_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/VirtualMedia/v1_2_2/RedfishVirtualMedia_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..0c492284b2a --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_2_2/RedfishVirtualMedia_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VirtualMedia.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVirtualMedia_V1_2_2_Dxe + FILE_GUID = f3f22c13-0f52-4d5a-8660-ec811e59f7cf + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVirtualMedia_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishVirtualMedia_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VirtualMedia_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VirtualMediaV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_2_2/VirtualMedia_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/VirtualMedia/v1_2_2/VirtualMedia_V1_2_2_Dxe.c new file mode 100644 index 00000000000..370b6dbc6cb --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_2_2/VirtualMedia_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VirtualMedia.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VirtualMedia"; +BOOLEAN IsRevisonController = TRUE; + +// Support VirtualMedia V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VirtualMedia", + "1", + "2", + "2" + }, + "VirtualMedia" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_2_2 *VirtualMediaV1_2_2; + EFI_REDFISH_VIRTUALMEDIA_V1_2_2_CS *VirtualMediaV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VirtualMedia") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VirtualMedia_V1_2_2_To_CS (ResoruceRaw, &VirtualMediaV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VirtualMediaV1_2_2 = (EFI_REDFISH_VIRTUALMEDIA_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VIRTUALMEDIA_V1_2_2)); + if (VirtualMediaV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VirtualMediaV1_2_2; + VirtualMediaV1_2_2->VirtualMedia = VirtualMediaV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VirtualMediaToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VirtualMediaToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VirtualMedia_V1_2_2_JSON (*((EFI_REDFISH_VIRTUALMEDIA_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VirtualMediaToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_2_2 *VirtualMediaV1_2_2; + + VirtualMediaV1_2_2 = (EFI_REDFISH_VIRTUALMEDIA_V1_2_2 *)InterpProp; + DestroyVirtualMedia_V1_2_2_CS (VirtualMediaV1_2_2->VirtualMedia); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VirtualMediaFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVirtualMedia_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VirtualMediaToStructWrapper, + VirtualMediaToJson, + VirtualMediaDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_2_3/RedfishVirtualMedia_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/VirtualMedia/v1_2_3/RedfishVirtualMedia_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..201b1f7d6f9 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_2_3/RedfishVirtualMedia_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VirtualMedia.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVirtualMedia_V1_2_3_Dxe + FILE_GUID = 319fe9fd-6756-48a6-b268-543bbf7e172b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVirtualMedia_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishVirtualMedia_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VirtualMedia_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VirtualMediaV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_2_3/VirtualMedia_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/VirtualMedia/v1_2_3/VirtualMedia_V1_2_3_Dxe.c new file mode 100644 index 00000000000..1fc64cca2b0 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_2_3/VirtualMedia_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VirtualMedia.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VirtualMedia"; +BOOLEAN IsRevisonController = TRUE; + +// Support VirtualMedia V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VirtualMedia", + "1", + "2", + "3" + }, + "VirtualMedia" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_2_3 *VirtualMediaV1_2_3; + EFI_REDFISH_VIRTUALMEDIA_V1_2_3_CS *VirtualMediaV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VirtualMedia") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VirtualMedia_V1_2_3_To_CS (ResoruceRaw, &VirtualMediaV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VirtualMediaV1_2_3 = (EFI_REDFISH_VIRTUALMEDIA_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VIRTUALMEDIA_V1_2_3)); + if (VirtualMediaV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VirtualMediaV1_2_3; + VirtualMediaV1_2_3->VirtualMedia = VirtualMediaV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VirtualMediaToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VirtualMediaToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VirtualMedia_V1_2_3_JSON (*((EFI_REDFISH_VIRTUALMEDIA_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VirtualMediaToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_2_3 *VirtualMediaV1_2_3; + + VirtualMediaV1_2_3 = (EFI_REDFISH_VIRTUALMEDIA_V1_2_3 *)InterpProp; + DestroyVirtualMedia_V1_2_3_CS (VirtualMediaV1_2_3->VirtualMedia); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VirtualMediaFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVirtualMedia_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VirtualMediaToStructWrapper, + VirtualMediaToJson, + VirtualMediaDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_2_4/RedfishVirtualMedia_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/VirtualMedia/v1_2_4/RedfishVirtualMedia_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..c4d73ef63e2 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_2_4/RedfishVirtualMedia_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VirtualMedia.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVirtualMedia_V1_2_4_Dxe + FILE_GUID = 9bcc7d8f-8903-43f6-9175-0a64f300587b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVirtualMedia_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishVirtualMedia_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VirtualMedia_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VirtualMediaV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_2_4/VirtualMedia_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/VirtualMedia/v1_2_4/VirtualMedia_V1_2_4_Dxe.c new file mode 100644 index 00000000000..a7b8f419de9 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_2_4/VirtualMedia_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VirtualMedia.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VirtualMedia"; +BOOLEAN IsRevisonController = TRUE; + +// Support VirtualMedia V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VirtualMedia", + "1", + "2", + "4" + }, + "VirtualMedia" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_2_4 *VirtualMediaV1_2_4; + EFI_REDFISH_VIRTUALMEDIA_V1_2_4_CS *VirtualMediaV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VirtualMedia") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VirtualMedia_V1_2_4_To_CS (ResoruceRaw, &VirtualMediaV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VirtualMediaV1_2_4 = (EFI_REDFISH_VIRTUALMEDIA_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VIRTUALMEDIA_V1_2_4)); + if (VirtualMediaV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VirtualMediaV1_2_4; + VirtualMediaV1_2_4->VirtualMedia = VirtualMediaV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VirtualMediaToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VirtualMediaToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VirtualMedia_V1_2_4_JSON (*((EFI_REDFISH_VIRTUALMEDIA_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VirtualMediaToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_2_4 *VirtualMediaV1_2_4; + + VirtualMediaV1_2_4 = (EFI_REDFISH_VIRTUALMEDIA_V1_2_4 *)InterpProp; + DestroyVirtualMedia_V1_2_4_CS (VirtualMediaV1_2_4->VirtualMedia); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VirtualMediaFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVirtualMedia_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VirtualMediaToStructWrapper, + VirtualMediaToJson, + VirtualMediaDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_3_0/RedfishVirtualMedia_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/VirtualMedia/v1_3_0/RedfishVirtualMedia_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..d8aee473c49 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_3_0/RedfishVirtualMedia_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VirtualMedia.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVirtualMedia_V1_3_0_Dxe + FILE_GUID = bbdc70a3-f931-468b-9c65-642647867991 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVirtualMedia_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishVirtualMedia_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VirtualMedia_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VirtualMediaV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_3_0/VirtualMedia_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/VirtualMedia/v1_3_0/VirtualMedia_V1_3_0_Dxe.c new file mode 100644 index 00000000000..3e253e06d68 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_3_0/VirtualMedia_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VirtualMedia.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VirtualMedia"; +BOOLEAN IsRevisonController = TRUE; + +// Support VirtualMedia V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VirtualMedia", + "1", + "3", + "0" + }, + "VirtualMedia" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_3_0 *VirtualMediaV1_3_0; + EFI_REDFISH_VIRTUALMEDIA_V1_3_0_CS *VirtualMediaV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VirtualMedia") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VirtualMedia_V1_3_0_To_CS (ResoruceRaw, &VirtualMediaV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VirtualMediaV1_3_0 = (EFI_REDFISH_VIRTUALMEDIA_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VIRTUALMEDIA_V1_3_0)); + if (VirtualMediaV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VirtualMediaV1_3_0; + VirtualMediaV1_3_0->VirtualMedia = VirtualMediaV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VirtualMediaToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VirtualMediaToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VirtualMedia_V1_3_0_JSON (*((EFI_REDFISH_VIRTUALMEDIA_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VirtualMediaToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_3_0 *VirtualMediaV1_3_0; + + VirtualMediaV1_3_0 = (EFI_REDFISH_VIRTUALMEDIA_V1_3_0 *)InterpProp; + DestroyVirtualMedia_V1_3_0_CS (VirtualMediaV1_3_0->VirtualMedia); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VirtualMediaFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVirtualMedia_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VirtualMediaToStructWrapper, + VirtualMediaToJson, + VirtualMediaDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_3_1/RedfishVirtualMedia_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/VirtualMedia/v1_3_1/RedfishVirtualMedia_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..7848930d3fc --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_3_1/RedfishVirtualMedia_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VirtualMedia.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVirtualMedia_V1_3_1_Dxe + FILE_GUID = d1fab971-a4b3-4110-b500-b021af0a7fa9 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVirtualMedia_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishVirtualMedia_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VirtualMedia_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VirtualMediaV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_3_1/VirtualMedia_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/VirtualMedia/v1_3_1/VirtualMedia_V1_3_1_Dxe.c new file mode 100644 index 00000000000..096ce6394c7 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_3_1/VirtualMedia_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VirtualMedia.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VirtualMedia"; +BOOLEAN IsRevisonController = TRUE; + +// Support VirtualMedia V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VirtualMedia", + "1", + "3", + "1" + }, + "VirtualMedia" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_3_1 *VirtualMediaV1_3_1; + EFI_REDFISH_VIRTUALMEDIA_V1_3_1_CS *VirtualMediaV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VirtualMedia") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VirtualMedia_V1_3_1_To_CS (ResoruceRaw, &VirtualMediaV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VirtualMediaV1_3_1 = (EFI_REDFISH_VIRTUALMEDIA_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VIRTUALMEDIA_V1_3_1)); + if (VirtualMediaV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VirtualMediaV1_3_1; + VirtualMediaV1_3_1->VirtualMedia = VirtualMediaV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VirtualMediaToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VirtualMediaToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VirtualMedia_V1_3_1_JSON (*((EFI_REDFISH_VIRTUALMEDIA_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VirtualMediaToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_3_1 *VirtualMediaV1_3_1; + + VirtualMediaV1_3_1 = (EFI_REDFISH_VIRTUALMEDIA_V1_3_1 *)InterpProp; + DestroyVirtualMedia_V1_3_1_CS (VirtualMediaV1_3_1->VirtualMedia); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VirtualMediaFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVirtualMedia_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VirtualMediaToStructWrapper, + VirtualMediaToJson, + VirtualMediaDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_3_2/RedfishVirtualMedia_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/VirtualMedia/v1_3_2/RedfishVirtualMedia_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..2bd212fa2b3 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_3_2/RedfishVirtualMedia_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VirtualMedia.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVirtualMedia_V1_3_2_Dxe + FILE_GUID = 469ed073-883f-4ca0-b167-b30ed0ae7b1a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVirtualMedia_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishVirtualMedia_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VirtualMedia_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VirtualMediaV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VirtualMedia/v1_3_2/VirtualMedia_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/VirtualMedia/v1_3_2/VirtualMedia_V1_3_2_Dxe.c new file mode 100644 index 00000000000..5534eac3883 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMedia/v1_3_2/VirtualMedia_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VirtualMedia.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VirtualMedia"; +BOOLEAN IsRevisonController = TRUE; + +// Support VirtualMedia V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VirtualMedia", + "1", + "3", + "2" + }, + "VirtualMedia" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_3_2 *VirtualMediaV1_3_2; + EFI_REDFISH_VIRTUALMEDIA_V1_3_2_CS *VirtualMediaV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VirtualMedia") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VirtualMedia_V1_3_2_To_CS (ResoruceRaw, &VirtualMediaV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VirtualMediaV1_3_2 = (EFI_REDFISH_VIRTUALMEDIA_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VIRTUALMEDIA_V1_3_2)); + if (VirtualMediaV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VirtualMediaV1_3_2; + VirtualMediaV1_3_2->VirtualMedia = VirtualMediaV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMedia")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VirtualMedia"), "VirtualMedia"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VirtualMediaToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VirtualMediaToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VirtualMedia_V1_3_2_JSON (*((EFI_REDFISH_VIRTUALMEDIA_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VirtualMediaToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIA_V1_3_2 *VirtualMediaV1_3_2; + + VirtualMediaV1_3_2 = (EFI_REDFISH_VIRTUALMEDIA_V1_3_2 *)InterpProp; + DestroyVirtualMedia_V1_3_2_CS (VirtualMediaV1_3_2->VirtualMedia); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VirtualMediaFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVirtualMedia_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VirtualMediaToStructWrapper, + VirtualMediaToJson, + VirtualMediaDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMedia_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VirtualMediaCollection/RedfishVirtualMediaCollection_Dxe.inf b/RedfishClientPkg/Converter/VirtualMediaCollection/RedfishVirtualMediaCollection_Dxe.inf new file mode 100644 index 00000000000..e3b519d6aef --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMediaCollection/RedfishVirtualMediaCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VirtualMediaCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVirtualMediaCollection_Dxe + FILE_GUID = e32bbaa1-25d6-4a8d-98ec-9c163e317bb7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVirtualMediaCollectionEntryPoint + UNLOAD_IMAGE = RedfishVirtualMediaCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VirtualMediaCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VirtualMediaCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VirtualMediaCollection/VirtualMediaCollection_Dxe.c b/RedfishClientPkg/Converter/VirtualMediaCollection/VirtualMediaCollection_Dxe.c new file mode 100644 index 00000000000..2b892281757 --- /dev/null +++ b/RedfishClientPkg/Converter/VirtualMediaCollection/VirtualMediaCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VirtualMediaCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VirtualMediaCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support VirtualMediaCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VirtualMediaCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "VirtualMediaCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIACOLLECTION *VirtualMediaCollection; + EFI_REDFISH_VIRTUALMEDIACOLLECTION_CS *VirtualMediaCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VirtualMediaCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VirtualMediaCollection_To_CS (ResoruceRaw, &VirtualMediaCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + VirtualMediaCollection = (EFI_REDFISH_VIRTUALMEDIACOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VIRTUALMEDIACOLLECTION)); + if (VirtualMediaCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VirtualMediaCollection; + VirtualMediaCollection->VirtualMediaCollection = VirtualMediaCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMediaCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VirtualMediaCollection"), "VirtualMediaCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VirtualMediaCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VirtualMediaCollection"), "VirtualMediaCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VirtualMediaCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VirtualMediaCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VirtualMediaCollection_JSON (*((EFI_REDFISH_VIRTUALMEDIACOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VirtualMediaCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VIRTUALMEDIACOLLECTION *VirtualMediaCollection; + + VirtualMediaCollection = (EFI_REDFISH_VIRTUALMEDIACOLLECTION *)InterpProp; + DestroyVirtualMediaCollection_CS (VirtualMediaCollection->VirtualMediaCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VirtualMediaCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VirtualMediaCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVirtualMediaCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMediaCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VirtualMediaCollectionToStructWrapper, + VirtualMediaCollectionToJson, + VirtualMediaCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVirtualMediaCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_0_0/RedfishVolume_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_0_0/RedfishVolume_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..4c3cb98fc9c --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_0_0/RedfishVolume_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_0_0_Dxe + FILE_GUID = e85afb6b-e5cc-4167-bf94-2e01243e4e24 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_0_0/Volume_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_0_0/Volume_V1_0_0_Dxe.c new file mode 100644 index 00000000000..1ce19571dec --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_0_0/Volume_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "0", + "0" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_0_0 *VolumeV1_0_0; + EFI_REDFISH_VOLUME_V1_0_0_CS *VolumeV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_0_0_To_CS (ResoruceRaw, &VolumeV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_0_0 = (EFI_REDFISH_VOLUME_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_0_0)); + if (VolumeV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_0_0; + VolumeV1_0_0->Volume = VolumeV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_0_0_JSON (*((EFI_REDFISH_VOLUME_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_0_0 *VolumeV1_0_0; + + VolumeV1_0_0 = (EFI_REDFISH_VOLUME_V1_0_0 *)InterpProp; + DestroyVolume_V1_0_0_CS (VolumeV1_0_0->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_0_1/RedfishVolume_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_0_1/RedfishVolume_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..f59cf6b0c1e --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_0_1/RedfishVolume_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_0_1_Dxe + FILE_GUID = b16f3ab2-bade-4702-bd86-f673dacf835e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_0_1/Volume_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_0_1/Volume_V1_0_1_Dxe.c new file mode 100644 index 00000000000..931b0d29632 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_0_1/Volume_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "0", + "1" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_0_1 *VolumeV1_0_1; + EFI_REDFISH_VOLUME_V1_0_1_CS *VolumeV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_0_1_To_CS (ResoruceRaw, &VolumeV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_0_1 = (EFI_REDFISH_VOLUME_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_0_1)); + if (VolumeV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_0_1; + VolumeV1_0_1->Volume = VolumeV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_0_1_JSON (*((EFI_REDFISH_VOLUME_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_0_1 *VolumeV1_0_1; + + VolumeV1_0_1 = (EFI_REDFISH_VOLUME_V1_0_1 *)InterpProp; + DestroyVolume_V1_0_1_CS (VolumeV1_0_1->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_0_2/RedfishVolume_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_0_2/RedfishVolume_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..efd318756ee --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_0_2/RedfishVolume_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_0_2_Dxe + FILE_GUID = f78bbd93-cc29-47f4-9428-276f99e57045 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_0_2/Volume_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_0_2/Volume_V1_0_2_Dxe.c new file mode 100644 index 00000000000..267fe54fa0d --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_0_2/Volume_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "0", + "2" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_0_2 *VolumeV1_0_2; + EFI_REDFISH_VOLUME_V1_0_2_CS *VolumeV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_0_2_To_CS (ResoruceRaw, &VolumeV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_0_2 = (EFI_REDFISH_VOLUME_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_0_2)); + if (VolumeV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_0_2; + VolumeV1_0_2->Volume = VolumeV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_0_2_JSON (*((EFI_REDFISH_VOLUME_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_0_2 *VolumeV1_0_2; + + VolumeV1_0_2 = (EFI_REDFISH_VOLUME_V1_0_2 *)InterpProp; + DestroyVolume_V1_0_2_CS (VolumeV1_0_2->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_0_3/RedfishVolume_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_0_3/RedfishVolume_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..90ee4a8c5bf --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_0_3/RedfishVolume_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_0_3_Dxe + FILE_GUID = 554b1ac3-afca-4d37-9383-7cc79a046825 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_0_3/Volume_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_0_3/Volume_V1_0_3_Dxe.c new file mode 100644 index 00000000000..38979555a58 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_0_3/Volume_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "0", + "3" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_0_3 *VolumeV1_0_3; + EFI_REDFISH_VOLUME_V1_0_3_CS *VolumeV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_0_3_To_CS (ResoruceRaw, &VolumeV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_0_3 = (EFI_REDFISH_VOLUME_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_0_3)); + if (VolumeV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_0_3; + VolumeV1_0_3->Volume = VolumeV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_0_3_JSON (*((EFI_REDFISH_VOLUME_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_0_3 *VolumeV1_0_3; + + VolumeV1_0_3 = (EFI_REDFISH_VOLUME_V1_0_3 *)InterpProp; + DestroyVolume_V1_0_3_CS (VolumeV1_0_3->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_0_4/RedfishVolume_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_0_4/RedfishVolume_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..bd9574ebc6c --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_0_4/RedfishVolume_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_0_4_Dxe + FILE_GUID = 94f35caf-b064-4ead-a58a-b24d773dbf98 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_0_4/Volume_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_0_4/Volume_V1_0_4_Dxe.c new file mode 100644 index 00000000000..ec6b89d6f7b --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_0_4/Volume_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "0", + "4" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_0_4 *VolumeV1_0_4; + EFI_REDFISH_VOLUME_V1_0_4_CS *VolumeV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_0_4_To_CS (ResoruceRaw, &VolumeV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_0_4 = (EFI_REDFISH_VOLUME_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_0_4)); + if (VolumeV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_0_4; + VolumeV1_0_4->Volume = VolumeV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_0_4_JSON (*((EFI_REDFISH_VOLUME_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_0_4 *VolumeV1_0_4; + + VolumeV1_0_4 = (EFI_REDFISH_VOLUME_V1_0_4 *)InterpProp; + DestroyVolume_V1_0_4_CS (VolumeV1_0_4->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_1_0/RedfishVolume_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_1_0/RedfishVolume_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..c892a1b1ce2 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_1_0/RedfishVolume_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_1_0_Dxe + FILE_GUID = 2bc9747d-7935-42de-88dc-1f9b77899c6d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_1_0/Volume_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_1_0/Volume_V1_1_0_Dxe.c new file mode 100644 index 00000000000..ab18f872dbf --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_1_0/Volume_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "1", + "0" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_1_0 *VolumeV1_1_0; + EFI_REDFISH_VOLUME_V1_1_0_CS *VolumeV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_1_0_To_CS (ResoruceRaw, &VolumeV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_1_0 = (EFI_REDFISH_VOLUME_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_1_0)); + if (VolumeV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_1_0; + VolumeV1_1_0->Volume = VolumeV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_1_0_JSON (*((EFI_REDFISH_VOLUME_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_1_0 *VolumeV1_1_0; + + VolumeV1_1_0 = (EFI_REDFISH_VOLUME_V1_1_0 *)InterpProp; + DestroyVolume_V1_1_0_CS (VolumeV1_1_0->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_1_1/RedfishVolume_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_1_1/RedfishVolume_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..f319ee48fe3 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_1_1/RedfishVolume_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_1_1_Dxe + FILE_GUID = 6eb3ee8f-3ed2-447b-96c7-16622d5d300b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_1_1/Volume_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_1_1/Volume_V1_1_1_Dxe.c new file mode 100644 index 00000000000..d8d1c22e081 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_1_1/Volume_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "1", + "1" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_1_1 *VolumeV1_1_1; + EFI_REDFISH_VOLUME_V1_1_1_CS *VolumeV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_1_1_To_CS (ResoruceRaw, &VolumeV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_1_1 = (EFI_REDFISH_VOLUME_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_1_1)); + if (VolumeV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_1_1; + VolumeV1_1_1->Volume = VolumeV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_1_1_JSON (*((EFI_REDFISH_VOLUME_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_1_1 *VolumeV1_1_1; + + VolumeV1_1_1 = (EFI_REDFISH_VOLUME_V1_1_1 *)InterpProp; + DestroyVolume_V1_1_1_CS (VolumeV1_1_1->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_1_2/RedfishVolume_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_1_2/RedfishVolume_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..17613d40788 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_1_2/RedfishVolume_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_1_2_Dxe + FILE_GUID = b72d7566-29b2-4ba8-a64b-f88d00187feb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_1_2/Volume_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_1_2/Volume_V1_1_2_Dxe.c new file mode 100644 index 00000000000..ab712151d63 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_1_2/Volume_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "1", + "2" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_1_2 *VolumeV1_1_2; + EFI_REDFISH_VOLUME_V1_1_2_CS *VolumeV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_1_2_To_CS (ResoruceRaw, &VolumeV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_1_2 = (EFI_REDFISH_VOLUME_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_1_2)); + if (VolumeV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_1_2; + VolumeV1_1_2->Volume = VolumeV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_1_2_JSON (*((EFI_REDFISH_VOLUME_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_1_2 *VolumeV1_1_2; + + VolumeV1_1_2 = (EFI_REDFISH_VOLUME_V1_1_2 *)InterpProp; + DestroyVolume_V1_1_2_CS (VolumeV1_1_2->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_1_3/RedfishVolume_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_1_3/RedfishVolume_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..5f18dbcb0ed --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_1_3/RedfishVolume_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_1_3_Dxe + FILE_GUID = 7790bb4c-a21c-43fa-9723-f31904c759f7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_1_3/Volume_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_1_3/Volume_V1_1_3_Dxe.c new file mode 100644 index 00000000000..166953f8a7f --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_1_3/Volume_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "1", + "3" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_1_3 *VolumeV1_1_3; + EFI_REDFISH_VOLUME_V1_1_3_CS *VolumeV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_1_3_To_CS (ResoruceRaw, &VolumeV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_1_3 = (EFI_REDFISH_VOLUME_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_1_3)); + if (VolumeV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_1_3; + VolumeV1_1_3->Volume = VolumeV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_1_3_JSON (*((EFI_REDFISH_VOLUME_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_1_3 *VolumeV1_1_3; + + VolumeV1_1_3 = (EFI_REDFISH_VOLUME_V1_1_3 *)InterpProp; + DestroyVolume_V1_1_3_CS (VolumeV1_1_3->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_1_4/RedfishVolume_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_1_4/RedfishVolume_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..1bf5de5daf5 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_1_4/RedfishVolume_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_1_4_Dxe + FILE_GUID = c4312132-0a0c-4798-b46b-810f24d9f200 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_1_4/Volume_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_1_4/Volume_V1_1_4_Dxe.c new file mode 100644 index 00000000000..71236778d78 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_1_4/Volume_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "1", + "4" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_1_4 *VolumeV1_1_4; + EFI_REDFISH_VOLUME_V1_1_4_CS *VolumeV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_1_4_To_CS (ResoruceRaw, &VolumeV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_1_4 = (EFI_REDFISH_VOLUME_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_1_4)); + if (VolumeV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_1_4; + VolumeV1_1_4->Volume = VolumeV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_1_4_JSON (*((EFI_REDFISH_VOLUME_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_1_4 *VolumeV1_1_4; + + VolumeV1_1_4 = (EFI_REDFISH_VOLUME_V1_1_4 *)InterpProp; + DestroyVolume_V1_1_4_CS (VolumeV1_1_4->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_1_5/RedfishVolume_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_1_5/RedfishVolume_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..204434b1a6f --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_1_5/RedfishVolume_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_1_5_Dxe + FILE_GUID = f123098c-4bc0-4eb5-9ec6-eac2b1235580 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_1_5/Volume_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_1_5/Volume_V1_1_5_Dxe.c new file mode 100644 index 00000000000..56d20c9ae2e --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_1_5/Volume_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "1", + "5" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_1_5 *VolumeV1_1_5; + EFI_REDFISH_VOLUME_V1_1_5_CS *VolumeV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_1_5_To_CS (ResoruceRaw, &VolumeV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_1_5 = (EFI_REDFISH_VOLUME_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_1_5)); + if (VolumeV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_1_5; + VolumeV1_1_5->Volume = VolumeV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_1_5_JSON (*((EFI_REDFISH_VOLUME_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_1_5 *VolumeV1_1_5; + + VolumeV1_1_5 = (EFI_REDFISH_VOLUME_V1_1_5 *)InterpProp; + DestroyVolume_V1_1_5_CS (VolumeV1_1_5->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_2_0/RedfishVolume_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_2_0/RedfishVolume_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..ec0ec77ceed --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_2_0/RedfishVolume_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_2_0_Dxe + FILE_GUID = e317b77f-4892-40d0-821f-ab5920ed4111 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_2_0/Volume_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_2_0/Volume_V1_2_0_Dxe.c new file mode 100644 index 00000000000..1b741a933d4 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_2_0/Volume_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "2", + "0" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_2_0 *VolumeV1_2_0; + EFI_REDFISH_VOLUME_V1_2_0_CS *VolumeV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_2_0_To_CS (ResoruceRaw, &VolumeV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_2_0 = (EFI_REDFISH_VOLUME_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_2_0)); + if (VolumeV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_2_0; + VolumeV1_2_0->Volume = VolumeV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_2_0_JSON (*((EFI_REDFISH_VOLUME_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_2_0 *VolumeV1_2_0; + + VolumeV1_2_0 = (EFI_REDFISH_VOLUME_V1_2_0 *)InterpProp; + DestroyVolume_V1_2_0_CS (VolumeV1_2_0->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_2_1/RedfishVolume_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_2_1/RedfishVolume_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..20aa4fd37db --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_2_1/RedfishVolume_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_2_1_Dxe + FILE_GUID = a3964580-93a4-4e15-8596-cd4d2640a773 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_2_1/Volume_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_2_1/Volume_V1_2_1_Dxe.c new file mode 100644 index 00000000000..d8ba9781fdd --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_2_1/Volume_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "2", + "1" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_2_1 *VolumeV1_2_1; + EFI_REDFISH_VOLUME_V1_2_1_CS *VolumeV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_2_1_To_CS (ResoruceRaw, &VolumeV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_2_1 = (EFI_REDFISH_VOLUME_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_2_1)); + if (VolumeV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_2_1; + VolumeV1_2_1->Volume = VolumeV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_2_1_JSON (*((EFI_REDFISH_VOLUME_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_2_1 *VolumeV1_2_1; + + VolumeV1_2_1 = (EFI_REDFISH_VOLUME_V1_2_1 *)InterpProp; + DestroyVolume_V1_2_1_CS (VolumeV1_2_1->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_2_2/RedfishVolume_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_2_2/RedfishVolume_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..cbe9da173ac --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_2_2/RedfishVolume_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_2_2_Dxe + FILE_GUID = 25055f61-73e2-49fc-bd06-cde14913f241 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_2_2/Volume_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_2_2/Volume_V1_2_2_Dxe.c new file mode 100644 index 00000000000..39c4a93da21 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_2_2/Volume_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "2", + "2" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_2_2 *VolumeV1_2_2; + EFI_REDFISH_VOLUME_V1_2_2_CS *VolumeV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_2_2_To_CS (ResoruceRaw, &VolumeV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_2_2 = (EFI_REDFISH_VOLUME_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_2_2)); + if (VolumeV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_2_2; + VolumeV1_2_2->Volume = VolumeV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_2_2_JSON (*((EFI_REDFISH_VOLUME_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_2_2 *VolumeV1_2_2; + + VolumeV1_2_2 = (EFI_REDFISH_VOLUME_V1_2_2 *)InterpProp; + DestroyVolume_V1_2_2_CS (VolumeV1_2_2->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_2_3/RedfishVolume_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_2_3/RedfishVolume_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..465c4db374b --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_2_3/RedfishVolume_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_2_3_Dxe + FILE_GUID = 73bbd14f-7b1a-44bb-9f5a-ef304e9b43e5 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_2_3/Volume_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_2_3/Volume_V1_2_3_Dxe.c new file mode 100644 index 00000000000..33efb276870 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_2_3/Volume_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "2", + "3" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_2_3 *VolumeV1_2_3; + EFI_REDFISH_VOLUME_V1_2_3_CS *VolumeV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_2_3_To_CS (ResoruceRaw, &VolumeV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_2_3 = (EFI_REDFISH_VOLUME_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_2_3)); + if (VolumeV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_2_3; + VolumeV1_2_3->Volume = VolumeV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_2_3_JSON (*((EFI_REDFISH_VOLUME_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_2_3 *VolumeV1_2_3; + + VolumeV1_2_3 = (EFI_REDFISH_VOLUME_V1_2_3 *)InterpProp; + DestroyVolume_V1_2_3_CS (VolumeV1_2_3->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_2_4/RedfishVolume_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_2_4/RedfishVolume_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..b2bf2ce5664 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_2_4/RedfishVolume_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_2_4_Dxe + FILE_GUID = b7b35ab7-bd33-4709-a035-53ab4b8fa0e2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_2_4/Volume_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_2_4/Volume_V1_2_4_Dxe.c new file mode 100644 index 00000000000..27c7f152423 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_2_4/Volume_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "2", + "4" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_2_4 *VolumeV1_2_4; + EFI_REDFISH_VOLUME_V1_2_4_CS *VolumeV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_2_4_To_CS (ResoruceRaw, &VolumeV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_2_4 = (EFI_REDFISH_VOLUME_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_2_4)); + if (VolumeV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_2_4; + VolumeV1_2_4->Volume = VolumeV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_2_4_JSON (*((EFI_REDFISH_VOLUME_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_2_4 *VolumeV1_2_4; + + VolumeV1_2_4 = (EFI_REDFISH_VOLUME_V1_2_4 *)InterpProp; + DestroyVolume_V1_2_4_CS (VolumeV1_2_4->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_2_5/RedfishVolume_V1_2_5_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_2_5/RedfishVolume_V1_2_5_Dxe.inf new file mode 100644 index 00000000000..2ddb05a37c9 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_2_5/RedfishVolume_V1_2_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_2_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_2_5_Dxe + FILE_GUID = 9eee9df9-552d-4ed3-a4ad-daf36dc1db86 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_2_5EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_2_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_2_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_2_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_2_5/Volume_V1_2_5_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_2_5/Volume_V1_2_5_Dxe.c new file mode 100644 index 00000000000..013a0cf23b2 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_2_5/Volume_V1_2_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_2_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "2", + "5" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_2_5 *VolumeV1_2_5; + EFI_REDFISH_VOLUME_V1_2_5_CS *VolumeV1_2_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_2_5_To_CS (ResoruceRaw, &VolumeV1_2_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_2_5 = (EFI_REDFISH_VOLUME_V1_2_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_2_5)); + if (VolumeV1_2_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_2_5; + VolumeV1_2_5->Volume = VolumeV1_2_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_2_5_JSON (*((EFI_REDFISH_VOLUME_V1_2_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_2_5 *VolumeV1_2_5; + + VolumeV1_2_5 = (EFI_REDFISH_VOLUME_V1_2_5 *)InterpProp; + DestroyVolume_V1_2_5_CS (VolumeV1_2_5->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_2_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_2_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_2_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_3_0/RedfishVolume_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_3_0/RedfishVolume_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..03a1daf62c3 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_3_0/RedfishVolume_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_3_0_Dxe + FILE_GUID = 254d496f-c49a-4f03-9d0b-28232f6f54ab + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_3_0/Volume_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_3_0/Volume_V1_3_0_Dxe.c new file mode 100644 index 00000000000..3fe89053be0 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_3_0/Volume_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "3", + "0" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_3_0 *VolumeV1_3_0; + EFI_REDFISH_VOLUME_V1_3_0_CS *VolumeV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_3_0_To_CS (ResoruceRaw, &VolumeV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_3_0 = (EFI_REDFISH_VOLUME_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_3_0)); + if (VolumeV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_3_0; + VolumeV1_3_0->Volume = VolumeV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_3_0_JSON (*((EFI_REDFISH_VOLUME_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_3_0 *VolumeV1_3_0; + + VolumeV1_3_0 = (EFI_REDFISH_VOLUME_V1_3_0 *)InterpProp; + DestroyVolume_V1_3_0_CS (VolumeV1_3_0->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_3_1/RedfishVolume_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_3_1/RedfishVolume_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..02b5cdf44f7 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_3_1/RedfishVolume_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_3_1_Dxe + FILE_GUID = ccc028e4-99b3-4074-b62c-c6813a8da44e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_3_1/Volume_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_3_1/Volume_V1_3_1_Dxe.c new file mode 100644 index 00000000000..f666bbc8841 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_3_1/Volume_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "3", + "1" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_3_1 *VolumeV1_3_1; + EFI_REDFISH_VOLUME_V1_3_1_CS *VolumeV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_3_1_To_CS (ResoruceRaw, &VolumeV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_3_1 = (EFI_REDFISH_VOLUME_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_3_1)); + if (VolumeV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_3_1; + VolumeV1_3_1->Volume = VolumeV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_3_1_JSON (*((EFI_REDFISH_VOLUME_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_3_1 *VolumeV1_3_1; + + VolumeV1_3_1 = (EFI_REDFISH_VOLUME_V1_3_1 *)InterpProp; + DestroyVolume_V1_3_1_CS (VolumeV1_3_1->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_3_2/RedfishVolume_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_3_2/RedfishVolume_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..4def0285a8b --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_3_2/RedfishVolume_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_3_2_Dxe + FILE_GUID = 003845e1-c903-4fbc-904f-9fc9148cb74f + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_3_2/Volume_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_3_2/Volume_V1_3_2_Dxe.c new file mode 100644 index 00000000000..43ebefd8be3 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_3_2/Volume_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "3", + "2" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_3_2 *VolumeV1_3_2; + EFI_REDFISH_VOLUME_V1_3_2_CS *VolumeV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_3_2_To_CS (ResoruceRaw, &VolumeV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_3_2 = (EFI_REDFISH_VOLUME_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_3_2)); + if (VolumeV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_3_2; + VolumeV1_3_2->Volume = VolumeV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_3_2_JSON (*((EFI_REDFISH_VOLUME_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_3_2 *VolumeV1_3_2; + + VolumeV1_3_2 = (EFI_REDFISH_VOLUME_V1_3_2 *)InterpProp; + DestroyVolume_V1_3_2_CS (VolumeV1_3_2->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_3_3/RedfishVolume_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_3_3/RedfishVolume_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..bff555388db --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_3_3/RedfishVolume_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_3_3_Dxe + FILE_GUID = 4e6b90f8-6e9a-4fc0-8b74-262c8590e1bc + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_3_3/Volume_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_3_3/Volume_V1_3_3_Dxe.c new file mode 100644 index 00000000000..fdcc0d097cf --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_3_3/Volume_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "3", + "3" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_3_3 *VolumeV1_3_3; + EFI_REDFISH_VOLUME_V1_3_3_CS *VolumeV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_3_3_To_CS (ResoruceRaw, &VolumeV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_3_3 = (EFI_REDFISH_VOLUME_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_3_3)); + if (VolumeV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_3_3; + VolumeV1_3_3->Volume = VolumeV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_3_3_JSON (*((EFI_REDFISH_VOLUME_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_3_3 *VolumeV1_3_3; + + VolumeV1_3_3 = (EFI_REDFISH_VOLUME_V1_3_3 *)InterpProp; + DestroyVolume_V1_3_3_CS (VolumeV1_3_3->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_3_4/RedfishVolume_V1_3_4_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_3_4/RedfishVolume_V1_3_4_Dxe.inf new file mode 100644 index 00000000000..b83352348a4 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_3_4/RedfishVolume_V1_3_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_3_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_3_4_Dxe + FILE_GUID = 49ca2537-6902-4074-8a1f-0ea8379f245a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_3_4EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_3_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_3_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_3_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_3_4/Volume_V1_3_4_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_3_4/Volume_V1_3_4_Dxe.c new file mode 100644 index 00000000000..21a0d672d3f --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_3_4/Volume_V1_3_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_3_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "3", + "4" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_3_4 *VolumeV1_3_4; + EFI_REDFISH_VOLUME_V1_3_4_CS *VolumeV1_3_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_3_4_To_CS (ResoruceRaw, &VolumeV1_3_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_3_4 = (EFI_REDFISH_VOLUME_V1_3_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_3_4)); + if (VolumeV1_3_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_3_4; + VolumeV1_3_4->Volume = VolumeV1_3_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_3_4_JSON (*((EFI_REDFISH_VOLUME_V1_3_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_3_4 *VolumeV1_3_4; + + VolumeV1_3_4 = (EFI_REDFISH_VOLUME_V1_3_4 *)InterpProp; + DestroyVolume_V1_3_4_CS (VolumeV1_3_4->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_3_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_3_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_3_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_4_0/RedfishVolume_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_4_0/RedfishVolume_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..cd4afdd78f4 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_4_0/RedfishVolume_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_4_0_Dxe + FILE_GUID = a8d5f18c-eda8-454d-b7cd-0243f7c69963 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_4_0/Volume_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_4_0/Volume_V1_4_0_Dxe.c new file mode 100644 index 00000000000..a3043a52593 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_4_0/Volume_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "4", + "0" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_4_0 *VolumeV1_4_0; + EFI_REDFISH_VOLUME_V1_4_0_CS *VolumeV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_4_0_To_CS (ResoruceRaw, &VolumeV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_4_0 = (EFI_REDFISH_VOLUME_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_4_0)); + if (VolumeV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_4_0; + VolumeV1_4_0->Volume = VolumeV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_4_0_JSON (*((EFI_REDFISH_VOLUME_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_4_0 *VolumeV1_4_0; + + VolumeV1_4_0 = (EFI_REDFISH_VOLUME_V1_4_0 *)InterpProp; + DestroyVolume_V1_4_0_CS (VolumeV1_4_0->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_4_1/RedfishVolume_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_4_1/RedfishVolume_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..63ac2a03118 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_4_1/RedfishVolume_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_4_1_Dxe + FILE_GUID = e68132df-d8e4-410f-a8f1-90ca37a0e53d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_4_1/Volume_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_4_1/Volume_V1_4_1_Dxe.c new file mode 100644 index 00000000000..c61ca3cf720 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_4_1/Volume_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "4", + "1" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_4_1 *VolumeV1_4_1; + EFI_REDFISH_VOLUME_V1_4_1_CS *VolumeV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_4_1_To_CS (ResoruceRaw, &VolumeV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_4_1 = (EFI_REDFISH_VOLUME_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_4_1)); + if (VolumeV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_4_1; + VolumeV1_4_1->Volume = VolumeV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_4_1_JSON (*((EFI_REDFISH_VOLUME_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_4_1 *VolumeV1_4_1; + + VolumeV1_4_1 = (EFI_REDFISH_VOLUME_V1_4_1 *)InterpProp; + DestroyVolume_V1_4_1_CS (VolumeV1_4_1->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_4_2/RedfishVolume_V1_4_2_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_4_2/RedfishVolume_V1_4_2_Dxe.inf new file mode 100644 index 00000000000..474e5492107 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_4_2/RedfishVolume_V1_4_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_4_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_4_2_Dxe + FILE_GUID = c442d736-b49b-4748-b8df-94c086e97791 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_4_2EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_4_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_4_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_4_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_4_2/Volume_V1_4_2_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_4_2/Volume_V1_4_2_Dxe.c new file mode 100644 index 00000000000..9da89139aea --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_4_2/Volume_V1_4_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_4_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "4", + "2" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_4_2 *VolumeV1_4_2; + EFI_REDFISH_VOLUME_V1_4_2_CS *VolumeV1_4_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_4_2_To_CS (ResoruceRaw, &VolumeV1_4_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_4_2 = (EFI_REDFISH_VOLUME_V1_4_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_4_2)); + if (VolumeV1_4_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_4_2; + VolumeV1_4_2->Volume = VolumeV1_4_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_4_2_JSON (*((EFI_REDFISH_VOLUME_V1_4_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_4_2 *VolumeV1_4_2; + + VolumeV1_4_2 = (EFI_REDFISH_VOLUME_V1_4_2 *)InterpProp; + DestroyVolume_V1_4_2_CS (VolumeV1_4_2->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_4_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_4_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_4_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_4_3/RedfishVolume_V1_4_3_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_4_3/RedfishVolume_V1_4_3_Dxe.inf new file mode 100644 index 00000000000..f0f892e8cde --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_4_3/RedfishVolume_V1_4_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_4_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_4_3_Dxe + FILE_GUID = 51b700ea-02d8-4882-9239-0e3165f1f59e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_4_3EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_4_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_4_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_4_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_4_3/Volume_V1_4_3_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_4_3/Volume_V1_4_3_Dxe.c new file mode 100644 index 00000000000..67c79909a80 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_4_3/Volume_V1_4_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_4_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "4", + "3" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_4_3 *VolumeV1_4_3; + EFI_REDFISH_VOLUME_V1_4_3_CS *VolumeV1_4_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_4_3_To_CS (ResoruceRaw, &VolumeV1_4_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_4_3 = (EFI_REDFISH_VOLUME_V1_4_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_4_3)); + if (VolumeV1_4_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_4_3; + VolumeV1_4_3->Volume = VolumeV1_4_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_4_3_JSON (*((EFI_REDFISH_VOLUME_V1_4_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_4_3 *VolumeV1_4_3; + + VolumeV1_4_3 = (EFI_REDFISH_VOLUME_V1_4_3 *)InterpProp; + DestroyVolume_V1_4_3_CS (VolumeV1_4_3->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_4_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_4_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_4_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_5_0/RedfishVolume_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_5_0/RedfishVolume_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..03068ae2dd3 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_5_0/RedfishVolume_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_5_0_Dxe + FILE_GUID = ccf307fa-f9aa-4933-9942-38b92cf8c045 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_5_0/Volume_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_5_0/Volume_V1_5_0_Dxe.c new file mode 100644 index 00000000000..fe515d67fb3 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_5_0/Volume_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "5", + "0" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_5_0 *VolumeV1_5_0; + EFI_REDFISH_VOLUME_V1_5_0_CS *VolumeV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_5_0_To_CS (ResoruceRaw, &VolumeV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_5_0 = (EFI_REDFISH_VOLUME_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_5_0)); + if (VolumeV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_5_0; + VolumeV1_5_0->Volume = VolumeV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_5_0_JSON (*((EFI_REDFISH_VOLUME_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_5_0 *VolumeV1_5_0; + + VolumeV1_5_0 = (EFI_REDFISH_VOLUME_V1_5_0 *)InterpProp; + DestroyVolume_V1_5_0_CS (VolumeV1_5_0->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_5_1/RedfishVolume_V1_5_1_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_5_1/RedfishVolume_V1_5_1_Dxe.inf new file mode 100644 index 00000000000..3360f554d0e --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_5_1/RedfishVolume_V1_5_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_5_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_5_1_Dxe + FILE_GUID = 56092788-0296-4e10-a1a3-b8a9c1afa4d0 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_5_1EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_5_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_5_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_5_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_5_1/Volume_V1_5_1_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_5_1/Volume_V1_5_1_Dxe.c new file mode 100644 index 00000000000..1e08a363c43 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_5_1/Volume_V1_5_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_5_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "5", + "1" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_5_1 *VolumeV1_5_1; + EFI_REDFISH_VOLUME_V1_5_1_CS *VolumeV1_5_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_5_1_To_CS (ResoruceRaw, &VolumeV1_5_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_5_1 = (EFI_REDFISH_VOLUME_V1_5_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_5_1)); + if (VolumeV1_5_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_5_1; + VolumeV1_5_1->Volume = VolumeV1_5_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_5_1_JSON (*((EFI_REDFISH_VOLUME_V1_5_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_5_1 *VolumeV1_5_1; + + VolumeV1_5_1 = (EFI_REDFISH_VOLUME_V1_5_1 *)InterpProp; + DestroyVolume_V1_5_1_CS (VolumeV1_5_1->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_5_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_5_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_5_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_6_0/RedfishVolume_V1_6_0_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_6_0/RedfishVolume_V1_6_0_Dxe.inf new file mode 100644 index 00000000000..79287b67f50 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_6_0/RedfishVolume_V1_6_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_6_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_6_0_Dxe + FILE_GUID = 6bd76b6e-42bc-4c9a-bddd-763219be0011 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_6_0EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_6_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_6_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_6_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_6_0/Volume_V1_6_0_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_6_0/Volume_V1_6_0_Dxe.c new file mode 100644 index 00000000000..fa38bbf5ef0 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_6_0/Volume_V1_6_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_6_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "6", + "0" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_6_0 *VolumeV1_6_0; + EFI_REDFISH_VOLUME_V1_6_0_CS *VolumeV1_6_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_6_0_To_CS (ResoruceRaw, &VolumeV1_6_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_6_0 = (EFI_REDFISH_VOLUME_V1_6_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_6_0)); + if (VolumeV1_6_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_6_0; + VolumeV1_6_0->Volume = VolumeV1_6_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_6_0_JSON (*((EFI_REDFISH_VOLUME_V1_6_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_6_0 *VolumeV1_6_0; + + VolumeV1_6_0 = (EFI_REDFISH_VOLUME_V1_6_0 *)InterpProp; + DestroyVolume_V1_6_0_CS (VolumeV1_6_0->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_6_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_6_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_6_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Volume/v1_6_1/RedfishVolume_V1_6_1_Dxe.inf b/RedfishClientPkg/Converter/Volume/v1_6_1/RedfishVolume_V1_6_1_Dxe.inf new file mode 100644 index 00000000000..d399f5ef752 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_6_1/RedfishVolume_V1_6_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Volume.v1_6_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolume_V1_6_1_Dxe + FILE_GUID = 92a9ed6b-654f-460e-bd7a-dc03523848d7 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolume_V1_6_1EntryPoint + UNLOAD_IMAGE = RedfishVolume_V1_6_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Volume_V1_6_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeV1_6_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Volume/v1_6_1/Volume_V1_6_1_Dxe.c b/RedfishClientPkg/Converter/Volume/v1_6_1/Volume_V1_6_1_Dxe.c new file mode 100644 index 00000000000..b473a8c39a9 --- /dev/null +++ b/RedfishClientPkg/Converter/Volume/v1_6_1/Volume_V1_6_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Volume.v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Volume"; +BOOLEAN IsRevisonController = TRUE; + +// Support Volume V1_6_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Volume", + "1", + "6", + "1" + }, + "Volume" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_6_1 *VolumeV1_6_1; + EFI_REDFISH_VOLUME_V1_6_1_CS *VolumeV1_6_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Volume") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Volume_V1_6_1_To_CS (ResoruceRaw, &VolumeV1_6_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeV1_6_1 = (EFI_REDFISH_VOLUME_V1_6_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUME_V1_6_1)); + if (VolumeV1_6_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeV1_6_1; + VolumeV1_6_1->Volume = VolumeV1_6_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Volume"), "Volume"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Volume")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Volume"), "Volume"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Volume_V1_6_1_JSON (*((EFI_REDFISH_VOLUME_V1_6_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUME_V1_6_1 *VolumeV1_6_1; + + VolumeV1_6_1 = (EFI_REDFISH_VOLUME_V1_6_1 *)InterpProp; + DestroyVolume_V1_6_1_CS (VolumeV1_6_1->Volume); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolume_V1_6_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_6_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeToStructWrapper, + VolumeToJson, + VolumeDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolume_V1_6_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/VolumeCollection/RedfishVolumeCollection_Dxe.inf b/RedfishClientPkg/Converter/VolumeCollection/RedfishVolumeCollection_Dxe.inf new file mode 100644 index 00000000000..32187a34f48 --- /dev/null +++ b/RedfishClientPkg/Converter/VolumeCollection/RedfishVolumeCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of VolumeCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishVolumeCollection_Dxe + FILE_GUID = bea67fe5-f023-4b54-9f57-a668282d34ee + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishVolumeCollectionEntryPoint + UNLOAD_IMAGE = RedfishVolumeCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + VolumeCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + VolumeCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/VolumeCollection/VolumeCollection_Dxe.c b/RedfishClientPkg/Converter/VolumeCollection/VolumeCollection_Dxe.c new file mode 100644 index 00000000000..3ad1ce96550 --- /dev/null +++ b/RedfishClientPkg/Converter/VolumeCollection/VolumeCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - VolumeCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#VolumeCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support VolumeCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "VolumeCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "VolumeCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_VOLUMECOLLECTION *VolumeCollection; + EFI_REDFISH_VOLUMECOLLECTION_CS *VolumeCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "VolumeCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_VolumeCollection_To_CS (ResoruceRaw, &VolumeCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + VolumeCollection = (EFI_REDFISH_VOLUMECOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_VOLUMECOLLECTION)); + if (VolumeCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)VolumeCollection; + VolumeCollection->VolumeCollection = VolumeCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("VolumeCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("VolumeCollection"), "VolumeCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("VolumeCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("VolumeCollection"), "VolumeCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of VolumeCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return VolumeCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_VolumeCollection_JSON (*((EFI_REDFISH_VOLUMECOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in VolumeCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_VOLUMECOLLECTION *VolumeCollection; + + VolumeCollection = (EFI_REDFISH_VOLUMECOLLECTION *)InterpProp; + DestroyVolumeCollection_CS (VolumeCollection->VolumeCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from VolumeCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +VolumeCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyVolumeCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishVolumeCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + VolumeCollectionToStructWrapper, + VolumeCollectionToJson, + VolumeCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishVolumeCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_0_0/RedfishZone_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_0_0/RedfishZone_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..813159c358b --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_0_0/RedfishZone_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_0_0_Dxe + FILE_GUID = bbcd43e9-e668-4840-99c0-08d0ba875be6 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_0_0EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_0_0/Zone_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_0_0/Zone_V1_0_0_Dxe.c new file mode 100644 index 00000000000..c71c444170b --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_0_0/Zone_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "0", + "0" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_0_0 *ZoneV1_0_0; + EFI_REDFISH_ZONE_V1_0_0_CS *ZoneV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_0_0_To_CS (ResoruceRaw, &ZoneV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_0_0 = (EFI_REDFISH_ZONE_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_0_0)); + if (ZoneV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_0_0; + ZoneV1_0_0->Zone = ZoneV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_0_0_JSON (*((EFI_REDFISH_ZONE_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_0_0 *ZoneV1_0_0; + + ZoneV1_0_0 = (EFI_REDFISH_ZONE_V1_0_0 *)InterpProp; + DestroyZone_V1_0_0_CS (ZoneV1_0_0->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_0_1/RedfishZone_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_0_1/RedfishZone_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..a1e9f1154c4 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_0_1/RedfishZone_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_0_1_Dxe + FILE_GUID = c9ee3d04-607b-474b-82f0-2c272f776322 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_0_1EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_0_1/Zone_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_0_1/Zone_V1_0_1_Dxe.c new file mode 100644 index 00000000000..715dfbbece2 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_0_1/Zone_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "0", + "1" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_0_1 *ZoneV1_0_1; + EFI_REDFISH_ZONE_V1_0_1_CS *ZoneV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_0_1_To_CS (ResoruceRaw, &ZoneV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_0_1 = (EFI_REDFISH_ZONE_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_0_1)); + if (ZoneV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_0_1; + ZoneV1_0_1->Zone = ZoneV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_0_1_JSON (*((EFI_REDFISH_ZONE_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_0_1 *ZoneV1_0_1; + + ZoneV1_0_1 = (EFI_REDFISH_ZONE_V1_0_1 *)InterpProp; + DestroyZone_V1_0_1_CS (ZoneV1_0_1->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_0_2/RedfishZone_V1_0_2_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_0_2/RedfishZone_V1_0_2_Dxe.inf new file mode 100644 index 00000000000..bda196500f0 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_0_2/RedfishZone_V1_0_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_0_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_0_2_Dxe + FILE_GUID = f4cad5a3-44c7-467c-a538-175c9ee1b103 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_0_2EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_0_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_0_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_0_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_0_2/Zone_V1_0_2_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_0_2/Zone_V1_0_2_Dxe.c new file mode 100644 index 00000000000..c11853a480c --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_0_2/Zone_V1_0_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_0_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "0", + "2" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_0_2 *ZoneV1_0_2; + EFI_REDFISH_ZONE_V1_0_2_CS *ZoneV1_0_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_0_2_To_CS (ResoruceRaw, &ZoneV1_0_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_0_2 = (EFI_REDFISH_ZONE_V1_0_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_0_2)); + if (ZoneV1_0_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_0_2; + ZoneV1_0_2->Zone = ZoneV1_0_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_0_2_JSON (*((EFI_REDFISH_ZONE_V1_0_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_0_2 *ZoneV1_0_2; + + ZoneV1_0_2 = (EFI_REDFISH_ZONE_V1_0_2 *)InterpProp; + DestroyZone_V1_0_2_CS (ZoneV1_0_2->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_0_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_0_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_0_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_0_3/RedfishZone_V1_0_3_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_0_3/RedfishZone_V1_0_3_Dxe.inf new file mode 100644 index 00000000000..53d6b46db3e --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_0_3/RedfishZone_V1_0_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_0_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_0_3_Dxe + FILE_GUID = 3c1ee2e3-6965-4de7-8fd3-6ca1308d5a25 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_0_3EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_0_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_0_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_0_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_0_3/Zone_V1_0_3_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_0_3/Zone_V1_0_3_Dxe.c new file mode 100644 index 00000000000..85d72c0b2d0 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_0_3/Zone_V1_0_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_0_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "0", + "3" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_0_3 *ZoneV1_0_3; + EFI_REDFISH_ZONE_V1_0_3_CS *ZoneV1_0_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_0_3_To_CS (ResoruceRaw, &ZoneV1_0_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_0_3 = (EFI_REDFISH_ZONE_V1_0_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_0_3)); + if (ZoneV1_0_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_0_3; + ZoneV1_0_3->Zone = ZoneV1_0_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_0_3_JSON (*((EFI_REDFISH_ZONE_V1_0_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_0_3 *ZoneV1_0_3; + + ZoneV1_0_3 = (EFI_REDFISH_ZONE_V1_0_3 *)InterpProp; + DestroyZone_V1_0_3_CS (ZoneV1_0_3->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_0_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_0_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_0_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_0_4/RedfishZone_V1_0_4_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_0_4/RedfishZone_V1_0_4_Dxe.inf new file mode 100644 index 00000000000..4f93a21277a --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_0_4/RedfishZone_V1_0_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_0_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_0_4_Dxe + FILE_GUID = 5cadd52c-c63d-4e96-b3a1-bb00cb090394 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_0_4EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_0_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_0_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_0_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_0_4/Zone_V1_0_4_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_0_4/Zone_V1_0_4_Dxe.c new file mode 100644 index 00000000000..f391d3e9f99 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_0_4/Zone_V1_0_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_0_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "0", + "4" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_0_4 *ZoneV1_0_4; + EFI_REDFISH_ZONE_V1_0_4_CS *ZoneV1_0_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_0_4_To_CS (ResoruceRaw, &ZoneV1_0_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_0_4 = (EFI_REDFISH_ZONE_V1_0_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_0_4)); + if (ZoneV1_0_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_0_4; + ZoneV1_0_4->Zone = ZoneV1_0_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_0_4_JSON (*((EFI_REDFISH_ZONE_V1_0_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_0_4 *ZoneV1_0_4; + + ZoneV1_0_4 = (EFI_REDFISH_ZONE_V1_0_4 *)InterpProp; + DestroyZone_V1_0_4_CS (ZoneV1_0_4->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_0_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_0_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_0_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_0_5/RedfishZone_V1_0_5_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_0_5/RedfishZone_V1_0_5_Dxe.inf new file mode 100644 index 00000000000..e598f927dd8 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_0_5/RedfishZone_V1_0_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_0_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_0_5_Dxe + FILE_GUID = d607b204-7ae3-4949-8f01-b732e8fcf73c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_0_5EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_0_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_0_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_0_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_0_5/Zone_V1_0_5_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_0_5/Zone_V1_0_5_Dxe.c new file mode 100644 index 00000000000..2df045eac16 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_0_5/Zone_V1_0_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_0_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "0", + "5" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_0_5 *ZoneV1_0_5; + EFI_REDFISH_ZONE_V1_0_5_CS *ZoneV1_0_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_0_5_To_CS (ResoruceRaw, &ZoneV1_0_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_0_5 = (EFI_REDFISH_ZONE_V1_0_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_0_5)); + if (ZoneV1_0_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_0_5; + ZoneV1_0_5->Zone = ZoneV1_0_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_0_5_JSON (*((EFI_REDFISH_ZONE_V1_0_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_0_5 *ZoneV1_0_5; + + ZoneV1_0_5 = (EFI_REDFISH_ZONE_V1_0_5 *)InterpProp; + DestroyZone_V1_0_5_CS (ZoneV1_0_5->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_0_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_0_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_0_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_0_6/RedfishZone_V1_0_6_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_0_6/RedfishZone_V1_0_6_Dxe.inf new file mode 100644 index 00000000000..ef37972a8c1 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_0_6/RedfishZone_V1_0_6_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_0_6 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_0_6_Dxe + FILE_GUID = 64927c9a-48b7-4ea3-901f-67e45370cb93 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_0_6EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_0_6Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_0_6_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_0_6Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_0_6/Zone_V1_0_6_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_0_6/Zone_V1_0_6_Dxe.c new file mode 100644 index 00000000000..25d879d4efa --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_0_6/Zone_V1_0_6_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_0_6 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "0", + "6" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_0_6 *ZoneV1_0_6; + EFI_REDFISH_ZONE_V1_0_6_CS *ZoneV1_0_6Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_0_6_To_CS (ResoruceRaw, &ZoneV1_0_6Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_0_6 = (EFI_REDFISH_ZONE_V1_0_6 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_0_6)); + if (ZoneV1_0_6 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_0_6; + ZoneV1_0_6->Zone = ZoneV1_0_6Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "6"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_0_6_JSON (*((EFI_REDFISH_ZONE_V1_0_6_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_0_6 *ZoneV1_0_6; + + ZoneV1_0_6 = (EFI_REDFISH_ZONE_V1_0_6 *)InterpProp; + DestroyZone_V1_0_6_CS (ZoneV1_0_6->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_0_6_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_0_6EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_0_6Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_1_0/RedfishZone_V1_1_0_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_1_0/RedfishZone_V1_1_0_Dxe.inf new file mode 100644 index 00000000000..469f36ba69f --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_1_0/RedfishZone_V1_1_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_1_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_1_0_Dxe + FILE_GUID = 10652bcf-ad52-4605-9d2b-35aee2258f52 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_1_0EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_1_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_1_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_1_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_1_0/Zone_V1_1_0_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_1_0/Zone_V1_1_0_Dxe.c new file mode 100644 index 00000000000..872a9a367ad --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_1_0/Zone_V1_1_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_1_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "1", + "0" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_1_0 *ZoneV1_1_0; + EFI_REDFISH_ZONE_V1_1_0_CS *ZoneV1_1_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_1_0_To_CS (ResoruceRaw, &ZoneV1_1_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_1_0 = (EFI_REDFISH_ZONE_V1_1_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_1_0)); + if (ZoneV1_1_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_1_0; + ZoneV1_1_0->Zone = ZoneV1_1_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_1_0_JSON (*((EFI_REDFISH_ZONE_V1_1_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_1_0 *ZoneV1_1_0; + + ZoneV1_1_0 = (EFI_REDFISH_ZONE_V1_1_0 *)InterpProp; + DestroyZone_V1_1_0_CS (ZoneV1_1_0->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_1_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_1_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_1_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_1_1/RedfishZone_V1_1_1_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_1_1/RedfishZone_V1_1_1_Dxe.inf new file mode 100644 index 00000000000..f3d4d5b59f9 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_1_1/RedfishZone_V1_1_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_1_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_1_1_Dxe + FILE_GUID = 91511ca9-064b-4463-afd7-1fffdbdfd26d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_1_1EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_1_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_1_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_1_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_1_1/Zone_V1_1_1_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_1_1/Zone_V1_1_1_Dxe.c new file mode 100644 index 00000000000..742fd123bbf --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_1_1/Zone_V1_1_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_1_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "1", + "1" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_1_1 *ZoneV1_1_1; + EFI_REDFISH_ZONE_V1_1_1_CS *ZoneV1_1_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_1_1_To_CS (ResoruceRaw, &ZoneV1_1_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_1_1 = (EFI_REDFISH_ZONE_V1_1_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_1_1)); + if (ZoneV1_1_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_1_1; + ZoneV1_1_1->Zone = ZoneV1_1_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_1_1_JSON (*((EFI_REDFISH_ZONE_V1_1_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_1_1 *ZoneV1_1_1; + + ZoneV1_1_1 = (EFI_REDFISH_ZONE_V1_1_1 *)InterpProp; + DestroyZone_V1_1_1_CS (ZoneV1_1_1->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_1_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_1_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_1_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_1_2/RedfishZone_V1_1_2_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_1_2/RedfishZone_V1_1_2_Dxe.inf new file mode 100644 index 00000000000..12ff4623b5f --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_1_2/RedfishZone_V1_1_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_1_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_1_2_Dxe + FILE_GUID = 49019cbe-286d-4806-ba3f-3a1d70fd86fa + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_1_2EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_1_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_1_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_1_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_1_2/Zone_V1_1_2_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_1_2/Zone_V1_1_2_Dxe.c new file mode 100644 index 00000000000..8d2c28d8187 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_1_2/Zone_V1_1_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_1_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "1", + "2" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_1_2 *ZoneV1_1_2; + EFI_REDFISH_ZONE_V1_1_2_CS *ZoneV1_1_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_1_2_To_CS (ResoruceRaw, &ZoneV1_1_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_1_2 = (EFI_REDFISH_ZONE_V1_1_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_1_2)); + if (ZoneV1_1_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_1_2; + ZoneV1_1_2->Zone = ZoneV1_1_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_1_2_JSON (*((EFI_REDFISH_ZONE_V1_1_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_1_2 *ZoneV1_1_2; + + ZoneV1_1_2 = (EFI_REDFISH_ZONE_V1_1_2 *)InterpProp; + DestroyZone_V1_1_2_CS (ZoneV1_1_2->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_1_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_1_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_1_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_1_3/RedfishZone_V1_1_3_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_1_3/RedfishZone_V1_1_3_Dxe.inf new file mode 100644 index 00000000000..aa088149462 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_1_3/RedfishZone_V1_1_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_1_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_1_3_Dxe + FILE_GUID = 6f222a97-d204-47e5-8770-d2cfb06c0760 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_1_3EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_1_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_1_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_1_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_1_3/Zone_V1_1_3_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_1_3/Zone_V1_1_3_Dxe.c new file mode 100644 index 00000000000..3ec5ca0b912 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_1_3/Zone_V1_1_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_1_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "1", + "3" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_1_3 *ZoneV1_1_3; + EFI_REDFISH_ZONE_V1_1_3_CS *ZoneV1_1_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_1_3_To_CS (ResoruceRaw, &ZoneV1_1_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_1_3 = (EFI_REDFISH_ZONE_V1_1_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_1_3)); + if (ZoneV1_1_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_1_3; + ZoneV1_1_3->Zone = ZoneV1_1_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_1_3_JSON (*((EFI_REDFISH_ZONE_V1_1_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_1_3 *ZoneV1_1_3; + + ZoneV1_1_3 = (EFI_REDFISH_ZONE_V1_1_3 *)InterpProp; + DestroyZone_V1_1_3_CS (ZoneV1_1_3->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_1_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_1_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_1_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_1_4/RedfishZone_V1_1_4_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_1_4/RedfishZone_V1_1_4_Dxe.inf new file mode 100644 index 00000000000..2eea1c3b6bf --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_1_4/RedfishZone_V1_1_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_1_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_1_4_Dxe + FILE_GUID = 28a78e51-0c03-4251-a1b7-8e0cdb6d7725 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_1_4EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_1_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_1_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_1_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_1_4/Zone_V1_1_4_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_1_4/Zone_V1_1_4_Dxe.c new file mode 100644 index 00000000000..1a1d45ca06e --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_1_4/Zone_V1_1_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_1_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "1", + "4" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_1_4 *ZoneV1_1_4; + EFI_REDFISH_ZONE_V1_1_4_CS *ZoneV1_1_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_1_4_To_CS (ResoruceRaw, &ZoneV1_1_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_1_4 = (EFI_REDFISH_ZONE_V1_1_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_1_4)); + if (ZoneV1_1_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_1_4; + ZoneV1_1_4->Zone = ZoneV1_1_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_1_4_JSON (*((EFI_REDFISH_ZONE_V1_1_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_1_4 *ZoneV1_1_4; + + ZoneV1_1_4 = (EFI_REDFISH_ZONE_V1_1_4 *)InterpProp; + DestroyZone_V1_1_4_CS (ZoneV1_1_4->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_1_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_1_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_1_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_1_5/RedfishZone_V1_1_5_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_1_5/RedfishZone_V1_1_5_Dxe.inf new file mode 100644 index 00000000000..ad1324e1161 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_1_5/RedfishZone_V1_1_5_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_1_5 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_1_5_Dxe + FILE_GUID = f771b31d-b592-4769-a6d5-96ac04fae3f1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_1_5EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_1_5Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_1_5_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_1_5Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_1_5/Zone_V1_1_5_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_1_5/Zone_V1_1_5_Dxe.c new file mode 100644 index 00000000000..dec33cf78ef --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_1_5/Zone_V1_1_5_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_1_5 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "1", + "5" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_1_5 *ZoneV1_1_5; + EFI_REDFISH_ZONE_V1_1_5_CS *ZoneV1_1_5Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_1_5_To_CS (ResoruceRaw, &ZoneV1_1_5Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_1_5 = (EFI_REDFISH_ZONE_V1_1_5 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_1_5)); + if (ZoneV1_1_5 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_1_5; + ZoneV1_1_5->Zone = ZoneV1_1_5Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "1"; + ResourceTypeErrataVersion = "5"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_1_5_JSON (*((EFI_REDFISH_ZONE_V1_1_5_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_1_5 *ZoneV1_1_5; + + ZoneV1_1_5 = (EFI_REDFISH_ZONE_V1_1_5 *)InterpProp; + DestroyZone_V1_1_5_CS (ZoneV1_1_5->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_1_5_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_1_5EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_1_5Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_2_0/RedfishZone_V1_2_0_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_2_0/RedfishZone_V1_2_0_Dxe.inf new file mode 100644 index 00000000000..10b13b297ed --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_2_0/RedfishZone_V1_2_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_2_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_2_0_Dxe + FILE_GUID = d673f68b-28f4-442b-9004-1ba1ada104d1 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_2_0EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_2_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_2_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_2_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_2_0/Zone_V1_2_0_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_2_0/Zone_V1_2_0_Dxe.c new file mode 100644 index 00000000000..ed60c709111 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_2_0/Zone_V1_2_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_2_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "2", + "0" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_2_0 *ZoneV1_2_0; + EFI_REDFISH_ZONE_V1_2_0_CS *ZoneV1_2_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_2_0_To_CS (ResoruceRaw, &ZoneV1_2_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_2_0 = (EFI_REDFISH_ZONE_V1_2_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_2_0)); + if (ZoneV1_2_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_2_0; + ZoneV1_2_0->Zone = ZoneV1_2_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_2_0_JSON (*((EFI_REDFISH_ZONE_V1_2_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_2_0 *ZoneV1_2_0; + + ZoneV1_2_0 = (EFI_REDFISH_ZONE_V1_2_0 *)InterpProp; + DestroyZone_V1_2_0_CS (ZoneV1_2_0->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_2_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_2_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_2_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_2_1/RedfishZone_V1_2_1_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_2_1/RedfishZone_V1_2_1_Dxe.inf new file mode 100644 index 00000000000..2b33ed58db5 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_2_1/RedfishZone_V1_2_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_2_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_2_1_Dxe + FILE_GUID = 178c56c4-a953-442b-99c5-a5b4085ce75c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_2_1EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_2_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_2_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_2_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_2_1/Zone_V1_2_1_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_2_1/Zone_V1_2_1_Dxe.c new file mode 100644 index 00000000000..e83db57bbc4 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_2_1/Zone_V1_2_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_2_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "2", + "1" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_2_1 *ZoneV1_2_1; + EFI_REDFISH_ZONE_V1_2_1_CS *ZoneV1_2_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_2_1_To_CS (ResoruceRaw, &ZoneV1_2_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_2_1 = (EFI_REDFISH_ZONE_V1_2_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_2_1)); + if (ZoneV1_2_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_2_1; + ZoneV1_2_1->Zone = ZoneV1_2_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_2_1_JSON (*((EFI_REDFISH_ZONE_V1_2_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_2_1 *ZoneV1_2_1; + + ZoneV1_2_1 = (EFI_REDFISH_ZONE_V1_2_1 *)InterpProp; + DestroyZone_V1_2_1_CS (ZoneV1_2_1->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_2_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_2_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_2_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_2_2/RedfishZone_V1_2_2_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_2_2/RedfishZone_V1_2_2_Dxe.inf new file mode 100644 index 00000000000..ecd3aeab7b6 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_2_2/RedfishZone_V1_2_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_2_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_2_2_Dxe + FILE_GUID = bf3e512d-76fa-442f-a032-3630cc6ec8ca + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_2_2EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_2_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_2_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_2_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_2_2/Zone_V1_2_2_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_2_2/Zone_V1_2_2_Dxe.c new file mode 100644 index 00000000000..2db986089b7 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_2_2/Zone_V1_2_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_2_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "2", + "2" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_2_2 *ZoneV1_2_2; + EFI_REDFISH_ZONE_V1_2_2_CS *ZoneV1_2_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_2_2_To_CS (ResoruceRaw, &ZoneV1_2_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_2_2 = (EFI_REDFISH_ZONE_V1_2_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_2_2)); + if (ZoneV1_2_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_2_2; + ZoneV1_2_2->Zone = ZoneV1_2_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_2_2_JSON (*((EFI_REDFISH_ZONE_V1_2_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_2_2 *ZoneV1_2_2; + + ZoneV1_2_2 = (EFI_REDFISH_ZONE_V1_2_2 *)InterpProp; + DestroyZone_V1_2_2_CS (ZoneV1_2_2->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_2_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_2_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_2_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_2_3/RedfishZone_V1_2_3_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_2_3/RedfishZone_V1_2_3_Dxe.inf new file mode 100644 index 00000000000..b1f7b048823 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_2_3/RedfishZone_V1_2_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_2_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_2_3_Dxe + FILE_GUID = 2ee08ec5-a9df-4e6a-a2c2-42f8bb89406d + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_2_3EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_2_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_2_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_2_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_2_3/Zone_V1_2_3_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_2_3/Zone_V1_2_3_Dxe.c new file mode 100644 index 00000000000..5a95b4fdf70 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_2_3/Zone_V1_2_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_2_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "2", + "3" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_2_3 *ZoneV1_2_3; + EFI_REDFISH_ZONE_V1_2_3_CS *ZoneV1_2_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_2_3_To_CS (ResoruceRaw, &ZoneV1_2_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_2_3 = (EFI_REDFISH_ZONE_V1_2_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_2_3)); + if (ZoneV1_2_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_2_3; + ZoneV1_2_3->Zone = ZoneV1_2_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_2_3_JSON (*((EFI_REDFISH_ZONE_V1_2_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_2_3 *ZoneV1_2_3; + + ZoneV1_2_3 = (EFI_REDFISH_ZONE_V1_2_3 *)InterpProp; + DestroyZone_V1_2_3_CS (ZoneV1_2_3->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_2_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_2_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_2_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_2_4/RedfishZone_V1_2_4_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_2_4/RedfishZone_V1_2_4_Dxe.inf new file mode 100644 index 00000000000..6bd71116bd9 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_2_4/RedfishZone_V1_2_4_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_2_4 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_2_4_Dxe + FILE_GUID = 545c80f6-91bd-4d5f-8547-f152222a2f60 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_2_4EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_2_4Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_2_4_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_2_4Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_2_4/Zone_V1_2_4_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_2_4/Zone_V1_2_4_Dxe.c new file mode 100644 index 00000000000..dcdb1bf0715 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_2_4/Zone_V1_2_4_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_2_4 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "2", + "4" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_2_4 *ZoneV1_2_4; + EFI_REDFISH_ZONE_V1_2_4_CS *ZoneV1_2_4Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_2_4_To_CS (ResoruceRaw, &ZoneV1_2_4Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_2_4 = (EFI_REDFISH_ZONE_V1_2_4 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_2_4)); + if (ZoneV1_2_4 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_2_4; + ZoneV1_2_4->Zone = ZoneV1_2_4Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "2"; + ResourceTypeErrataVersion = "4"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_2_4_JSON (*((EFI_REDFISH_ZONE_V1_2_4_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_2_4 *ZoneV1_2_4; + + ZoneV1_2_4 = (EFI_REDFISH_ZONE_V1_2_4 *)InterpProp; + DestroyZone_V1_2_4_CS (ZoneV1_2_4->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_2_4_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_2_4EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_2_4Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_3_0/RedfishZone_V1_3_0_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_3_0/RedfishZone_V1_3_0_Dxe.inf new file mode 100644 index 00000000000..5f1aa5e9b51 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_3_0/RedfishZone_V1_3_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_3_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_3_0_Dxe + FILE_GUID = 22184aef-78ee-4881-a0e5-d9463fc90f81 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_3_0EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_3_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_3_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_3_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_3_0/Zone_V1_3_0_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_3_0/Zone_V1_3_0_Dxe.c new file mode 100644 index 00000000000..449774d4ea2 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_3_0/Zone_V1_3_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_3_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "3", + "0" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_3_0 *ZoneV1_3_0; + EFI_REDFISH_ZONE_V1_3_0_CS *ZoneV1_3_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_3_0_To_CS (ResoruceRaw, &ZoneV1_3_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_3_0 = (EFI_REDFISH_ZONE_V1_3_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_3_0)); + if (ZoneV1_3_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_3_0; + ZoneV1_3_0->Zone = ZoneV1_3_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_3_0_JSON (*((EFI_REDFISH_ZONE_V1_3_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_3_0 *ZoneV1_3_0; + + ZoneV1_3_0 = (EFI_REDFISH_ZONE_V1_3_0 *)InterpProp; + DestroyZone_V1_3_0_CS (ZoneV1_3_0->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_3_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_3_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_3_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_3_1/RedfishZone_V1_3_1_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_3_1/RedfishZone_V1_3_1_Dxe.inf new file mode 100644 index 00000000000..49e914bf534 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_3_1/RedfishZone_V1_3_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_3_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_3_1_Dxe + FILE_GUID = 6c1679a3-55f3-4f7e-ba44-9363dacc6213 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_3_1EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_3_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_3_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_3_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_3_1/Zone_V1_3_1_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_3_1/Zone_V1_3_1_Dxe.c new file mode 100644 index 00000000000..2732481f3f3 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_3_1/Zone_V1_3_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_3_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "3", + "1" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_3_1 *ZoneV1_3_1; + EFI_REDFISH_ZONE_V1_3_1_CS *ZoneV1_3_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_3_1_To_CS (ResoruceRaw, &ZoneV1_3_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_3_1 = (EFI_REDFISH_ZONE_V1_3_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_3_1)); + if (ZoneV1_3_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_3_1; + ZoneV1_3_1->Zone = ZoneV1_3_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_3_1_JSON (*((EFI_REDFISH_ZONE_V1_3_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_3_1 *ZoneV1_3_1; + + ZoneV1_3_1 = (EFI_REDFISH_ZONE_V1_3_1 *)InterpProp; + DestroyZone_V1_3_1_CS (ZoneV1_3_1->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_3_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_3_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_3_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_3_2/RedfishZone_V1_3_2_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_3_2/RedfishZone_V1_3_2_Dxe.inf new file mode 100644 index 00000000000..6210de2d038 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_3_2/RedfishZone_V1_3_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_3_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_3_2_Dxe + FILE_GUID = 35d04d84-d1c4-4c68-a121-b04bdb4c43b4 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_3_2EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_3_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_3_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_3_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_3_2/Zone_V1_3_2_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_3_2/Zone_V1_3_2_Dxe.c new file mode 100644 index 00000000000..ed63f124221 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_3_2/Zone_V1_3_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_3_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "3", + "2" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_3_2 *ZoneV1_3_2; + EFI_REDFISH_ZONE_V1_3_2_CS *ZoneV1_3_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_3_2_To_CS (ResoruceRaw, &ZoneV1_3_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_3_2 = (EFI_REDFISH_ZONE_V1_3_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_3_2)); + if (ZoneV1_3_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_3_2; + ZoneV1_3_2->Zone = ZoneV1_3_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_3_2_JSON (*((EFI_REDFISH_ZONE_V1_3_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_3_2 *ZoneV1_3_2; + + ZoneV1_3_2 = (EFI_REDFISH_ZONE_V1_3_2 *)InterpProp; + DestroyZone_V1_3_2_CS (ZoneV1_3_2->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_3_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_3_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_3_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_3_3/RedfishZone_V1_3_3_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_3_3/RedfishZone_V1_3_3_Dxe.inf new file mode 100644 index 00000000000..2d195d8a340 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_3_3/RedfishZone_V1_3_3_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_3_3 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_3_3_Dxe + FILE_GUID = 4307c85f-a2f8-4d4b-b874-3e89739c676a + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_3_3EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_3_3Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_3_3_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_3_3Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_3_3/Zone_V1_3_3_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_3_3/Zone_V1_3_3_Dxe.c new file mode 100644 index 00000000000..b502608bde8 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_3_3/Zone_V1_3_3_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_3_3 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "3", + "3" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_3_3 *ZoneV1_3_3; + EFI_REDFISH_ZONE_V1_3_3_CS *ZoneV1_3_3Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "3") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_3_3_To_CS (ResoruceRaw, &ZoneV1_3_3Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_3_3 = (EFI_REDFISH_ZONE_V1_3_3 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_3_3)); + if (ZoneV1_3_3 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_3_3; + ZoneV1_3_3->Zone = ZoneV1_3_3Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "3"; + ResourceTypeErrataVersion = "3"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_3_3_JSON (*((EFI_REDFISH_ZONE_V1_3_3_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_3_3 *ZoneV1_3_3; + + ZoneV1_3_3 = (EFI_REDFISH_ZONE_V1_3_3 *)InterpProp; + DestroyZone_V1_3_3_CS (ZoneV1_3_3->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_3_3_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_3_3EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_3_3Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_4_0/RedfishZone_V1_4_0_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_4_0/RedfishZone_V1_4_0_Dxe.inf new file mode 100644 index 00000000000..1e1d7c676fd --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_4_0/RedfishZone_V1_4_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_4_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_4_0_Dxe + FILE_GUID = 09aaa4e0-3ff3-42de-a091-52dfa797a95c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_4_0EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_4_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_4_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_4_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_4_0/Zone_V1_4_0_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_4_0/Zone_V1_4_0_Dxe.c new file mode 100644 index 00000000000..565ec3e7e03 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_4_0/Zone_V1_4_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_4_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "4", + "0" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_4_0 *ZoneV1_4_0; + EFI_REDFISH_ZONE_V1_4_0_CS *ZoneV1_4_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_4_0_To_CS (ResoruceRaw, &ZoneV1_4_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_4_0 = (EFI_REDFISH_ZONE_V1_4_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_4_0)); + if (ZoneV1_4_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_4_0; + ZoneV1_4_0->Zone = ZoneV1_4_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_4_0_JSON (*((EFI_REDFISH_ZONE_V1_4_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_4_0 *ZoneV1_4_0; + + ZoneV1_4_0 = (EFI_REDFISH_ZONE_V1_4_0 *)InterpProp; + DestroyZone_V1_4_0_CS (ZoneV1_4_0->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_4_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_4_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_4_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_4_1/RedfishZone_V1_4_1_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_4_1/RedfishZone_V1_4_1_Dxe.inf new file mode 100644 index 00000000000..72dd8daff61 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_4_1/RedfishZone_V1_4_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_4_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_4_1_Dxe + FILE_GUID = b807e44f-3cc6-49a0-9c16-e351d4891e8e + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_4_1EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_4_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_4_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_4_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_4_1/Zone_V1_4_1_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_4_1/Zone_V1_4_1_Dxe.c new file mode 100644 index 00000000000..a5957bffc3f --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_4_1/Zone_V1_4_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_4_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "4", + "1" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_4_1 *ZoneV1_4_1; + EFI_REDFISH_ZONE_V1_4_1_CS *ZoneV1_4_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_4_1_To_CS (ResoruceRaw, &ZoneV1_4_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_4_1 = (EFI_REDFISH_ZONE_V1_4_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_4_1)); + if (ZoneV1_4_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_4_1; + ZoneV1_4_1->Zone = ZoneV1_4_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_4_1_JSON (*((EFI_REDFISH_ZONE_V1_4_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_4_1 *ZoneV1_4_1; + + ZoneV1_4_1 = (EFI_REDFISH_ZONE_V1_4_1 *)InterpProp; + DestroyZone_V1_4_1_CS (ZoneV1_4_1->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_4_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_4_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_4_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_4_2/RedfishZone_V1_4_2_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_4_2/RedfishZone_V1_4_2_Dxe.inf new file mode 100644 index 00000000000..db53b617142 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_4_2/RedfishZone_V1_4_2_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_4_2 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_4_2_Dxe + FILE_GUID = 601fc136-12d8-4763-850e-a48a00653c9c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_4_2EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_4_2Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_4_2_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_4_2Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_4_2/Zone_V1_4_2_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_4_2/Zone_V1_4_2_Dxe.c new file mode 100644 index 00000000000..4d2126a4c91 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_4_2/Zone_V1_4_2_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_4_2 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "4", + "2" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_4_2 *ZoneV1_4_2; + EFI_REDFISH_ZONE_V1_4_2_CS *ZoneV1_4_2Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "4") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "2") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_4_2_To_CS (ResoruceRaw, &ZoneV1_4_2Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_4_2 = (EFI_REDFISH_ZONE_V1_4_2 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_4_2)); + if (ZoneV1_4_2 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_4_2; + ZoneV1_4_2->Zone = ZoneV1_4_2Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "4"; + ResourceTypeErrataVersion = "2"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_4_2_JSON (*((EFI_REDFISH_ZONE_V1_4_2_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_4_2 *ZoneV1_4_2; + + ZoneV1_4_2 = (EFI_REDFISH_ZONE_V1_4_2 *)InterpProp; + DestroyZone_V1_4_2_CS (ZoneV1_4_2->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_4_2_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_4_2EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_4_2Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_5_0/RedfishZone_V1_5_0_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_5_0/RedfishZone_V1_5_0_Dxe.inf new file mode 100644 index 00000000000..6a5964d40e4 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_5_0/RedfishZone_V1_5_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_5_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_5_0_Dxe + FILE_GUID = 25ce63bf-20da-4053-9ba0-d3ebe3aa701c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_5_0EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_5_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_5_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_5_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_5_0/Zone_V1_5_0_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_5_0/Zone_V1_5_0_Dxe.c new file mode 100644 index 00000000000..19920ab548e --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_5_0/Zone_V1_5_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_5_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "5", + "0" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_5_0 *ZoneV1_5_0; + EFI_REDFISH_ZONE_V1_5_0_CS *ZoneV1_5_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "5") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_5_0_To_CS (ResoruceRaw, &ZoneV1_5_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_5_0 = (EFI_REDFISH_ZONE_V1_5_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_5_0)); + if (ZoneV1_5_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_5_0; + ZoneV1_5_0->Zone = ZoneV1_5_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "5"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_5_0_JSON (*((EFI_REDFISH_ZONE_V1_5_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_5_0 *ZoneV1_5_0; + + ZoneV1_5_0 = (EFI_REDFISH_ZONE_V1_5_0 *)InterpProp; + DestroyZone_V1_5_0_CS (ZoneV1_5_0->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_5_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_5_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_5_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/Zone/v1_6_0/RedfishZone_V1_6_0_Dxe.inf b/RedfishClientPkg/Converter/Zone/v1_6_0/RedfishZone_V1_6_0_Dxe.inf new file mode 100644 index 00000000000..34d5eb67f38 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_6_0/RedfishZone_V1_6_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of Zone.v1_6_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZone_V1_6_0_Dxe + FILE_GUID = 06ac0555-415e-46f1-8bee-5c246eac059b + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZone_V1_6_0EntryPoint + UNLOAD_IMAGE = RedfishZone_V1_6_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + Zone_V1_6_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneV1_6_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/Zone/v1_6_0/Zone_V1_6_0_Dxe.c b/RedfishClientPkg/Converter/Zone/v1_6_0/Zone_V1_6_0_Dxe.c new file mode 100644 index 00000000000..02dc3b50958 --- /dev/null +++ b/RedfishClientPkg/Converter/Zone/v1_6_0/Zone_V1_6_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - Zone.v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#Zone"; +BOOLEAN IsRevisonController = TRUE; + +// Support Zone V1_6_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "Zone", + "1", + "6", + "0" + }, + "Zone" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONE_V1_6_0 *ZoneV1_6_0; + EFI_REDFISH_ZONE_V1_6_0_CS *ZoneV1_6_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "6") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "Zone") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_Zone_V1_6_0_To_CS (ResoruceRaw, &ZoneV1_6_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneV1_6_0 = (EFI_REDFISH_ZONE_V1_6_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONE_V1_6_0)); + if (ZoneV1_6_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneV1_6_0; + ZoneV1_6_0->Zone = ZoneV1_6_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "6"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("Zone"), "Zone"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("Zone")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("Zone"), "Zone"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_Zone_V1_6_0_JSON (*((EFI_REDFISH_ZONE_V1_6_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONE_V1_6_0 *ZoneV1_6_0; + + ZoneV1_6_0 = (EFI_REDFISH_ZONE_V1_6_0 *)InterpProp; + DestroyZone_V1_6_0_CS (ZoneV1_6_0->Zone); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZone_V1_6_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_6_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneToStructWrapper, + ZoneToJson, + ZoneDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZone_V1_6_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/ZoneCollection/RedfishZoneCollection_Dxe.inf b/RedfishClientPkg/Converter/ZoneCollection/RedfishZoneCollection_Dxe.inf new file mode 100644 index 00000000000..8851b8174ee --- /dev/null +++ b/RedfishClientPkg/Converter/ZoneCollection/RedfishZoneCollection_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of ZoneCollection. EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RedfishZoneCollection_Dxe + FILE_GUID = 82d52ac2-a72c-4036-846a-d87bc1e0f990 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = RedfishZoneCollectionEntryPoint + UNLOAD_IMAGE = RedfishZoneCollectionUnload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + ZoneCollection_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + ZoneCollectionLib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/ZoneCollection/ZoneCollection_Dxe.c b/RedfishClientPkg/Converter/ZoneCollection/ZoneCollection_Dxe.c new file mode 100644 index 00000000000..13cce7bad83 --- /dev/null +++ b/RedfishClientPkg/Converter/ZoneCollection/ZoneCollection_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - ZoneCollection. + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#ZoneCollection"; +BOOLEAN IsRevisonController = FALSE; + +// Support ZoneCollection +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "ZoneCollection", + "NOVERSIONED", + "NOVERSIONED", + "NOVERSIONED" + }, + "ZoneCollection" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneCollectionToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_ZONECOLLECTION *ZoneCollection; + EFI_REDFISH_ZONECOLLECTION_CS *ZoneCollectionCs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "NOVERSIONED") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "ZoneCollection") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_ZoneCollection_To_CS (ResoruceRaw, &ZoneCollectionCs); + if (EFI_ERROR (Status)){ + return Status; + } + ZoneCollection = (EFI_REDFISH_ZONECOLLECTION *)AllocateZeroPool ( + sizeof (EFI_REDFISH_ZONECOLLECTION)); + if (ZoneCollection == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)ZoneCollection; + ZoneCollection->ZoneCollection = ZoneCollectionCs; + ResourceTypeMajorVersion = "NOVERSIONED"; + ResourceTypeMinorVersion = "NOVERSIONED"; + ResourceTypeErrataVersion = "NOVERSIONED"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("ZoneCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("ZoneCollection"), "ZoneCollection"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("ZoneCollection")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("ZoneCollection"), "ZoneCollection"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of ZoneCollectionToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneCollectionToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return ZoneCollectionToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneCollectionToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_ZoneCollection_JSON (*((EFI_REDFISH_ZONECOLLECTION_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in ZoneCollectionToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneCollectionDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_ZONECOLLECTION *ZoneCollection; + + ZoneCollection = (EFI_REDFISH_ZONECOLLECTION *)InterpProp; + DestroyZoneCollection_CS (ZoneCollection->ZoneCollection); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from ZoneCollectionFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +ZoneCollectionDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)DestroyZoneCollection_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +RedfishZoneCollectionEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + ZoneCollectionToStructWrapper, + ZoneCollectionToJson, + ZoneCollectionDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +RedfishZoneCollectionUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/redfisherror/v1_0_0/Redfishredfisherror_V1_0_0_Dxe.inf b/RedfishClientPkg/Converter/redfisherror/v1_0_0/Redfishredfisherror_V1_0_0_Dxe.inf new file mode 100644 index 00000000000..680bd214323 --- /dev/null +++ b/RedfishClientPkg/Converter/redfisherror/v1_0_0/Redfishredfisherror_V1_0_0_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of redfisherror.v1_0_0 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = Redfishredfisherror_V1_0_0_Dxe + FILE_GUID = 5bdea508-a88e-4394-84aa-603537fd8bdb + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = Redfishredfisherror_V1_0_0EntryPoint + UNLOAD_IMAGE = Redfishredfisherror_V1_0_0Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + redfisherror_V1_0_0_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + redfisherrorV1_0_0Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/redfisherror/v1_0_0/redfisherror_V1_0_0_Dxe.c b/RedfishClientPkg/Converter/redfisherror/v1_0_0/redfisherror_V1_0_0_Dxe.c new file mode 100644 index 00000000000..b7436fc6598 --- /dev/null +++ b/RedfishClientPkg/Converter/redfisherror/v1_0_0/redfisherror_V1_0_0_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - redfisherror.v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#redfisherror"; +BOOLEAN IsRevisonController = TRUE; + +// Support redfisherror V1_0_0 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "redfisherror", + "1", + "0", + "0" + }, + "redfisherror" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +redfisherrorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_REDFISHERROR_V1_0_0 *redfisherrorV1_0_0; + EFI_REDFISH_REDFISHERROR_V1_0_0_CS *redfisherrorV1_0_0Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "redfisherror") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_redfisherror_V1_0_0_To_CS (ResoruceRaw, &redfisherrorV1_0_0Cs); + if (EFI_ERROR (Status)){ + return Status; + } + redfisherrorV1_0_0 = (EFI_REDFISH_REDFISHERROR_V1_0_0 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_REDFISHERROR_V1_0_0)); + if (redfisherrorV1_0_0 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)redfisherrorV1_0_0; + redfisherrorV1_0_0->redfisherror = redfisherrorV1_0_0Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "0"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("redfisherror")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("redfisherror"), "redfisherror"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("redfisherror")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("redfisherror"), "redfisherror"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of redfisherrorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +redfisherrorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return redfisherrorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +redfisherrorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_redfisherror_V1_0_0_JSON (*((EFI_REDFISH_REDFISHERROR_V1_0_0_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in redfisherrorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +redfisherrorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_REDFISHERROR_V1_0_0 *redfisherrorV1_0_0; + + redfisherrorV1_0_0 = (EFI_REDFISH_REDFISHERROR_V1_0_0 *)InterpProp; + Destroyredfisherror_V1_0_0_CS (redfisherrorV1_0_0->redfisherror); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from redfisherrorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +redfisherrorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)Destroyredfisherror_V1_0_0_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +Redfishredfisherror_V1_0_0EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + redfisherrorToStructWrapper, + redfisherrorToJson, + redfisherrorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +Redfishredfisherror_V1_0_0Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Converter/redfisherror/v1_0_1/Redfishredfisherror_V1_0_1_Dxe.inf b/RedfishClientPkg/Converter/redfisherror/v1_0_1/Redfishredfisherror_V1_0_1_Dxe.inf new file mode 100644 index 00000000000..a748003f140 --- /dev/null +++ b/RedfishClientPkg/Converter/redfisherror/v1_0_1/Redfishredfisherror_V1_0_1_Dxe.inf @@ -0,0 +1,55 @@ +## @file +# +# INF file of redfisherror.v1_0_1 EFI Redfish JSON Structure DXE driver +# +# (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# Auto-generated file by Redfish Schema C Structure Generator. +# https://github.com/DMTF/Redfish-Schema-C-Struct-Generator +# +# Copyright Notice: +# Copyright 2019-2021 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 +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = Redfishredfisherror_V1_0_1_Dxe + FILE_GUID = 7954397b-bd59-44c2-8216-70dde9ad955c + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = Redfishredfisherror_V1_0_1EntryPoint + UNLOAD_IMAGE = Redfishredfisherror_V1_0_1Unload + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + RedfishPkg/RedfishPkg.dec + RedfishClientPkg/RedfishClientPkg.dec + +[Sources] + redfisherror_V1_0_1_Dxe.c + +[LibraryClasses] + BaseLib + BaseMemoryLib + DebugLib + PrintLib + UefiLib + UefiBootServicesTableLib + UefiDriverEntryPoint + MemoryAllocationLib + + redfisherrorV1_0_1Lib + +[Protocols] + gEfiRestJsonStructureProtocolGuid ## Consuming + +[Depex] + gEfiRestJsonStructureProtocolGuid + +[BuildOptions] + #MSFT:*_*_*_CC_FLAGS = /Od + diff --git a/RedfishClientPkg/Converter/redfisherror/v1_0_1/redfisherror_V1_0_1_Dxe.c b/RedfishClientPkg/Converter/redfisherror/v1_0_1/redfisherror_V1_0_1_Dxe.c new file mode 100644 index 00000000000..077d5a9d670 --- /dev/null +++ b/RedfishClientPkg/Converter/redfisherror/v1_0_1/redfisherror_V1_0_1_Dxe.c @@ -0,0 +1,427 @@ +/** @file + The implementation of EFI Redfish JSON Structure DXE driver for below + Redfish schema. + - redfisherror.v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 d + +**/ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +// +// EFI Redfish Resource Type Identifier. +// +#include +CHAR8 mResourceTypeStr [] = "#redfisherror"; +BOOLEAN IsRevisonController = TRUE; + +// Support redfisherror V1_0_1 +EFI_REST_JSON_STRUCTURE_SUPPORTED ResourceInterP [] = { + { + { + (LIST_ENTRY *)&ResourceInterP[0], (LIST_ENTRY *)&ResourceInterP[0] + }, + { + { + "redfisherror", + "1", + "0", + "1" + }, + "redfisherror" + } + } +}; + +EFI_REST_JSON_STRUCTURE_PROTOCOL *mRestJsonStructureProt = NULL; + +/** + This function gets the string of revision number. + + @param[in] Str Odata.type string. + @param[in] StrIndex Current string index. + @param[in] OdataTypeStrLen Odata.type string length + + @retval != 0 Number found. + @retval 0 Number not found. + +**/ +UINTN +GetOdataTypeVersionNum (CHAR8 *Str, UINTN *StrIndex, UINTN OdataTypeStrLen) +{ + UINTN NumIndex; + UINTN Index; + + Index = *StrIndex; + while (Str[Index] < 0x30 || Str[Index] > 0x39) { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + NumIndex = Index; + while (Str [Index] != '.' && Str [Index] != '_') { + Index ++; + if (OdataTypeStrLen < Index) { + return 0; + } + }; + Str [Index] = 0; + *StrIndex = Index; + return NumIndex; +} + +/** + This function checks if the given JSON property supported by this + Redfish JSON to C structure convertor. + + @param[in] ResoruceRaw Given JSON property. + + @retval EFI_SUCCESS + @retval Others + +**/ +BOOLEAN +CheckSupportedSchema (IN CHAR8 *ResoruceRaw) +{ + json_t *TempJsonObj; + json_t *JsonObjReturned; + CHAR8 *TempChar; + UINTN StrIndex; + UINTN StrMajorIndex; + UINTN StrMinorIndex; + UINTN StrErrataIndex; + UINTN OdataTypeStrLen; + + JsonObjReturned = json_loads(ResoruceRaw, 0, NULL); + TempJsonObj = json_object_get(JsonObjReturned, "@odata.type"); + if (TempJsonObj == NULL) { + goto Error; + } + TempChar = (CHAR8 *)json_string_value(TempJsonObj); + OdataTypeStrLen = AsciiStrLen(TempChar); + // + // Validate odata.type + // + if (OdataTypeStrLen < AsciiStrLen(mResourceTypeStr)) { + goto Error; + } + + if (CompareMem ((VOID *)TempChar, (VOID *)mResourceTypeStr, AsciiStrLen(mResourceTypeStr)) != 0) { + goto Error; + } + StrIndex = AsciiStrLen(mResourceTypeStr); + if (TempChar [StrIndex] != '.' ) { + goto Error; + } + StrIndex ++; + if (OdataTypeStrLen < StrIndex) { + goto Error; + } + if (!IsRevisonController) { + // + // No revision controllerd. + // + return TRUE; + } + + // + // Check major revision. + // + StrMajorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + + // + // Check minor revision. + // + StrMinorIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + // + // Check errata revision. + // + StrErrataIndex = GetOdataTypeVersionNum (TempChar, &StrIndex, OdataTypeStrLen); + if (StrMajorIndex == 0) { + goto Error; + } + if ((AsciiStrCmp(TempChar + StrMajorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MajorVersion) == 0) && + (AsciiStrCmp(TempChar + StrMinorIndex, ResourceInterP[0].RestResourceInterp.NameSpace.MinorVersion) == 0) && + (AsciiStrCmp(TempChar + StrErrataIndex, ResourceInterP[0].RestResourceInterp.NameSpace.ErrataVersion) == 0)) { + json_decref(JsonObjReturned); + return TRUE; + } +Error:; + json_decref(JsonObjReturned); + return FALSE; +} + +/** + This function sets the structure of givin JSON resource in text format through + supported Redfish schema interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[in] PropertyName Name of property defined in the data type to retrieve. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +redfisherrorToStruct ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + IN CHAR8 *PropertyName OPTIONAL, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + EFI_REDFISH_REDFISHERROR_V1_0_1 *redfisherrorV1_0_1; + EFI_REDFISH_REDFISHERROR_V1_0_1_CS *redfisherrorV1_0_1Cs; + EFI_REST_JSON_STRUCTURE_HEADER *RestIntrpHeader; + CHAR8 *ResourceTypeMajorVersion; + CHAR8 *ResourceTypeMinorVersion; + CHAR8 *ResourceTypeErrataVersion; + EFI_STATUS Status; + + if (ResoruceRaw == NULL || (RsrcIdentifier != NULL && RsrcIdentifier->NameSpace.ResourceTypeName == NULL)) { + return EFI_INVALID_PARAMETER; + } + if (RsrcIdentifier == NULL || + (RsrcIdentifier != NULL && + (RsrcIdentifier->NameSpace.MajorVersion == NULL || + RsrcIdentifier->NameSpace.MinorVersion == NULL || + RsrcIdentifier->NameSpace.ErrataVersion == NULL)) + ) { + // + // Support revision determination. + // + if (!CheckSupportedSchema (ResoruceRaw)) { + return EFI_UNSUPPORTED; + } + } else if ((AsciiStrCmp (RsrcIdentifier->NameSpace.MajorVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.MinorVersion, "0") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ErrataVersion, "1") != 0) || + (AsciiStrCmp (RsrcIdentifier->NameSpace.ResourceTypeName, "redfisherror") != 0)) { + return EFI_UNSUPPORTED; + } + + Status = (EFI_STATUS)Json_redfisherror_V1_0_1_To_CS (ResoruceRaw, &redfisherrorV1_0_1Cs); + if (EFI_ERROR (Status)){ + return Status; + } + redfisherrorV1_0_1 = (EFI_REDFISH_REDFISHERROR_V1_0_1 *)AllocateZeroPool ( + sizeof (EFI_REDFISH_REDFISHERROR_V1_0_1)); + if (redfisherrorV1_0_1 == NULL){ + return EFI_OUT_OF_RESOURCES; + } + RestIntrpHeader = (EFI_REST_JSON_STRUCTURE_HEADER *)redfisherrorV1_0_1; + redfisherrorV1_0_1->redfisherror = redfisherrorV1_0_1Cs; + ResourceTypeMajorVersion = "1"; + ResourceTypeMinorVersion = "0"; + ResourceTypeErrataVersion = "1"; + // + // Set header. + // + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName = (CHAR8 *)AllocatePool (AsciiStrSize ("redfisherror")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName, AsciiStrSize ("redfisherror"), "redfisherror"); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMajorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MajorVersion, AsciiStrSize (ResourceTypeMajorVersion), ResourceTypeMajorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeMinorVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.MinorVersion, AsciiStrSize (ResourceTypeMinorVersion), ResourceTypeMinorVersion); + RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion = (CHAR8 *)AllocatePool (AsciiStrSize (ResourceTypeErrataVersion)); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion, AsciiStrSize (ResourceTypeErrataVersion), ResourceTypeErrataVersion); + RestIntrpHeader->JsonRsrcIdentifier.DataType = (CHAR8 *)AllocatePool (AsciiStrSize ("redfisherror")); + AsciiStrCpyS (RestIntrpHeader->JsonRsrcIdentifier.DataType, AsciiStrSize ("redfisherror"), "redfisherror"); + *InterpProp = RestIntrpHeader; + return EFI_SUCCESS; +} + + +/** + The wrapper function of redfisherrorToStruct which invokes **RESOURCE_TYPE**!ToStruct + with additional parameter "PropertyName". + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw Given Restful resource. + @param[out] InterpProp Property interpreted from given ResoruceRaw. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +redfisherrorToStructWrapper ( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier OPTIONAL, + IN CHAR8 *ResoruceRaw, + OUT EFI_REST_JSON_STRUCTURE_HEADER **InterpProp +) +{ + return redfisherrorToStruct ( + This, + RsrcIdentifier, + ResoruceRaw, + NULL, + InterpProp + ); +} + +/** + This function returns JSON property in text format for the given structure through + supported Restful data interpreter. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + @param[out] ResoruceRaw Resource in RESTfuls service oriented property interpreted from given ResoruceRaw. + Caller has to release the memory allocated for ResoruceRaw using DestoryJson function. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +redfisherrorToJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp, + OUT CHAR8 **ResoruceRaw +) +{ + if (InterpProp == NULL || ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)CS_To_redfisherror_V1_0_1_JSON (*((EFI_REDFISH_REDFISHERROR_V1_0_1_CS **)((UINT8 *)InterpProp + sizeof (EFI_REST_JSON_STRUCTURE_HEADER))), ResoruceRaw); +} + +/** + This function destory structure retunred in redfisherrorToStruct. + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] InterpProp Given Restful resource. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +redfisherrorDestoryStruct( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_STRUCTURE_HEADER *InterpProp +) +{ + EFI_REDFISH_REDFISHERROR_V1_0_1 *redfisherrorV1_0_1; + + redfisherrorV1_0_1 = (EFI_REDFISH_REDFISHERROR_V1_0_1 *)InterpProp; + Destroyredfisherror_V1_0_1_CS (redfisherrorV1_0_1->redfisherror); + return EFI_SUCCESS; +} + +/** + This function destory JSON raw text returned from redfisherrorFromStruct + + @param[in] This EFI_REST_JSON_STRUCTURE_PROTOCOL instance. + @param[in] RsrcTypeIdentifier Resource type identifier. + @param[in] ResoruceRaw JSON raw text. + + @retval EFI_SUCCESS + @retval Others + +**/ +EFI_STATUS +EFIAPI +redfisherrorDestoryJson( + IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This, + IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcIdentifier, + IN CHAR8 *ResoruceRaw +) +{ + if (ResoruceRaw == NULL) { + return EFI_INVALID_PARAMETER; + } + return (EFI_STATUS)Destroyredfisherror_V1_0_1_Json (ResoruceRaw); +} + +/** + This is the declaration of an EFI image entry point. + + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The operation completed successfully. + @retval Others An unexpected error occurred. +**/ +EFI_STATUS +EFIAPI +Redfishredfisherror_V1_0_1EntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + if (mRestJsonStructureProt == NULL) { + Status = gBS->LocateProtocol(&gEfiRestJsonStructureProtocolGuid, NULL, (VOID **)&mRestJsonStructureProt); + if ((EFI_ERROR (Status))) { + return Status; + } + } + Status = mRestJsonStructureProt->Register ( + mRestJsonStructureProt, + ResourceInterP, + redfisherrorToStructWrapper, + redfisherrorToJson, + redfisherrorDestoryStruct + ); + return Status; +} + +/** + This is the unload handle for Redfish discover module. + + Disconnect the driver specified by ImageHandle from all the devices in the handle database. + Uninstall all the protocols installed in the driver entry point. + + @param[in] ImageHandle The drivers' driver image. + + @retval EFI_SUCCESS The image is unloaded. + @retval Others Failed to unload the image. + +**/ +EFI_STATUS +EFIAPI +Redfishredfisherror_V1_0_1Unload ( + IN EFI_HANDLE ImageHandle + ) +{ + // + // Shall we implement Unregister() function in EFI JSON Structure Protocol? + // + return EFI_SUCCESS; +} diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccelerationFunction/v1_0_0/EfiAccelerationFunctionV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccelerationFunction/v1_0_0/EfiAccelerationFunctionV1_0_0.h new file mode 100644 index 00000000000..7ab400f851f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccelerationFunction/v1_0_0/EfiAccelerationFunctionV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccelerationFunction v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCELERATIONFUNCTION_V1_0_0_H__ +#define EFI_REDFISH_INTERP_ACCELERATIONFUNCTION_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/AccelerationFunction/v1_0_0/Redfish_AccelerationFunction_v1_0_0_CS.h" +// +// EFI structure of Redfish AccelerationFunction v1_0_0 +// +typedef struct _EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_0_CS *AccelerationFunction; +} EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccelerationFunction/v1_0_1/EfiAccelerationFunctionV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccelerationFunction/v1_0_1/EfiAccelerationFunctionV1_0_1.h new file mode 100644 index 00000000000..add0aa6862c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccelerationFunction/v1_0_1/EfiAccelerationFunctionV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccelerationFunction v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCELERATIONFUNCTION_V1_0_1_H__ +#define EFI_REDFISH_INTERP_ACCELERATIONFUNCTION_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/AccelerationFunction/v1_0_1/Redfish_AccelerationFunction_v1_0_1_CS.h" +// +// EFI structure of Redfish AccelerationFunction v1_0_1 +// +typedef struct _EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_1_CS *AccelerationFunction; +} EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccelerationFunction/v1_0_2/EfiAccelerationFunctionV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccelerationFunction/v1_0_2/EfiAccelerationFunctionV1_0_2.h new file mode 100644 index 00000000000..31f6b5ffc59 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccelerationFunction/v1_0_2/EfiAccelerationFunctionV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccelerationFunction v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCELERATIONFUNCTION_V1_0_2_H__ +#define EFI_REDFISH_INTERP_ACCELERATIONFUNCTION_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/AccelerationFunction/v1_0_2/Redfish_AccelerationFunction_v1_0_2_CS.h" +// +// EFI structure of Redfish AccelerationFunction v1_0_2 +// +typedef struct _EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_2_CS *AccelerationFunction; +} EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccelerationFunction/v1_0_3/EfiAccelerationFunctionV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccelerationFunction/v1_0_3/EfiAccelerationFunctionV1_0_3.h new file mode 100644 index 00000000000..02d44981bbb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccelerationFunction/v1_0_3/EfiAccelerationFunctionV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccelerationFunction v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCELERATIONFUNCTION_V1_0_3_H__ +#define EFI_REDFISH_INTERP_ACCELERATIONFUNCTION_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/AccelerationFunction/v1_0_3/Redfish_AccelerationFunction_v1_0_3_CS.h" +// +// EFI structure of Redfish AccelerationFunction v1_0_3 +// +typedef struct _EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_3_CS *AccelerationFunction; +} EFI_REDFISH_ACCELERATIONFUNCTION_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccelerationFunctionCollection/EfiAccelerationFunctionCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccelerationFunctionCollection/EfiAccelerationFunctionCollection.h new file mode 100644 index 00000000000..be06b80a79a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccelerationFunctionCollection/EfiAccelerationFunctionCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccelerationFunctionCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCELERATIONFUNCTIONCOLLECTION_H__ +#define EFI_REDFISH_INTERP_ACCELERATIONFUNCTIONCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/AccelerationFunctionCollection/Redfish_AccelerationFunctionCollection_CS.h" +// +// EFI structure of Redfish AccelerationFunctionCollection +// +typedef struct _EFI_REDFISH_ACCELERATIONFUNCTIONCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCELERATIONFUNCTIONCOLLECTION_CS *AccelerationFunctionCollection; +} EFI_REDFISH_ACCELERATIONFUNCTIONCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_0/EfiAccountServiceV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_0/EfiAccountServiceV1_0_0.h new file mode 100644 index 00000000000..270291bcfa6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_0/EfiAccountServiceV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_0_0/Redfish_AccountService_v1_0_0_CS.h" +// +// EFI structure of Redfish AccountService v1_0_0 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_0_0_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_10/EfiAccountServiceV1_0_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_10/EfiAccountServiceV1_0_10.h new file mode 100644 index 00000000000..7cdb2637917 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_10/EfiAccountServiceV1_0_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_0_10_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_0_10_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_0_10/Redfish_AccountService_v1_0_10_CS.h" +// +// EFI structure of Redfish AccountService v1_0_10 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_0_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_0_10_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_0_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_11/EfiAccountServiceV1_0_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_11/EfiAccountServiceV1_0_11.h new file mode 100644 index 00000000000..0e9525d7cdd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_11/EfiAccountServiceV1_0_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_0_11_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_0_11_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_0_11/Redfish_AccountService_v1_0_11_CS.h" +// +// EFI structure of Redfish AccountService v1_0_11 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_0_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_0_11_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_0_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_2/EfiAccountServiceV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_2/EfiAccountServiceV1_0_2.h new file mode 100644 index 00000000000..8934c683460 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_2/EfiAccountServiceV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_0_2_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_0_2/Redfish_AccountService_v1_0_2_CS.h" +// +// EFI structure of Redfish AccountService v1_0_2 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_0_2_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_3/EfiAccountServiceV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_3/EfiAccountServiceV1_0_3.h new file mode 100644 index 00000000000..18b08292e8f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_3/EfiAccountServiceV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_0_3_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_0_3/Redfish_AccountService_v1_0_3_CS.h" +// +// EFI structure of Redfish AccountService v1_0_3 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_0_3_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_4/EfiAccountServiceV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_4/EfiAccountServiceV1_0_4.h new file mode 100644 index 00000000000..96bae3e69cc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_4/EfiAccountServiceV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_0_4_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_0_4/Redfish_AccountService_v1_0_4_CS.h" +// +// EFI structure of Redfish AccountService v1_0_4 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_0_4_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_5/EfiAccountServiceV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_5/EfiAccountServiceV1_0_5.h new file mode 100644 index 00000000000..58f6372732c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_5/EfiAccountServiceV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_0_5_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_0_5/Redfish_AccountService_v1_0_5_CS.h" +// +// EFI structure of Redfish AccountService v1_0_5 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_0_5_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_6/EfiAccountServiceV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_6/EfiAccountServiceV1_0_6.h new file mode 100644 index 00000000000..be165e5a75a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_6/EfiAccountServiceV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_0_6_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_0_6/Redfish_AccountService_v1_0_6_CS.h" +// +// EFI structure of Redfish AccountService v1_0_6 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_0_6_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_7/EfiAccountServiceV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_7/EfiAccountServiceV1_0_7.h new file mode 100644 index 00000000000..76620aff8e2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_7/EfiAccountServiceV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_0_7_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_0_7/Redfish_AccountService_v1_0_7_CS.h" +// +// EFI structure of Redfish AccountService v1_0_7 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_0_7_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_8/EfiAccountServiceV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_8/EfiAccountServiceV1_0_8.h new file mode 100644 index 00000000000..7a2490f168d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_8/EfiAccountServiceV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_0_8_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_0_8/Redfish_AccountService_v1_0_8_CS.h" +// +// EFI structure of Redfish AccountService v1_0_8 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_0_8_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_9/EfiAccountServiceV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_9/EfiAccountServiceV1_0_9.h new file mode 100644 index 00000000000..c5e253c3b7a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_0_9/EfiAccountServiceV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_0_9_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_0_9/Redfish_AccountService_v1_0_9_CS.h" +// +// EFI structure of Redfish AccountService v1_0_9 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_0_9_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_0/EfiAccountServiceV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_0/EfiAccountServiceV1_1_0.h new file mode 100644 index 00000000000..049a39b8174 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_0/EfiAccountServiceV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_1_0_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_1_0/Redfish_AccountService_v1_1_0_CS.h" +// +// EFI structure of Redfish AccountService v1_1_0 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_1_0_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_1/EfiAccountServiceV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_1/EfiAccountServiceV1_1_1.h new file mode 100644 index 00000000000..0955a3a0c2d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_1/EfiAccountServiceV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_1_1_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_1_1/Redfish_AccountService_v1_1_1_CS.h" +// +// EFI structure of Redfish AccountService v1_1_1 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_1_1_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_2/EfiAccountServiceV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_2/EfiAccountServiceV1_1_2.h new file mode 100644 index 00000000000..da978de3c8b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_2/EfiAccountServiceV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_1_2_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_1_2/Redfish_AccountService_v1_1_2_CS.h" +// +// EFI structure of Redfish AccountService v1_1_2 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_1_2_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_3/EfiAccountServiceV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_3/EfiAccountServiceV1_1_3.h new file mode 100644 index 00000000000..e26b38eeef6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_3/EfiAccountServiceV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_1_3_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_1_3/Redfish_AccountService_v1_1_3_CS.h" +// +// EFI structure of Redfish AccountService v1_1_3 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_1_3_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_4/EfiAccountServiceV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_4/EfiAccountServiceV1_1_4.h new file mode 100644 index 00000000000..d6adf84a837 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_4/EfiAccountServiceV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_1_4_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_1_4/Redfish_AccountService_v1_1_4_CS.h" +// +// EFI structure of Redfish AccountService v1_1_4 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_1_4_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_5/EfiAccountServiceV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_5/EfiAccountServiceV1_1_5.h new file mode 100644 index 00000000000..8791bd4f2cb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_5/EfiAccountServiceV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_1_5_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_1_5/Redfish_AccountService_v1_1_5_CS.h" +// +// EFI structure of Redfish AccountService v1_1_5 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_1_5_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_6/EfiAccountServiceV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_6/EfiAccountServiceV1_1_6.h new file mode 100644 index 00000000000..2022f489dba --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_6/EfiAccountServiceV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_1_6_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_1_6/Redfish_AccountService_v1_1_6_CS.h" +// +// EFI structure of Redfish AccountService v1_1_6 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_1_6_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_7/EfiAccountServiceV1_1_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_7/EfiAccountServiceV1_1_7.h new file mode 100644 index 00000000000..9bed238f937 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_7/EfiAccountServiceV1_1_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_1_7_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_1_7_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_1_7/Redfish_AccountService_v1_1_7_CS.h" +// +// EFI structure of Redfish AccountService v1_1_7 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_1_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_1_7_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_1_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_8/EfiAccountServiceV1_1_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_8/EfiAccountServiceV1_1_8.h new file mode 100644 index 00000000000..a7058a34097 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_1_8/EfiAccountServiceV1_1_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_1_8_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_1_8_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_1_8/Redfish_AccountService_v1_1_8_CS.h" +// +// EFI structure of Redfish AccountService v1_1_8 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_1_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_1_8_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_1_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_0/EfiAccountServiceV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_0/EfiAccountServiceV1_2_0.h new file mode 100644 index 00000000000..2c935cdb04f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_0/EfiAccountServiceV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_2_0_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_2_0/Redfish_AccountService_v1_2_0_CS.h" +// +// EFI structure of Redfish AccountService v1_2_0 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_2_0_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_1/EfiAccountServiceV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_1/EfiAccountServiceV1_2_1.h new file mode 100644 index 00000000000..cc4cbc4ab45 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_1/EfiAccountServiceV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_2_1_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_2_1/Redfish_AccountService_v1_2_1_CS.h" +// +// EFI structure of Redfish AccountService v1_2_1 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_2_1_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_2/EfiAccountServiceV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_2/EfiAccountServiceV1_2_2.h new file mode 100644 index 00000000000..bc6ad7b2c54 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_2/EfiAccountServiceV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_2_2_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_2_2/Redfish_AccountService_v1_2_2_CS.h" +// +// EFI structure of Redfish AccountService v1_2_2 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_2_2_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_3/EfiAccountServiceV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_3/EfiAccountServiceV1_2_3.h new file mode 100644 index 00000000000..a26cebcbdbf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_3/EfiAccountServiceV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_2_3_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_2_3/Redfish_AccountService_v1_2_3_CS.h" +// +// EFI structure of Redfish AccountService v1_2_3 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_2_3_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_4/EfiAccountServiceV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_4/EfiAccountServiceV1_2_4.h new file mode 100644 index 00000000000..315b28dae43 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_4/EfiAccountServiceV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_2_4_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_2_4/Redfish_AccountService_v1_2_4_CS.h" +// +// EFI structure of Redfish AccountService v1_2_4 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_2_4_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_5/EfiAccountServiceV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_5/EfiAccountServiceV1_2_5.h new file mode 100644 index 00000000000..d5ba6b3e353 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_5/EfiAccountServiceV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_2_5_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_2_5/Redfish_AccountService_v1_2_5_CS.h" +// +// EFI structure of Redfish AccountService v1_2_5 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_2_5_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_6/EfiAccountServiceV1_2_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_6/EfiAccountServiceV1_2_6.h new file mode 100644 index 00000000000..15d9f430d22 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_6/EfiAccountServiceV1_2_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_2_6_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_2_6_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_2_6/Redfish_AccountService_v1_2_6_CS.h" +// +// EFI structure of Redfish AccountService v1_2_6 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_2_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_2_6_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_2_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_7/EfiAccountServiceV1_2_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_7/EfiAccountServiceV1_2_7.h new file mode 100644 index 00000000000..2d2df781cc5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_7/EfiAccountServiceV1_2_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_2_7_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_2_7_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_2_7/Redfish_AccountService_v1_2_7_CS.h" +// +// EFI structure of Redfish AccountService v1_2_7 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_2_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_2_7_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_2_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_8/EfiAccountServiceV1_2_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_8/EfiAccountServiceV1_2_8.h new file mode 100644 index 00000000000..db2b3bc94b5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_2_8/EfiAccountServiceV1_2_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_2_8_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_2_8_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_2_8/Redfish_AccountService_v1_2_8_CS.h" +// +// EFI structure of Redfish AccountService v1_2_8 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_2_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_2_8_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_2_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_0/EfiAccountServiceV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_0/EfiAccountServiceV1_3_0.h new file mode 100644 index 00000000000..88692659615 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_0/EfiAccountServiceV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_3_0_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_3_0/Redfish_AccountService_v1_3_0_CS.h" +// +// EFI structure of Redfish AccountService v1_3_0 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_3_0_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_1/EfiAccountServiceV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_1/EfiAccountServiceV1_3_1.h new file mode 100644 index 00000000000..3708680e862 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_1/EfiAccountServiceV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_3_1_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_3_1/Redfish_AccountService_v1_3_1_CS.h" +// +// EFI structure of Redfish AccountService v1_3_1 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_3_1_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_2/EfiAccountServiceV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_2/EfiAccountServiceV1_3_2.h new file mode 100644 index 00000000000..1c5c2d7ae35 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_2/EfiAccountServiceV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_3_2_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_3_2/Redfish_AccountService_v1_3_2_CS.h" +// +// EFI structure of Redfish AccountService v1_3_2 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_3_2_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_3/EfiAccountServiceV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_3/EfiAccountServiceV1_3_3.h new file mode 100644 index 00000000000..a510664d390 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_3/EfiAccountServiceV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_3_3_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_3_3/Redfish_AccountService_v1_3_3_CS.h" +// +// EFI structure of Redfish AccountService v1_3_3 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_3_3_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_4/EfiAccountServiceV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_4/EfiAccountServiceV1_3_4.h new file mode 100644 index 00000000000..cb2a9db9dd1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_4/EfiAccountServiceV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_3_4_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_3_4/Redfish_AccountService_v1_3_4_CS.h" +// +// EFI structure of Redfish AccountService v1_3_4 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_3_4_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_5/EfiAccountServiceV1_3_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_5/EfiAccountServiceV1_3_5.h new file mode 100644 index 00000000000..e8cc08d112d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_5/EfiAccountServiceV1_3_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_3_5_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_3_5_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_3_5/Redfish_AccountService_v1_3_5_CS.h" +// +// EFI structure of Redfish AccountService v1_3_5 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_3_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_3_5_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_3_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_6/EfiAccountServiceV1_3_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_6/EfiAccountServiceV1_3_6.h new file mode 100644 index 00000000000..53e63ebf770 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_6/EfiAccountServiceV1_3_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_3_6_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_3_6_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_3_6/Redfish_AccountService_v1_3_6_CS.h" +// +// EFI structure of Redfish AccountService v1_3_6 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_3_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_3_6_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_3_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_7/EfiAccountServiceV1_3_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_7/EfiAccountServiceV1_3_7.h new file mode 100644 index 00000000000..7d1c6ff20c9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_3_7/EfiAccountServiceV1_3_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_3_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_3_7_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_3_7_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_3_7/Redfish_AccountService_v1_3_7_CS.h" +// +// EFI structure of Redfish AccountService v1_3_7 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_3_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_3_7_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_3_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_4_0/EfiAccountServiceV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_4_0/EfiAccountServiceV1_4_0.h new file mode 100644 index 00000000000..130c9f536bc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_4_0/EfiAccountServiceV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_4_0_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_4_0/Redfish_AccountService_v1_4_0_CS.h" +// +// EFI structure of Redfish AccountService v1_4_0 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_4_0_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_4_1/EfiAccountServiceV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_4_1/EfiAccountServiceV1_4_1.h new file mode 100644 index 00000000000..7082d5c072f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_4_1/EfiAccountServiceV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_4_1_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_4_1/Redfish_AccountService_v1_4_1_CS.h" +// +// EFI structure of Redfish AccountService v1_4_1 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_4_1_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_4_2/EfiAccountServiceV1_4_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_4_2/EfiAccountServiceV1_4_2.h new file mode 100644 index 00000000000..1db6bbd0272 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_4_2/EfiAccountServiceV1_4_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_4_2_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_4_2_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_4_2/Redfish_AccountService_v1_4_2_CS.h" +// +// EFI structure of Redfish AccountService v1_4_2 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_4_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_4_2_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_4_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_4_3/EfiAccountServiceV1_4_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_4_3/EfiAccountServiceV1_4_3.h new file mode 100644 index 00000000000..c1e4d2df4ef --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_4_3/EfiAccountServiceV1_4_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_4_3_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_4_3_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_4_3/Redfish_AccountService_v1_4_3_CS.h" +// +// EFI structure of Redfish AccountService v1_4_3 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_4_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_4_3_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_4_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_4_4/EfiAccountServiceV1_4_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_4_4/EfiAccountServiceV1_4_4.h new file mode 100644 index 00000000000..35a8273f25b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_4_4/EfiAccountServiceV1_4_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_4_4_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_4_4_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_4_4/Redfish_AccountService_v1_4_4_CS.h" +// +// EFI structure of Redfish AccountService v1_4_4 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_4_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_4_4_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_4_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_4_5/EfiAccountServiceV1_4_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_4_5/EfiAccountServiceV1_4_5.h new file mode 100644 index 00000000000..bc995b6db0f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_4_5/EfiAccountServiceV1_4_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_4_5_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_4_5_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_4_5/Redfish_AccountService_v1_4_5_CS.h" +// +// EFI structure of Redfish AccountService v1_4_5 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_4_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_4_5_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_4_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_5_0/EfiAccountServiceV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_5_0/EfiAccountServiceV1_5_0.h new file mode 100644 index 00000000000..86590e3f130 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_5_0/EfiAccountServiceV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_5_0_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_5_0/Redfish_AccountService_v1_5_0_CS.h" +// +// EFI structure of Redfish AccountService v1_5_0 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_5_0_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_5_1/EfiAccountServiceV1_5_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_5_1/EfiAccountServiceV1_5_1.h new file mode 100644 index 00000000000..3d049389652 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_5_1/EfiAccountServiceV1_5_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_5_1_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_5_1_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_5_1/Redfish_AccountService_v1_5_1_CS.h" +// +// EFI structure of Redfish AccountService v1_5_1 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_5_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_5_1_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_5_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_5_2/EfiAccountServiceV1_5_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_5_2/EfiAccountServiceV1_5_2.h new file mode 100644 index 00000000000..06cab5da4cf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_5_2/EfiAccountServiceV1_5_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_5_2_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_5_2_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_5_2/Redfish_AccountService_v1_5_2_CS.h" +// +// EFI structure of Redfish AccountService v1_5_2 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_5_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_5_2_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_5_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_5_3/EfiAccountServiceV1_5_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_5_3/EfiAccountServiceV1_5_3.h new file mode 100644 index 00000000000..a0561505217 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_5_3/EfiAccountServiceV1_5_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_5_3_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_5_3_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_5_3/Redfish_AccountService_v1_5_3_CS.h" +// +// EFI structure of Redfish AccountService v1_5_3 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_5_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_5_3_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_5_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_5_4/EfiAccountServiceV1_5_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_5_4/EfiAccountServiceV1_5_4.h new file mode 100644 index 00000000000..11a0c9a1b2b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_5_4/EfiAccountServiceV1_5_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_5_4_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_5_4_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_5_4/Redfish_AccountService_v1_5_4_CS.h" +// +// EFI structure of Redfish AccountService v1_5_4 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_5_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_5_4_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_5_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_6_0/EfiAccountServiceV1_6_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_6_0/EfiAccountServiceV1_6_0.h new file mode 100644 index 00000000000..f09d9709f03 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_6_0/EfiAccountServiceV1_6_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_6_0_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_6_0_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_6_0/Redfish_AccountService_v1_6_0_CS.h" +// +// EFI structure of Redfish AccountService v1_6_0 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_6_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_6_0_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_6_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_6_1/EfiAccountServiceV1_6_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_6_1/EfiAccountServiceV1_6_1.h new file mode 100644 index 00000000000..55803032bc3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_6_1/EfiAccountServiceV1_6_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_6_1_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_6_1_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_6_1/Redfish_AccountService_v1_6_1_CS.h" +// +// EFI structure of Redfish AccountService v1_6_1 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_6_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_6_1_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_6_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_6_2/EfiAccountServiceV1_6_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_6_2/EfiAccountServiceV1_6_2.h new file mode 100644 index 00000000000..031f3833f22 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_6_2/EfiAccountServiceV1_6_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_6_2_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_6_2_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_6_2/Redfish_AccountService_v1_6_2_CS.h" +// +// EFI structure of Redfish AccountService v1_6_2 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_6_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_6_2_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_6_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_6_3/EfiAccountServiceV1_6_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_6_3/EfiAccountServiceV1_6_3.h new file mode 100644 index 00000000000..828630594a9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_6_3/EfiAccountServiceV1_6_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_6_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_6_3_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_6_3_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_6_3/Redfish_AccountService_v1_6_3_CS.h" +// +// EFI structure of Redfish AccountService v1_6_3 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_6_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_6_3_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_6_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_7_0/EfiAccountServiceV1_7_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_7_0/EfiAccountServiceV1_7_0.h new file mode 100644 index 00000000000..a6895bd5716 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_7_0/EfiAccountServiceV1_7_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_7_0_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_7_0_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_7_0/Redfish_AccountService_v1_7_0_CS.h" +// +// EFI structure of Redfish AccountService v1_7_0 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_7_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_7_0_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_7_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_7_1/EfiAccountServiceV1_7_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_7_1/EfiAccountServiceV1_7_1.h new file mode 100644 index 00000000000..c54055a9dd1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_7_1/EfiAccountServiceV1_7_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_7_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_7_1_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_7_1_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_7_1/Redfish_AccountService_v1_7_1_CS.h" +// +// EFI structure of Redfish AccountService v1_7_1 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_7_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_7_1_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_7_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_7_2/EfiAccountServiceV1_7_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_7_2/EfiAccountServiceV1_7_2.h new file mode 100644 index 00000000000..39d9738b864 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_7_2/EfiAccountServiceV1_7_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_7_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_7_2_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_7_2_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_7_2/Redfish_AccountService_v1_7_2_CS.h" +// +// EFI structure of Redfish AccountService v1_7_2 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_7_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_7_2_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_7_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_7_3/EfiAccountServiceV1_7_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_7_3/EfiAccountServiceV1_7_3.h new file mode 100644 index 00000000000..d1e996bcb08 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_7_3/EfiAccountServiceV1_7_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_7_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_7_3_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_7_3_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_7_3/Redfish_AccountService_v1_7_3_CS.h" +// +// EFI structure of Redfish AccountService v1_7_3 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_7_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_7_3_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_7_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_8_0/EfiAccountServiceV1_8_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_8_0/EfiAccountServiceV1_8_0.h new file mode 100644 index 00000000000..5de98cb4bce --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AccountService/v1_8_0/EfiAccountServiceV1_8_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AccountService v1_8_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_8_0_H__ +#define EFI_REDFISH_INTERP_ACCOUNTSERVICE_V1_8_0_H__ + +#include +#include +#include "ConverterLib/edk2library/AccountService/v1_8_0/Redfish_AccountService_v1_8_0_CS.h" +// +// EFI structure of Redfish AccountService v1_8_0 +// +typedef struct _EFI_REDFISH_ACCOUNTSERVICE_V1_8_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACCOUNTSERVICE_V1_8_0_CS *AccountService; +} EFI_REDFISH_ACCOUNTSERVICE_V1_8_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_0/EfiActionInfoV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_0/EfiActionInfoV1_0_0.h new file mode 100644 index 00000000000..17103ee5519 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_0/EfiActionInfoV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ActionInfo v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACTIONINFO_V1_0_0_H__ +#define EFI_REDFISH_INTERP_ACTIONINFO_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ActionInfo/v1_0_0/Redfish_ActionInfo_v1_0_0_CS.h" +// +// EFI structure of Redfish ActionInfo v1_0_0 +// +typedef struct _EFI_REDFISH_ACTIONINFO_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACTIONINFO_V1_0_0_CS *ActionInfo; +} EFI_REDFISH_ACTIONINFO_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_1/EfiActionInfoV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_1/EfiActionInfoV1_0_1.h new file mode 100644 index 00000000000..6bdf7904e90 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_1/EfiActionInfoV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ActionInfo v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACTIONINFO_V1_0_1_H__ +#define EFI_REDFISH_INTERP_ACTIONINFO_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ActionInfo/v1_0_1/Redfish_ActionInfo_v1_0_1_CS.h" +// +// EFI structure of Redfish ActionInfo v1_0_1 +// +typedef struct _EFI_REDFISH_ACTIONINFO_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACTIONINFO_V1_0_1_CS *ActionInfo; +} EFI_REDFISH_ACTIONINFO_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_2/EfiActionInfoV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_2/EfiActionInfoV1_0_2.h new file mode 100644 index 00000000000..72133972073 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_2/EfiActionInfoV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ActionInfo v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACTIONINFO_V1_0_2_H__ +#define EFI_REDFISH_INTERP_ACTIONINFO_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ActionInfo/v1_0_2/Redfish_ActionInfo_v1_0_2_CS.h" +// +// EFI structure of Redfish ActionInfo v1_0_2 +// +typedef struct _EFI_REDFISH_ACTIONINFO_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACTIONINFO_V1_0_2_CS *ActionInfo; +} EFI_REDFISH_ACTIONINFO_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_3/EfiActionInfoV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_3/EfiActionInfoV1_0_3.h new file mode 100644 index 00000000000..283b6815eff --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_3/EfiActionInfoV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ActionInfo v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACTIONINFO_V1_0_3_H__ +#define EFI_REDFISH_INTERP_ACTIONINFO_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ActionInfo/v1_0_3/Redfish_ActionInfo_v1_0_3_CS.h" +// +// EFI structure of Redfish ActionInfo v1_0_3 +// +typedef struct _EFI_REDFISH_ACTIONINFO_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACTIONINFO_V1_0_3_CS *ActionInfo; +} EFI_REDFISH_ACTIONINFO_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_4/EfiActionInfoV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_4/EfiActionInfoV1_0_4.h new file mode 100644 index 00000000000..7883983a432 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_4/EfiActionInfoV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ActionInfo v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACTIONINFO_V1_0_4_H__ +#define EFI_REDFISH_INTERP_ACTIONINFO_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ActionInfo/v1_0_4/Redfish_ActionInfo_v1_0_4_CS.h" +// +// EFI structure of Redfish ActionInfo v1_0_4 +// +typedef struct _EFI_REDFISH_ACTIONINFO_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACTIONINFO_V1_0_4_CS *ActionInfo; +} EFI_REDFISH_ACTIONINFO_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_5/EfiActionInfoV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_5/EfiActionInfoV1_0_5.h new file mode 100644 index 00000000000..30fdd5f8ea4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_5/EfiActionInfoV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ActionInfo v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACTIONINFO_V1_0_5_H__ +#define EFI_REDFISH_INTERP_ACTIONINFO_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/ActionInfo/v1_0_5/Redfish_ActionInfo_v1_0_5_CS.h" +// +// EFI structure of Redfish ActionInfo v1_0_5 +// +typedef struct _EFI_REDFISH_ACTIONINFO_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACTIONINFO_V1_0_5_CS *ActionInfo; +} EFI_REDFISH_ACTIONINFO_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_6/EfiActionInfoV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_6/EfiActionInfoV1_0_6.h new file mode 100644 index 00000000000..defe6e55ff4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_0_6/EfiActionInfoV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ActionInfo v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACTIONINFO_V1_0_6_H__ +#define EFI_REDFISH_INTERP_ACTIONINFO_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/ActionInfo/v1_0_6/Redfish_ActionInfo_v1_0_6_CS.h" +// +// EFI structure of Redfish ActionInfo v1_0_6 +// +typedef struct _EFI_REDFISH_ACTIONINFO_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACTIONINFO_V1_0_6_CS *ActionInfo; +} EFI_REDFISH_ACTIONINFO_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_1_0/EfiActionInfoV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_1_0/EfiActionInfoV1_1_0.h new file mode 100644 index 00000000000..21127e9ae5e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_1_0/EfiActionInfoV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ActionInfo v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACTIONINFO_V1_1_0_H__ +#define EFI_REDFISH_INTERP_ACTIONINFO_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ActionInfo/v1_1_0/Redfish_ActionInfo_v1_1_0_CS.h" +// +// EFI structure of Redfish ActionInfo v1_1_0 +// +typedef struct _EFI_REDFISH_ACTIONINFO_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACTIONINFO_V1_1_0_CS *ActionInfo; +} EFI_REDFISH_ACTIONINFO_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_1_1/EfiActionInfoV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_1_1/EfiActionInfoV1_1_1.h new file mode 100644 index 00000000000..d64c5cc797d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_1_1/EfiActionInfoV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ActionInfo v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACTIONINFO_V1_1_1_H__ +#define EFI_REDFISH_INTERP_ACTIONINFO_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ActionInfo/v1_1_1/Redfish_ActionInfo_v1_1_1_CS.h" +// +// EFI structure of Redfish ActionInfo v1_1_1 +// +typedef struct _EFI_REDFISH_ACTIONINFO_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACTIONINFO_V1_1_1_CS *ActionInfo; +} EFI_REDFISH_ACTIONINFO_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_1_2/EfiActionInfoV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_1_2/EfiActionInfoV1_1_2.h new file mode 100644 index 00000000000..b16135c1f69 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ActionInfo/v1_1_2/EfiActionInfoV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ActionInfo v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ACTIONINFO_V1_1_2_H__ +#define EFI_REDFISH_INTERP_ACTIONINFO_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ActionInfo/v1_1_2/Redfish_ActionInfo_v1_1_2_CS.h" +// +// EFI structure of Redfish ActionInfo v1_1_2 +// +typedef struct _EFI_REDFISH_ACTIONINFO_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ACTIONINFO_V1_1_2_CS *ActionInfo; +} EFI_REDFISH_ACTIONINFO_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AddressPool/v1_0_0/EfiAddressPoolV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/AddressPool/v1_0_0/EfiAddressPoolV1_0_0.h new file mode 100644 index 00000000000..71b80e358da --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AddressPool/v1_0_0/EfiAddressPoolV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AddressPool v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ADDRESSPOOL_V1_0_0_H__ +#define EFI_REDFISH_INTERP_ADDRESSPOOL_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/AddressPool/v1_0_0/Redfish_AddressPool_v1_0_0_CS.h" +// +// EFI structure of Redfish AddressPool v1_0_0 +// +typedef struct _EFI_REDFISH_ADDRESSPOOL_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ADDRESSPOOL_V1_0_0_CS *AddressPool; +} EFI_REDFISH_ADDRESSPOOL_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AddressPool/v1_0_1/EfiAddressPoolV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/AddressPool/v1_0_1/EfiAddressPoolV1_0_1.h new file mode 100644 index 00000000000..5d919291240 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AddressPool/v1_0_1/EfiAddressPoolV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AddressPool v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ADDRESSPOOL_V1_0_1_H__ +#define EFI_REDFISH_INTERP_ADDRESSPOOL_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/AddressPool/v1_0_1/Redfish_AddressPool_v1_0_1_CS.h" +// +// EFI structure of Redfish AddressPool v1_0_1 +// +typedef struct _EFI_REDFISH_ADDRESSPOOL_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ADDRESSPOOL_V1_0_1_CS *AddressPool; +} EFI_REDFISH_ADDRESSPOOL_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AddressPool/v1_0_2/EfiAddressPoolV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/AddressPool/v1_0_2/EfiAddressPoolV1_0_2.h new file mode 100644 index 00000000000..c929e9a9f6f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AddressPool/v1_0_2/EfiAddressPoolV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AddressPool v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ADDRESSPOOL_V1_0_2_H__ +#define EFI_REDFISH_INTERP_ADDRESSPOOL_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/AddressPool/v1_0_2/Redfish_AddressPool_v1_0_2_CS.h" +// +// EFI structure of Redfish AddressPool v1_0_2 +// +typedef struct _EFI_REDFISH_ADDRESSPOOL_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ADDRESSPOOL_V1_0_2_CS *AddressPool; +} EFI_REDFISH_ADDRESSPOOL_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AddressPool/v1_1_0/EfiAddressPoolV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/AddressPool/v1_1_0/EfiAddressPoolV1_1_0.h new file mode 100644 index 00000000000..60be91308a1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AddressPool/v1_1_0/EfiAddressPoolV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AddressPool v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ADDRESSPOOL_V1_1_0_H__ +#define EFI_REDFISH_INTERP_ADDRESSPOOL_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/AddressPool/v1_1_0/Redfish_AddressPool_v1_1_0_CS.h" +// +// EFI structure of Redfish AddressPool v1_1_0 +// +typedef struct _EFI_REDFISH_ADDRESSPOOL_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ADDRESSPOOL_V1_1_0_CS *AddressPool; +} EFI_REDFISH_ADDRESSPOOL_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AddressPool/v1_1_1/EfiAddressPoolV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/AddressPool/v1_1_1/EfiAddressPoolV1_1_1.h new file mode 100644 index 00000000000..3f59dd1a26c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AddressPool/v1_1_1/EfiAddressPoolV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AddressPool v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ADDRESSPOOL_V1_1_1_H__ +#define EFI_REDFISH_INTERP_ADDRESSPOOL_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/AddressPool/v1_1_1/Redfish_AddressPool_v1_1_1_CS.h" +// +// EFI structure of Redfish AddressPool v1_1_1 +// +typedef struct _EFI_REDFISH_ADDRESSPOOL_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ADDRESSPOOL_V1_1_1_CS *AddressPool; +} EFI_REDFISH_ADDRESSPOOL_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AddressPoolCollection/EfiAddressPoolCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/AddressPoolCollection/EfiAddressPoolCollection.h new file mode 100644 index 00000000000..c9232290c28 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AddressPoolCollection/EfiAddressPoolCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AddressPoolCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ADDRESSPOOLCOLLECTION_H__ +#define EFI_REDFISH_INTERP_ADDRESSPOOLCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/AddressPoolCollection/Redfish_AddressPoolCollection_CS.h" +// +// EFI structure of Redfish AddressPoolCollection +// +typedef struct _EFI_REDFISH_ADDRESSPOOLCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ADDRESSPOOLCOLLECTION_CS *AddressPoolCollection; +} EFI_REDFISH_ADDRESSPOOLCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Aggregate/v1_0_0/EfiAggregateV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Aggregate/v1_0_0/EfiAggregateV1_0_0.h new file mode 100644 index 00000000000..889e71a63ce --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Aggregate/v1_0_0/EfiAggregateV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Aggregate v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_AGGREGATE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_AGGREGATE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Aggregate/v1_0_0/Redfish_Aggregate_v1_0_0_CS.h" +// +// EFI structure of Redfish Aggregate v1_0_0 +// +typedef struct _EFI_REDFISH_AGGREGATE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_AGGREGATE_V1_0_0_CS *Aggregate; +} EFI_REDFISH_AGGREGATE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Aggregate/v1_0_1/EfiAggregateV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Aggregate/v1_0_1/EfiAggregateV1_0_1.h new file mode 100644 index 00000000000..0373e393dcc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Aggregate/v1_0_1/EfiAggregateV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Aggregate v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_AGGREGATE_V1_0_1_H__ +#define EFI_REDFISH_INTERP_AGGREGATE_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Aggregate/v1_0_1/Redfish_Aggregate_v1_0_1_CS.h" +// +// EFI structure of Redfish Aggregate v1_0_1 +// +typedef struct _EFI_REDFISH_AGGREGATE_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_AGGREGATE_V1_0_1_CS *Aggregate; +} EFI_REDFISH_AGGREGATE_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AggregateCollection/EfiAggregateCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/AggregateCollection/EfiAggregateCollection.h new file mode 100644 index 00000000000..7529a11fdc7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AggregateCollection/EfiAggregateCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AggregateCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_AGGREGATECOLLECTION_H__ +#define EFI_REDFISH_INTERP_AGGREGATECOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/AggregateCollection/Redfish_AggregateCollection_CS.h" +// +// EFI structure of Redfish AggregateCollection +// +typedef struct _EFI_REDFISH_AGGREGATECOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_AGGREGATECOLLECTION_CS *AggregateCollection; +} EFI_REDFISH_AGGREGATECOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AggregationService/v1_0_0/EfiAggregationServiceV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/AggregationService/v1_0_0/EfiAggregationServiceV1_0_0.h new file mode 100644 index 00000000000..d9fddfc02e8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AggregationService/v1_0_0/EfiAggregationServiceV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AggregationService v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_AGGREGATIONSERVICE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_AGGREGATIONSERVICE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/AggregationService/v1_0_0/Redfish_AggregationService_v1_0_0_CS.h" +// +// EFI structure of Redfish AggregationService v1_0_0 +// +typedef struct _EFI_REDFISH_AGGREGATIONSERVICE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_AGGREGATIONSERVICE_V1_0_0_CS *AggregationService; +} EFI_REDFISH_AGGREGATIONSERVICE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AggregationService/v1_0_1/EfiAggregationServiceV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/AggregationService/v1_0_1/EfiAggregationServiceV1_0_1.h new file mode 100644 index 00000000000..48003a587ad --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AggregationService/v1_0_1/EfiAggregationServiceV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AggregationService v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_AGGREGATIONSERVICE_V1_0_1_H__ +#define EFI_REDFISH_INTERP_AGGREGATIONSERVICE_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/AggregationService/v1_0_1/Redfish_AggregationService_v1_0_1_CS.h" +// +// EFI structure of Redfish AggregationService v1_0_1 +// +typedef struct _EFI_REDFISH_AGGREGATIONSERVICE_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_AGGREGATIONSERVICE_V1_0_1_CS *AggregationService; +} EFI_REDFISH_AGGREGATIONSERVICE_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AggregationSource/v1_0_0/EfiAggregationSourceV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/AggregationSource/v1_0_0/EfiAggregationSourceV1_0_0.h new file mode 100644 index 00000000000..fa2a00293a3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AggregationSource/v1_0_0/EfiAggregationSourceV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AggregationSource v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_AGGREGATIONSOURCE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_AGGREGATIONSOURCE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/AggregationSource/v1_0_0/Redfish_AggregationSource_v1_0_0_CS.h" +// +// EFI structure of Redfish AggregationSource v1_0_0 +// +typedef struct _EFI_REDFISH_AGGREGATIONSOURCE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_AGGREGATIONSOURCE_V1_0_0_CS *AggregationSource; +} EFI_REDFISH_AGGREGATIONSOURCE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AggregationSource/v1_1_0/EfiAggregationSourceV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/AggregationSource/v1_1_0/EfiAggregationSourceV1_1_0.h new file mode 100644 index 00000000000..3d85d4c1578 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AggregationSource/v1_1_0/EfiAggregationSourceV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AggregationSource v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_AGGREGATIONSOURCE_V1_1_0_H__ +#define EFI_REDFISH_INTERP_AGGREGATIONSOURCE_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/AggregationSource/v1_1_0/Redfish_AggregationSource_v1_1_0_CS.h" +// +// EFI structure of Redfish AggregationSource v1_1_0 +// +typedef struct _EFI_REDFISH_AGGREGATIONSOURCE_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_AGGREGATIONSOURCE_V1_1_0_CS *AggregationSource; +} EFI_REDFISH_AGGREGATIONSOURCE_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AggregationSourceCollection/EfiAggregationSourceCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/AggregationSourceCollection/EfiAggregationSourceCollection.h new file mode 100644 index 00000000000..afde2a3dc8b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AggregationSourceCollection/EfiAggregationSourceCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AggregationSourceCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_AGGREGATIONSOURCECOLLECTION_H__ +#define EFI_REDFISH_INTERP_AGGREGATIONSOURCECOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/AggregationSourceCollection/Redfish_AggregationSourceCollection_CS.h" +// +// EFI structure of Redfish AggregationSourceCollection +// +typedef struct _EFI_REDFISH_AGGREGATIONSOURCECOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_AGGREGATIONSOURCECOLLECTION_CS *AggregationSourceCollection; +} EFI_REDFISH_AGGREGATIONSOURCECOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_0_0/EfiAssemblyV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_0_0/EfiAssemblyV1_0_0.h new file mode 100644 index 00000000000..cf25454c9b6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_0_0/EfiAssemblyV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Assembly v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ASSEMBLY_V1_0_0_H__ +#define EFI_REDFISH_INTERP_ASSEMBLY_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Assembly/v1_0_0/Redfish_Assembly_v1_0_0_CS.h" +// +// EFI structure of Redfish Assembly v1_0_0 +// +typedef struct _EFI_REDFISH_ASSEMBLY_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ASSEMBLY_V1_0_0_CS *Assembly; +} EFI_REDFISH_ASSEMBLY_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_0_1/EfiAssemblyV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_0_1/EfiAssemblyV1_0_1.h new file mode 100644 index 00000000000..6dfdda8eba7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_0_1/EfiAssemblyV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Assembly v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ASSEMBLY_V1_0_1_H__ +#define EFI_REDFISH_INTERP_ASSEMBLY_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Assembly/v1_0_1/Redfish_Assembly_v1_0_1_CS.h" +// +// EFI structure of Redfish Assembly v1_0_1 +// +typedef struct _EFI_REDFISH_ASSEMBLY_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ASSEMBLY_V1_0_1_CS *Assembly; +} EFI_REDFISH_ASSEMBLY_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_0_2/EfiAssemblyV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_0_2/EfiAssemblyV1_0_2.h new file mode 100644 index 00000000000..1902ffcdc3f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_0_2/EfiAssemblyV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Assembly v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ASSEMBLY_V1_0_2_H__ +#define EFI_REDFISH_INTERP_ASSEMBLY_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Assembly/v1_0_2/Redfish_Assembly_v1_0_2_CS.h" +// +// EFI structure of Redfish Assembly v1_0_2 +// +typedef struct _EFI_REDFISH_ASSEMBLY_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ASSEMBLY_V1_0_2_CS *Assembly; +} EFI_REDFISH_ASSEMBLY_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_0_3/EfiAssemblyV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_0_3/EfiAssemblyV1_0_3.h new file mode 100644 index 00000000000..00766771800 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_0_3/EfiAssemblyV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Assembly v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ASSEMBLY_V1_0_3_H__ +#define EFI_REDFISH_INTERP_ASSEMBLY_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Assembly/v1_0_3/Redfish_Assembly_v1_0_3_CS.h" +// +// EFI structure of Redfish Assembly v1_0_3 +// +typedef struct _EFI_REDFISH_ASSEMBLY_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ASSEMBLY_V1_0_3_CS *Assembly; +} EFI_REDFISH_ASSEMBLY_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_0_4/EfiAssemblyV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_0_4/EfiAssemblyV1_0_4.h new file mode 100644 index 00000000000..a05eff54805 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_0_4/EfiAssemblyV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Assembly v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ASSEMBLY_V1_0_4_H__ +#define EFI_REDFISH_INTERP_ASSEMBLY_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Assembly/v1_0_4/Redfish_Assembly_v1_0_4_CS.h" +// +// EFI structure of Redfish Assembly v1_0_4 +// +typedef struct _EFI_REDFISH_ASSEMBLY_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ASSEMBLY_V1_0_4_CS *Assembly; +} EFI_REDFISH_ASSEMBLY_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_1_0/EfiAssemblyV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_1_0/EfiAssemblyV1_1_0.h new file mode 100644 index 00000000000..988fd0f0ec3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_1_0/EfiAssemblyV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Assembly v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ASSEMBLY_V1_1_0_H__ +#define EFI_REDFISH_INTERP_ASSEMBLY_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Assembly/v1_1_0/Redfish_Assembly_v1_1_0_CS.h" +// +// EFI structure of Redfish Assembly v1_1_0 +// +typedef struct _EFI_REDFISH_ASSEMBLY_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ASSEMBLY_V1_1_0_CS *Assembly; +} EFI_REDFISH_ASSEMBLY_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_1_1/EfiAssemblyV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_1_1/EfiAssemblyV1_1_1.h new file mode 100644 index 00000000000..71dec10ef65 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_1_1/EfiAssemblyV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Assembly v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ASSEMBLY_V1_1_1_H__ +#define EFI_REDFISH_INTERP_ASSEMBLY_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Assembly/v1_1_1/Redfish_Assembly_v1_1_1_CS.h" +// +// EFI structure of Redfish Assembly v1_1_1 +// +typedef struct _EFI_REDFISH_ASSEMBLY_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ASSEMBLY_V1_1_1_CS *Assembly; +} EFI_REDFISH_ASSEMBLY_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_1_2/EfiAssemblyV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_1_2/EfiAssemblyV1_1_2.h new file mode 100644 index 00000000000..803d56d2a95 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_1_2/EfiAssemblyV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Assembly v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ASSEMBLY_V1_1_2_H__ +#define EFI_REDFISH_INTERP_ASSEMBLY_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Assembly/v1_1_2/Redfish_Assembly_v1_1_2_CS.h" +// +// EFI structure of Redfish Assembly v1_1_2 +// +typedef struct _EFI_REDFISH_ASSEMBLY_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ASSEMBLY_V1_1_2_CS *Assembly; +} EFI_REDFISH_ASSEMBLY_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_1_3/EfiAssemblyV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_1_3/EfiAssemblyV1_1_3.h new file mode 100644 index 00000000000..830abc1cfcf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_1_3/EfiAssemblyV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Assembly v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ASSEMBLY_V1_1_3_H__ +#define EFI_REDFISH_INTERP_ASSEMBLY_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Assembly/v1_1_3/Redfish_Assembly_v1_1_3_CS.h" +// +// EFI structure of Redfish Assembly v1_1_3 +// +typedef struct _EFI_REDFISH_ASSEMBLY_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ASSEMBLY_V1_1_3_CS *Assembly; +} EFI_REDFISH_ASSEMBLY_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_1_4/EfiAssemblyV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_1_4/EfiAssemblyV1_1_4.h new file mode 100644 index 00000000000..459339e3015 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_1_4/EfiAssemblyV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Assembly v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ASSEMBLY_V1_1_4_H__ +#define EFI_REDFISH_INTERP_ASSEMBLY_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Assembly/v1_1_4/Redfish_Assembly_v1_1_4_CS.h" +// +// EFI structure of Redfish Assembly v1_1_4 +// +typedef struct _EFI_REDFISH_ASSEMBLY_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ASSEMBLY_V1_1_4_CS *Assembly; +} EFI_REDFISH_ASSEMBLY_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_2_0/EfiAssemblyV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_2_0/EfiAssemblyV1_2_0.h new file mode 100644 index 00000000000..5a53d23fb60 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_2_0/EfiAssemblyV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Assembly v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ASSEMBLY_V1_2_0_H__ +#define EFI_REDFISH_INTERP_ASSEMBLY_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Assembly/v1_2_0/Redfish_Assembly_v1_2_0_CS.h" +// +// EFI structure of Redfish Assembly v1_2_0 +// +typedef struct _EFI_REDFISH_ASSEMBLY_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ASSEMBLY_V1_2_0_CS *Assembly; +} EFI_REDFISH_ASSEMBLY_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_2_1/EfiAssemblyV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_2_1/EfiAssemblyV1_2_1.h new file mode 100644 index 00000000000..b65385fa6ab --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_2_1/EfiAssemblyV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Assembly v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ASSEMBLY_V1_2_1_H__ +#define EFI_REDFISH_INTERP_ASSEMBLY_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Assembly/v1_2_1/Redfish_Assembly_v1_2_1_CS.h" +// +// EFI structure of Redfish Assembly v1_2_1 +// +typedef struct _EFI_REDFISH_ASSEMBLY_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ASSEMBLY_V1_2_1_CS *Assembly; +} EFI_REDFISH_ASSEMBLY_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_2_2/EfiAssemblyV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_2_2/EfiAssemblyV1_2_2.h new file mode 100644 index 00000000000..54f18381c28 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_2_2/EfiAssemblyV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Assembly v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ASSEMBLY_V1_2_2_H__ +#define EFI_REDFISH_INTERP_ASSEMBLY_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Assembly/v1_2_2/Redfish_Assembly_v1_2_2_CS.h" +// +// EFI structure of Redfish Assembly v1_2_2 +// +typedef struct _EFI_REDFISH_ASSEMBLY_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ASSEMBLY_V1_2_2_CS *Assembly; +} EFI_REDFISH_ASSEMBLY_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_2_3/EfiAssemblyV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_2_3/EfiAssemblyV1_2_3.h new file mode 100644 index 00000000000..b2efec053a2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_2_3/EfiAssemblyV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Assembly v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ASSEMBLY_V1_2_3_H__ +#define EFI_REDFISH_INTERP_ASSEMBLY_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Assembly/v1_2_3/Redfish_Assembly_v1_2_3_CS.h" +// +// EFI structure of Redfish Assembly v1_2_3 +// +typedef struct _EFI_REDFISH_ASSEMBLY_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ASSEMBLY_V1_2_3_CS *Assembly; +} EFI_REDFISH_ASSEMBLY_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_3_0/EfiAssemblyV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_3_0/EfiAssemblyV1_3_0.h new file mode 100644 index 00000000000..a9dc4400153 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Assembly/v1_3_0/EfiAssemblyV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Assembly v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ASSEMBLY_V1_3_0_H__ +#define EFI_REDFISH_INTERP_ASSEMBLY_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Assembly/v1_3_0/Redfish_Assembly_v1_3_0_CS.h" +// +// EFI structure of Redfish Assembly v1_3_0 +// +typedef struct _EFI_REDFISH_ASSEMBLY_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ASSEMBLY_V1_3_0_CS *Assembly; +} EFI_REDFISH_ASSEMBLY_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_0/EfiAttributeRegistryV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_0/EfiAttributeRegistryV1_0_0.h new file mode 100644 index 00000000000..b57fd0ad392 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_0/EfiAttributeRegistryV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_0_0_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_0_0/Redfish_AttributeRegistry_v1_0_0_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_0_0 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_0_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_1/EfiAttributeRegistryV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_1/EfiAttributeRegistryV1_0_1.h new file mode 100644 index 00000000000..257c60234fb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_1/EfiAttributeRegistryV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_0_1_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_0_1/Redfish_AttributeRegistry_v1_0_1_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_0_1 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_1_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_10/EfiAttributeRegistryV1_0_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_10/EfiAttributeRegistryV1_0_10.h new file mode 100644 index 00000000000..0cd5629770d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_10/EfiAttributeRegistryV1_0_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_0_10_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_0_10_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_0_10/Redfish_AttributeRegistry_v1_0_10_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_0_10 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_10_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_2/EfiAttributeRegistryV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_2/EfiAttributeRegistryV1_0_2.h new file mode 100644 index 00000000000..6fafd5b8cef --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_2/EfiAttributeRegistryV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_0_2_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_0_2/Redfish_AttributeRegistry_v1_0_2_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_0_2 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_2_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_3/EfiAttributeRegistryV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_3/EfiAttributeRegistryV1_0_3.h new file mode 100644 index 00000000000..968f6b82ce1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_3/EfiAttributeRegistryV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_0_3_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_0_3/Redfish_AttributeRegistry_v1_0_3_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_0_3 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_3_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_4/EfiAttributeRegistryV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_4/EfiAttributeRegistryV1_0_4.h new file mode 100644 index 00000000000..d9820ccb8f7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_4/EfiAttributeRegistryV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_0_4_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_0_4/Redfish_AttributeRegistry_v1_0_4_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_0_4 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_4_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_5/EfiAttributeRegistryV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_5/EfiAttributeRegistryV1_0_5.h new file mode 100644 index 00000000000..2864103c1c5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_5/EfiAttributeRegistryV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_0_5_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_0_5/Redfish_AttributeRegistry_v1_0_5_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_0_5 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_5_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_6/EfiAttributeRegistryV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_6/EfiAttributeRegistryV1_0_6.h new file mode 100644 index 00000000000..051018afc54 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_6/EfiAttributeRegistryV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_0_6_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_0_6/Redfish_AttributeRegistry_v1_0_6_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_0_6 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_6_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_7/EfiAttributeRegistryV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_7/EfiAttributeRegistryV1_0_7.h new file mode 100644 index 00000000000..67ddf4cd2a1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_7/EfiAttributeRegistryV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_0_7_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_0_7/Redfish_AttributeRegistry_v1_0_7_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_0_7 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_7_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_8/EfiAttributeRegistryV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_8/EfiAttributeRegistryV1_0_8.h new file mode 100644 index 00000000000..5e32c184bb3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_8/EfiAttributeRegistryV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_0_8_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_0_8/Redfish_AttributeRegistry_v1_0_8_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_0_8 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_8_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_9/EfiAttributeRegistryV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_9/EfiAttributeRegistryV1_0_9.h new file mode 100644 index 00000000000..1f141a0aa89 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_0_9/EfiAttributeRegistryV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_0_9_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_0_9/Redfish_AttributeRegistry_v1_0_9_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_0_9 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_9_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_0/EfiAttributeRegistryV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_0/EfiAttributeRegistryV1_1_0.h new file mode 100644 index 00000000000..fb253e60568 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_0/EfiAttributeRegistryV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_1_0_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_1_0/Redfish_AttributeRegistry_v1_1_0_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_1_0 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_0_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_1/EfiAttributeRegistryV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_1/EfiAttributeRegistryV1_1_1.h new file mode 100644 index 00000000000..c9914540a9d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_1/EfiAttributeRegistryV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_1_1_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_1_1/Redfish_AttributeRegistry_v1_1_1_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_1_1 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_1_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_2/EfiAttributeRegistryV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_2/EfiAttributeRegistryV1_1_2.h new file mode 100644 index 00000000000..45026c7b0dd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_2/EfiAttributeRegistryV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_1_2_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_1_2/Redfish_AttributeRegistry_v1_1_2_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_1_2 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_2_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_3/EfiAttributeRegistryV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_3/EfiAttributeRegistryV1_1_3.h new file mode 100644 index 00000000000..c48d711914d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_3/EfiAttributeRegistryV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_1_3_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_1_3/Redfish_AttributeRegistry_v1_1_3_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_1_3 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_3_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_4/EfiAttributeRegistryV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_4/EfiAttributeRegistryV1_1_4.h new file mode 100644 index 00000000000..bf98a07adf2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_4/EfiAttributeRegistryV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_1_4_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_1_4/Redfish_AttributeRegistry_v1_1_4_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_1_4 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_4_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_5/EfiAttributeRegistryV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_5/EfiAttributeRegistryV1_1_5.h new file mode 100644 index 00000000000..7deb614e840 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_5/EfiAttributeRegistryV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_1_5_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_1_5/Redfish_AttributeRegistry_v1_1_5_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_1_5 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_5_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_6/EfiAttributeRegistryV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_6/EfiAttributeRegistryV1_1_6.h new file mode 100644 index 00000000000..9c4995da30d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_6/EfiAttributeRegistryV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_1_6_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_1_6/Redfish_AttributeRegistry_v1_1_6_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_1_6 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_6_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_7/EfiAttributeRegistryV1_1_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_7/EfiAttributeRegistryV1_1_7.h new file mode 100644 index 00000000000..26762ccdf54 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_7/EfiAttributeRegistryV1_1_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_1_7_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_1_7_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_1_7/Redfish_AttributeRegistry_v1_1_7_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_1_7 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_7_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_8/EfiAttributeRegistryV1_1_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_8/EfiAttributeRegistryV1_1_8.h new file mode 100644 index 00000000000..9e2d2a02d1b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_8/EfiAttributeRegistryV1_1_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_1_8_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_1_8_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_1_8/Redfish_AttributeRegistry_v1_1_8_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_1_8 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_8_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_9/EfiAttributeRegistryV1_1_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_9/EfiAttributeRegistryV1_1_9.h new file mode 100644 index 00000000000..e35286504e7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_1_9/EfiAttributeRegistryV1_1_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_1_9_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_1_9_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_1_9/Redfish_AttributeRegistry_v1_1_9_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_1_9 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_9_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_1_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_0/EfiAttributeRegistryV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_0/EfiAttributeRegistryV1_2_0.h new file mode 100644 index 00000000000..22a74143dc8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_0/EfiAttributeRegistryV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_2_0_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_2_0/Redfish_AttributeRegistry_v1_2_0_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_2_0 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_0_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_1/EfiAttributeRegistryV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_1/EfiAttributeRegistryV1_2_1.h new file mode 100644 index 00000000000..f5fe39baa1b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_1/EfiAttributeRegistryV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_2_1_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_2_1/Redfish_AttributeRegistry_v1_2_1_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_2_1 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_1_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_2/EfiAttributeRegistryV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_2/EfiAttributeRegistryV1_2_2.h new file mode 100644 index 00000000000..22e355e231e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_2/EfiAttributeRegistryV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_2_2_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_2_2/Redfish_AttributeRegistry_v1_2_2_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_2_2 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_2_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_3/EfiAttributeRegistryV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_3/EfiAttributeRegistryV1_2_3.h new file mode 100644 index 00000000000..94046273bc9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_3/EfiAttributeRegistryV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_2_3_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_2_3/Redfish_AttributeRegistry_v1_2_3_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_2_3 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_3_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_4/EfiAttributeRegistryV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_4/EfiAttributeRegistryV1_2_4.h new file mode 100644 index 00000000000..9bd59f265b5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_4/EfiAttributeRegistryV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_2_4_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_2_4/Redfish_AttributeRegistry_v1_2_4_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_2_4 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_4_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_5/EfiAttributeRegistryV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_5/EfiAttributeRegistryV1_2_5.h new file mode 100644 index 00000000000..8e389dae63e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_5/EfiAttributeRegistryV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_2_5_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_2_5/Redfish_AttributeRegistry_v1_2_5_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_2_5 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_5_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_6/EfiAttributeRegistryV1_2_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_6/EfiAttributeRegistryV1_2_6.h new file mode 100644 index 00000000000..6d6cef4f172 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_6/EfiAttributeRegistryV1_2_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_2_6_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_2_6_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_2_6/Redfish_AttributeRegistry_v1_2_6_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_2_6 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_6_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_7/EfiAttributeRegistryV1_2_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_7/EfiAttributeRegistryV1_2_7.h new file mode 100644 index 00000000000..bc003c0a29c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_2_7/EfiAttributeRegistryV1_2_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_2_7_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_2_7_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_2_7/Redfish_AttributeRegistry_v1_2_7_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_2_7 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_7_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_2_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_3_0/EfiAttributeRegistryV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_3_0/EfiAttributeRegistryV1_3_0.h new file mode 100644 index 00000000000..cc9026f5d24 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_3_0/EfiAttributeRegistryV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_3_0_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_3_0/Redfish_AttributeRegistry_v1_3_0_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_3_0 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_0_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_3_1/EfiAttributeRegistryV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_3_1/EfiAttributeRegistryV1_3_1.h new file mode 100644 index 00000000000..e3f7b1feba9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_3_1/EfiAttributeRegistryV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_3_1_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_3_1/Redfish_AttributeRegistry_v1_3_1_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_3_1 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_1_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_3_2/EfiAttributeRegistryV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_3_2/EfiAttributeRegistryV1_3_2.h new file mode 100644 index 00000000000..e311418f27c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_3_2/EfiAttributeRegistryV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_3_2_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_3_2/Redfish_AttributeRegistry_v1_3_2_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_3_2 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_2_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_3_3/EfiAttributeRegistryV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_3_3/EfiAttributeRegistryV1_3_3.h new file mode 100644 index 00000000000..5b3958f6186 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_3_3/EfiAttributeRegistryV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_3_3_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_3_3/Redfish_AttributeRegistry_v1_3_3_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_3_3 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_3_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_3_4/EfiAttributeRegistryV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_3_4/EfiAttributeRegistryV1_3_4.h new file mode 100644 index 00000000000..d64987b04a5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_3_4/EfiAttributeRegistryV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_3_4_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_3_4/Redfish_AttributeRegistry_v1_3_4_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_3_4 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_4_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_3_5/EfiAttributeRegistryV1_3_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_3_5/EfiAttributeRegistryV1_3_5.h new file mode 100644 index 00000000000..d7aebd5395a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/AttributeRegistry/v1_3_5/EfiAttributeRegistryV1_3_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for AttributeRegistry v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_3_5_H__ +#define EFI_REDFISH_INTERP_ATTRIBUTEREGISTRY_V1_3_5_H__ + +#include +#include +#include "ConverterLib/edk2library/AttributeRegistry/v1_3_5/Redfish_AttributeRegistry_v1_3_5_CS.h" +// +// EFI structure of Redfish AttributeRegistry v1_3_5 +// +typedef struct _EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_5_CS *AttributeRegistry; +} EFI_REDFISH_ATTRIBUTEREGISTRY_V1_3_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_0/EfiBiosV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_0/EfiBiosV1_0_0.h new file mode 100644 index 00000000000..2099dd3f5a3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_0/EfiBiosV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Bios v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_BIOS_V1_0_0_H__ +#define EFI_REDFISH_INTERP_BIOS_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Bios/v1_0_0/Redfish_Bios_v1_0_0_CS.h" +// +// EFI structure of Redfish Bios v1_0_0 +// +typedef struct _EFI_REDFISH_BIOS_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_BIOS_V1_0_0_CS *Bios; +} EFI_REDFISH_BIOS_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_1/EfiBiosV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_1/EfiBiosV1_0_1.h new file mode 100644 index 00000000000..2393cc687de --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_1/EfiBiosV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Bios v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_BIOS_V1_0_1_H__ +#define EFI_REDFISH_INTERP_BIOS_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Bios/v1_0_1/Redfish_Bios_v1_0_1_CS.h" +// +// EFI structure of Redfish Bios v1_0_1 +// +typedef struct _EFI_REDFISH_BIOS_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_BIOS_V1_0_1_CS *Bios; +} EFI_REDFISH_BIOS_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_2/EfiBiosV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_2/EfiBiosV1_0_2.h new file mode 100644 index 00000000000..82c3250a6b0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_2/EfiBiosV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Bios v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_BIOS_V1_0_2_H__ +#define EFI_REDFISH_INTERP_BIOS_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Bios/v1_0_2/Redfish_Bios_v1_0_2_CS.h" +// +// EFI structure of Redfish Bios v1_0_2 +// +typedef struct _EFI_REDFISH_BIOS_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_BIOS_V1_0_2_CS *Bios; +} EFI_REDFISH_BIOS_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_3/EfiBiosV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_3/EfiBiosV1_0_3.h new file mode 100644 index 00000000000..0e7c5d6aefa --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_3/EfiBiosV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Bios v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_BIOS_V1_0_3_H__ +#define EFI_REDFISH_INTERP_BIOS_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Bios/v1_0_3/Redfish_Bios_v1_0_3_CS.h" +// +// EFI structure of Redfish Bios v1_0_3 +// +typedef struct _EFI_REDFISH_BIOS_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_BIOS_V1_0_3_CS *Bios; +} EFI_REDFISH_BIOS_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_4/EfiBiosV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_4/EfiBiosV1_0_4.h new file mode 100644 index 00000000000..d34ef7b4c32 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_4/EfiBiosV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Bios v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_BIOS_V1_0_4_H__ +#define EFI_REDFISH_INTERP_BIOS_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Bios/v1_0_4/Redfish_Bios_v1_0_4_CS.h" +// +// EFI structure of Redfish Bios v1_0_4 +// +typedef struct _EFI_REDFISH_BIOS_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_BIOS_V1_0_4_CS *Bios; +} EFI_REDFISH_BIOS_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_5/EfiBiosV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_5/EfiBiosV1_0_5.h new file mode 100644 index 00000000000..30f1c529a6e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_5/EfiBiosV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Bios v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_BIOS_V1_0_5_H__ +#define EFI_REDFISH_INTERP_BIOS_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Bios/v1_0_5/Redfish_Bios_v1_0_5_CS.h" +// +// EFI structure of Redfish Bios v1_0_5 +// +typedef struct _EFI_REDFISH_BIOS_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_BIOS_V1_0_5_CS *Bios; +} EFI_REDFISH_BIOS_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_6/EfiBiosV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_6/EfiBiosV1_0_6.h new file mode 100644 index 00000000000..f9b2e2a561c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_6/EfiBiosV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Bios v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_BIOS_V1_0_6_H__ +#define EFI_REDFISH_INTERP_BIOS_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Bios/v1_0_6/Redfish_Bios_v1_0_6_CS.h" +// +// EFI structure of Redfish Bios v1_0_6 +// +typedef struct _EFI_REDFISH_BIOS_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_BIOS_V1_0_6_CS *Bios; +} EFI_REDFISH_BIOS_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_7/EfiBiosV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_7/EfiBiosV1_0_7.h new file mode 100644 index 00000000000..072e9df7a0c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_7/EfiBiosV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Bios v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_BIOS_V1_0_7_H__ +#define EFI_REDFISH_INTERP_BIOS_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Bios/v1_0_7/Redfish_Bios_v1_0_7_CS.h" +// +// EFI structure of Redfish Bios v1_0_7 +// +typedef struct _EFI_REDFISH_BIOS_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_BIOS_V1_0_7_CS *Bios; +} EFI_REDFISH_BIOS_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_8/EfiBiosV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_8/EfiBiosV1_0_8.h new file mode 100644 index 00000000000..d30d8e95971 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_0_8/EfiBiosV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Bios v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_BIOS_V1_0_8_H__ +#define EFI_REDFISH_INTERP_BIOS_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Bios/v1_0_8/Redfish_Bios_v1_0_8_CS.h" +// +// EFI structure of Redfish Bios v1_0_8 +// +typedef struct _EFI_REDFISH_BIOS_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_BIOS_V1_0_8_CS *Bios; +} EFI_REDFISH_BIOS_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_1_0/EfiBiosV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_1_0/EfiBiosV1_1_0.h new file mode 100644 index 00000000000..679fa182145 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_1_0/EfiBiosV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Bios v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_BIOS_V1_1_0_H__ +#define EFI_REDFISH_INTERP_BIOS_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Bios/v1_1_0/Redfish_Bios_v1_1_0_CS.h" +// +// EFI structure of Redfish Bios v1_1_0 +// +typedef struct _EFI_REDFISH_BIOS_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_BIOS_V1_1_0_CS *Bios; +} EFI_REDFISH_BIOS_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_1_1/EfiBiosV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_1_1/EfiBiosV1_1_1.h new file mode 100644 index 00000000000..1eeb6516f93 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Bios/v1_1_1/EfiBiosV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Bios v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_BIOS_V1_1_1_H__ +#define EFI_REDFISH_INTERP_BIOS_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Bios/v1_1_1/Redfish_Bios_v1_1_1_CS.h" +// +// EFI structure of Redfish Bios v1_1_1 +// +typedef struct _EFI_REDFISH_BIOS_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_BIOS_V1_1_1_CS *Bios; +} EFI_REDFISH_BIOS_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/BootOption/v1_0_0/EfiBootOptionV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/BootOption/v1_0_0/EfiBootOptionV1_0_0.h new file mode 100644 index 00000000000..127e69726a5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/BootOption/v1_0_0/EfiBootOptionV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for BootOption v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_BOOTOPTION_V1_0_0_H__ +#define EFI_REDFISH_INTERP_BOOTOPTION_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/BootOption/v1_0_0/Redfish_BootOption_v1_0_0_CS.h" +// +// EFI structure of Redfish BootOption v1_0_0 +// +typedef struct _EFI_REDFISH_BOOTOPTION_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_BOOTOPTION_V1_0_0_CS *BootOption; +} EFI_REDFISH_BOOTOPTION_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/BootOption/v1_0_1/EfiBootOptionV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/BootOption/v1_0_1/EfiBootOptionV1_0_1.h new file mode 100644 index 00000000000..8c2e2693140 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/BootOption/v1_0_1/EfiBootOptionV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for BootOption v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_BOOTOPTION_V1_0_1_H__ +#define EFI_REDFISH_INTERP_BOOTOPTION_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/BootOption/v1_0_1/Redfish_BootOption_v1_0_1_CS.h" +// +// EFI structure of Redfish BootOption v1_0_1 +// +typedef struct _EFI_REDFISH_BOOTOPTION_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_BOOTOPTION_V1_0_1_CS *BootOption; +} EFI_REDFISH_BOOTOPTION_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/BootOption/v1_0_2/EfiBootOptionV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/BootOption/v1_0_2/EfiBootOptionV1_0_2.h new file mode 100644 index 00000000000..4afa79b8eb2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/BootOption/v1_0_2/EfiBootOptionV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for BootOption v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_BOOTOPTION_V1_0_2_H__ +#define EFI_REDFISH_INTERP_BOOTOPTION_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/BootOption/v1_0_2/Redfish_BootOption_v1_0_2_CS.h" +// +// EFI structure of Redfish BootOption v1_0_2 +// +typedef struct _EFI_REDFISH_BOOTOPTION_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_BOOTOPTION_V1_0_2_CS *BootOption; +} EFI_REDFISH_BOOTOPTION_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/BootOption/v1_0_3/EfiBootOptionV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/BootOption/v1_0_3/EfiBootOptionV1_0_3.h new file mode 100644 index 00000000000..a7ce4fb958b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/BootOption/v1_0_3/EfiBootOptionV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for BootOption v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_BOOTOPTION_V1_0_3_H__ +#define EFI_REDFISH_INTERP_BOOTOPTION_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/BootOption/v1_0_3/Redfish_BootOption_v1_0_3_CS.h" +// +// EFI structure of Redfish BootOption v1_0_3 +// +typedef struct _EFI_REDFISH_BOOTOPTION_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_BOOTOPTION_V1_0_3_CS *BootOption; +} EFI_REDFISH_BOOTOPTION_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/BootOption/v1_0_4/EfiBootOptionV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/BootOption/v1_0_4/EfiBootOptionV1_0_4.h new file mode 100644 index 00000000000..cd46c8ec73c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/BootOption/v1_0_4/EfiBootOptionV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for BootOption v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_BOOTOPTION_V1_0_4_H__ +#define EFI_REDFISH_INTERP_BOOTOPTION_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/BootOption/v1_0_4/Redfish_BootOption_v1_0_4_CS.h" +// +// EFI structure of Redfish BootOption v1_0_4 +// +typedef struct _EFI_REDFISH_BOOTOPTION_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_BOOTOPTION_V1_0_4_CS *BootOption; +} EFI_REDFISH_BOOTOPTION_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/BootOptionCollection/EfiBootOptionCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/BootOptionCollection/EfiBootOptionCollection.h new file mode 100644 index 00000000000..58e5d5e1bbf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/BootOptionCollection/EfiBootOptionCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for BootOptionCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_BOOTOPTIONCOLLECTION_H__ +#define EFI_REDFISH_INTERP_BOOTOPTIONCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/BootOptionCollection/Redfish_BootOptionCollection_CS.h" +// +// EFI structure of Redfish BootOptionCollection +// +typedef struct _EFI_REDFISH_BOOTOPTIONCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_BOOTOPTIONCOLLECTION_CS *BootOptionCollection; +} EFI_REDFISH_BOOTOPTIONCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_0_0/EfiCertificateV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_0_0/EfiCertificateV1_0_0.h new file mode 100644 index 00000000000..1bcc2c64d97 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_0_0/EfiCertificateV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Certificate v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CERTIFICATE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_CERTIFICATE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Certificate/v1_0_0/Redfish_Certificate_v1_0_0_CS.h" +// +// EFI structure of Redfish Certificate v1_0_0 +// +typedef struct _EFI_REDFISH_CERTIFICATE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CERTIFICATE_V1_0_0_CS *Certificate; +} EFI_REDFISH_CERTIFICATE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_0_1/EfiCertificateV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_0_1/EfiCertificateV1_0_1.h new file mode 100644 index 00000000000..156c81b54f5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_0_1/EfiCertificateV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Certificate v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CERTIFICATE_V1_0_1_H__ +#define EFI_REDFISH_INTERP_CERTIFICATE_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Certificate/v1_0_1/Redfish_Certificate_v1_0_1_CS.h" +// +// EFI structure of Redfish Certificate v1_0_1 +// +typedef struct _EFI_REDFISH_CERTIFICATE_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CERTIFICATE_V1_0_1_CS *Certificate; +} EFI_REDFISH_CERTIFICATE_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_0_2/EfiCertificateV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_0_2/EfiCertificateV1_0_2.h new file mode 100644 index 00000000000..bfbebb5e028 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_0_2/EfiCertificateV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Certificate v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CERTIFICATE_V1_0_2_H__ +#define EFI_REDFISH_INTERP_CERTIFICATE_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Certificate/v1_0_2/Redfish_Certificate_v1_0_2_CS.h" +// +// EFI structure of Redfish Certificate v1_0_2 +// +typedef struct _EFI_REDFISH_CERTIFICATE_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CERTIFICATE_V1_0_2_CS *Certificate; +} EFI_REDFISH_CERTIFICATE_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_0_3/EfiCertificateV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_0_3/EfiCertificateV1_0_3.h new file mode 100644 index 00000000000..3c1ed852cb5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_0_3/EfiCertificateV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Certificate v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CERTIFICATE_V1_0_3_H__ +#define EFI_REDFISH_INTERP_CERTIFICATE_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Certificate/v1_0_3/Redfish_Certificate_v1_0_3_CS.h" +// +// EFI structure of Redfish Certificate v1_0_3 +// +typedef struct _EFI_REDFISH_CERTIFICATE_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CERTIFICATE_V1_0_3_CS *Certificate; +} EFI_REDFISH_CERTIFICATE_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_0_4/EfiCertificateV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_0_4/EfiCertificateV1_0_4.h new file mode 100644 index 00000000000..cb1c2a09741 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_0_4/EfiCertificateV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Certificate v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CERTIFICATE_V1_0_4_H__ +#define EFI_REDFISH_INTERP_CERTIFICATE_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Certificate/v1_0_4/Redfish_Certificate_v1_0_4_CS.h" +// +// EFI structure of Redfish Certificate v1_0_4 +// +typedef struct _EFI_REDFISH_CERTIFICATE_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CERTIFICATE_V1_0_4_CS *Certificate; +} EFI_REDFISH_CERTIFICATE_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_1_0/EfiCertificateV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_1_0/EfiCertificateV1_1_0.h new file mode 100644 index 00000000000..6b4bd249e73 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_1_0/EfiCertificateV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Certificate v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CERTIFICATE_V1_1_0_H__ +#define EFI_REDFISH_INTERP_CERTIFICATE_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Certificate/v1_1_0/Redfish_Certificate_v1_1_0_CS.h" +// +// EFI structure of Redfish Certificate v1_1_0 +// +typedef struct _EFI_REDFISH_CERTIFICATE_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CERTIFICATE_V1_1_0_CS *Certificate; +} EFI_REDFISH_CERTIFICATE_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_1_1/EfiCertificateV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_1_1/EfiCertificateV1_1_1.h new file mode 100644 index 00000000000..74e37a91777 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_1_1/EfiCertificateV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Certificate v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CERTIFICATE_V1_1_1_H__ +#define EFI_REDFISH_INTERP_CERTIFICATE_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Certificate/v1_1_1/Redfish_Certificate_v1_1_1_CS.h" +// +// EFI structure of Redfish Certificate v1_1_1 +// +typedef struct _EFI_REDFISH_CERTIFICATE_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CERTIFICATE_V1_1_1_CS *Certificate; +} EFI_REDFISH_CERTIFICATE_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_1_2/EfiCertificateV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_1_2/EfiCertificateV1_1_2.h new file mode 100644 index 00000000000..69b6f50987a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_1_2/EfiCertificateV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Certificate v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CERTIFICATE_V1_1_2_H__ +#define EFI_REDFISH_INTERP_CERTIFICATE_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Certificate/v1_1_2/Redfish_Certificate_v1_1_2_CS.h" +// +// EFI structure of Redfish Certificate v1_1_2 +// +typedef struct _EFI_REDFISH_CERTIFICATE_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CERTIFICATE_V1_1_2_CS *Certificate; +} EFI_REDFISH_CERTIFICATE_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_1_3/EfiCertificateV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_1_3/EfiCertificateV1_1_3.h new file mode 100644 index 00000000000..c50955ed674 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_1_3/EfiCertificateV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Certificate v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CERTIFICATE_V1_1_3_H__ +#define EFI_REDFISH_INTERP_CERTIFICATE_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Certificate/v1_1_3/Redfish_Certificate_v1_1_3_CS.h" +// +// EFI structure of Redfish Certificate v1_1_3 +// +typedef struct _EFI_REDFISH_CERTIFICATE_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CERTIFICATE_V1_1_3_CS *Certificate; +} EFI_REDFISH_CERTIFICATE_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_2_0/EfiCertificateV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_2_0/EfiCertificateV1_2_0.h new file mode 100644 index 00000000000..334ba04c4dd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_2_0/EfiCertificateV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Certificate v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CERTIFICATE_V1_2_0_H__ +#define EFI_REDFISH_INTERP_CERTIFICATE_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Certificate/v1_2_0/Redfish_Certificate_v1_2_0_CS.h" +// +// EFI structure of Redfish Certificate v1_2_0 +// +typedef struct _EFI_REDFISH_CERTIFICATE_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CERTIFICATE_V1_2_0_CS *Certificate; +} EFI_REDFISH_CERTIFICATE_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_2_1/EfiCertificateV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_2_1/EfiCertificateV1_2_1.h new file mode 100644 index 00000000000..320a3c4a577 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_2_1/EfiCertificateV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Certificate v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CERTIFICATE_V1_2_1_H__ +#define EFI_REDFISH_INTERP_CERTIFICATE_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Certificate/v1_2_1/Redfish_Certificate_v1_2_1_CS.h" +// +// EFI structure of Redfish Certificate v1_2_1 +// +typedef struct _EFI_REDFISH_CERTIFICATE_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CERTIFICATE_V1_2_1_CS *Certificate; +} EFI_REDFISH_CERTIFICATE_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_2_2/EfiCertificateV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_2_2/EfiCertificateV1_2_2.h new file mode 100644 index 00000000000..90f5d2819ab --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Certificate/v1_2_2/EfiCertificateV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Certificate v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CERTIFICATE_V1_2_2_H__ +#define EFI_REDFISH_INTERP_CERTIFICATE_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Certificate/v1_2_2/Redfish_Certificate_v1_2_2_CS.h" +// +// EFI structure of Redfish Certificate v1_2_2 +// +typedef struct _EFI_REDFISH_CERTIFICATE_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CERTIFICATE_V1_2_2_CS *Certificate; +} EFI_REDFISH_CERTIFICATE_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/CertificateCollection/EfiCertificateCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/CertificateCollection/EfiCertificateCollection.h new file mode 100644 index 00000000000..ec93ef7ebd4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/CertificateCollection/EfiCertificateCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for CertificateCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CERTIFICATECOLLECTION_H__ +#define EFI_REDFISH_INTERP_CERTIFICATECOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/CertificateCollection/Redfish_CertificateCollection_CS.h" +// +// EFI structure of Redfish CertificateCollection +// +typedef struct _EFI_REDFISH_CERTIFICATECOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CERTIFICATECOLLECTION_CS *CertificateCollection; +} EFI_REDFISH_CERTIFICATECOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/CertificateLocations/v1_0_0/EfiCertificateLocationsV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/CertificateLocations/v1_0_0/EfiCertificateLocationsV1_0_0.h new file mode 100644 index 00000000000..cf7ff04c831 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/CertificateLocations/v1_0_0/EfiCertificateLocationsV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for CertificateLocations v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CERTIFICATELOCATIONS_V1_0_0_H__ +#define EFI_REDFISH_INTERP_CERTIFICATELOCATIONS_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/CertificateLocations/v1_0_0/Redfish_CertificateLocations_v1_0_0_CS.h" +// +// EFI structure of Redfish CertificateLocations v1_0_0 +// +typedef struct _EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_0_CS *CertificateLocations; +} EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/CertificateLocations/v1_0_1/EfiCertificateLocationsV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/CertificateLocations/v1_0_1/EfiCertificateLocationsV1_0_1.h new file mode 100644 index 00000000000..66064575758 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/CertificateLocations/v1_0_1/EfiCertificateLocationsV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for CertificateLocations v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CERTIFICATELOCATIONS_V1_0_1_H__ +#define EFI_REDFISH_INTERP_CERTIFICATELOCATIONS_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/CertificateLocations/v1_0_1/Redfish_CertificateLocations_v1_0_1_CS.h" +// +// EFI structure of Redfish CertificateLocations v1_0_1 +// +typedef struct _EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_1_CS *CertificateLocations; +} EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/CertificateLocations/v1_0_2/EfiCertificateLocationsV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/CertificateLocations/v1_0_2/EfiCertificateLocationsV1_0_2.h new file mode 100644 index 00000000000..94c9e1f62fb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/CertificateLocations/v1_0_2/EfiCertificateLocationsV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for CertificateLocations v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CERTIFICATELOCATIONS_V1_0_2_H__ +#define EFI_REDFISH_INTERP_CERTIFICATELOCATIONS_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/CertificateLocations/v1_0_2/Redfish_CertificateLocations_v1_0_2_CS.h" +// +// EFI structure of Redfish CertificateLocations v1_0_2 +// +typedef struct _EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_2_CS *CertificateLocations; +} EFI_REDFISH_CERTIFICATELOCATIONS_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/CertificateService/v1_0_0/EfiCertificateServiceV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/CertificateService/v1_0_0/EfiCertificateServiceV1_0_0.h new file mode 100644 index 00000000000..63fe87f431e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/CertificateService/v1_0_0/EfiCertificateServiceV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for CertificateService v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CERTIFICATESERVICE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_CERTIFICATESERVICE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/CertificateService/v1_0_0/Redfish_CertificateService_v1_0_0_CS.h" +// +// EFI structure of Redfish CertificateService v1_0_0 +// +typedef struct _EFI_REDFISH_CERTIFICATESERVICE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CERTIFICATESERVICE_V1_0_0_CS *CertificateService; +} EFI_REDFISH_CERTIFICATESERVICE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/CertificateService/v1_0_1/EfiCertificateServiceV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/CertificateService/v1_0_1/EfiCertificateServiceV1_0_1.h new file mode 100644 index 00000000000..5850e3e0124 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/CertificateService/v1_0_1/EfiCertificateServiceV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for CertificateService v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CERTIFICATESERVICE_V1_0_1_H__ +#define EFI_REDFISH_INTERP_CERTIFICATESERVICE_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/CertificateService/v1_0_1/Redfish_CertificateService_v1_0_1_CS.h" +// +// EFI structure of Redfish CertificateService v1_0_1 +// +typedef struct _EFI_REDFISH_CERTIFICATESERVICE_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CERTIFICATESERVICE_V1_0_1_CS *CertificateService; +} EFI_REDFISH_CERTIFICATESERVICE_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/CertificateService/v1_0_2/EfiCertificateServiceV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/CertificateService/v1_0_2/EfiCertificateServiceV1_0_2.h new file mode 100644 index 00000000000..78f9ae8def9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/CertificateService/v1_0_2/EfiCertificateServiceV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for CertificateService v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CERTIFICATESERVICE_V1_0_2_H__ +#define EFI_REDFISH_INTERP_CERTIFICATESERVICE_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/CertificateService/v1_0_2/Redfish_CertificateService_v1_0_2_CS.h" +// +// EFI structure of Redfish CertificateService v1_0_2 +// +typedef struct _EFI_REDFISH_CERTIFICATESERVICE_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CERTIFICATESERVICE_V1_0_2_CS *CertificateService; +} EFI_REDFISH_CERTIFICATESERVICE_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/CertificateService/v1_0_3/EfiCertificateServiceV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/CertificateService/v1_0_3/EfiCertificateServiceV1_0_3.h new file mode 100644 index 00000000000..2427f00aaf4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/CertificateService/v1_0_3/EfiCertificateServiceV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for CertificateService v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CERTIFICATESERVICE_V1_0_3_H__ +#define EFI_REDFISH_INTERP_CERTIFICATESERVICE_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/CertificateService/v1_0_3/Redfish_CertificateService_v1_0_3_CS.h" +// +// EFI structure of Redfish CertificateService v1_0_3 +// +typedef struct _EFI_REDFISH_CERTIFICATESERVICE_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CERTIFICATESERVICE_V1_0_3_CS *CertificateService; +} EFI_REDFISH_CERTIFICATESERVICE_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/CertificateService/v1_0_4/EfiCertificateServiceV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/CertificateService/v1_0_4/EfiCertificateServiceV1_0_4.h new file mode 100644 index 00000000000..f1e4a605133 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/CertificateService/v1_0_4/EfiCertificateServiceV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for CertificateService v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CERTIFICATESERVICE_V1_0_4_H__ +#define EFI_REDFISH_INTERP_CERTIFICATESERVICE_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/CertificateService/v1_0_4/Redfish_CertificateService_v1_0_4_CS.h" +// +// EFI structure of Redfish CertificateService v1_0_4 +// +typedef struct _EFI_REDFISH_CERTIFICATESERVICE_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CERTIFICATESERVICE_V1_0_4_CS *CertificateService; +} EFI_REDFISH_CERTIFICATESERVICE_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_0/EfiChassisV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_0/EfiChassisV1_0_0.h new file mode 100644 index 00000000000..8bfd4270368 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_0/EfiChassisV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_0_0_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_0_0/Redfish_Chassis_v1_0_0_CS.h" +// +// EFI structure of Redfish Chassis v1_0_0 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_0_0_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_1/EfiChassisV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_1/EfiChassisV1_0_1.h new file mode 100644 index 00000000000..236280fb84a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_1/EfiChassisV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_0_1_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_0_1/Redfish_Chassis_v1_0_1_CS.h" +// +// EFI structure of Redfish Chassis v1_0_1 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_0_1_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_10/EfiChassisV1_0_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_10/EfiChassisV1_0_10.h new file mode 100644 index 00000000000..9f7500d7b18 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_10/EfiChassisV1_0_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_0_10_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_0_10_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_0_10/Redfish_Chassis_v1_0_10_CS.h" +// +// EFI structure of Redfish Chassis v1_0_10 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_0_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_0_10_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_0_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_11/EfiChassisV1_0_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_11/EfiChassisV1_0_11.h new file mode 100644 index 00000000000..71850468fb1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_11/EfiChassisV1_0_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_0_11_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_0_11_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_0_11/Redfish_Chassis_v1_0_11_CS.h" +// +// EFI structure of Redfish Chassis v1_0_11 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_0_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_0_11_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_0_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_12/EfiChassisV1_0_12.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_12/EfiChassisV1_0_12.h new file mode 100644 index 00000000000..fee0d39dd78 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_12/EfiChassisV1_0_12.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_0_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_0_12_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_0_12_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_0_12/Redfish_Chassis_v1_0_12_CS.h" +// +// EFI structure of Redfish Chassis v1_0_12 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_0_12 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_0_12_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_0_12; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_13/EfiChassisV1_0_13.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_13/EfiChassisV1_0_13.h new file mode 100644 index 00000000000..031f9d58172 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_13/EfiChassisV1_0_13.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_0_13 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_0_13_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_0_13_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_0_13/Redfish_Chassis_v1_0_13_CS.h" +// +// EFI structure of Redfish Chassis v1_0_13 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_0_13 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_0_13_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_0_13; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_2/EfiChassisV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_2/EfiChassisV1_0_2.h new file mode 100644 index 00000000000..1f89593e08e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_2/EfiChassisV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_0_2_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_0_2/Redfish_Chassis_v1_0_2_CS.h" +// +// EFI structure of Redfish Chassis v1_0_2 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_0_2_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_3/EfiChassisV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_3/EfiChassisV1_0_3.h new file mode 100644 index 00000000000..e0de0444aee --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_3/EfiChassisV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_0_3_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_0_3/Redfish_Chassis_v1_0_3_CS.h" +// +// EFI structure of Redfish Chassis v1_0_3 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_0_3_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_4/EfiChassisV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_4/EfiChassisV1_0_4.h new file mode 100644 index 00000000000..3c0ecffc36c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_4/EfiChassisV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_0_4_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_0_4/Redfish_Chassis_v1_0_4_CS.h" +// +// EFI structure of Redfish Chassis v1_0_4 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_0_4_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_5/EfiChassisV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_5/EfiChassisV1_0_5.h new file mode 100644 index 00000000000..9e21511bfda --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_5/EfiChassisV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_0_5_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_0_5/Redfish_Chassis_v1_0_5_CS.h" +// +// EFI structure of Redfish Chassis v1_0_5 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_0_5_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_6/EfiChassisV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_6/EfiChassisV1_0_6.h new file mode 100644 index 00000000000..02fcb92d152 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_6/EfiChassisV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_0_6_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_0_6/Redfish_Chassis_v1_0_6_CS.h" +// +// EFI structure of Redfish Chassis v1_0_6 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_0_6_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_7/EfiChassisV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_7/EfiChassisV1_0_7.h new file mode 100644 index 00000000000..d07a850c273 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_7/EfiChassisV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_0_7_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_0_7/Redfish_Chassis_v1_0_7_CS.h" +// +// EFI structure of Redfish Chassis v1_0_7 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_0_7_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_8/EfiChassisV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_8/EfiChassisV1_0_8.h new file mode 100644 index 00000000000..e84278f451f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_8/EfiChassisV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_0_8_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_0_8/Redfish_Chassis_v1_0_8_CS.h" +// +// EFI structure of Redfish Chassis v1_0_8 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_0_8_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_9/EfiChassisV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_9/EfiChassisV1_0_9.h new file mode 100644 index 00000000000..cf294cb6802 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_0_9/EfiChassisV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_0_9_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_0_9/Redfish_Chassis_v1_0_9_CS.h" +// +// EFI structure of Redfish Chassis v1_0_9 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_0_9_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_10_0/EfiChassisV1_10_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_10_0/EfiChassisV1_10_0.h new file mode 100644 index 00000000000..3369b3658f9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_10_0/EfiChassisV1_10_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_10_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_10_0_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_10_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_10_0/Redfish_Chassis_v1_10_0_CS.h" +// +// EFI structure of Redfish Chassis v1_10_0 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_10_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_10_0_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_10_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_10_1/EfiChassisV1_10_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_10_1/EfiChassisV1_10_1.h new file mode 100644 index 00000000000..3f708746e6e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_10_1/EfiChassisV1_10_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_10_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_10_1_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_10_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_10_1/Redfish_Chassis_v1_10_1_CS.h" +// +// EFI structure of Redfish Chassis v1_10_1 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_10_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_10_1_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_10_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_10_2/EfiChassisV1_10_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_10_2/EfiChassisV1_10_2.h new file mode 100644 index 00000000000..cecd555be8e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_10_2/EfiChassisV1_10_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_10_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_10_2_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_10_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_10_2/Redfish_Chassis_v1_10_2_CS.h" +// +// EFI structure of Redfish Chassis v1_10_2 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_10_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_10_2_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_10_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_10_3/EfiChassisV1_10_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_10_3/EfiChassisV1_10_3.h new file mode 100644 index 00000000000..53e09368b49 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_10_3/EfiChassisV1_10_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_10_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_10_3_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_10_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_10_3/Redfish_Chassis_v1_10_3_CS.h" +// +// EFI structure of Redfish Chassis v1_10_3 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_10_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_10_3_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_10_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_11_0/EfiChassisV1_11_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_11_0/EfiChassisV1_11_0.h new file mode 100644 index 00000000000..19bf35b8d1d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_11_0/EfiChassisV1_11_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_11_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_11_0_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_11_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_11_0/Redfish_Chassis_v1_11_0_CS.h" +// +// EFI structure of Redfish Chassis v1_11_0 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_11_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_11_0_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_11_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_11_1/EfiChassisV1_11_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_11_1/EfiChassisV1_11_1.h new file mode 100644 index 00000000000..32c08598017 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_11_1/EfiChassisV1_11_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_11_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_11_1_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_11_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_11_1/Redfish_Chassis_v1_11_1_CS.h" +// +// EFI structure of Redfish Chassis v1_11_1 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_11_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_11_1_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_11_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_11_2/EfiChassisV1_11_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_11_2/EfiChassisV1_11_2.h new file mode 100644 index 00000000000..edb54a591fc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_11_2/EfiChassisV1_11_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_11_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_11_2_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_11_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_11_2/Redfish_Chassis_v1_11_2_CS.h" +// +// EFI structure of Redfish Chassis v1_11_2 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_11_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_11_2_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_11_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_11_3/EfiChassisV1_11_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_11_3/EfiChassisV1_11_3.h new file mode 100644 index 00000000000..d59414f4aa3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_11_3/EfiChassisV1_11_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_11_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_11_3_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_11_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_11_3/Redfish_Chassis_v1_11_3_CS.h" +// +// EFI structure of Redfish Chassis v1_11_3 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_11_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_11_3_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_11_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_12_0/EfiChassisV1_12_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_12_0/EfiChassisV1_12_0.h new file mode 100644 index 00000000000..4d022c6d326 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_12_0/EfiChassisV1_12_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_12_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_12_0_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_12_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_12_0/Redfish_Chassis_v1_12_0_CS.h" +// +// EFI structure of Redfish Chassis v1_12_0 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_12_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_12_0_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_12_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_12_1/EfiChassisV1_12_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_12_1/EfiChassisV1_12_1.h new file mode 100644 index 00000000000..a294b47b4a7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_12_1/EfiChassisV1_12_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_12_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_12_1_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_12_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_12_1/Redfish_Chassis_v1_12_1_CS.h" +// +// EFI structure of Redfish Chassis v1_12_1 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_12_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_12_1_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_12_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_12_2/EfiChassisV1_12_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_12_2/EfiChassisV1_12_2.h new file mode 100644 index 00000000000..e6b7f102517 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_12_2/EfiChassisV1_12_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_12_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_12_2_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_12_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_12_2/Redfish_Chassis_v1_12_2_CS.h" +// +// EFI structure of Redfish Chassis v1_12_2 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_12_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_12_2_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_12_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_13_0/EfiChassisV1_13_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_13_0/EfiChassisV1_13_0.h new file mode 100644 index 00000000000..6277aea9223 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_13_0/EfiChassisV1_13_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_13_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_13_0_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_13_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_13_0/Redfish_Chassis_v1_13_0_CS.h" +// +// EFI structure of Redfish Chassis v1_13_0 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_13_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_13_0_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_13_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_13_1/EfiChassisV1_13_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_13_1/EfiChassisV1_13_1.h new file mode 100644 index 00000000000..e1c85d3b742 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_13_1/EfiChassisV1_13_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_13_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_13_1_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_13_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_13_1/Redfish_Chassis_v1_13_1_CS.h" +// +// EFI structure of Redfish Chassis v1_13_1 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_13_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_13_1_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_13_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_14_0/EfiChassisV1_14_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_14_0/EfiChassisV1_14_0.h new file mode 100644 index 00000000000..0b6de2e3d46 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_14_0/EfiChassisV1_14_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_14_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_14_0_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_14_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_14_0/Redfish_Chassis_v1_14_0_CS.h" +// +// EFI structure of Redfish Chassis v1_14_0 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_14_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_14_0_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_14_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_15_0/EfiChassisV1_15_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_15_0/EfiChassisV1_15_0.h new file mode 100644 index 00000000000..cc562630c02 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_15_0/EfiChassisV1_15_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_15_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_15_0_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_15_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_15_0/Redfish_Chassis_v1_15_0_CS.h" +// +// EFI structure of Redfish Chassis v1_15_0 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_15_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_15_0_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_15_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_0/EfiChassisV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_0/EfiChassisV1_1_0.h new file mode 100644 index 00000000000..5f280de10be --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_0/EfiChassisV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_1_0_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_1_0/Redfish_Chassis_v1_1_0_CS.h" +// +// EFI structure of Redfish Chassis v1_1_0 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_1_0_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_10/EfiChassisV1_1_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_10/EfiChassisV1_1_10.h new file mode 100644 index 00000000000..4875cbc2b66 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_10/EfiChassisV1_1_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_1_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_1_10_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_1_10_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_1_10/Redfish_Chassis_v1_1_10_CS.h" +// +// EFI structure of Redfish Chassis v1_1_10 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_1_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_1_10_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_1_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_11/EfiChassisV1_1_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_11/EfiChassisV1_1_11.h new file mode 100644 index 00000000000..299d4daf1be --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_11/EfiChassisV1_1_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_1_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_1_11_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_1_11_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_1_11/Redfish_Chassis_v1_1_11_CS.h" +// +// EFI structure of Redfish Chassis v1_1_11 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_1_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_1_11_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_1_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_12/EfiChassisV1_1_12.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_12/EfiChassisV1_1_12.h new file mode 100644 index 00000000000..b40056a96b0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_12/EfiChassisV1_1_12.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_1_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_1_12_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_1_12_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_1_12/Redfish_Chassis_v1_1_12_CS.h" +// +// EFI structure of Redfish Chassis v1_1_12 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_1_12 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_1_12_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_1_12; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_13/EfiChassisV1_1_13.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_13/EfiChassisV1_1_13.h new file mode 100644 index 00000000000..c78ad011e8f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_13/EfiChassisV1_1_13.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_1_13 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_1_13_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_1_13_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_1_13/Redfish_Chassis_v1_1_13_CS.h" +// +// EFI structure of Redfish Chassis v1_1_13 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_1_13 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_1_13_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_1_13; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_2/EfiChassisV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_2/EfiChassisV1_1_2.h new file mode 100644 index 00000000000..7cae60a3ec9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_2/EfiChassisV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_1_2_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_1_2/Redfish_Chassis_v1_1_2_CS.h" +// +// EFI structure of Redfish Chassis v1_1_2 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_1_2_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_3/EfiChassisV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_3/EfiChassisV1_1_3.h new file mode 100644 index 00000000000..aefe1fb49da --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_3/EfiChassisV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_1_3_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_1_3/Redfish_Chassis_v1_1_3_CS.h" +// +// EFI structure of Redfish Chassis v1_1_3 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_1_3_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_4/EfiChassisV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_4/EfiChassisV1_1_4.h new file mode 100644 index 00000000000..f01bc80997c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_4/EfiChassisV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_1_4_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_1_4/Redfish_Chassis_v1_1_4_CS.h" +// +// EFI structure of Redfish Chassis v1_1_4 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_1_4_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_5/EfiChassisV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_5/EfiChassisV1_1_5.h new file mode 100644 index 00000000000..7be9c2a158d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_5/EfiChassisV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_1_5_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_1_5/Redfish_Chassis_v1_1_5_CS.h" +// +// EFI structure of Redfish Chassis v1_1_5 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_1_5_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_6/EfiChassisV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_6/EfiChassisV1_1_6.h new file mode 100644 index 00000000000..fc741f0c201 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_6/EfiChassisV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_1_6_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_1_6/Redfish_Chassis_v1_1_6_CS.h" +// +// EFI structure of Redfish Chassis v1_1_6 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_1_6_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_7/EfiChassisV1_1_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_7/EfiChassisV1_1_7.h new file mode 100644 index 00000000000..5c1f54f371a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_7/EfiChassisV1_1_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_1_7_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_1_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_1_7/Redfish_Chassis_v1_1_7_CS.h" +// +// EFI structure of Redfish Chassis v1_1_7 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_1_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_1_7_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_1_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_8/EfiChassisV1_1_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_8/EfiChassisV1_1_8.h new file mode 100644 index 00000000000..25e857fbe74 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_8/EfiChassisV1_1_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_1_8_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_1_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_1_8/Redfish_Chassis_v1_1_8_CS.h" +// +// EFI structure of Redfish Chassis v1_1_8 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_1_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_1_8_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_1_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_9/EfiChassisV1_1_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_9/EfiChassisV1_1_9.h new file mode 100644 index 00000000000..fffbe4f5b18 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_1_9/EfiChassisV1_1_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_1_9_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_1_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_1_9/Redfish_Chassis_v1_1_9_CS.h" +// +// EFI structure of Redfish Chassis v1_1_9 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_1_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_1_9_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_1_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_0/EfiChassisV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_0/EfiChassisV1_2_0.h new file mode 100644 index 00000000000..b469fa768b5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_0/EfiChassisV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_2_0_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_2_0/Redfish_Chassis_v1_2_0_CS.h" +// +// EFI structure of Redfish Chassis v1_2_0 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_2_0_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_1/EfiChassisV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_1/EfiChassisV1_2_1.h new file mode 100644 index 00000000000..c103af641e1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_1/EfiChassisV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_2_1_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_2_1/Redfish_Chassis_v1_2_1_CS.h" +// +// EFI structure of Redfish Chassis v1_2_1 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_2_1_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_10/EfiChassisV1_2_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_10/EfiChassisV1_2_10.h new file mode 100644 index 00000000000..940a1f3ec39 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_10/EfiChassisV1_2_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_2_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_2_10_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_2_10_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_2_10/Redfish_Chassis_v1_2_10_CS.h" +// +// EFI structure of Redfish Chassis v1_2_10 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_2_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_2_10_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_2_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_11/EfiChassisV1_2_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_11/EfiChassisV1_2_11.h new file mode 100644 index 00000000000..427a92d31ac --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_11/EfiChassisV1_2_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_2_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_2_11_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_2_11_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_2_11/Redfish_Chassis_v1_2_11_CS.h" +// +// EFI structure of Redfish Chassis v1_2_11 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_2_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_2_11_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_2_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_2/EfiChassisV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_2/EfiChassisV1_2_2.h new file mode 100644 index 00000000000..de6fdaa1eb4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_2/EfiChassisV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_2_2_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_2_2/Redfish_Chassis_v1_2_2_CS.h" +// +// EFI structure of Redfish Chassis v1_2_2 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_2_2_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_3/EfiChassisV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_3/EfiChassisV1_2_3.h new file mode 100644 index 00000000000..47f2719f93a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_3/EfiChassisV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_2_3_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_2_3/Redfish_Chassis_v1_2_3_CS.h" +// +// EFI structure of Redfish Chassis v1_2_3 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_2_3_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_4/EfiChassisV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_4/EfiChassisV1_2_4.h new file mode 100644 index 00000000000..1e4ac207cf2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_4/EfiChassisV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_2_4_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_2_4/Redfish_Chassis_v1_2_4_CS.h" +// +// EFI structure of Redfish Chassis v1_2_4 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_2_4_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_5/EfiChassisV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_5/EfiChassisV1_2_5.h new file mode 100644 index 00000000000..559ed1c6b26 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_5/EfiChassisV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_2_5_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_2_5/Redfish_Chassis_v1_2_5_CS.h" +// +// EFI structure of Redfish Chassis v1_2_5 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_2_5_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_6/EfiChassisV1_2_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_6/EfiChassisV1_2_6.h new file mode 100644 index 00000000000..c0bbaf09149 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_6/EfiChassisV1_2_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_2_6_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_2_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_2_6/Redfish_Chassis_v1_2_6_CS.h" +// +// EFI structure of Redfish Chassis v1_2_6 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_2_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_2_6_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_2_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_7/EfiChassisV1_2_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_7/EfiChassisV1_2_7.h new file mode 100644 index 00000000000..02520561106 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_7/EfiChassisV1_2_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_2_7_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_2_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_2_7/Redfish_Chassis_v1_2_7_CS.h" +// +// EFI structure of Redfish Chassis v1_2_7 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_2_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_2_7_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_2_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_8/EfiChassisV1_2_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_8/EfiChassisV1_2_8.h new file mode 100644 index 00000000000..411c9ef2bc6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_8/EfiChassisV1_2_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_2_8_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_2_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_2_8/Redfish_Chassis_v1_2_8_CS.h" +// +// EFI structure of Redfish Chassis v1_2_8 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_2_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_2_8_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_2_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_9/EfiChassisV1_2_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_9/EfiChassisV1_2_9.h new file mode 100644 index 00000000000..c71853eca3d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_2_9/EfiChassisV1_2_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_2_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_2_9_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_2_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_2_9/Redfish_Chassis_v1_2_9_CS.h" +// +// EFI structure of Redfish Chassis v1_2_9 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_2_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_2_9_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_2_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_0/EfiChassisV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_0/EfiChassisV1_3_0.h new file mode 100644 index 00000000000..6cf85bbe9c5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_0/EfiChassisV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_3_0_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_3_0/Redfish_Chassis_v1_3_0_CS.h" +// +// EFI structure of Redfish Chassis v1_3_0 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_3_0_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_1/EfiChassisV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_1/EfiChassisV1_3_1.h new file mode 100644 index 00000000000..b9511ea498b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_1/EfiChassisV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_3_1_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_3_1/Redfish_Chassis_v1_3_1_CS.h" +// +// EFI structure of Redfish Chassis v1_3_1 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_3_1_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_10/EfiChassisV1_3_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_10/EfiChassisV1_3_10.h new file mode 100644 index 00000000000..bfde722eddd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_10/EfiChassisV1_3_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_3_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_3_10_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_3_10_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_3_10/Redfish_Chassis_v1_3_10_CS.h" +// +// EFI structure of Redfish Chassis v1_3_10 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_3_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_3_10_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_3_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_11/EfiChassisV1_3_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_11/EfiChassisV1_3_11.h new file mode 100644 index 00000000000..172253686d8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_11/EfiChassisV1_3_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_3_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_3_11_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_3_11_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_3_11/Redfish_Chassis_v1_3_11_CS.h" +// +// EFI structure of Redfish Chassis v1_3_11 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_3_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_3_11_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_3_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_2/EfiChassisV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_2/EfiChassisV1_3_2.h new file mode 100644 index 00000000000..3766ade3442 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_2/EfiChassisV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_3_2_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_3_2/Redfish_Chassis_v1_3_2_CS.h" +// +// EFI structure of Redfish Chassis v1_3_2 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_3_2_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_3/EfiChassisV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_3/EfiChassisV1_3_3.h new file mode 100644 index 00000000000..19f16d4ce98 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_3/EfiChassisV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_3_3_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_3_3/Redfish_Chassis_v1_3_3_CS.h" +// +// EFI structure of Redfish Chassis v1_3_3 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_3_3_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_4/EfiChassisV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_4/EfiChassisV1_3_4.h new file mode 100644 index 00000000000..205cf04cc92 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_4/EfiChassisV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_3_4_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_3_4/Redfish_Chassis_v1_3_4_CS.h" +// +// EFI structure of Redfish Chassis v1_3_4 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_3_4_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_5/EfiChassisV1_3_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_5/EfiChassisV1_3_5.h new file mode 100644 index 00000000000..fb9331319cb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_5/EfiChassisV1_3_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_3_5_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_3_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_3_5/Redfish_Chassis_v1_3_5_CS.h" +// +// EFI structure of Redfish Chassis v1_3_5 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_3_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_3_5_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_3_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_6/EfiChassisV1_3_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_6/EfiChassisV1_3_6.h new file mode 100644 index 00000000000..47ceabc6df2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_6/EfiChassisV1_3_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_3_6_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_3_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_3_6/Redfish_Chassis_v1_3_6_CS.h" +// +// EFI structure of Redfish Chassis v1_3_6 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_3_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_3_6_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_3_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_7/EfiChassisV1_3_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_7/EfiChassisV1_3_7.h new file mode 100644 index 00000000000..6e45ae4d24e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_7/EfiChassisV1_3_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_3_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_3_7_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_3_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_3_7/Redfish_Chassis_v1_3_7_CS.h" +// +// EFI structure of Redfish Chassis v1_3_7 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_3_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_3_7_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_3_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_8/EfiChassisV1_3_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_8/EfiChassisV1_3_8.h new file mode 100644 index 00000000000..201c17473fa --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_8/EfiChassisV1_3_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_3_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_3_8_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_3_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_3_8/Redfish_Chassis_v1_3_8_CS.h" +// +// EFI structure of Redfish Chassis v1_3_8 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_3_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_3_8_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_3_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_9/EfiChassisV1_3_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_9/EfiChassisV1_3_9.h new file mode 100644 index 00000000000..92c2f0616d6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_3_9/EfiChassisV1_3_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_3_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_3_9_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_3_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_3_9/Redfish_Chassis_v1_3_9_CS.h" +// +// EFI structure of Redfish Chassis v1_3_9 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_3_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_3_9_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_3_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_0/EfiChassisV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_0/EfiChassisV1_4_0.h new file mode 100644 index 00000000000..7769a70c0b7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_0/EfiChassisV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_4_0_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_4_0/Redfish_Chassis_v1_4_0_CS.h" +// +// EFI structure of Redfish Chassis v1_4_0 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_4_0_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_1/EfiChassisV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_1/EfiChassisV1_4_1.h new file mode 100644 index 00000000000..f7b92791b16 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_1/EfiChassisV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_4_1_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_4_1/Redfish_Chassis_v1_4_1_CS.h" +// +// EFI structure of Redfish Chassis v1_4_1 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_4_1_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_10/EfiChassisV1_4_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_10/EfiChassisV1_4_10.h new file mode 100644 index 00000000000..092b93e18a7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_10/EfiChassisV1_4_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_4_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_4_10_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_4_10_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_4_10/Redfish_Chassis_v1_4_10_CS.h" +// +// EFI structure of Redfish Chassis v1_4_10 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_4_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_4_10_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_4_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_2/EfiChassisV1_4_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_2/EfiChassisV1_4_2.h new file mode 100644 index 00000000000..c0e32cad82c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_2/EfiChassisV1_4_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_4_2_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_4_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_4_2/Redfish_Chassis_v1_4_2_CS.h" +// +// EFI structure of Redfish Chassis v1_4_2 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_4_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_4_2_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_4_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_3/EfiChassisV1_4_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_3/EfiChassisV1_4_3.h new file mode 100644 index 00000000000..8da0665ca88 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_3/EfiChassisV1_4_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_4_3_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_4_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_4_3/Redfish_Chassis_v1_4_3_CS.h" +// +// EFI structure of Redfish Chassis v1_4_3 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_4_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_4_3_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_4_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_4/EfiChassisV1_4_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_4/EfiChassisV1_4_4.h new file mode 100644 index 00000000000..ed829b9a992 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_4/EfiChassisV1_4_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_4_4_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_4_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_4_4/Redfish_Chassis_v1_4_4_CS.h" +// +// EFI structure of Redfish Chassis v1_4_4 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_4_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_4_4_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_4_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_5/EfiChassisV1_4_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_5/EfiChassisV1_4_5.h new file mode 100644 index 00000000000..badc49160ad --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_5/EfiChassisV1_4_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_4_5_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_4_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_4_5/Redfish_Chassis_v1_4_5_CS.h" +// +// EFI structure of Redfish Chassis v1_4_5 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_4_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_4_5_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_4_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_6/EfiChassisV1_4_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_6/EfiChassisV1_4_6.h new file mode 100644 index 00000000000..50a23ea6266 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_6/EfiChassisV1_4_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_4_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_4_6_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_4_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_4_6/Redfish_Chassis_v1_4_6_CS.h" +// +// EFI structure of Redfish Chassis v1_4_6 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_4_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_4_6_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_4_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_7/EfiChassisV1_4_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_7/EfiChassisV1_4_7.h new file mode 100644 index 00000000000..9eeb34e2408 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_7/EfiChassisV1_4_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_4_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_4_7_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_4_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_4_7/Redfish_Chassis_v1_4_7_CS.h" +// +// EFI structure of Redfish Chassis v1_4_7 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_4_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_4_7_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_4_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_8/EfiChassisV1_4_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_8/EfiChassisV1_4_8.h new file mode 100644 index 00000000000..f74bb8618be --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_8/EfiChassisV1_4_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_4_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_4_8_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_4_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_4_8/Redfish_Chassis_v1_4_8_CS.h" +// +// EFI structure of Redfish Chassis v1_4_8 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_4_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_4_8_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_4_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_9/EfiChassisV1_4_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_9/EfiChassisV1_4_9.h new file mode 100644 index 00000000000..347ec453696 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_4_9/EfiChassisV1_4_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_4_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_4_9_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_4_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_4_9/Redfish_Chassis_v1_4_9_CS.h" +// +// EFI structure of Redfish Chassis v1_4_9 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_4_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_4_9_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_4_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_0/EfiChassisV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_0/EfiChassisV1_5_0.h new file mode 100644 index 00000000000..de323d5f4fa --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_0/EfiChassisV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_5_0_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_5_0/Redfish_Chassis_v1_5_0_CS.h" +// +// EFI structure of Redfish Chassis v1_5_0 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_5_0_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_1/EfiChassisV1_5_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_1/EfiChassisV1_5_1.h new file mode 100644 index 00000000000..e1fe679b468 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_1/EfiChassisV1_5_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_5_1_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_5_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_5_1/Redfish_Chassis_v1_5_1_CS.h" +// +// EFI structure of Redfish Chassis v1_5_1 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_5_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_5_1_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_5_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_2/EfiChassisV1_5_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_2/EfiChassisV1_5_2.h new file mode 100644 index 00000000000..8de5d807821 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_2/EfiChassisV1_5_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_5_2_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_5_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_5_2/Redfish_Chassis_v1_5_2_CS.h" +// +// EFI structure of Redfish Chassis v1_5_2 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_5_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_5_2_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_5_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_3/EfiChassisV1_5_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_3/EfiChassisV1_5_3.h new file mode 100644 index 00000000000..a9fcc328e53 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_3/EfiChassisV1_5_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_5_3_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_5_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_5_3/Redfish_Chassis_v1_5_3_CS.h" +// +// EFI structure of Redfish Chassis v1_5_3 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_5_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_5_3_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_5_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_4/EfiChassisV1_5_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_4/EfiChassisV1_5_4.h new file mode 100644 index 00000000000..761f75cdd85 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_4/EfiChassisV1_5_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_5_4_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_5_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_5_4/Redfish_Chassis_v1_5_4_CS.h" +// +// EFI structure of Redfish Chassis v1_5_4 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_5_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_5_4_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_5_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_5/EfiChassisV1_5_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_5/EfiChassisV1_5_5.h new file mode 100644 index 00000000000..cd704bd8e8b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_5/EfiChassisV1_5_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_5_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_5_5_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_5_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_5_5/Redfish_Chassis_v1_5_5_CS.h" +// +// EFI structure of Redfish Chassis v1_5_5 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_5_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_5_5_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_5_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_6/EfiChassisV1_5_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_6/EfiChassisV1_5_6.h new file mode 100644 index 00000000000..4255b382703 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_6/EfiChassisV1_5_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_5_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_5_6_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_5_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_5_6/Redfish_Chassis_v1_5_6_CS.h" +// +// EFI structure of Redfish Chassis v1_5_6 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_5_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_5_6_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_5_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_7/EfiChassisV1_5_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_7/EfiChassisV1_5_7.h new file mode 100644 index 00000000000..d1a77ec3935 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_7/EfiChassisV1_5_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_5_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_5_7_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_5_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_5_7/Redfish_Chassis_v1_5_7_CS.h" +// +// EFI structure of Redfish Chassis v1_5_7 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_5_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_5_7_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_5_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_8/EfiChassisV1_5_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_8/EfiChassisV1_5_8.h new file mode 100644 index 00000000000..b1ab03cdcec --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_8/EfiChassisV1_5_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_5_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_5_8_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_5_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_5_8/Redfish_Chassis_v1_5_8_CS.h" +// +// EFI structure of Redfish Chassis v1_5_8 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_5_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_5_8_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_5_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_9/EfiChassisV1_5_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_9/EfiChassisV1_5_9.h new file mode 100644 index 00000000000..3b541d00eff --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_5_9/EfiChassisV1_5_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_5_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_5_9_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_5_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_5_9/Redfish_Chassis_v1_5_9_CS.h" +// +// EFI structure of Redfish Chassis v1_5_9 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_5_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_5_9_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_5_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_0/EfiChassisV1_6_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_0/EfiChassisV1_6_0.h new file mode 100644 index 00000000000..eedb336a23f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_0/EfiChassisV1_6_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_6_0_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_6_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_6_0/Redfish_Chassis_v1_6_0_CS.h" +// +// EFI structure of Redfish Chassis v1_6_0 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_6_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_6_0_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_6_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_1/EfiChassisV1_6_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_1/EfiChassisV1_6_1.h new file mode 100644 index 00000000000..54bbe81cb7b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_1/EfiChassisV1_6_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_6_1_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_6_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_6_1/Redfish_Chassis_v1_6_1_CS.h" +// +// EFI structure of Redfish Chassis v1_6_1 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_6_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_6_1_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_6_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_2/EfiChassisV1_6_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_2/EfiChassisV1_6_2.h new file mode 100644 index 00000000000..6cbd82bdae0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_2/EfiChassisV1_6_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_6_2_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_6_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_6_2/Redfish_Chassis_v1_6_2_CS.h" +// +// EFI structure of Redfish Chassis v1_6_2 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_6_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_6_2_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_6_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_3/EfiChassisV1_6_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_3/EfiChassisV1_6_3.h new file mode 100644 index 00000000000..f8bbf8efe82 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_3/EfiChassisV1_6_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_6_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_6_3_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_6_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_6_3/Redfish_Chassis_v1_6_3_CS.h" +// +// EFI structure of Redfish Chassis v1_6_3 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_6_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_6_3_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_6_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_4/EfiChassisV1_6_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_4/EfiChassisV1_6_4.h new file mode 100644 index 00000000000..6bb6aae6260 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_4/EfiChassisV1_6_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_6_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_6_4_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_6_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_6_4/Redfish_Chassis_v1_6_4_CS.h" +// +// EFI structure of Redfish Chassis v1_6_4 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_6_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_6_4_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_6_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_5/EfiChassisV1_6_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_5/EfiChassisV1_6_5.h new file mode 100644 index 00000000000..202986eb294 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_5/EfiChassisV1_6_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_6_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_6_5_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_6_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_6_5/Redfish_Chassis_v1_6_5_CS.h" +// +// EFI structure of Redfish Chassis v1_6_5 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_6_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_6_5_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_6_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_6/EfiChassisV1_6_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_6/EfiChassisV1_6_6.h new file mode 100644 index 00000000000..0f1f0622cab --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_6/EfiChassisV1_6_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_6_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_6_6_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_6_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_6_6/Redfish_Chassis_v1_6_6_CS.h" +// +// EFI structure of Redfish Chassis v1_6_6 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_6_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_6_6_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_6_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_7/EfiChassisV1_6_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_7/EfiChassisV1_6_7.h new file mode 100644 index 00000000000..7760dfdd3b4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_6_7/EfiChassisV1_6_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_6_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_6_7_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_6_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_6_7/Redfish_Chassis_v1_6_7_CS.h" +// +// EFI structure of Redfish Chassis v1_6_7 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_6_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_6_7_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_6_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_0/EfiChassisV1_7_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_0/EfiChassisV1_7_0.h new file mode 100644 index 00000000000..ce71ab2982a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_0/EfiChassisV1_7_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_7_0_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_7_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_7_0/Redfish_Chassis_v1_7_0_CS.h" +// +// EFI structure of Redfish Chassis v1_7_0 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_7_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_7_0_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_7_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_1/EfiChassisV1_7_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_1/EfiChassisV1_7_1.h new file mode 100644 index 00000000000..fffed867dec --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_1/EfiChassisV1_7_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_7_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_7_1_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_7_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_7_1/Redfish_Chassis_v1_7_1_CS.h" +// +// EFI structure of Redfish Chassis v1_7_1 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_7_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_7_1_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_7_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_2/EfiChassisV1_7_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_2/EfiChassisV1_7_2.h new file mode 100644 index 00000000000..38e228ce1bc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_2/EfiChassisV1_7_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_7_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_7_2_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_7_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_7_2/Redfish_Chassis_v1_7_2_CS.h" +// +// EFI structure of Redfish Chassis v1_7_2 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_7_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_7_2_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_7_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_3/EfiChassisV1_7_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_3/EfiChassisV1_7_3.h new file mode 100644 index 00000000000..ec24e6a6b30 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_3/EfiChassisV1_7_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_7_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_7_3_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_7_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_7_3/Redfish_Chassis_v1_7_3_CS.h" +// +// EFI structure of Redfish Chassis v1_7_3 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_7_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_7_3_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_7_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_4/EfiChassisV1_7_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_4/EfiChassisV1_7_4.h new file mode 100644 index 00000000000..d6e919b62a7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_4/EfiChassisV1_7_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_7_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_7_4_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_7_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_7_4/Redfish_Chassis_v1_7_4_CS.h" +// +// EFI structure of Redfish Chassis v1_7_4 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_7_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_7_4_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_7_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_5/EfiChassisV1_7_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_5/EfiChassisV1_7_5.h new file mode 100644 index 00000000000..b311d291e7a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_5/EfiChassisV1_7_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_7_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_7_5_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_7_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_7_5/Redfish_Chassis_v1_7_5_CS.h" +// +// EFI structure of Redfish Chassis v1_7_5 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_7_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_7_5_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_7_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_6/EfiChassisV1_7_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_6/EfiChassisV1_7_6.h new file mode 100644 index 00000000000..6d41e322df4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_6/EfiChassisV1_7_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_7_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_7_6_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_7_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_7_6/Redfish_Chassis_v1_7_6_CS.h" +// +// EFI structure of Redfish Chassis v1_7_6 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_7_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_7_6_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_7_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_7/EfiChassisV1_7_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_7/EfiChassisV1_7_7.h new file mode 100644 index 00000000000..68e3cb7d15a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_7_7/EfiChassisV1_7_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_7_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_7_7_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_7_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_7_7/Redfish_Chassis_v1_7_7_CS.h" +// +// EFI structure of Redfish Chassis v1_7_7 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_7_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_7_7_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_7_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_0/EfiChassisV1_8_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_0/EfiChassisV1_8_0.h new file mode 100644 index 00000000000..63bdaa97700 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_0/EfiChassisV1_8_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_8_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_8_0_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_8_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_8_0/Redfish_Chassis_v1_8_0_CS.h" +// +// EFI structure of Redfish Chassis v1_8_0 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_8_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_8_0_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_8_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_1/EfiChassisV1_8_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_1/EfiChassisV1_8_1.h new file mode 100644 index 00000000000..16dc600edb3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_1/EfiChassisV1_8_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_8_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_8_1_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_8_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_8_1/Redfish_Chassis_v1_8_1_CS.h" +// +// EFI structure of Redfish Chassis v1_8_1 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_8_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_8_1_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_8_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_2/EfiChassisV1_8_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_2/EfiChassisV1_8_2.h new file mode 100644 index 00000000000..7da1841c05f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_2/EfiChassisV1_8_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_8_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_8_2_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_8_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_8_2/Redfish_Chassis_v1_8_2_CS.h" +// +// EFI structure of Redfish Chassis v1_8_2 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_8_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_8_2_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_8_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_3/EfiChassisV1_8_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_3/EfiChassisV1_8_3.h new file mode 100644 index 00000000000..ec19c05c649 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_3/EfiChassisV1_8_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_8_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_8_3_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_8_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_8_3/Redfish_Chassis_v1_8_3_CS.h" +// +// EFI structure of Redfish Chassis v1_8_3 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_8_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_8_3_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_8_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_4/EfiChassisV1_8_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_4/EfiChassisV1_8_4.h new file mode 100644 index 00000000000..c1a61687a29 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_4/EfiChassisV1_8_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_8_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_8_4_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_8_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_8_4/Redfish_Chassis_v1_8_4_CS.h" +// +// EFI structure of Redfish Chassis v1_8_4 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_8_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_8_4_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_8_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_5/EfiChassisV1_8_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_5/EfiChassisV1_8_5.h new file mode 100644 index 00000000000..2702bb30095 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_5/EfiChassisV1_8_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_8_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_8_5_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_8_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_8_5/Redfish_Chassis_v1_8_5_CS.h" +// +// EFI structure of Redfish Chassis v1_8_5 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_8_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_8_5_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_8_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_6/EfiChassisV1_8_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_6/EfiChassisV1_8_6.h new file mode 100644 index 00000000000..7f675c4293d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_8_6/EfiChassisV1_8_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_8_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_8_6_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_8_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_8_6/Redfish_Chassis_v1_8_6_CS.h" +// +// EFI structure of Redfish Chassis v1_8_6 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_8_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_8_6_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_8_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_9_0/EfiChassisV1_9_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_9_0/EfiChassisV1_9_0.h new file mode 100644 index 00000000000..5ec1eec35c3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_9_0/EfiChassisV1_9_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_9_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_9_0_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_9_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_9_0/Redfish_Chassis_v1_9_0_CS.h" +// +// EFI structure of Redfish Chassis v1_9_0 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_9_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_9_0_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_9_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_9_1/EfiChassisV1_9_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_9_1/EfiChassisV1_9_1.h new file mode 100644 index 00000000000..06769a1a706 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_9_1/EfiChassisV1_9_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_9_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_9_1_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_9_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_9_1/Redfish_Chassis_v1_9_1_CS.h" +// +// EFI structure of Redfish Chassis v1_9_1 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_9_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_9_1_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_9_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_9_2/EfiChassisV1_9_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_9_2/EfiChassisV1_9_2.h new file mode 100644 index 00000000000..46315d5fbf3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_9_2/EfiChassisV1_9_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_9_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_9_2_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_9_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_9_2/Redfish_Chassis_v1_9_2_CS.h" +// +// EFI structure of Redfish Chassis v1_9_2 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_9_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_9_2_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_9_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_9_3/EfiChassisV1_9_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_9_3/EfiChassisV1_9_3.h new file mode 100644 index 00000000000..db5a715f1ce --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_9_3/EfiChassisV1_9_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_9_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_9_3_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_9_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_9_3/Redfish_Chassis_v1_9_3_CS.h" +// +// EFI structure of Redfish Chassis v1_9_3 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_9_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_9_3_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_9_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_9_4/EfiChassisV1_9_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_9_4/EfiChassisV1_9_4.h new file mode 100644 index 00000000000..0942ce60492 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_9_4/EfiChassisV1_9_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_9_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_9_4_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_9_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_9_4/Redfish_Chassis_v1_9_4_CS.h" +// +// EFI structure of Redfish Chassis v1_9_4 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_9_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_9_4_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_9_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_9_5/EfiChassisV1_9_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_9_5/EfiChassisV1_9_5.h new file mode 100644 index 00000000000..e2ad9ad5b68 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Chassis/v1_9_5/EfiChassisV1_9_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Chassis v1_9_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSIS_V1_9_5_H__ +#define EFI_REDFISH_INTERP_CHASSIS_V1_9_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Chassis/v1_9_5/Redfish_Chassis_v1_9_5_CS.h" +// +// EFI structure of Redfish Chassis v1_9_5 +// +typedef struct _EFI_REDFISH_CHASSIS_V1_9_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSIS_V1_9_5_CS *Chassis; +} EFI_REDFISH_CHASSIS_V1_9_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ChassisCollection/EfiChassisCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/ChassisCollection/EfiChassisCollection.h new file mode 100644 index 00000000000..948e7bc3e4a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ChassisCollection/EfiChassisCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ChassisCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CHASSISCOLLECTION_H__ +#define EFI_REDFISH_INTERP_CHASSISCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/ChassisCollection/Redfish_ChassisCollection_CS.h" +// +// EFI structure of Redfish ChassisCollection +// +typedef struct _EFI_REDFISH_CHASSISCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CHASSISCOLLECTION_CS *ChassisCollection; +} EFI_REDFISH_CHASSISCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Circuit/v1_0_0/EfiCircuitV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Circuit/v1_0_0/EfiCircuitV1_0_0.h new file mode 100644 index 00000000000..cefe5c94044 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Circuit/v1_0_0/EfiCircuitV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Circuit v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CIRCUIT_V1_0_0_H__ +#define EFI_REDFISH_INTERP_CIRCUIT_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Circuit/v1_0_0/Redfish_Circuit_v1_0_0_CS.h" +// +// EFI structure of Redfish Circuit v1_0_0 +// +typedef struct _EFI_REDFISH_CIRCUIT_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CIRCUIT_V1_0_0_CS *Circuit; +} EFI_REDFISH_CIRCUIT_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Circuit/v1_0_1/EfiCircuitV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Circuit/v1_0_1/EfiCircuitV1_0_1.h new file mode 100644 index 00000000000..9bac3ef0312 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Circuit/v1_0_1/EfiCircuitV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Circuit v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CIRCUIT_V1_0_1_H__ +#define EFI_REDFISH_INTERP_CIRCUIT_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Circuit/v1_0_1/Redfish_Circuit_v1_0_1_CS.h" +// +// EFI structure of Redfish Circuit v1_0_1 +// +typedef struct _EFI_REDFISH_CIRCUIT_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CIRCUIT_V1_0_1_CS *Circuit; +} EFI_REDFISH_CIRCUIT_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Circuit/v1_0_2/EfiCircuitV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Circuit/v1_0_2/EfiCircuitV1_0_2.h new file mode 100644 index 00000000000..2fba5cc4f9c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Circuit/v1_0_2/EfiCircuitV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Circuit v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CIRCUIT_V1_0_2_H__ +#define EFI_REDFISH_INTERP_CIRCUIT_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Circuit/v1_0_2/Redfish_Circuit_v1_0_2_CS.h" +// +// EFI structure of Redfish Circuit v1_0_2 +// +typedef struct _EFI_REDFISH_CIRCUIT_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CIRCUIT_V1_0_2_CS *Circuit; +} EFI_REDFISH_CIRCUIT_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Circuit/v1_1_0/EfiCircuitV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Circuit/v1_1_0/EfiCircuitV1_1_0.h new file mode 100644 index 00000000000..bca5bf5c2df --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Circuit/v1_1_0/EfiCircuitV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Circuit v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CIRCUIT_V1_1_0_H__ +#define EFI_REDFISH_INTERP_CIRCUIT_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Circuit/v1_1_0/Redfish_Circuit_v1_1_0_CS.h" +// +// EFI structure of Redfish Circuit v1_1_0 +// +typedef struct _EFI_REDFISH_CIRCUIT_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CIRCUIT_V1_1_0_CS *Circuit; +} EFI_REDFISH_CIRCUIT_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Circuit/v1_1_1/EfiCircuitV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Circuit/v1_1_1/EfiCircuitV1_1_1.h new file mode 100644 index 00000000000..0f1993a4083 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Circuit/v1_1_1/EfiCircuitV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Circuit v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CIRCUIT_V1_1_1_H__ +#define EFI_REDFISH_INTERP_CIRCUIT_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Circuit/v1_1_1/Redfish_Circuit_v1_1_1_CS.h" +// +// EFI structure of Redfish Circuit v1_1_1 +// +typedef struct _EFI_REDFISH_CIRCUIT_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CIRCUIT_V1_1_1_CS *Circuit; +} EFI_REDFISH_CIRCUIT_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Circuit/v1_2_0/EfiCircuitV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Circuit/v1_2_0/EfiCircuitV1_2_0.h new file mode 100644 index 00000000000..101f9ffc306 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Circuit/v1_2_0/EfiCircuitV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Circuit v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CIRCUIT_V1_2_0_H__ +#define EFI_REDFISH_INTERP_CIRCUIT_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Circuit/v1_2_0/Redfish_Circuit_v1_2_0_CS.h" +// +// EFI structure of Redfish Circuit v1_2_0 +// +typedef struct _EFI_REDFISH_CIRCUIT_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CIRCUIT_V1_2_0_CS *Circuit; +} EFI_REDFISH_CIRCUIT_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/CircuitCollection/EfiCircuitCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/CircuitCollection/EfiCircuitCollection.h new file mode 100644 index 00000000000..2076ebeeeda --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/CircuitCollection/EfiCircuitCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for CircuitCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CIRCUITCOLLECTION_H__ +#define EFI_REDFISH_INTERP_CIRCUITCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/CircuitCollection/Redfish_CircuitCollection_CS.h" +// +// EFI structure of Redfish CircuitCollection +// +typedef struct _EFI_REDFISH_CIRCUITCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CIRCUITCOLLECTION_CS *CircuitCollection; +} EFI_REDFISH_CIRCUITCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_0_0/EfiCompositionServiceV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_0_0/EfiCompositionServiceV1_0_0.h new file mode 100644 index 00000000000..49ae35e0e26 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_0_0/EfiCompositionServiceV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for CompositionService v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPOSITIONSERVICE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_COMPOSITIONSERVICE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/CompositionService/v1_0_0/Redfish_CompositionService_v1_0_0_CS.h" +// +// EFI structure of Redfish CompositionService v1_0_0 +// +typedef struct _EFI_REDFISH_COMPOSITIONSERVICE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPOSITIONSERVICE_V1_0_0_CS *CompositionService; +} EFI_REDFISH_COMPOSITIONSERVICE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_0_1/EfiCompositionServiceV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_0_1/EfiCompositionServiceV1_0_1.h new file mode 100644 index 00000000000..85ec9d6b34b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_0_1/EfiCompositionServiceV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for CompositionService v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPOSITIONSERVICE_V1_0_1_H__ +#define EFI_REDFISH_INTERP_COMPOSITIONSERVICE_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/CompositionService/v1_0_1/Redfish_CompositionService_v1_0_1_CS.h" +// +// EFI structure of Redfish CompositionService v1_0_1 +// +typedef struct _EFI_REDFISH_COMPOSITIONSERVICE_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPOSITIONSERVICE_V1_0_1_CS *CompositionService; +} EFI_REDFISH_COMPOSITIONSERVICE_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_0_2/EfiCompositionServiceV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_0_2/EfiCompositionServiceV1_0_2.h new file mode 100644 index 00000000000..7ad9365131c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_0_2/EfiCompositionServiceV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for CompositionService v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPOSITIONSERVICE_V1_0_2_H__ +#define EFI_REDFISH_INTERP_COMPOSITIONSERVICE_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/CompositionService/v1_0_2/Redfish_CompositionService_v1_0_2_CS.h" +// +// EFI structure of Redfish CompositionService v1_0_2 +// +typedef struct _EFI_REDFISH_COMPOSITIONSERVICE_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPOSITIONSERVICE_V1_0_2_CS *CompositionService; +} EFI_REDFISH_COMPOSITIONSERVICE_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_0_3/EfiCompositionServiceV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_0_3/EfiCompositionServiceV1_0_3.h new file mode 100644 index 00000000000..3aa16c5f1ee --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_0_3/EfiCompositionServiceV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for CompositionService v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPOSITIONSERVICE_V1_0_3_H__ +#define EFI_REDFISH_INTERP_COMPOSITIONSERVICE_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/CompositionService/v1_0_3/Redfish_CompositionService_v1_0_3_CS.h" +// +// EFI structure of Redfish CompositionService v1_0_3 +// +typedef struct _EFI_REDFISH_COMPOSITIONSERVICE_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPOSITIONSERVICE_V1_0_3_CS *CompositionService; +} EFI_REDFISH_COMPOSITIONSERVICE_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_0_4/EfiCompositionServiceV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_0_4/EfiCompositionServiceV1_0_4.h new file mode 100644 index 00000000000..84b4b27fc67 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_0_4/EfiCompositionServiceV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for CompositionService v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPOSITIONSERVICE_V1_0_4_H__ +#define EFI_REDFISH_INTERP_COMPOSITIONSERVICE_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/CompositionService/v1_0_4/Redfish_CompositionService_v1_0_4_CS.h" +// +// EFI structure of Redfish CompositionService v1_0_4 +// +typedef struct _EFI_REDFISH_COMPOSITIONSERVICE_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPOSITIONSERVICE_V1_0_4_CS *CompositionService; +} EFI_REDFISH_COMPOSITIONSERVICE_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_1_0/EfiCompositionServiceV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_1_0/EfiCompositionServiceV1_1_0.h new file mode 100644 index 00000000000..a08f86d27ff --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_1_0/EfiCompositionServiceV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for CompositionService v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPOSITIONSERVICE_V1_1_0_H__ +#define EFI_REDFISH_INTERP_COMPOSITIONSERVICE_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/CompositionService/v1_1_0/Redfish_CompositionService_v1_1_0_CS.h" +// +// EFI structure of Redfish CompositionService v1_1_0 +// +typedef struct _EFI_REDFISH_COMPOSITIONSERVICE_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPOSITIONSERVICE_V1_1_0_CS *CompositionService; +} EFI_REDFISH_COMPOSITIONSERVICE_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_1_1/EfiCompositionServiceV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_1_1/EfiCompositionServiceV1_1_1.h new file mode 100644 index 00000000000..8892b2ad6a9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_1_1/EfiCompositionServiceV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for CompositionService v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPOSITIONSERVICE_V1_1_1_H__ +#define EFI_REDFISH_INTERP_COMPOSITIONSERVICE_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/CompositionService/v1_1_1/Redfish_CompositionService_v1_1_1_CS.h" +// +// EFI structure of Redfish CompositionService v1_1_1 +// +typedef struct _EFI_REDFISH_COMPOSITIONSERVICE_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPOSITIONSERVICE_V1_1_1_CS *CompositionService; +} EFI_REDFISH_COMPOSITIONSERVICE_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_1_2/EfiCompositionServiceV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_1_2/EfiCompositionServiceV1_1_2.h new file mode 100644 index 00000000000..d0912f4cede --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/CompositionService/v1_1_2/EfiCompositionServiceV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for CompositionService v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPOSITIONSERVICE_V1_1_2_H__ +#define EFI_REDFISH_INTERP_COMPOSITIONSERVICE_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/CompositionService/v1_1_2/Redfish_CompositionService_v1_1_2_CS.h" +// +// EFI structure of Redfish CompositionService v1_1_2 +// +typedef struct _EFI_REDFISH_COMPOSITIONSERVICE_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPOSITIONSERVICE_V1_1_2_CS *CompositionService; +} EFI_REDFISH_COMPOSITIONSERVICE_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_0/EfiComputerSystemV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_0/EfiComputerSystemV1_0_0.h new file mode 100644 index 00000000000..1cdbf1153f6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_0/EfiComputerSystemV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_0_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_0_0/Redfish_ComputerSystem_v1_0_0_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_0_0 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_0_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_1/EfiComputerSystemV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_1/EfiComputerSystemV1_0_1.h new file mode 100644 index 00000000000..9e8da3167e3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_1/EfiComputerSystemV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_1_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_0_1/Redfish_ComputerSystem_v1_0_1_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_0_1 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_1_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_10/EfiComputerSystemV1_0_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_10/EfiComputerSystemV1_0_10.h new file mode 100644 index 00000000000..adfb25161bf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_10/EfiComputerSystemV1_0_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_10_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_10_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_0_10/Redfish_ComputerSystem_v1_0_10_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_0_10 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_0_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_10_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_0_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_11/EfiComputerSystemV1_0_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_11/EfiComputerSystemV1_0_11.h new file mode 100644 index 00000000000..4886ea7531b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_11/EfiComputerSystemV1_0_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_11_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_11_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_0_11/Redfish_ComputerSystem_v1_0_11_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_0_11 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_0_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_11_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_0_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_12/EfiComputerSystemV1_0_12.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_12/EfiComputerSystemV1_0_12.h new file mode 100644 index 00000000000..5d2f7e39839 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_12/EfiComputerSystemV1_0_12.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_0_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_12_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_12_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_0_12/Redfish_ComputerSystem_v1_0_12_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_0_12 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_0_12 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_12_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_0_12; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_13/EfiComputerSystemV1_0_13.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_13/EfiComputerSystemV1_0_13.h new file mode 100644 index 00000000000..b4b6c5ed68b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_13/EfiComputerSystemV1_0_13.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_0_13 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_13_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_13_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_0_13/Redfish_ComputerSystem_v1_0_13_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_0_13 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_0_13 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_13_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_0_13; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_14/EfiComputerSystemV1_0_14.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_14/EfiComputerSystemV1_0_14.h new file mode 100644 index 00000000000..557453aa00a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_14/EfiComputerSystemV1_0_14.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_0_14 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_14_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_14_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_0_14/Redfish_ComputerSystem_v1_0_14_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_0_14 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_0_14 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_14_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_0_14; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_15/EfiComputerSystemV1_0_15.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_15/EfiComputerSystemV1_0_15.h new file mode 100644 index 00000000000..eec45eecea9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_15/EfiComputerSystemV1_0_15.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_0_15 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_15_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_15_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_0_15/Redfish_ComputerSystem_v1_0_15_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_0_15 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_0_15 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_15_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_0_15; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_16/EfiComputerSystemV1_0_16.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_16/EfiComputerSystemV1_0_16.h new file mode 100644 index 00000000000..087a97e881c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_16/EfiComputerSystemV1_0_16.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_0_16 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_16_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_16_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_0_16/Redfish_ComputerSystem_v1_0_16_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_0_16 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_0_16 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_16_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_0_16; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_2/EfiComputerSystemV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_2/EfiComputerSystemV1_0_2.h new file mode 100644 index 00000000000..822a9c5e49c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_2/EfiComputerSystemV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_2_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_0_2/Redfish_ComputerSystem_v1_0_2_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_0_2 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_2_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_3/EfiComputerSystemV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_3/EfiComputerSystemV1_0_3.h new file mode 100644 index 00000000000..c2fb914e654 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_3/EfiComputerSystemV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_3_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_0_3/Redfish_ComputerSystem_v1_0_3_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_0_3 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_3_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_4/EfiComputerSystemV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_4/EfiComputerSystemV1_0_4.h new file mode 100644 index 00000000000..fdc9a1a7896 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_4/EfiComputerSystemV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_4_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_0_4/Redfish_ComputerSystem_v1_0_4_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_0_4 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_4_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_5/EfiComputerSystemV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_5/EfiComputerSystemV1_0_5.h new file mode 100644 index 00000000000..f3f8b3d80e7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_5/EfiComputerSystemV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_5_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_0_5/Redfish_ComputerSystem_v1_0_5_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_0_5 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_5_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_6/EfiComputerSystemV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_6/EfiComputerSystemV1_0_6.h new file mode 100644 index 00000000000..e771f1f9e39 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_6/EfiComputerSystemV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_6_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_0_6/Redfish_ComputerSystem_v1_0_6_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_0_6 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_6_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_7/EfiComputerSystemV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_7/EfiComputerSystemV1_0_7.h new file mode 100644 index 00000000000..d3b30d7c10d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_7/EfiComputerSystemV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_7_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_0_7/Redfish_ComputerSystem_v1_0_7_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_0_7 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_7_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_8/EfiComputerSystemV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_8/EfiComputerSystemV1_0_8.h new file mode 100644 index 00000000000..b5467918937 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_8/EfiComputerSystemV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_8_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_0_8/Redfish_ComputerSystem_v1_0_8_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_0_8 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_8_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_9/EfiComputerSystemV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_9/EfiComputerSystemV1_0_9.h new file mode 100644 index 00000000000..f6fe1ada457 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_0_9/EfiComputerSystemV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_9_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_0_9/Redfish_ComputerSystem_v1_0_9_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_0_9 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_0_9_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_10_0/EfiComputerSystemV1_10_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_10_0/EfiComputerSystemV1_10_0.h new file mode 100644 index 00000000000..343c223d223 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_10_0/EfiComputerSystemV1_10_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_10_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_10_0_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_10_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_10_0/Redfish_ComputerSystem_v1_10_0_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_10_0 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_10_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_10_0_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_10_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_10_1/EfiComputerSystemV1_10_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_10_1/EfiComputerSystemV1_10_1.h new file mode 100644 index 00000000000..5b4dcf1bdbb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_10_1/EfiComputerSystemV1_10_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_10_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_10_1_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_10_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_10_1/Redfish_ComputerSystem_v1_10_1_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_10_1 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_10_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_10_1_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_10_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_10_2/EfiComputerSystemV1_10_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_10_2/EfiComputerSystemV1_10_2.h new file mode 100644 index 00000000000..f452ee5caf1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_10_2/EfiComputerSystemV1_10_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_10_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_10_2_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_10_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_10_2/Redfish_ComputerSystem_v1_10_2_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_10_2 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_10_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_10_2_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_10_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_10_3/EfiComputerSystemV1_10_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_10_3/EfiComputerSystemV1_10_3.h new file mode 100644 index 00000000000..17e2861b116 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_10_3/EfiComputerSystemV1_10_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_10_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_10_3_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_10_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_10_3/Redfish_ComputerSystem_v1_10_3_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_10_3 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_10_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_10_3_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_10_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_10_4/EfiComputerSystemV1_10_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_10_4/EfiComputerSystemV1_10_4.h new file mode 100644 index 00000000000..ce8229cabf1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_10_4/EfiComputerSystemV1_10_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_10_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_10_4_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_10_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_10_4/Redfish_ComputerSystem_v1_10_4_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_10_4 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_10_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_10_4_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_10_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_11_0/EfiComputerSystemV1_11_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_11_0/EfiComputerSystemV1_11_0.h new file mode 100644 index 00000000000..dd41f9c4bee --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_11_0/EfiComputerSystemV1_11_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_11_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_11_0_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_11_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_11_0/Redfish_ComputerSystem_v1_11_0_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_11_0 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_11_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_11_0_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_11_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_11_1/EfiComputerSystemV1_11_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_11_1/EfiComputerSystemV1_11_1.h new file mode 100644 index 00000000000..eaa5b838774 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_11_1/EfiComputerSystemV1_11_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_11_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_11_1_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_11_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_11_1/Redfish_ComputerSystem_v1_11_1_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_11_1 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_11_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_11_1_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_11_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_11_2/EfiComputerSystemV1_11_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_11_2/EfiComputerSystemV1_11_2.h new file mode 100644 index 00000000000..6560726057a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_11_2/EfiComputerSystemV1_11_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_11_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_11_2_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_11_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_11_2/Redfish_ComputerSystem_v1_11_2_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_11_2 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_11_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_11_2_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_11_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_11_3/EfiComputerSystemV1_11_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_11_3/EfiComputerSystemV1_11_3.h new file mode 100644 index 00000000000..33118f9a295 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_11_3/EfiComputerSystemV1_11_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_11_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_11_3_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_11_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_11_3/Redfish_ComputerSystem_v1_11_3_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_11_3 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_11_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_11_3_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_11_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_12_0/EfiComputerSystemV1_12_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_12_0/EfiComputerSystemV1_12_0.h new file mode 100644 index 00000000000..f62836a750f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_12_0/EfiComputerSystemV1_12_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_12_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_12_0_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_12_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_12_0/Redfish_ComputerSystem_v1_12_0_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_12_0 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_12_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_12_0_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_12_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_12_1/EfiComputerSystemV1_12_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_12_1/EfiComputerSystemV1_12_1.h new file mode 100644 index 00000000000..b561053962d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_12_1/EfiComputerSystemV1_12_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_12_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_12_1_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_12_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_12_1/Redfish_ComputerSystem_v1_12_1_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_12_1 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_12_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_12_1_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_12_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_12_2/EfiComputerSystemV1_12_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_12_2/EfiComputerSystemV1_12_2.h new file mode 100644 index 00000000000..c07dbf8f324 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_12_2/EfiComputerSystemV1_12_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_12_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_12_2_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_12_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_12_2/Redfish_ComputerSystem_v1_12_2_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_12_2 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_12_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_12_2_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_12_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_13_0/EfiComputerSystemV1_13_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_13_0/EfiComputerSystemV1_13_0.h new file mode 100644 index 00000000000..d2f4fbeb32d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_13_0/EfiComputerSystemV1_13_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_13_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_13_0_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_13_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_13_0/Redfish_ComputerSystem_v1_13_0_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_13_0 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_13_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_13_0_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_13_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_13_1/EfiComputerSystemV1_13_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_13_1/EfiComputerSystemV1_13_1.h new file mode 100644 index 00000000000..745eeb171ee --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_13_1/EfiComputerSystemV1_13_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_13_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_13_1_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_13_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_13_1/Redfish_ComputerSystem_v1_13_1_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_13_1 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_13_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_13_1_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_13_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_14_0/EfiComputerSystemV1_14_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_14_0/EfiComputerSystemV1_14_0.h new file mode 100644 index 00000000000..b27f87e7ea2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_14_0/EfiComputerSystemV1_14_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_14_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_14_0_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_14_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_14_0/Redfish_ComputerSystem_v1_14_0_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_14_0 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_14_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_14_0_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_14_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_0/EfiComputerSystemV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_0/EfiComputerSystemV1_1_0.h new file mode 100644 index 00000000000..b6d59a0a482 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_0/EfiComputerSystemV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_0_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_1_0/Redfish_ComputerSystem_v1_1_0_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_1_0 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_0_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_1/EfiComputerSystemV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_1/EfiComputerSystemV1_1_1.h new file mode 100644 index 00000000000..ea0fcaa5795 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_1/EfiComputerSystemV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_1_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_1_1/Redfish_ComputerSystem_v1_1_1_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_1_1 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_1_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_10/EfiComputerSystemV1_1_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_10/EfiComputerSystemV1_1_10.h new file mode 100644 index 00000000000..940cda9ec15 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_10/EfiComputerSystemV1_1_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_1_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_10_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_10_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_1_10/Redfish_ComputerSystem_v1_1_10_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_1_10 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_1_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_10_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_1_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_11/EfiComputerSystemV1_1_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_11/EfiComputerSystemV1_1_11.h new file mode 100644 index 00000000000..501beacbb40 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_11/EfiComputerSystemV1_1_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_1_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_11_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_11_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_1_11/Redfish_ComputerSystem_v1_1_11_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_1_11 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_1_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_11_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_1_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_12/EfiComputerSystemV1_1_12.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_12/EfiComputerSystemV1_1_12.h new file mode 100644 index 00000000000..fdeda2a3e0f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_12/EfiComputerSystemV1_1_12.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_1_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_12_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_12_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_1_12/Redfish_ComputerSystem_v1_1_12_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_1_12 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_1_12 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_12_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_1_12; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_13/EfiComputerSystemV1_1_13.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_13/EfiComputerSystemV1_1_13.h new file mode 100644 index 00000000000..439a9af43c2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_13/EfiComputerSystemV1_1_13.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_1_13 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_13_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_13_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_1_13/Redfish_ComputerSystem_v1_1_13_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_1_13 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_1_13 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_13_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_1_13; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_14/EfiComputerSystemV1_1_14.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_14/EfiComputerSystemV1_1_14.h new file mode 100644 index 00000000000..1eaed9ba19d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_14/EfiComputerSystemV1_1_14.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_1_14 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_14_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_14_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_1_14/Redfish_ComputerSystem_v1_1_14_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_1_14 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_1_14 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_14_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_1_14; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_2/EfiComputerSystemV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_2/EfiComputerSystemV1_1_2.h new file mode 100644 index 00000000000..2a2bb467593 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_2/EfiComputerSystemV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_2_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_1_2/Redfish_ComputerSystem_v1_1_2_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_1_2 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_2_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_3/EfiComputerSystemV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_3/EfiComputerSystemV1_1_3.h new file mode 100644 index 00000000000..24711dfaffc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_3/EfiComputerSystemV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_3_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_1_3/Redfish_ComputerSystem_v1_1_3_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_1_3 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_3_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_4/EfiComputerSystemV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_4/EfiComputerSystemV1_1_4.h new file mode 100644 index 00000000000..95e20357969 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_4/EfiComputerSystemV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_4_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_1_4/Redfish_ComputerSystem_v1_1_4_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_1_4 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_4_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_5/EfiComputerSystemV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_5/EfiComputerSystemV1_1_5.h new file mode 100644 index 00000000000..d47039798fa --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_5/EfiComputerSystemV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_5_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_1_5/Redfish_ComputerSystem_v1_1_5_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_1_5 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_5_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_6/EfiComputerSystemV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_6/EfiComputerSystemV1_1_6.h new file mode 100644 index 00000000000..c338bc57998 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_6/EfiComputerSystemV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_6_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_1_6/Redfish_ComputerSystem_v1_1_6_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_1_6 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_6_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_7/EfiComputerSystemV1_1_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_7/EfiComputerSystemV1_1_7.h new file mode 100644 index 00000000000..64dca80097f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_7/EfiComputerSystemV1_1_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_7_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_7_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_1_7/Redfish_ComputerSystem_v1_1_7_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_1_7 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_1_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_7_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_1_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_8/EfiComputerSystemV1_1_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_8/EfiComputerSystemV1_1_8.h new file mode 100644 index 00000000000..488415d2c68 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_8/EfiComputerSystemV1_1_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_8_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_8_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_1_8/Redfish_ComputerSystem_v1_1_8_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_1_8 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_1_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_8_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_1_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_9/EfiComputerSystemV1_1_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_9/EfiComputerSystemV1_1_9.h new file mode 100644 index 00000000000..e4a1644f0f2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_1_9/EfiComputerSystemV1_1_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_9_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_1_9_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_1_9/Redfish_ComputerSystem_v1_1_9_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_1_9 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_1_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_1_9_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_1_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_0/EfiComputerSystemV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_0/EfiComputerSystemV1_2_0.h new file mode 100644 index 00000000000..6b69a24fabd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_0/EfiComputerSystemV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_0_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_2_0/Redfish_ComputerSystem_v1_2_0_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_2_0 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_0_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_1/EfiComputerSystemV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_1/EfiComputerSystemV1_2_1.h new file mode 100644 index 00000000000..6d2a155c0ec --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_1/EfiComputerSystemV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_1_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_2_1/Redfish_ComputerSystem_v1_2_1_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_2_1 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_1_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_10/EfiComputerSystemV1_2_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_10/EfiComputerSystemV1_2_10.h new file mode 100644 index 00000000000..2e820690ba9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_10/EfiComputerSystemV1_2_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_2_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_10_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_10_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_2_10/Redfish_ComputerSystem_v1_2_10_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_2_10 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_2_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_10_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_2_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_11/EfiComputerSystemV1_2_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_11/EfiComputerSystemV1_2_11.h new file mode 100644 index 00000000000..e711b664f1d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_11/EfiComputerSystemV1_2_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_2_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_11_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_11_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_2_11/Redfish_ComputerSystem_v1_2_11_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_2_11 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_2_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_11_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_2_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_12/EfiComputerSystemV1_2_12.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_12/EfiComputerSystemV1_2_12.h new file mode 100644 index 00000000000..5045e0b0b33 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_12/EfiComputerSystemV1_2_12.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_2_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_12_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_12_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_2_12/Redfish_ComputerSystem_v1_2_12_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_2_12 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_2_12 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_12_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_2_12; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_13/EfiComputerSystemV1_2_13.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_13/EfiComputerSystemV1_2_13.h new file mode 100644 index 00000000000..12599fa9b71 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_13/EfiComputerSystemV1_2_13.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_2_13 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_13_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_13_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_2_13/Redfish_ComputerSystem_v1_2_13_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_2_13 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_2_13 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_13_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_2_13; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_2/EfiComputerSystemV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_2/EfiComputerSystemV1_2_2.h new file mode 100644 index 00000000000..f1a50ce40ca --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_2/EfiComputerSystemV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_2_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_2_2/Redfish_ComputerSystem_v1_2_2_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_2_2 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_2_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_3/EfiComputerSystemV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_3/EfiComputerSystemV1_2_3.h new file mode 100644 index 00000000000..4a0d149fa51 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_3/EfiComputerSystemV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_3_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_2_3/Redfish_ComputerSystem_v1_2_3_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_2_3 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_3_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_4/EfiComputerSystemV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_4/EfiComputerSystemV1_2_4.h new file mode 100644 index 00000000000..cceb267c231 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_4/EfiComputerSystemV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_4_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_2_4/Redfish_ComputerSystem_v1_2_4_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_2_4 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_4_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_5/EfiComputerSystemV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_5/EfiComputerSystemV1_2_5.h new file mode 100644 index 00000000000..568c230da07 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_5/EfiComputerSystemV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_5_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_2_5/Redfish_ComputerSystem_v1_2_5_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_2_5 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_5_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_6/EfiComputerSystemV1_2_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_6/EfiComputerSystemV1_2_6.h new file mode 100644 index 00000000000..a0a1adf9049 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_6/EfiComputerSystemV1_2_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_6_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_6_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_2_6/Redfish_ComputerSystem_v1_2_6_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_2_6 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_2_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_6_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_2_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_7/EfiComputerSystemV1_2_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_7/EfiComputerSystemV1_2_7.h new file mode 100644 index 00000000000..e36375a8d58 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_7/EfiComputerSystemV1_2_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_7_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_7_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_2_7/Redfish_ComputerSystem_v1_2_7_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_2_7 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_2_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_7_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_2_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_8/EfiComputerSystemV1_2_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_8/EfiComputerSystemV1_2_8.h new file mode 100644 index 00000000000..3f7641cfac9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_8/EfiComputerSystemV1_2_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_8_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_8_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_2_8/Redfish_ComputerSystem_v1_2_8_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_2_8 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_2_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_8_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_2_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_9/EfiComputerSystemV1_2_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_9/EfiComputerSystemV1_2_9.h new file mode 100644 index 00000000000..00687d6baff --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_2_9/EfiComputerSystemV1_2_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_2_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_9_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_2_9_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_2_9/Redfish_ComputerSystem_v1_2_9_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_2_9 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_2_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_2_9_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_2_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_0/EfiComputerSystemV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_0/EfiComputerSystemV1_3_0.h new file mode 100644 index 00000000000..e651cdeae0b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_0/EfiComputerSystemV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_0_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_3_0/Redfish_ComputerSystem_v1_3_0_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_3_0 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_0_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_1/EfiComputerSystemV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_1/EfiComputerSystemV1_3_1.h new file mode 100644 index 00000000000..386a9987035 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_1/EfiComputerSystemV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_1_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_3_1/Redfish_ComputerSystem_v1_3_1_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_3_1 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_1_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_10/EfiComputerSystemV1_3_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_10/EfiComputerSystemV1_3_10.h new file mode 100644 index 00000000000..741b8f45b25 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_10/EfiComputerSystemV1_3_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_3_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_10_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_10_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_3_10/Redfish_ComputerSystem_v1_3_10_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_3_10 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_3_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_10_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_3_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_11/EfiComputerSystemV1_3_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_11/EfiComputerSystemV1_3_11.h new file mode 100644 index 00000000000..efd6cda4e25 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_11/EfiComputerSystemV1_3_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_3_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_11_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_11_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_3_11/Redfish_ComputerSystem_v1_3_11_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_3_11 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_3_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_11_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_3_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_12/EfiComputerSystemV1_3_12.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_12/EfiComputerSystemV1_3_12.h new file mode 100644 index 00000000000..b0a79bc721e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_12/EfiComputerSystemV1_3_12.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_3_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_12_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_12_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_3_12/Redfish_ComputerSystem_v1_3_12_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_3_12 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_3_12 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_12_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_3_12; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_2/EfiComputerSystemV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_2/EfiComputerSystemV1_3_2.h new file mode 100644 index 00000000000..d78e25d7257 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_2/EfiComputerSystemV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_2_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_3_2/Redfish_ComputerSystem_v1_3_2_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_3_2 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_2_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_3/EfiComputerSystemV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_3/EfiComputerSystemV1_3_3.h new file mode 100644 index 00000000000..477c6937bbc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_3/EfiComputerSystemV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_3_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_3_3/Redfish_ComputerSystem_v1_3_3_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_3_3 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_3_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_4/EfiComputerSystemV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_4/EfiComputerSystemV1_3_4.h new file mode 100644 index 00000000000..5a55b7cc8b2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_4/EfiComputerSystemV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_4_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_3_4/Redfish_ComputerSystem_v1_3_4_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_3_4 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_4_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_5/EfiComputerSystemV1_3_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_5/EfiComputerSystemV1_3_5.h new file mode 100644 index 00000000000..b023587b9d7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_5/EfiComputerSystemV1_3_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_5_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_5_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_3_5/Redfish_ComputerSystem_v1_3_5_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_3_5 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_3_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_5_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_3_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_6/EfiComputerSystemV1_3_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_6/EfiComputerSystemV1_3_6.h new file mode 100644 index 00000000000..162525f7275 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_6/EfiComputerSystemV1_3_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_6_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_6_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_3_6/Redfish_ComputerSystem_v1_3_6_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_3_6 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_3_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_6_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_3_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_7/EfiComputerSystemV1_3_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_7/EfiComputerSystemV1_3_7.h new file mode 100644 index 00000000000..75372942294 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_7/EfiComputerSystemV1_3_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_3_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_7_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_7_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_3_7/Redfish_ComputerSystem_v1_3_7_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_3_7 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_3_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_7_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_3_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_8/EfiComputerSystemV1_3_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_8/EfiComputerSystemV1_3_8.h new file mode 100644 index 00000000000..a4146944e74 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_8/EfiComputerSystemV1_3_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_3_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_8_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_8_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_3_8/Redfish_ComputerSystem_v1_3_8_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_3_8 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_3_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_8_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_3_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_9/EfiComputerSystemV1_3_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_9/EfiComputerSystemV1_3_9.h new file mode 100644 index 00000000000..3a03ffaae16 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_3_9/EfiComputerSystemV1_3_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_3_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_9_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_3_9_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_3_9/Redfish_ComputerSystem_v1_3_9_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_3_9 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_3_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_3_9_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_3_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_0/EfiComputerSystemV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_0/EfiComputerSystemV1_4_0.h new file mode 100644 index 00000000000..373ae3e4975 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_0/EfiComputerSystemV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_4_0_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_4_0/Redfish_ComputerSystem_v1_4_0_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_4_0 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_4_0_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_1/EfiComputerSystemV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_1/EfiComputerSystemV1_4_1.h new file mode 100644 index 00000000000..eff875b45d3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_1/EfiComputerSystemV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_4_1_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_4_1/Redfish_ComputerSystem_v1_4_1_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_4_1 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_4_1_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_10/EfiComputerSystemV1_4_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_10/EfiComputerSystemV1_4_10.h new file mode 100644 index 00000000000..043f406a18b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_10/EfiComputerSystemV1_4_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_4_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_4_10_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_4_10_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_4_10/Redfish_ComputerSystem_v1_4_10_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_4_10 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_4_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_4_10_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_4_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_11/EfiComputerSystemV1_4_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_11/EfiComputerSystemV1_4_11.h new file mode 100644 index 00000000000..5c235cbe86f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_11/EfiComputerSystemV1_4_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_4_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_4_11_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_4_11_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_4_11/Redfish_ComputerSystem_v1_4_11_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_4_11 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_4_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_4_11_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_4_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_2/EfiComputerSystemV1_4_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_2/EfiComputerSystemV1_4_2.h new file mode 100644 index 00000000000..b7abe1ff3f7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_2/EfiComputerSystemV1_4_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_4_2_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_4_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_4_2/Redfish_ComputerSystem_v1_4_2_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_4_2 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_4_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_4_2_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_4_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_3/EfiComputerSystemV1_4_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_3/EfiComputerSystemV1_4_3.h new file mode 100644 index 00000000000..03f9e45a83c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_3/EfiComputerSystemV1_4_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_4_3_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_4_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_4_3/Redfish_ComputerSystem_v1_4_3_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_4_3 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_4_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_4_3_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_4_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_4/EfiComputerSystemV1_4_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_4/EfiComputerSystemV1_4_4.h new file mode 100644 index 00000000000..4e3a5bde304 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_4/EfiComputerSystemV1_4_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_4_4_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_4_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_4_4/Redfish_ComputerSystem_v1_4_4_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_4_4 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_4_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_4_4_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_4_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_5/EfiComputerSystemV1_4_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_5/EfiComputerSystemV1_4_5.h new file mode 100644 index 00000000000..c20378385d7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_5/EfiComputerSystemV1_4_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_4_5_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_4_5_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_4_5/Redfish_ComputerSystem_v1_4_5_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_4_5 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_4_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_4_5_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_4_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_6/EfiComputerSystemV1_4_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_6/EfiComputerSystemV1_4_6.h new file mode 100644 index 00000000000..ac69ad556ea --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_6/EfiComputerSystemV1_4_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_4_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_4_6_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_4_6_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_4_6/Redfish_ComputerSystem_v1_4_6_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_4_6 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_4_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_4_6_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_4_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_7/EfiComputerSystemV1_4_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_7/EfiComputerSystemV1_4_7.h new file mode 100644 index 00000000000..4b5fc9fc22a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_7/EfiComputerSystemV1_4_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_4_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_4_7_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_4_7_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_4_7/Redfish_ComputerSystem_v1_4_7_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_4_7 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_4_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_4_7_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_4_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_8/EfiComputerSystemV1_4_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_8/EfiComputerSystemV1_4_8.h new file mode 100644 index 00000000000..1ab6df21f2b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_8/EfiComputerSystemV1_4_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_4_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_4_8_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_4_8_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_4_8/Redfish_ComputerSystem_v1_4_8_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_4_8 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_4_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_4_8_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_4_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_9/EfiComputerSystemV1_4_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_9/EfiComputerSystemV1_4_9.h new file mode 100644 index 00000000000..52d33835976 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_4_9/EfiComputerSystemV1_4_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_4_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_4_9_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_4_9_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_4_9/Redfish_ComputerSystem_v1_4_9_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_4_9 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_4_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_4_9_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_4_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_0/EfiComputerSystemV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_0/EfiComputerSystemV1_5_0.h new file mode 100644 index 00000000000..16beb6072fb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_0/EfiComputerSystemV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_5_0_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_5_0/Redfish_ComputerSystem_v1_5_0_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_5_0 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_0_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_1/EfiComputerSystemV1_5_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_1/EfiComputerSystemV1_5_1.h new file mode 100644 index 00000000000..38d00dcac08 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_1/EfiComputerSystemV1_5_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_5_1_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_5_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_5_1/Redfish_ComputerSystem_v1_5_1_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_5_1 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_5_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_1_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_5_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_2/EfiComputerSystemV1_5_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_2/EfiComputerSystemV1_5_2.h new file mode 100644 index 00000000000..912d7cde37b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_2/EfiComputerSystemV1_5_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_5_2_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_5_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_5_2/Redfish_ComputerSystem_v1_5_2_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_5_2 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_5_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_2_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_5_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_3/EfiComputerSystemV1_5_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_3/EfiComputerSystemV1_5_3.h new file mode 100644 index 00000000000..8674d533723 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_3/EfiComputerSystemV1_5_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_5_3_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_5_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_5_3/Redfish_ComputerSystem_v1_5_3_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_5_3 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_5_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_3_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_5_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_4/EfiComputerSystemV1_5_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_4/EfiComputerSystemV1_5_4.h new file mode 100644 index 00000000000..40f0ba3505c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_4/EfiComputerSystemV1_5_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_5_4_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_5_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_5_4/Redfish_ComputerSystem_v1_5_4_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_5_4 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_5_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_4_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_5_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_5/EfiComputerSystemV1_5_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_5/EfiComputerSystemV1_5_5.h new file mode 100644 index 00000000000..39674b7891f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_5/EfiComputerSystemV1_5_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_5_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_5_5_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_5_5_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_5_5/Redfish_ComputerSystem_v1_5_5_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_5_5 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_5_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_5_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_5_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_6/EfiComputerSystemV1_5_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_6/EfiComputerSystemV1_5_6.h new file mode 100644 index 00000000000..76f892ef13c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_6/EfiComputerSystemV1_5_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_5_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_5_6_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_5_6_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_5_6/Redfish_ComputerSystem_v1_5_6_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_5_6 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_5_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_6_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_5_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_7/EfiComputerSystemV1_5_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_7/EfiComputerSystemV1_5_7.h new file mode 100644 index 00000000000..3be2e87fd89 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_7/EfiComputerSystemV1_5_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_5_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_5_7_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_5_7_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_5_7/Redfish_ComputerSystem_v1_5_7_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_5_7 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_5_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_7_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_5_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_8/EfiComputerSystemV1_5_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_8/EfiComputerSystemV1_5_8.h new file mode 100644 index 00000000000..b8f879fb09a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_8/EfiComputerSystemV1_5_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_5_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_5_8_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_5_8_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_5_8/Redfish_ComputerSystem_v1_5_8_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_5_8 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_5_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_8_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_5_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_9/EfiComputerSystemV1_5_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_9/EfiComputerSystemV1_5_9.h new file mode 100644 index 00000000000..11cdc4916b9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_5_9/EfiComputerSystemV1_5_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_5_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_5_9_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_5_9_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_5_9/Redfish_ComputerSystem_v1_5_9_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_5_9 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_5_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_5_9_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_5_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_0/EfiComputerSystemV1_6_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_0/EfiComputerSystemV1_6_0.h new file mode 100644 index 00000000000..dea52b71b55 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_0/EfiComputerSystemV1_6_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_6_0_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_6_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_6_0/Redfish_ComputerSystem_v1_6_0_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_6_0 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_6_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_6_0_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_6_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_1/EfiComputerSystemV1_6_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_1/EfiComputerSystemV1_6_1.h new file mode 100644 index 00000000000..9fc3d84799c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_1/EfiComputerSystemV1_6_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_6_1_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_6_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_6_1/Redfish_ComputerSystem_v1_6_1_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_6_1 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_6_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_6_1_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_6_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_2/EfiComputerSystemV1_6_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_2/EfiComputerSystemV1_6_2.h new file mode 100644 index 00000000000..cee22579e5b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_2/EfiComputerSystemV1_6_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_6_2_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_6_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_6_2/Redfish_ComputerSystem_v1_6_2_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_6_2 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_6_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_6_2_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_6_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_3/EfiComputerSystemV1_6_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_3/EfiComputerSystemV1_6_3.h new file mode 100644 index 00000000000..89b23151799 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_3/EfiComputerSystemV1_6_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_6_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_6_3_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_6_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_6_3/Redfish_ComputerSystem_v1_6_3_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_6_3 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_6_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_6_3_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_6_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_4/EfiComputerSystemV1_6_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_4/EfiComputerSystemV1_6_4.h new file mode 100644 index 00000000000..dd508e20c53 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_4/EfiComputerSystemV1_6_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_6_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_6_4_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_6_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_6_4/Redfish_ComputerSystem_v1_6_4_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_6_4 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_6_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_6_4_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_6_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_5/EfiComputerSystemV1_6_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_5/EfiComputerSystemV1_6_5.h new file mode 100644 index 00000000000..2ea60552d9e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_5/EfiComputerSystemV1_6_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_6_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_6_5_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_6_5_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_6_5/Redfish_ComputerSystem_v1_6_5_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_6_5 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_6_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_6_5_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_6_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_6/EfiComputerSystemV1_6_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_6/EfiComputerSystemV1_6_6.h new file mode 100644 index 00000000000..cd9d77c9708 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_6/EfiComputerSystemV1_6_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_6_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_6_6_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_6_6_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_6_6/Redfish_ComputerSystem_v1_6_6_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_6_6 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_6_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_6_6_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_6_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_7/EfiComputerSystemV1_6_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_7/EfiComputerSystemV1_6_7.h new file mode 100644 index 00000000000..2f787643cb5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_6_7/EfiComputerSystemV1_6_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_6_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_6_7_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_6_7_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_6_7/Redfish_ComputerSystem_v1_6_7_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_6_7 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_6_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_6_7_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_6_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_0/EfiComputerSystemV1_7_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_0/EfiComputerSystemV1_7_0.h new file mode 100644 index 00000000000..72234f50dbc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_0/EfiComputerSystemV1_7_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_7_0_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_7_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_7_0/Redfish_ComputerSystem_v1_7_0_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_7_0 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_7_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_7_0_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_7_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_1/EfiComputerSystemV1_7_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_1/EfiComputerSystemV1_7_1.h new file mode 100644 index 00000000000..16b0eed69dc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_1/EfiComputerSystemV1_7_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_7_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_7_1_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_7_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_7_1/Redfish_ComputerSystem_v1_7_1_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_7_1 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_7_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_7_1_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_7_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_2/EfiComputerSystemV1_7_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_2/EfiComputerSystemV1_7_2.h new file mode 100644 index 00000000000..e3bc1c32f23 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_2/EfiComputerSystemV1_7_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_7_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_7_2_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_7_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_7_2/Redfish_ComputerSystem_v1_7_2_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_7_2 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_7_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_7_2_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_7_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_3/EfiComputerSystemV1_7_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_3/EfiComputerSystemV1_7_3.h new file mode 100644 index 00000000000..01ea278c8c0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_3/EfiComputerSystemV1_7_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_7_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_7_3_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_7_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_7_3/Redfish_ComputerSystem_v1_7_3_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_7_3 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_7_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_7_3_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_7_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_4/EfiComputerSystemV1_7_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_4/EfiComputerSystemV1_7_4.h new file mode 100644 index 00000000000..0689c4ecdf7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_4/EfiComputerSystemV1_7_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_7_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_7_4_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_7_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_7_4/Redfish_ComputerSystem_v1_7_4_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_7_4 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_7_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_7_4_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_7_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_5/EfiComputerSystemV1_7_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_5/EfiComputerSystemV1_7_5.h new file mode 100644 index 00000000000..16a09878878 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_5/EfiComputerSystemV1_7_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_7_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_7_5_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_7_5_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_7_5/Redfish_ComputerSystem_v1_7_5_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_7_5 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_7_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_7_5_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_7_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_6/EfiComputerSystemV1_7_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_6/EfiComputerSystemV1_7_6.h new file mode 100644 index 00000000000..a74c026a60f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_7_6/EfiComputerSystemV1_7_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_7_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_7_6_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_7_6_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_7_6/Redfish_ComputerSystem_v1_7_6_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_7_6 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_7_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_7_6_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_7_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_8_0/EfiComputerSystemV1_8_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_8_0/EfiComputerSystemV1_8_0.h new file mode 100644 index 00000000000..c0ca5464f89 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_8_0/EfiComputerSystemV1_8_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_8_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_8_0_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_8_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_8_0/Redfish_ComputerSystem_v1_8_0_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_8_0 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_8_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_8_0_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_8_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_8_1/EfiComputerSystemV1_8_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_8_1/EfiComputerSystemV1_8_1.h new file mode 100644 index 00000000000..0947f3ae561 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_8_1/EfiComputerSystemV1_8_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_8_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_8_1_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_8_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_8_1/Redfish_ComputerSystem_v1_8_1_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_8_1 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_8_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_8_1_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_8_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_8_2/EfiComputerSystemV1_8_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_8_2/EfiComputerSystemV1_8_2.h new file mode 100644 index 00000000000..b0787411d9e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_8_2/EfiComputerSystemV1_8_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_8_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_8_2_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_8_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_8_2/Redfish_ComputerSystem_v1_8_2_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_8_2 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_8_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_8_2_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_8_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_8_3/EfiComputerSystemV1_8_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_8_3/EfiComputerSystemV1_8_3.h new file mode 100644 index 00000000000..8f0ec021fd9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_8_3/EfiComputerSystemV1_8_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_8_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_8_3_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_8_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_8_3/Redfish_ComputerSystem_v1_8_3_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_8_3 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_8_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_8_3_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_8_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_8_4/EfiComputerSystemV1_8_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_8_4/EfiComputerSystemV1_8_4.h new file mode 100644 index 00000000000..d21c666b691 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_8_4/EfiComputerSystemV1_8_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_8_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_8_4_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_8_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_8_4/Redfish_ComputerSystem_v1_8_4_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_8_4 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_8_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_8_4_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_8_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_8_5/EfiComputerSystemV1_8_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_8_5/EfiComputerSystemV1_8_5.h new file mode 100644 index 00000000000..ce1fb895ceb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_8_5/EfiComputerSystemV1_8_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_8_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_8_5_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_8_5_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_8_5/Redfish_ComputerSystem_v1_8_5_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_8_5 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_8_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_8_5_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_8_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_9_0/EfiComputerSystemV1_9_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_9_0/EfiComputerSystemV1_9_0.h new file mode 100644 index 00000000000..bc41efac4ff --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_9_0/EfiComputerSystemV1_9_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_9_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_9_0_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_9_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_9_0/Redfish_ComputerSystem_v1_9_0_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_9_0 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_9_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_9_0_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_9_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_9_1/EfiComputerSystemV1_9_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_9_1/EfiComputerSystemV1_9_1.h new file mode 100644 index 00000000000..3d7826edde3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_9_1/EfiComputerSystemV1_9_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_9_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_9_1_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_9_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_9_1/Redfish_ComputerSystem_v1_9_1_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_9_1 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_9_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_9_1_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_9_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_9_2/EfiComputerSystemV1_9_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_9_2/EfiComputerSystemV1_9_2.h new file mode 100644 index 00000000000..e87d897e11d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_9_2/EfiComputerSystemV1_9_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_9_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_9_2_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_9_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_9_2/Redfish_ComputerSystem_v1_9_2_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_9_2 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_9_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_9_2_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_9_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_9_3/EfiComputerSystemV1_9_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_9_3/EfiComputerSystemV1_9_3.h new file mode 100644 index 00000000000..600c958bb42 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_9_3/EfiComputerSystemV1_9_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_9_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_9_3_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_9_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_9_3/Redfish_ComputerSystem_v1_9_3_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_9_3 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_9_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_9_3_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_9_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_9_4/EfiComputerSystemV1_9_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_9_4/EfiComputerSystemV1_9_4.h new file mode 100644 index 00000000000..9acd6322f08 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_9_4/EfiComputerSystemV1_9_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_9_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_9_4_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_9_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_9_4/Redfish_ComputerSystem_v1_9_4_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_9_4 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_9_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_9_4_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_9_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_9_5/EfiComputerSystemV1_9_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_9_5/EfiComputerSystemV1_9_5.h new file mode 100644 index 00000000000..2f0eae45fe6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystem/v1_9_5/EfiComputerSystemV1_9_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystem v1_9_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_9_5_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEM_V1_9_5_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystem/v1_9_5/Redfish_ComputerSystem_v1_9_5_CS.h" +// +// EFI structure of Redfish ComputerSystem v1_9_5 +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEM_V1_9_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEM_V1_9_5_CS *ComputerSystem; +} EFI_REDFISH_COMPUTERSYSTEM_V1_9_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystemCollection/EfiComputerSystemCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystemCollection/EfiComputerSystemCollection.h new file mode 100644 index 00000000000..021a3a78ba8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ComputerSystemCollection/EfiComputerSystemCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ComputerSystemCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_COMPUTERSYSTEMCOLLECTION_H__ +#define EFI_REDFISH_INTERP_COMPUTERSYSTEMCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/ComputerSystemCollection/Redfish_ComputerSystemCollection_CS.h" +// +// EFI structure of Redfish ComputerSystemCollection +// +typedef struct _EFI_REDFISH_COMPUTERSYSTEMCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_COMPUTERSYSTEMCOLLECTION_CS *ComputerSystemCollection; +} EFI_REDFISH_COMPUTERSYSTEMCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Connection/v1_0_0/EfiConnectionV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Connection/v1_0_0/EfiConnectionV1_0_0.h new file mode 100644 index 00000000000..4b19870db26 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Connection/v1_0_0/EfiConnectionV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Connection v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CONNECTION_V1_0_0_H__ +#define EFI_REDFISH_INTERP_CONNECTION_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Connection/v1_0_0/Redfish_Connection_v1_0_0_CS.h" +// +// EFI structure of Redfish Connection v1_0_0 +// +typedef struct _EFI_REDFISH_CONNECTION_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CONNECTION_V1_0_0_CS *Connection; +} EFI_REDFISH_CONNECTION_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ConnectionCollection/EfiConnectionCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/ConnectionCollection/EfiConnectionCollection.h new file mode 100644 index 00000000000..b6269f41d70 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ConnectionCollection/EfiConnectionCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ConnectionCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CONNECTIONCOLLECTION_H__ +#define EFI_REDFISH_INTERP_CONNECTIONCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/ConnectionCollection/Redfish_ConnectionCollection_CS.h" +// +// EFI structure of Redfish ConnectionCollection +// +typedef struct _EFI_REDFISH_CONNECTIONCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CONNECTIONCOLLECTION_CS *ConnectionCollection; +} EFI_REDFISH_CONNECTIONCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ConnectionMethod/v1_0_0/EfiConnectionMethodV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ConnectionMethod/v1_0_0/EfiConnectionMethodV1_0_0.h new file mode 100644 index 00000000000..f97ece04cd1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ConnectionMethod/v1_0_0/EfiConnectionMethodV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ConnectionMethod v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CONNECTIONMETHOD_V1_0_0_H__ +#define EFI_REDFISH_INTERP_CONNECTIONMETHOD_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ConnectionMethod/v1_0_0/Redfish_ConnectionMethod_v1_0_0_CS.h" +// +// EFI structure of Redfish ConnectionMethod v1_0_0 +// +typedef struct _EFI_REDFISH_CONNECTIONMETHOD_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CONNECTIONMETHOD_V1_0_0_CS *ConnectionMethod; +} EFI_REDFISH_CONNECTIONMETHOD_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ConnectionMethodCollection/EfiConnectionMethodCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/ConnectionMethodCollection/EfiConnectionMethodCollection.h new file mode 100644 index 00000000000..56497b83aa5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ConnectionMethodCollection/EfiConnectionMethodCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ConnectionMethodCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_CONNECTIONMETHODCOLLECTION_H__ +#define EFI_REDFISH_INTERP_CONNECTIONMETHODCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/ConnectionMethodCollection/Redfish_ConnectionMethodCollection_CS.h" +// +// EFI structure of Redfish ConnectionMethodCollection +// +typedef struct _EFI_REDFISH_CONNECTIONMETHODCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_CONNECTIONMETHODCOLLECTION_CS *ConnectionMethodCollection; +} EFI_REDFISH_CONNECTIONMETHODCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_0/EfiDriveV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_0/EfiDriveV1_0_0.h new file mode 100644 index 00000000000..777a5bce04b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_0/EfiDriveV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_0_0/Redfish_Drive_v1_0_0_CS.h" +// +// EFI structure of Redfish Drive v1_0_0 +// +typedef struct _EFI_REDFISH_DRIVE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_0_0_CS *Drive; +} EFI_REDFISH_DRIVE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_1/EfiDriveV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_1/EfiDriveV1_0_1.h new file mode 100644 index 00000000000..9eaa150f387 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_1/EfiDriveV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_0_1_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_0_1/Redfish_Drive_v1_0_1_CS.h" +// +// EFI structure of Redfish Drive v1_0_1 +// +typedef struct _EFI_REDFISH_DRIVE_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_0_1_CS *Drive; +} EFI_REDFISH_DRIVE_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_10/EfiDriveV1_0_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_10/EfiDriveV1_0_10.h new file mode 100644 index 00000000000..07a7d9a26b2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_10/EfiDriveV1_0_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_0_10_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_0_10_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_0_10/Redfish_Drive_v1_0_10_CS.h" +// +// EFI structure of Redfish Drive v1_0_10 +// +typedef struct _EFI_REDFISH_DRIVE_V1_0_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_0_10_CS *Drive; +} EFI_REDFISH_DRIVE_V1_0_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_11/EfiDriveV1_0_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_11/EfiDriveV1_0_11.h new file mode 100644 index 00000000000..cf714ce0bce --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_11/EfiDriveV1_0_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_0_11_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_0_11_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_0_11/Redfish_Drive_v1_0_11_CS.h" +// +// EFI structure of Redfish Drive v1_0_11 +// +typedef struct _EFI_REDFISH_DRIVE_V1_0_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_0_11_CS *Drive; +} EFI_REDFISH_DRIVE_V1_0_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_2/EfiDriveV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_2/EfiDriveV1_0_2.h new file mode 100644 index 00000000000..5a2d788dc7a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_2/EfiDriveV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_0_2_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_0_2/Redfish_Drive_v1_0_2_CS.h" +// +// EFI structure of Redfish Drive v1_0_2 +// +typedef struct _EFI_REDFISH_DRIVE_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_0_2_CS *Drive; +} EFI_REDFISH_DRIVE_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_3/EfiDriveV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_3/EfiDriveV1_0_3.h new file mode 100644 index 00000000000..efdd7eeb303 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_3/EfiDriveV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_0_3_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_0_3/Redfish_Drive_v1_0_3_CS.h" +// +// EFI structure of Redfish Drive v1_0_3 +// +typedef struct _EFI_REDFISH_DRIVE_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_0_3_CS *Drive; +} EFI_REDFISH_DRIVE_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_4/EfiDriveV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_4/EfiDriveV1_0_4.h new file mode 100644 index 00000000000..fc77a4f229d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_4/EfiDriveV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_0_4_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_0_4/Redfish_Drive_v1_0_4_CS.h" +// +// EFI structure of Redfish Drive v1_0_4 +// +typedef struct _EFI_REDFISH_DRIVE_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_0_4_CS *Drive; +} EFI_REDFISH_DRIVE_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_5/EfiDriveV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_5/EfiDriveV1_0_5.h new file mode 100644 index 00000000000..d223755f9c8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_5/EfiDriveV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_0_5_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_0_5/Redfish_Drive_v1_0_5_CS.h" +// +// EFI structure of Redfish Drive v1_0_5 +// +typedef struct _EFI_REDFISH_DRIVE_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_0_5_CS *Drive; +} EFI_REDFISH_DRIVE_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_6/EfiDriveV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_6/EfiDriveV1_0_6.h new file mode 100644 index 00000000000..84bfc852e4c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_6/EfiDriveV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_0_6_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_0_6/Redfish_Drive_v1_0_6_CS.h" +// +// EFI structure of Redfish Drive v1_0_6 +// +typedef struct _EFI_REDFISH_DRIVE_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_0_6_CS *Drive; +} EFI_REDFISH_DRIVE_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_7/EfiDriveV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_7/EfiDriveV1_0_7.h new file mode 100644 index 00000000000..6f2ac60acde --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_7/EfiDriveV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_0_7_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_0_7/Redfish_Drive_v1_0_7_CS.h" +// +// EFI structure of Redfish Drive v1_0_7 +// +typedef struct _EFI_REDFISH_DRIVE_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_0_7_CS *Drive; +} EFI_REDFISH_DRIVE_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_8/EfiDriveV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_8/EfiDriveV1_0_8.h new file mode 100644 index 00000000000..39e9d6598fb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_8/EfiDriveV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_0_8_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_0_8/Redfish_Drive_v1_0_8_CS.h" +// +// EFI structure of Redfish Drive v1_0_8 +// +typedef struct _EFI_REDFISH_DRIVE_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_0_8_CS *Drive; +} EFI_REDFISH_DRIVE_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_9/EfiDriveV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_9/EfiDriveV1_0_9.h new file mode 100644 index 00000000000..e3080f92ee4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_0_9/EfiDriveV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_0_9_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_0_9/Redfish_Drive_v1_0_9_CS.h" +// +// EFI structure of Redfish Drive v1_0_9 +// +typedef struct _EFI_REDFISH_DRIVE_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_0_9_CS *Drive; +} EFI_REDFISH_DRIVE_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_10_0/EfiDriveV1_10_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_10_0/EfiDriveV1_10_0.h new file mode 100644 index 00000000000..dffb1bfeaac --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_10_0/EfiDriveV1_10_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_10_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_10_0_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_10_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_10_0/Redfish_Drive_v1_10_0_CS.h" +// +// EFI structure of Redfish Drive v1_10_0 +// +typedef struct _EFI_REDFISH_DRIVE_V1_10_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_10_0_CS *Drive; +} EFI_REDFISH_DRIVE_V1_10_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_10_1/EfiDriveV1_10_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_10_1/EfiDriveV1_10_1.h new file mode 100644 index 00000000000..43026bba55f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_10_1/EfiDriveV1_10_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_10_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_10_1_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_10_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_10_1/Redfish_Drive_v1_10_1_CS.h" +// +// EFI structure of Redfish Drive v1_10_1 +// +typedef struct _EFI_REDFISH_DRIVE_V1_10_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_10_1_CS *Drive; +} EFI_REDFISH_DRIVE_V1_10_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_11_0/EfiDriveV1_11_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_11_0/EfiDriveV1_11_0.h new file mode 100644 index 00000000000..40d0a63d4e9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_11_0/EfiDriveV1_11_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_11_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_11_0_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_11_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_11_0/Redfish_Drive_v1_11_0_CS.h" +// +// EFI structure of Redfish Drive v1_11_0 +// +typedef struct _EFI_REDFISH_DRIVE_V1_11_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_11_0_CS *Drive; +} EFI_REDFISH_DRIVE_V1_11_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_11_1/EfiDriveV1_11_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_11_1/EfiDriveV1_11_1.h new file mode 100644 index 00000000000..31c97bcedba --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_11_1/EfiDriveV1_11_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_11_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_11_1_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_11_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_11_1/Redfish_Drive_v1_11_1_CS.h" +// +// EFI structure of Redfish Drive v1_11_1 +// +typedef struct _EFI_REDFISH_DRIVE_V1_11_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_11_1_CS *Drive; +} EFI_REDFISH_DRIVE_V1_11_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_12_0/EfiDriveV1_12_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_12_0/EfiDriveV1_12_0.h new file mode 100644 index 00000000000..e12267d412a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_12_0/EfiDriveV1_12_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_12_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_12_0_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_12_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_12_0/Redfish_Drive_v1_12_0_CS.h" +// +// EFI structure of Redfish Drive v1_12_0 +// +typedef struct _EFI_REDFISH_DRIVE_V1_12_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_12_0_CS *Drive; +} EFI_REDFISH_DRIVE_V1_12_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_0/EfiDriveV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_0/EfiDriveV1_1_0.h new file mode 100644 index 00000000000..c644be30388 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_0/EfiDriveV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_1_0_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_1_0/Redfish_Drive_v1_1_0_CS.h" +// +// EFI structure of Redfish Drive v1_1_0 +// +typedef struct _EFI_REDFISH_DRIVE_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_1_0_CS *Drive; +} EFI_REDFISH_DRIVE_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_1/EfiDriveV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_1/EfiDriveV1_1_1.h new file mode 100644 index 00000000000..dfe72380c75 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_1/EfiDriveV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_1_1_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_1_1/Redfish_Drive_v1_1_1_CS.h" +// +// EFI structure of Redfish Drive v1_1_1 +// +typedef struct _EFI_REDFISH_DRIVE_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_1_1_CS *Drive; +} EFI_REDFISH_DRIVE_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_10/EfiDriveV1_1_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_10/EfiDriveV1_1_10.h new file mode 100644 index 00000000000..b8931ad7d0a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_10/EfiDriveV1_1_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_1_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_1_10_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_1_10_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_1_10/Redfish_Drive_v1_1_10_CS.h" +// +// EFI structure of Redfish Drive v1_1_10 +// +typedef struct _EFI_REDFISH_DRIVE_V1_1_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_1_10_CS *Drive; +} EFI_REDFISH_DRIVE_V1_1_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_2/EfiDriveV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_2/EfiDriveV1_1_2.h new file mode 100644 index 00000000000..77b02273f7a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_2/EfiDriveV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_1_2_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_1_2/Redfish_Drive_v1_1_2_CS.h" +// +// EFI structure of Redfish Drive v1_1_2 +// +typedef struct _EFI_REDFISH_DRIVE_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_1_2_CS *Drive; +} EFI_REDFISH_DRIVE_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_3/EfiDriveV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_3/EfiDriveV1_1_3.h new file mode 100644 index 00000000000..710bc3a809e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_3/EfiDriveV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_1_3_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_1_3/Redfish_Drive_v1_1_3_CS.h" +// +// EFI structure of Redfish Drive v1_1_3 +// +typedef struct _EFI_REDFISH_DRIVE_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_1_3_CS *Drive; +} EFI_REDFISH_DRIVE_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_4/EfiDriveV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_4/EfiDriveV1_1_4.h new file mode 100644 index 00000000000..2dc8f7818ad --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_4/EfiDriveV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_1_4_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_1_4/Redfish_Drive_v1_1_4_CS.h" +// +// EFI structure of Redfish Drive v1_1_4 +// +typedef struct _EFI_REDFISH_DRIVE_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_1_4_CS *Drive; +} EFI_REDFISH_DRIVE_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_5/EfiDriveV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_5/EfiDriveV1_1_5.h new file mode 100644 index 00000000000..2db62080e00 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_5/EfiDriveV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_1_5_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_1_5/Redfish_Drive_v1_1_5_CS.h" +// +// EFI structure of Redfish Drive v1_1_5 +// +typedef struct _EFI_REDFISH_DRIVE_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_1_5_CS *Drive; +} EFI_REDFISH_DRIVE_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_6/EfiDriveV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_6/EfiDriveV1_1_6.h new file mode 100644 index 00000000000..881227e1e9d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_6/EfiDriveV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_1_6_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_1_6/Redfish_Drive_v1_1_6_CS.h" +// +// EFI structure of Redfish Drive v1_1_6 +// +typedef struct _EFI_REDFISH_DRIVE_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_1_6_CS *Drive; +} EFI_REDFISH_DRIVE_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_7/EfiDriveV1_1_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_7/EfiDriveV1_1_7.h new file mode 100644 index 00000000000..bd1a7f39597 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_7/EfiDriveV1_1_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_1_7_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_1_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_1_7/Redfish_Drive_v1_1_7_CS.h" +// +// EFI structure of Redfish Drive v1_1_7 +// +typedef struct _EFI_REDFISH_DRIVE_V1_1_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_1_7_CS *Drive; +} EFI_REDFISH_DRIVE_V1_1_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_8/EfiDriveV1_1_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_8/EfiDriveV1_1_8.h new file mode 100644 index 00000000000..82680a1a0a3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_8/EfiDriveV1_1_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_1_8_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_1_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_1_8/Redfish_Drive_v1_1_8_CS.h" +// +// EFI structure of Redfish Drive v1_1_8 +// +typedef struct _EFI_REDFISH_DRIVE_V1_1_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_1_8_CS *Drive; +} EFI_REDFISH_DRIVE_V1_1_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_9/EfiDriveV1_1_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_9/EfiDriveV1_1_9.h new file mode 100644 index 00000000000..7b35dcbe138 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_1_9/EfiDriveV1_1_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_1_9_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_1_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_1_9/Redfish_Drive_v1_1_9_CS.h" +// +// EFI structure of Redfish Drive v1_1_9 +// +typedef struct _EFI_REDFISH_DRIVE_V1_1_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_1_9_CS *Drive; +} EFI_REDFISH_DRIVE_V1_1_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_0/EfiDriveV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_0/EfiDriveV1_2_0.h new file mode 100644 index 00000000000..0c776d5b158 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_0/EfiDriveV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_2_0_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_2_0/Redfish_Drive_v1_2_0_CS.h" +// +// EFI structure of Redfish Drive v1_2_0 +// +typedef struct _EFI_REDFISH_DRIVE_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_2_0_CS *Drive; +} EFI_REDFISH_DRIVE_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_1/EfiDriveV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_1/EfiDriveV1_2_1.h new file mode 100644 index 00000000000..d96821ee1f7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_1/EfiDriveV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_2_1_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_2_1/Redfish_Drive_v1_2_1_CS.h" +// +// EFI structure of Redfish Drive v1_2_1 +// +typedef struct _EFI_REDFISH_DRIVE_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_2_1_CS *Drive; +} EFI_REDFISH_DRIVE_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_2/EfiDriveV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_2/EfiDriveV1_2_2.h new file mode 100644 index 00000000000..f3658bb3597 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_2/EfiDriveV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_2_2_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_2_2/Redfish_Drive_v1_2_2_CS.h" +// +// EFI structure of Redfish Drive v1_2_2 +// +typedef struct _EFI_REDFISH_DRIVE_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_2_2_CS *Drive; +} EFI_REDFISH_DRIVE_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_3/EfiDriveV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_3/EfiDriveV1_2_3.h new file mode 100644 index 00000000000..835b6091f79 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_3/EfiDriveV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_2_3_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_2_3/Redfish_Drive_v1_2_3_CS.h" +// +// EFI structure of Redfish Drive v1_2_3 +// +typedef struct _EFI_REDFISH_DRIVE_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_2_3_CS *Drive; +} EFI_REDFISH_DRIVE_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_4/EfiDriveV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_4/EfiDriveV1_2_4.h new file mode 100644 index 00000000000..73112c2c83b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_4/EfiDriveV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_2_4_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_2_4/Redfish_Drive_v1_2_4_CS.h" +// +// EFI structure of Redfish Drive v1_2_4 +// +typedef struct _EFI_REDFISH_DRIVE_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_2_4_CS *Drive; +} EFI_REDFISH_DRIVE_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_5/EfiDriveV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_5/EfiDriveV1_2_5.h new file mode 100644 index 00000000000..f8ec8d05780 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_5/EfiDriveV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_2_5_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_2_5/Redfish_Drive_v1_2_5_CS.h" +// +// EFI structure of Redfish Drive v1_2_5 +// +typedef struct _EFI_REDFISH_DRIVE_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_2_5_CS *Drive; +} EFI_REDFISH_DRIVE_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_6/EfiDriveV1_2_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_6/EfiDriveV1_2_6.h new file mode 100644 index 00000000000..6c36b2b2a96 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_6/EfiDriveV1_2_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_2_6_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_2_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_2_6/Redfish_Drive_v1_2_6_CS.h" +// +// EFI structure of Redfish Drive v1_2_6 +// +typedef struct _EFI_REDFISH_DRIVE_V1_2_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_2_6_CS *Drive; +} EFI_REDFISH_DRIVE_V1_2_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_7/EfiDriveV1_2_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_7/EfiDriveV1_2_7.h new file mode 100644 index 00000000000..a5021fe91f1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_7/EfiDriveV1_2_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_2_7_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_2_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_2_7/Redfish_Drive_v1_2_7_CS.h" +// +// EFI structure of Redfish Drive v1_2_7 +// +typedef struct _EFI_REDFISH_DRIVE_V1_2_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_2_7_CS *Drive; +} EFI_REDFISH_DRIVE_V1_2_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_8/EfiDriveV1_2_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_8/EfiDriveV1_2_8.h new file mode 100644 index 00000000000..cc7a25da387 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_2_8/EfiDriveV1_2_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_2_8_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_2_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_2_8/Redfish_Drive_v1_2_8_CS.h" +// +// EFI structure of Redfish Drive v1_2_8 +// +typedef struct _EFI_REDFISH_DRIVE_V1_2_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_2_8_CS *Drive; +} EFI_REDFISH_DRIVE_V1_2_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_0/EfiDriveV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_0/EfiDriveV1_3_0.h new file mode 100644 index 00000000000..9331815ea57 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_0/EfiDriveV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_3_0_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_3_0/Redfish_Drive_v1_3_0_CS.h" +// +// EFI structure of Redfish Drive v1_3_0 +// +typedef struct _EFI_REDFISH_DRIVE_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_3_0_CS *Drive; +} EFI_REDFISH_DRIVE_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_1/EfiDriveV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_1/EfiDriveV1_3_1.h new file mode 100644 index 00000000000..cca756b742d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_1/EfiDriveV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_3_1_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_3_1/Redfish_Drive_v1_3_1_CS.h" +// +// EFI structure of Redfish Drive v1_3_1 +// +typedef struct _EFI_REDFISH_DRIVE_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_3_1_CS *Drive; +} EFI_REDFISH_DRIVE_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_2/EfiDriveV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_2/EfiDriveV1_3_2.h new file mode 100644 index 00000000000..04d329cda2f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_2/EfiDriveV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_3_2_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_3_2/Redfish_Drive_v1_3_2_CS.h" +// +// EFI structure of Redfish Drive v1_3_2 +// +typedef struct _EFI_REDFISH_DRIVE_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_3_2_CS *Drive; +} EFI_REDFISH_DRIVE_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_3/EfiDriveV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_3/EfiDriveV1_3_3.h new file mode 100644 index 00000000000..b41eae966a2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_3/EfiDriveV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_3_3_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_3_3/Redfish_Drive_v1_3_3_CS.h" +// +// EFI structure of Redfish Drive v1_3_3 +// +typedef struct _EFI_REDFISH_DRIVE_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_3_3_CS *Drive; +} EFI_REDFISH_DRIVE_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_4/EfiDriveV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_4/EfiDriveV1_3_4.h new file mode 100644 index 00000000000..638603530e5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_4/EfiDriveV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_3_4_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_3_4/Redfish_Drive_v1_3_4_CS.h" +// +// EFI structure of Redfish Drive v1_3_4 +// +typedef struct _EFI_REDFISH_DRIVE_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_3_4_CS *Drive; +} EFI_REDFISH_DRIVE_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_5/EfiDriveV1_3_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_5/EfiDriveV1_3_5.h new file mode 100644 index 00000000000..e16c4a283e2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_5/EfiDriveV1_3_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_3_5_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_3_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_3_5/Redfish_Drive_v1_3_5_CS.h" +// +// EFI structure of Redfish Drive v1_3_5 +// +typedef struct _EFI_REDFISH_DRIVE_V1_3_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_3_5_CS *Drive; +} EFI_REDFISH_DRIVE_V1_3_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_6/EfiDriveV1_3_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_6/EfiDriveV1_3_6.h new file mode 100644 index 00000000000..2196c5a0860 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_6/EfiDriveV1_3_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_3_6_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_3_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_3_6/Redfish_Drive_v1_3_6_CS.h" +// +// EFI structure of Redfish Drive v1_3_6 +// +typedef struct _EFI_REDFISH_DRIVE_V1_3_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_3_6_CS *Drive; +} EFI_REDFISH_DRIVE_V1_3_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_7/EfiDriveV1_3_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_7/EfiDriveV1_3_7.h new file mode 100644 index 00000000000..1c3d7e1b5b3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_3_7/EfiDriveV1_3_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_3_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_3_7_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_3_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_3_7/Redfish_Drive_v1_3_7_CS.h" +// +// EFI structure of Redfish Drive v1_3_7 +// +typedef struct _EFI_REDFISH_DRIVE_V1_3_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_3_7_CS *Drive; +} EFI_REDFISH_DRIVE_V1_3_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_0/EfiDriveV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_0/EfiDriveV1_4_0.h new file mode 100644 index 00000000000..f2804b92fae --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_0/EfiDriveV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_4_0_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_4_0/Redfish_Drive_v1_4_0_CS.h" +// +// EFI structure of Redfish Drive v1_4_0 +// +typedef struct _EFI_REDFISH_DRIVE_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_4_0_CS *Drive; +} EFI_REDFISH_DRIVE_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_1/EfiDriveV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_1/EfiDriveV1_4_1.h new file mode 100644 index 00000000000..e13c646036a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_1/EfiDriveV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_4_1_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_4_1/Redfish_Drive_v1_4_1_CS.h" +// +// EFI structure of Redfish Drive v1_4_1 +// +typedef struct _EFI_REDFISH_DRIVE_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_4_1_CS *Drive; +} EFI_REDFISH_DRIVE_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_2/EfiDriveV1_4_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_2/EfiDriveV1_4_2.h new file mode 100644 index 00000000000..e2ff64af254 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_2/EfiDriveV1_4_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_4_2_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_4_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_4_2/Redfish_Drive_v1_4_2_CS.h" +// +// EFI structure of Redfish Drive v1_4_2 +// +typedef struct _EFI_REDFISH_DRIVE_V1_4_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_4_2_CS *Drive; +} EFI_REDFISH_DRIVE_V1_4_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_3/EfiDriveV1_4_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_3/EfiDriveV1_4_3.h new file mode 100644 index 00000000000..3c6fd2ac2be --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_3/EfiDriveV1_4_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_4_3_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_4_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_4_3/Redfish_Drive_v1_4_3_CS.h" +// +// EFI structure of Redfish Drive v1_4_3 +// +typedef struct _EFI_REDFISH_DRIVE_V1_4_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_4_3_CS *Drive; +} EFI_REDFISH_DRIVE_V1_4_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_4/EfiDriveV1_4_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_4/EfiDriveV1_4_4.h new file mode 100644 index 00000000000..291312d2656 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_4/EfiDriveV1_4_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_4_4_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_4_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_4_4/Redfish_Drive_v1_4_4_CS.h" +// +// EFI structure of Redfish Drive v1_4_4 +// +typedef struct _EFI_REDFISH_DRIVE_V1_4_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_4_4_CS *Drive; +} EFI_REDFISH_DRIVE_V1_4_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_5/EfiDriveV1_4_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_5/EfiDriveV1_4_5.h new file mode 100644 index 00000000000..7ba867df658 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_5/EfiDriveV1_4_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_4_5_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_4_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_4_5/Redfish_Drive_v1_4_5_CS.h" +// +// EFI structure of Redfish Drive v1_4_5 +// +typedef struct _EFI_REDFISH_DRIVE_V1_4_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_4_5_CS *Drive; +} EFI_REDFISH_DRIVE_V1_4_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_6/EfiDriveV1_4_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_6/EfiDriveV1_4_6.h new file mode 100644 index 00000000000..89c3c03c8f4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_6/EfiDriveV1_4_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_4_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_4_6_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_4_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_4_6/Redfish_Drive_v1_4_6_CS.h" +// +// EFI structure of Redfish Drive v1_4_6 +// +typedef struct _EFI_REDFISH_DRIVE_V1_4_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_4_6_CS *Drive; +} EFI_REDFISH_DRIVE_V1_4_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_7/EfiDriveV1_4_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_7/EfiDriveV1_4_7.h new file mode 100644 index 00000000000..2aa17597d60 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_4_7/EfiDriveV1_4_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_4_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_4_7_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_4_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_4_7/Redfish_Drive_v1_4_7_CS.h" +// +// EFI structure of Redfish Drive v1_4_7 +// +typedef struct _EFI_REDFISH_DRIVE_V1_4_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_4_7_CS *Drive; +} EFI_REDFISH_DRIVE_V1_4_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_0/EfiDriveV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_0/EfiDriveV1_5_0.h new file mode 100644 index 00000000000..a349f716803 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_0/EfiDriveV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_5_0_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_5_0/Redfish_Drive_v1_5_0_CS.h" +// +// EFI structure of Redfish Drive v1_5_0 +// +typedef struct _EFI_REDFISH_DRIVE_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_5_0_CS *Drive; +} EFI_REDFISH_DRIVE_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_1/EfiDriveV1_5_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_1/EfiDriveV1_5_1.h new file mode 100644 index 00000000000..16234d452f1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_1/EfiDriveV1_5_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_5_1_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_5_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_5_1/Redfish_Drive_v1_5_1_CS.h" +// +// EFI structure of Redfish Drive v1_5_1 +// +typedef struct _EFI_REDFISH_DRIVE_V1_5_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_5_1_CS *Drive; +} EFI_REDFISH_DRIVE_V1_5_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_2/EfiDriveV1_5_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_2/EfiDriveV1_5_2.h new file mode 100644 index 00000000000..e3bbc5dc5fe --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_2/EfiDriveV1_5_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_5_2_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_5_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_5_2/Redfish_Drive_v1_5_2_CS.h" +// +// EFI structure of Redfish Drive v1_5_2 +// +typedef struct _EFI_REDFISH_DRIVE_V1_5_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_5_2_CS *Drive; +} EFI_REDFISH_DRIVE_V1_5_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_3/EfiDriveV1_5_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_3/EfiDriveV1_5_3.h new file mode 100644 index 00000000000..4cdc05d390e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_3/EfiDriveV1_5_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_5_3_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_5_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_5_3/Redfish_Drive_v1_5_3_CS.h" +// +// EFI structure of Redfish Drive v1_5_3 +// +typedef struct _EFI_REDFISH_DRIVE_V1_5_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_5_3_CS *Drive; +} EFI_REDFISH_DRIVE_V1_5_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_4/EfiDriveV1_5_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_4/EfiDriveV1_5_4.h new file mode 100644 index 00000000000..33ac915a25a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_4/EfiDriveV1_5_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_5_4_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_5_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_5_4/Redfish_Drive_v1_5_4_CS.h" +// +// EFI structure of Redfish Drive v1_5_4 +// +typedef struct _EFI_REDFISH_DRIVE_V1_5_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_5_4_CS *Drive; +} EFI_REDFISH_DRIVE_V1_5_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_5/EfiDriveV1_5_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_5/EfiDriveV1_5_5.h new file mode 100644 index 00000000000..894c34e5eb9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_5/EfiDriveV1_5_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_5_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_5_5_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_5_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_5_5/Redfish_Drive_v1_5_5_CS.h" +// +// EFI structure of Redfish Drive v1_5_5 +// +typedef struct _EFI_REDFISH_DRIVE_V1_5_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_5_5_CS *Drive; +} EFI_REDFISH_DRIVE_V1_5_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_6/EfiDriveV1_5_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_6/EfiDriveV1_5_6.h new file mode 100644 index 00000000000..4655b29f0eb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_5_6/EfiDriveV1_5_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_5_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_5_6_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_5_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_5_6/Redfish_Drive_v1_5_6_CS.h" +// +// EFI structure of Redfish Drive v1_5_6 +// +typedef struct _EFI_REDFISH_DRIVE_V1_5_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_5_6_CS *Drive; +} EFI_REDFISH_DRIVE_V1_5_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_6_0/EfiDriveV1_6_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_6_0/EfiDriveV1_6_0.h new file mode 100644 index 00000000000..cb104949b09 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_6_0/EfiDriveV1_6_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_6_0_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_6_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_6_0/Redfish_Drive_v1_6_0_CS.h" +// +// EFI structure of Redfish Drive v1_6_0 +// +typedef struct _EFI_REDFISH_DRIVE_V1_6_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_6_0_CS *Drive; +} EFI_REDFISH_DRIVE_V1_6_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_6_1/EfiDriveV1_6_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_6_1/EfiDriveV1_6_1.h new file mode 100644 index 00000000000..0fad700456c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_6_1/EfiDriveV1_6_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_6_1_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_6_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_6_1/Redfish_Drive_v1_6_1_CS.h" +// +// EFI structure of Redfish Drive v1_6_1 +// +typedef struct _EFI_REDFISH_DRIVE_V1_6_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_6_1_CS *Drive; +} EFI_REDFISH_DRIVE_V1_6_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_6_2/EfiDriveV1_6_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_6_2/EfiDriveV1_6_2.h new file mode 100644 index 00000000000..04e4d745c42 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_6_2/EfiDriveV1_6_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_6_2_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_6_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_6_2/Redfish_Drive_v1_6_2_CS.h" +// +// EFI structure of Redfish Drive v1_6_2 +// +typedef struct _EFI_REDFISH_DRIVE_V1_6_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_6_2_CS *Drive; +} EFI_REDFISH_DRIVE_V1_6_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_6_3/EfiDriveV1_6_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_6_3/EfiDriveV1_6_3.h new file mode 100644 index 00000000000..3ae89a40a3a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_6_3/EfiDriveV1_6_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_6_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_6_3_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_6_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_6_3/Redfish_Drive_v1_6_3_CS.h" +// +// EFI structure of Redfish Drive v1_6_3 +// +typedef struct _EFI_REDFISH_DRIVE_V1_6_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_6_3_CS *Drive; +} EFI_REDFISH_DRIVE_V1_6_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_6_4/EfiDriveV1_6_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_6_4/EfiDriveV1_6_4.h new file mode 100644 index 00000000000..e69c837a545 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_6_4/EfiDriveV1_6_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_6_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_6_4_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_6_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_6_4/Redfish_Drive_v1_6_4_CS.h" +// +// EFI structure of Redfish Drive v1_6_4 +// +typedef struct _EFI_REDFISH_DRIVE_V1_6_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_6_4_CS *Drive; +} EFI_REDFISH_DRIVE_V1_6_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_7_0/EfiDriveV1_7_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_7_0/EfiDriveV1_7_0.h new file mode 100644 index 00000000000..7da6fa456ae --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_7_0/EfiDriveV1_7_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_7_0_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_7_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_7_0/Redfish_Drive_v1_7_0_CS.h" +// +// EFI structure of Redfish Drive v1_7_0 +// +typedef struct _EFI_REDFISH_DRIVE_V1_7_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_7_0_CS *Drive; +} EFI_REDFISH_DRIVE_V1_7_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_7_1/EfiDriveV1_7_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_7_1/EfiDriveV1_7_1.h new file mode 100644 index 00000000000..db0626e73b8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_7_1/EfiDriveV1_7_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_7_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_7_1_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_7_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_7_1/Redfish_Drive_v1_7_1_CS.h" +// +// EFI structure of Redfish Drive v1_7_1 +// +typedef struct _EFI_REDFISH_DRIVE_V1_7_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_7_1_CS *Drive; +} EFI_REDFISH_DRIVE_V1_7_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_7_2/EfiDriveV1_7_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_7_2/EfiDriveV1_7_2.h new file mode 100644 index 00000000000..4feacbf1e79 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_7_2/EfiDriveV1_7_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_7_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_7_2_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_7_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_7_2/Redfish_Drive_v1_7_2_CS.h" +// +// EFI structure of Redfish Drive v1_7_2 +// +typedef struct _EFI_REDFISH_DRIVE_V1_7_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_7_2_CS *Drive; +} EFI_REDFISH_DRIVE_V1_7_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_7_3/EfiDriveV1_7_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_7_3/EfiDriveV1_7_3.h new file mode 100644 index 00000000000..c390e3f0c87 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_7_3/EfiDriveV1_7_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_7_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_7_3_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_7_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_7_3/Redfish_Drive_v1_7_3_CS.h" +// +// EFI structure of Redfish Drive v1_7_3 +// +typedef struct _EFI_REDFISH_DRIVE_V1_7_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_7_3_CS *Drive; +} EFI_REDFISH_DRIVE_V1_7_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_8_0/EfiDriveV1_8_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_8_0/EfiDriveV1_8_0.h new file mode 100644 index 00000000000..87fbd6c1cdf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_8_0/EfiDriveV1_8_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_8_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_8_0_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_8_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_8_0/Redfish_Drive_v1_8_0_CS.h" +// +// EFI structure of Redfish Drive v1_8_0 +// +typedef struct _EFI_REDFISH_DRIVE_V1_8_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_8_0_CS *Drive; +} EFI_REDFISH_DRIVE_V1_8_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_8_1/EfiDriveV1_8_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_8_1/EfiDriveV1_8_1.h new file mode 100644 index 00000000000..916f24e4b1d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_8_1/EfiDriveV1_8_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_8_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_8_1_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_8_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_8_1/Redfish_Drive_v1_8_1_CS.h" +// +// EFI structure of Redfish Drive v1_8_1 +// +typedef struct _EFI_REDFISH_DRIVE_V1_8_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_8_1_CS *Drive; +} EFI_REDFISH_DRIVE_V1_8_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_8_2/EfiDriveV1_8_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_8_2/EfiDriveV1_8_2.h new file mode 100644 index 00000000000..375eb7373f1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_8_2/EfiDriveV1_8_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_8_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_8_2_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_8_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_8_2/Redfish_Drive_v1_8_2_CS.h" +// +// EFI structure of Redfish Drive v1_8_2 +// +typedef struct _EFI_REDFISH_DRIVE_V1_8_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_8_2_CS *Drive; +} EFI_REDFISH_DRIVE_V1_8_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_8_3/EfiDriveV1_8_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_8_3/EfiDriveV1_8_3.h new file mode 100644 index 00000000000..1e9cdfbb738 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_8_3/EfiDriveV1_8_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_8_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_8_3_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_8_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_8_3/Redfish_Drive_v1_8_3_CS.h" +// +// EFI structure of Redfish Drive v1_8_3 +// +typedef struct _EFI_REDFISH_DRIVE_V1_8_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_8_3_CS *Drive; +} EFI_REDFISH_DRIVE_V1_8_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_9_0/EfiDriveV1_9_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_9_0/EfiDriveV1_9_0.h new file mode 100644 index 00000000000..0038c6df32c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_9_0/EfiDriveV1_9_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_9_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_9_0_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_9_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_9_0/Redfish_Drive_v1_9_0_CS.h" +// +// EFI structure of Redfish Drive v1_9_0 +// +typedef struct _EFI_REDFISH_DRIVE_V1_9_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_9_0_CS *Drive; +} EFI_REDFISH_DRIVE_V1_9_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_9_1/EfiDriveV1_9_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_9_1/EfiDriveV1_9_1.h new file mode 100644 index 00000000000..81e13250ad2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_9_1/EfiDriveV1_9_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_9_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_9_1_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_9_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_9_1/Redfish_Drive_v1_9_1_CS.h" +// +// EFI structure of Redfish Drive v1_9_1 +// +typedef struct _EFI_REDFISH_DRIVE_V1_9_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_9_1_CS *Drive; +} EFI_REDFISH_DRIVE_V1_9_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_9_2/EfiDriveV1_9_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_9_2/EfiDriveV1_9_2.h new file mode 100644 index 00000000000..d4c6285f695 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_9_2/EfiDriveV1_9_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_9_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_9_2_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_9_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_9_2/Redfish_Drive_v1_9_2_CS.h" +// +// EFI structure of Redfish Drive v1_9_2 +// +typedef struct _EFI_REDFISH_DRIVE_V1_9_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_9_2_CS *Drive; +} EFI_REDFISH_DRIVE_V1_9_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_9_3/EfiDriveV1_9_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_9_3/EfiDriveV1_9_3.h new file mode 100644 index 00000000000..9930a0fcc49 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Drive/v1_9_3/EfiDriveV1_9_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Drive v1_9_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVE_V1_9_3_H__ +#define EFI_REDFISH_INTERP_DRIVE_V1_9_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Drive/v1_9_3/Redfish_Drive_v1_9_3_CS.h" +// +// EFI structure of Redfish Drive v1_9_3 +// +typedef struct _EFI_REDFISH_DRIVE_V1_9_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVE_V1_9_3_CS *Drive; +} EFI_REDFISH_DRIVE_V1_9_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/DriveCollection/EfiDriveCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/DriveCollection/EfiDriveCollection.h new file mode 100644 index 00000000000..c5f17152022 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/DriveCollection/EfiDriveCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for DriveCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_DRIVECOLLECTION_H__ +#define EFI_REDFISH_INTERP_DRIVECOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/DriveCollection/Redfish_DriveCollection_CS.h" +// +// EFI structure of Redfish DriveCollection +// +typedef struct _EFI_REDFISH_DRIVECOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_DRIVECOLLECTION_CS *DriveCollection; +} EFI_REDFISH_DRIVECOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_0/EfiEndpointV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_0/EfiEndpointV1_0_0.h new file mode 100644 index 00000000000..1b55b0f163e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_0/EfiEndpointV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_0_0_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_0_0/Redfish_Endpoint_v1_0_0_CS.h" +// +// EFI structure of Redfish Endpoint v1_0_0 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_0_0_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_1/EfiEndpointV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_1/EfiEndpointV1_0_1.h new file mode 100644 index 00000000000..c26ff12d591 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_1/EfiEndpointV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_0_1_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_0_1/Redfish_Endpoint_v1_0_1_CS.h" +// +// EFI structure of Redfish Endpoint v1_0_1 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_0_1_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_10/EfiEndpointV1_0_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_10/EfiEndpointV1_0_10.h new file mode 100644 index 00000000000..5a85d29d3ce --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_10/EfiEndpointV1_0_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_0_10_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_0_10_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_0_10/Redfish_Endpoint_v1_0_10_CS.h" +// +// EFI structure of Redfish Endpoint v1_0_10 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_0_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_0_10_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_0_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_2/EfiEndpointV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_2/EfiEndpointV1_0_2.h new file mode 100644 index 00000000000..339998241ca --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_2/EfiEndpointV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_0_2_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_0_2/Redfish_Endpoint_v1_0_2_CS.h" +// +// EFI structure of Redfish Endpoint v1_0_2 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_0_2_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_3/EfiEndpointV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_3/EfiEndpointV1_0_3.h new file mode 100644 index 00000000000..2fd00ee9ffb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_3/EfiEndpointV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_0_3_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_0_3/Redfish_Endpoint_v1_0_3_CS.h" +// +// EFI structure of Redfish Endpoint v1_0_3 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_0_3_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_4/EfiEndpointV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_4/EfiEndpointV1_0_4.h new file mode 100644 index 00000000000..222dad44cc7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_4/EfiEndpointV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_0_4_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_0_4/Redfish_Endpoint_v1_0_4_CS.h" +// +// EFI structure of Redfish Endpoint v1_0_4 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_0_4_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_5/EfiEndpointV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_5/EfiEndpointV1_0_5.h new file mode 100644 index 00000000000..a7df6f808c5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_5/EfiEndpointV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_0_5_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_0_5/Redfish_Endpoint_v1_0_5_CS.h" +// +// EFI structure of Redfish Endpoint v1_0_5 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_0_5_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_6/EfiEndpointV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_6/EfiEndpointV1_0_6.h new file mode 100644 index 00000000000..abbd81245d7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_6/EfiEndpointV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_0_6_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_0_6/Redfish_Endpoint_v1_0_6_CS.h" +// +// EFI structure of Redfish Endpoint v1_0_6 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_0_6_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_7/EfiEndpointV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_7/EfiEndpointV1_0_7.h new file mode 100644 index 00000000000..8a51759ac30 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_7/EfiEndpointV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_0_7_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_0_7/Redfish_Endpoint_v1_0_7_CS.h" +// +// EFI structure of Redfish Endpoint v1_0_7 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_0_7_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_8/EfiEndpointV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_8/EfiEndpointV1_0_8.h new file mode 100644 index 00000000000..f5b97548a92 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_8/EfiEndpointV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_0_8_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_0_8/Redfish_Endpoint_v1_0_8_CS.h" +// +// EFI structure of Redfish Endpoint v1_0_8 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_0_8_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_9/EfiEndpointV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_9/EfiEndpointV1_0_9.h new file mode 100644 index 00000000000..44837abee97 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_0_9/EfiEndpointV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_0_9_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_0_9/Redfish_Endpoint_v1_0_9_CS.h" +// +// EFI structure of Redfish Endpoint v1_0_9 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_0_9_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_0/EfiEndpointV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_0/EfiEndpointV1_1_0.h new file mode 100644 index 00000000000..ff2acb90030 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_0/EfiEndpointV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_1_0_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_1_0/Redfish_Endpoint_v1_1_0_CS.h" +// +// EFI structure of Redfish Endpoint v1_1_0 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_1_0_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_1/EfiEndpointV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_1/EfiEndpointV1_1_1.h new file mode 100644 index 00000000000..067d18cb7d7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_1/EfiEndpointV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_1_1_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_1_1/Redfish_Endpoint_v1_1_1_CS.h" +// +// EFI structure of Redfish Endpoint v1_1_1 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_1_1_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_2/EfiEndpointV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_2/EfiEndpointV1_1_2.h new file mode 100644 index 00000000000..0e70778f7db --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_2/EfiEndpointV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_1_2_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_1_2/Redfish_Endpoint_v1_1_2_CS.h" +// +// EFI structure of Redfish Endpoint v1_1_2 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_1_2_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_3/EfiEndpointV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_3/EfiEndpointV1_1_3.h new file mode 100644 index 00000000000..7b64ad7d2f5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_3/EfiEndpointV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_1_3_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_1_3/Redfish_Endpoint_v1_1_3_CS.h" +// +// EFI structure of Redfish Endpoint v1_1_3 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_1_3_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_4/EfiEndpointV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_4/EfiEndpointV1_1_4.h new file mode 100644 index 00000000000..19a7dd31885 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_4/EfiEndpointV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_1_4_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_1_4/Redfish_Endpoint_v1_1_4_CS.h" +// +// EFI structure of Redfish Endpoint v1_1_4 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_1_4_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_5/EfiEndpointV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_5/EfiEndpointV1_1_5.h new file mode 100644 index 00000000000..67561063a86 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_5/EfiEndpointV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_1_5_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_1_5/Redfish_Endpoint_v1_1_5_CS.h" +// +// EFI structure of Redfish Endpoint v1_1_5 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_1_5_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_6/EfiEndpointV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_6/EfiEndpointV1_1_6.h new file mode 100644 index 00000000000..6467e9efa7d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_6/EfiEndpointV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_1_6_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_1_6/Redfish_Endpoint_v1_1_6_CS.h" +// +// EFI structure of Redfish Endpoint v1_1_6 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_1_6_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_7/EfiEndpointV1_1_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_7/EfiEndpointV1_1_7.h new file mode 100644 index 00000000000..7846f4b2ebe --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_1_7/EfiEndpointV1_1_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_1_7_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_1_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_1_7/Redfish_Endpoint_v1_1_7_CS.h" +// +// EFI structure of Redfish Endpoint v1_1_7 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_1_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_1_7_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_1_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_0/EfiEndpointV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_0/EfiEndpointV1_2_0.h new file mode 100644 index 00000000000..7cb12539771 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_0/EfiEndpointV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_2_0_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_2_0/Redfish_Endpoint_v1_2_0_CS.h" +// +// EFI structure of Redfish Endpoint v1_2_0 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_2_0_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_1/EfiEndpointV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_1/EfiEndpointV1_2_1.h new file mode 100644 index 00000000000..f578880e495 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_1/EfiEndpointV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_2_1_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_2_1/Redfish_Endpoint_v1_2_1_CS.h" +// +// EFI structure of Redfish Endpoint v1_2_1 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_2_1_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_2/EfiEndpointV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_2/EfiEndpointV1_2_2.h new file mode 100644 index 00000000000..50be6a69892 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_2/EfiEndpointV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_2_2_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_2_2/Redfish_Endpoint_v1_2_2_CS.h" +// +// EFI structure of Redfish Endpoint v1_2_2 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_2_2_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_3/EfiEndpointV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_3/EfiEndpointV1_2_3.h new file mode 100644 index 00000000000..5ba0c86f943 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_3/EfiEndpointV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_2_3_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_2_3/Redfish_Endpoint_v1_2_3_CS.h" +// +// EFI structure of Redfish Endpoint v1_2_3 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_2_3_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_4/EfiEndpointV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_4/EfiEndpointV1_2_4.h new file mode 100644 index 00000000000..d10570b5849 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_4/EfiEndpointV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_2_4_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_2_4/Redfish_Endpoint_v1_2_4_CS.h" +// +// EFI structure of Redfish Endpoint v1_2_4 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_2_4_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_5/EfiEndpointV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_5/EfiEndpointV1_2_5.h new file mode 100644 index 00000000000..a3bc2d79a1e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_5/EfiEndpointV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_2_5_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_2_5/Redfish_Endpoint_v1_2_5_CS.h" +// +// EFI structure of Redfish Endpoint v1_2_5 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_2_5_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_6/EfiEndpointV1_2_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_6/EfiEndpointV1_2_6.h new file mode 100644 index 00000000000..f6d5790600e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_2_6/EfiEndpointV1_2_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_2_6_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_2_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_2_6/Redfish_Endpoint_v1_2_6_CS.h" +// +// EFI structure of Redfish Endpoint v1_2_6 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_2_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_2_6_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_2_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_3_0/EfiEndpointV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_3_0/EfiEndpointV1_3_0.h new file mode 100644 index 00000000000..7de3086ad2a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_3_0/EfiEndpointV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_3_0_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_3_0/Redfish_Endpoint_v1_3_0_CS.h" +// +// EFI structure of Redfish Endpoint v1_3_0 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_3_0_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_3_1/EfiEndpointV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_3_1/EfiEndpointV1_3_1.h new file mode 100644 index 00000000000..7e42a05f269 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_3_1/EfiEndpointV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_3_1_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_3_1/Redfish_Endpoint_v1_3_1_CS.h" +// +// EFI structure of Redfish Endpoint v1_3_1 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_3_1_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_3_2/EfiEndpointV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_3_2/EfiEndpointV1_3_2.h new file mode 100644 index 00000000000..d48e9392f01 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_3_2/EfiEndpointV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_3_2_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_3_2/Redfish_Endpoint_v1_3_2_CS.h" +// +// EFI structure of Redfish Endpoint v1_3_2 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_3_2_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_3_3/EfiEndpointV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_3_3/EfiEndpointV1_3_3.h new file mode 100644 index 00000000000..93544a5c37e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_3_3/EfiEndpointV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_3_3_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_3_3/Redfish_Endpoint_v1_3_3_CS.h" +// +// EFI structure of Redfish Endpoint v1_3_3 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_3_3_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_3_4/EfiEndpointV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_3_4/EfiEndpointV1_3_4.h new file mode 100644 index 00000000000..c5f07738ee4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_3_4/EfiEndpointV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_3_4_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_3_4/Redfish_Endpoint_v1_3_4_CS.h" +// +// EFI structure of Redfish Endpoint v1_3_4 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_3_4_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_3_5/EfiEndpointV1_3_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_3_5/EfiEndpointV1_3_5.h new file mode 100644 index 00000000000..68613d11b3c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_3_5/EfiEndpointV1_3_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_3_5_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_3_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_3_5/Redfish_Endpoint_v1_3_5_CS.h" +// +// EFI structure of Redfish Endpoint v1_3_5 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_3_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_3_5_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_3_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_4_0/EfiEndpointV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_4_0/EfiEndpointV1_4_0.h new file mode 100644 index 00000000000..e2a6389d2e8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_4_0/EfiEndpointV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_4_0_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_4_0/Redfish_Endpoint_v1_4_0_CS.h" +// +// EFI structure of Redfish Endpoint v1_4_0 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_4_0_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_4_1/EfiEndpointV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_4_1/EfiEndpointV1_4_1.h new file mode 100644 index 00000000000..2a5cefeef5b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_4_1/EfiEndpointV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_4_1_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_4_1/Redfish_Endpoint_v1_4_1_CS.h" +// +// EFI structure of Redfish Endpoint v1_4_1 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_4_1_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_4_2/EfiEndpointV1_4_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_4_2/EfiEndpointV1_4_2.h new file mode 100644 index 00000000000..8ad7d3227b9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_4_2/EfiEndpointV1_4_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_4_2_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_4_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_4_2/Redfish_Endpoint_v1_4_2_CS.h" +// +// EFI structure of Redfish Endpoint v1_4_2 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_4_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_4_2_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_4_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_4_3/EfiEndpointV1_4_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_4_3/EfiEndpointV1_4_3.h new file mode 100644 index 00000000000..5fa2d88a2ab --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_4_3/EfiEndpointV1_4_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_4_3_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_4_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_4_3/Redfish_Endpoint_v1_4_3_CS.h" +// +// EFI structure of Redfish Endpoint v1_4_3 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_4_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_4_3_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_4_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_5_0/EfiEndpointV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_5_0/EfiEndpointV1_5_0.h new file mode 100644 index 00000000000..bcad275effe --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_5_0/EfiEndpointV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_5_0_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_5_0/Redfish_Endpoint_v1_5_0_CS.h" +// +// EFI structure of Redfish Endpoint v1_5_0 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_5_0_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_5_1/EfiEndpointV1_5_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_5_1/EfiEndpointV1_5_1.h new file mode 100644 index 00000000000..5b4ea19ee43 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Endpoint/v1_5_1/EfiEndpointV1_5_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Endpoint v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINT_V1_5_1_H__ +#define EFI_REDFISH_INTERP_ENDPOINT_V1_5_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Endpoint/v1_5_1/Redfish_Endpoint_v1_5_1_CS.h" +// +// EFI structure of Redfish Endpoint v1_5_1 +// +typedef struct _EFI_REDFISH_ENDPOINT_V1_5_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINT_V1_5_1_CS *Endpoint; +} EFI_REDFISH_ENDPOINT_V1_5_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EndpointCollection/EfiEndpointCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointCollection/EfiEndpointCollection.h new file mode 100644 index 00000000000..fa850982482 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointCollection/EfiEndpointCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EndpointCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINTCOLLECTION_H__ +#define EFI_REDFISH_INTERP_ENDPOINTCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/EndpointCollection/Redfish_EndpointCollection_CS.h" +// +// EFI structure of Redfish EndpointCollection +// +typedef struct _EFI_REDFISH_ENDPOINTCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINTCOLLECTION_CS *EndpointCollection; +} EFI_REDFISH_ENDPOINTCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_0_0/EfiEndpointGroupV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_0_0/EfiEndpointGroupV1_0_0.h new file mode 100644 index 00000000000..7d37586dcbb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_0_0/EfiEndpointGroupV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EndpointGroup v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_0_0_H__ +#define EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EndpointGroup/v1_0_0/Redfish_EndpointGroup_v1_0_0_CS.h" +// +// EFI structure of Redfish EndpointGroup v1_0_0 +// +typedef struct _EFI_REDFISH_ENDPOINTGROUP_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINTGROUP_V1_0_0_CS *EndpointGroup; +} EFI_REDFISH_ENDPOINTGROUP_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_0_1/EfiEndpointGroupV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_0_1/EfiEndpointGroupV1_0_1.h new file mode 100644 index 00000000000..9eb9a82d9a1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_0_1/EfiEndpointGroupV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EndpointGroup v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_0_1_H__ +#define EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EndpointGroup/v1_0_1/Redfish_EndpointGroup_v1_0_1_CS.h" +// +// EFI structure of Redfish EndpointGroup v1_0_1 +// +typedef struct _EFI_REDFISH_ENDPOINTGROUP_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINTGROUP_V1_0_1_CS *EndpointGroup; +} EFI_REDFISH_ENDPOINTGROUP_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_0_2/EfiEndpointGroupV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_0_2/EfiEndpointGroupV1_0_2.h new file mode 100644 index 00000000000..7fd2a1ddb84 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_0_2/EfiEndpointGroupV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EndpointGroup v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_0_2_H__ +#define EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EndpointGroup/v1_0_2/Redfish_EndpointGroup_v1_0_2_CS.h" +// +// EFI structure of Redfish EndpointGroup v1_0_2 +// +typedef struct _EFI_REDFISH_ENDPOINTGROUP_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINTGROUP_V1_0_2_CS *EndpointGroup; +} EFI_REDFISH_ENDPOINTGROUP_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_0_3/EfiEndpointGroupV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_0_3/EfiEndpointGroupV1_0_3.h new file mode 100644 index 00000000000..07b416a4143 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_0_3/EfiEndpointGroupV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EndpointGroup v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_0_3_H__ +#define EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/EndpointGroup/v1_0_3/Redfish_EndpointGroup_v1_0_3_CS.h" +// +// EFI structure of Redfish EndpointGroup v1_0_3 +// +typedef struct _EFI_REDFISH_ENDPOINTGROUP_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINTGROUP_V1_0_3_CS *EndpointGroup; +} EFI_REDFISH_ENDPOINTGROUP_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_0_4/EfiEndpointGroupV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_0_4/EfiEndpointGroupV1_0_4.h new file mode 100644 index 00000000000..e04d26e9ef7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_0_4/EfiEndpointGroupV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EndpointGroup v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_0_4_H__ +#define EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/EndpointGroup/v1_0_4/Redfish_EndpointGroup_v1_0_4_CS.h" +// +// EFI structure of Redfish EndpointGroup v1_0_4 +// +typedef struct _EFI_REDFISH_ENDPOINTGROUP_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINTGROUP_V1_0_4_CS *EndpointGroup; +} EFI_REDFISH_ENDPOINTGROUP_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_1_0/EfiEndpointGroupV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_1_0/EfiEndpointGroupV1_1_0.h new file mode 100644 index 00000000000..5b41c69a7ec --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_1_0/EfiEndpointGroupV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EndpointGroup v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_1_0_H__ +#define EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EndpointGroup/v1_1_0/Redfish_EndpointGroup_v1_1_0_CS.h" +// +// EFI structure of Redfish EndpointGroup v1_1_0 +// +typedef struct _EFI_REDFISH_ENDPOINTGROUP_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINTGROUP_V1_1_0_CS *EndpointGroup; +} EFI_REDFISH_ENDPOINTGROUP_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_1_1/EfiEndpointGroupV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_1_1/EfiEndpointGroupV1_1_1.h new file mode 100644 index 00000000000..e6cc7825d8b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_1_1/EfiEndpointGroupV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EndpointGroup v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_1_1_H__ +#define EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EndpointGroup/v1_1_1/Redfish_EndpointGroup_v1_1_1_CS.h" +// +// EFI structure of Redfish EndpointGroup v1_1_1 +// +typedef struct _EFI_REDFISH_ENDPOINTGROUP_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINTGROUP_V1_1_1_CS *EndpointGroup; +} EFI_REDFISH_ENDPOINTGROUP_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_1_2/EfiEndpointGroupV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_1_2/EfiEndpointGroupV1_1_2.h new file mode 100644 index 00000000000..8d21e8b87eb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_1_2/EfiEndpointGroupV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EndpointGroup v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_1_2_H__ +#define EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EndpointGroup/v1_1_2/Redfish_EndpointGroup_v1_1_2_CS.h" +// +// EFI structure of Redfish EndpointGroup v1_1_2 +// +typedef struct _EFI_REDFISH_ENDPOINTGROUP_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINTGROUP_V1_1_2_CS *EndpointGroup; +} EFI_REDFISH_ENDPOINTGROUP_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_1_3/EfiEndpointGroupV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_1_3/EfiEndpointGroupV1_1_3.h new file mode 100644 index 00000000000..8653d4c681d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_1_3/EfiEndpointGroupV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EndpointGroup v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_1_3_H__ +#define EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/EndpointGroup/v1_1_3/Redfish_EndpointGroup_v1_1_3_CS.h" +// +// EFI structure of Redfish EndpointGroup v1_1_3 +// +typedef struct _EFI_REDFISH_ENDPOINTGROUP_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINTGROUP_V1_1_3_CS *EndpointGroup; +} EFI_REDFISH_ENDPOINTGROUP_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_1_4/EfiEndpointGroupV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_1_4/EfiEndpointGroupV1_1_4.h new file mode 100644 index 00000000000..8b2d91aae56 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_1_4/EfiEndpointGroupV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EndpointGroup v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_1_4_H__ +#define EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/EndpointGroup/v1_1_4/Redfish_EndpointGroup_v1_1_4_CS.h" +// +// EFI structure of Redfish EndpointGroup v1_1_4 +// +typedef struct _EFI_REDFISH_ENDPOINTGROUP_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINTGROUP_V1_1_4_CS *EndpointGroup; +} EFI_REDFISH_ENDPOINTGROUP_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_1_5/EfiEndpointGroupV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_1_5/EfiEndpointGroupV1_1_5.h new file mode 100644 index 00000000000..73c54da614d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_1_5/EfiEndpointGroupV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EndpointGroup v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_1_5_H__ +#define EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/EndpointGroup/v1_1_5/Redfish_EndpointGroup_v1_1_5_CS.h" +// +// EFI structure of Redfish EndpointGroup v1_1_5 +// +typedef struct _EFI_REDFISH_ENDPOINTGROUP_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINTGROUP_V1_1_5_CS *EndpointGroup; +} EFI_REDFISH_ENDPOINTGROUP_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_2_0/EfiEndpointGroupV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_2_0/EfiEndpointGroupV1_2_0.h new file mode 100644 index 00000000000..2dd14355e3b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_2_0/EfiEndpointGroupV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EndpointGroup v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_2_0_H__ +#define EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EndpointGroup/v1_2_0/Redfish_EndpointGroup_v1_2_0_CS.h" +// +// EFI structure of Redfish EndpointGroup v1_2_0 +// +typedef struct _EFI_REDFISH_ENDPOINTGROUP_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINTGROUP_V1_2_0_CS *EndpointGroup; +} EFI_REDFISH_ENDPOINTGROUP_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_2_1/EfiEndpointGroupV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_2_1/EfiEndpointGroupV1_2_1.h new file mode 100644 index 00000000000..4a1f1a51b2d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_2_1/EfiEndpointGroupV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EndpointGroup v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_2_1_H__ +#define EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EndpointGroup/v1_2_1/Redfish_EndpointGroup_v1_2_1_CS.h" +// +// EFI structure of Redfish EndpointGroup v1_2_1 +// +typedef struct _EFI_REDFISH_ENDPOINTGROUP_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINTGROUP_V1_2_1_CS *EndpointGroup; +} EFI_REDFISH_ENDPOINTGROUP_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_2_2/EfiEndpointGroupV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_2_2/EfiEndpointGroupV1_2_2.h new file mode 100644 index 00000000000..b4df3dc1c27 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_2_2/EfiEndpointGroupV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EndpointGroup v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_2_2_H__ +#define EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EndpointGroup/v1_2_2/Redfish_EndpointGroup_v1_2_2_CS.h" +// +// EFI structure of Redfish EndpointGroup v1_2_2 +// +typedef struct _EFI_REDFISH_ENDPOINTGROUP_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINTGROUP_V1_2_2_CS *EndpointGroup; +} EFI_REDFISH_ENDPOINTGROUP_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_2_3/EfiEndpointGroupV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_2_3/EfiEndpointGroupV1_2_3.h new file mode 100644 index 00000000000..883250cff0e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_2_3/EfiEndpointGroupV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EndpointGroup v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_2_3_H__ +#define EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/EndpointGroup/v1_2_3/Redfish_EndpointGroup_v1_2_3_CS.h" +// +// EFI structure of Redfish EndpointGroup v1_2_3 +// +typedef struct _EFI_REDFISH_ENDPOINTGROUP_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINTGROUP_V1_2_3_CS *EndpointGroup; +} EFI_REDFISH_ENDPOINTGROUP_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_3_0/EfiEndpointGroupV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_3_0/EfiEndpointGroupV1_3_0.h new file mode 100644 index 00000000000..14639dbcadf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_3_0/EfiEndpointGroupV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EndpointGroup v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_3_0_H__ +#define EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EndpointGroup/v1_3_0/Redfish_EndpointGroup_v1_3_0_CS.h" +// +// EFI structure of Redfish EndpointGroup v1_3_0 +// +typedef struct _EFI_REDFISH_ENDPOINTGROUP_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINTGROUP_V1_3_0_CS *EndpointGroup; +} EFI_REDFISH_ENDPOINTGROUP_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_3_1/EfiEndpointGroupV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_3_1/EfiEndpointGroupV1_3_1.h new file mode 100644 index 00000000000..30a7eae4a30 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroup/v1_3_1/EfiEndpointGroupV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EndpointGroup v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_3_1_H__ +#define EFI_REDFISH_INTERP_ENDPOINTGROUP_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EndpointGroup/v1_3_1/Redfish_EndpointGroup_v1_3_1_CS.h" +// +// EFI structure of Redfish EndpointGroup v1_3_1 +// +typedef struct _EFI_REDFISH_ENDPOINTGROUP_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINTGROUP_V1_3_1_CS *EndpointGroup; +} EFI_REDFISH_ENDPOINTGROUP_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroupCollection/EfiEndpointGroupCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroupCollection/EfiEndpointGroupCollection.h new file mode 100644 index 00000000000..06cd4007c28 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EndpointGroupCollection/EfiEndpointGroupCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EndpointGroupCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENDPOINTGROUPCOLLECTION_H__ +#define EFI_REDFISH_INTERP_ENDPOINTGROUPCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/EndpointGroupCollection/Redfish_EndpointGroupCollection_CS.h" +// +// EFI structure of Redfish EndpointGroupCollection +// +typedef struct _EFI_REDFISH_ENDPOINTGROUPCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENDPOINTGROUPCOLLECTION_CS *EndpointGroupCollection; +} EFI_REDFISH_ENDPOINTGROUPCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EnvironmentMetrics/v1_0_0/EfiEnvironmentMetricsV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EnvironmentMetrics/v1_0_0/EfiEnvironmentMetricsV1_0_0.h new file mode 100644 index 00000000000..8cda5e75c4a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EnvironmentMetrics/v1_0_0/EfiEnvironmentMetricsV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EnvironmentMetrics v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ENVIRONMENTMETRICS_V1_0_0_H__ +#define EFI_REDFISH_INTERP_ENVIRONMENTMETRICS_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EnvironmentMetrics/v1_0_0/Redfish_EnvironmentMetrics_v1_0_0_CS.h" +// +// EFI structure of Redfish EnvironmentMetrics v1_0_0 +// +typedef struct _EFI_REDFISH_ENVIRONMENTMETRICS_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ENVIRONMENTMETRICS_V1_0_0_CS *EnvironmentMetrics; +} EFI_REDFISH_ENVIRONMENTMETRICS_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_0/EfiEthernetInterfaceV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_0/EfiEthernetInterfaceV1_0_0.h new file mode 100644 index 00000000000..b94d44287f3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_0/EfiEthernetInterfaceV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_0_0/Redfish_EthernetInterface_v1_0_0_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_0_0 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_0_0_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_10/EfiEthernetInterfaceV1_0_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_10/EfiEthernetInterfaceV1_0_10.h new file mode 100644 index 00000000000..c1dbb001ca5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_10/EfiEthernetInterfaceV1_0_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_0_10_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_0_10_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_0_10/Redfish_EthernetInterface_v1_0_10_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_0_10 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_0_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_0_10_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_0_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_11/EfiEthernetInterfaceV1_0_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_11/EfiEthernetInterfaceV1_0_11.h new file mode 100644 index 00000000000..37fd09670f7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_11/EfiEthernetInterfaceV1_0_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_0_11_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_0_11_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_0_11/Redfish_EthernetInterface_v1_0_11_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_0_11 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_0_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_0_11_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_0_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_12/EfiEthernetInterfaceV1_0_12.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_12/EfiEthernetInterfaceV1_0_12.h new file mode 100644 index 00000000000..0a23e405b0a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_12/EfiEthernetInterfaceV1_0_12.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_0_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_0_12_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_0_12_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_0_12/Redfish_EthernetInterface_v1_0_12_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_0_12 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_0_12 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_0_12_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_0_12; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_2/EfiEthernetInterfaceV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_2/EfiEthernetInterfaceV1_0_2.h new file mode 100644 index 00000000000..09f1c9a566d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_2/EfiEthernetInterfaceV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_0_2_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_0_2/Redfish_EthernetInterface_v1_0_2_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_0_2 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_0_2_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_3/EfiEthernetInterfaceV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_3/EfiEthernetInterfaceV1_0_3.h new file mode 100644 index 00000000000..cee6ba0de9d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_3/EfiEthernetInterfaceV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_0_3_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_0_3/Redfish_EthernetInterface_v1_0_3_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_0_3 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_0_3_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_4/EfiEthernetInterfaceV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_4/EfiEthernetInterfaceV1_0_4.h new file mode 100644 index 00000000000..f7ae79231a4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_4/EfiEthernetInterfaceV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_0_4_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_0_4/Redfish_EthernetInterface_v1_0_4_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_0_4 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_0_4_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_5/EfiEthernetInterfaceV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_5/EfiEthernetInterfaceV1_0_5.h new file mode 100644 index 00000000000..5a612f71c45 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_5/EfiEthernetInterfaceV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_0_5_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_0_5/Redfish_EthernetInterface_v1_0_5_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_0_5 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_0_5_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_6/EfiEthernetInterfaceV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_6/EfiEthernetInterfaceV1_0_6.h new file mode 100644 index 00000000000..d1db5adaab1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_6/EfiEthernetInterfaceV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_0_6_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_0_6/Redfish_EthernetInterface_v1_0_6_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_0_6 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_0_6_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_7/EfiEthernetInterfaceV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_7/EfiEthernetInterfaceV1_0_7.h new file mode 100644 index 00000000000..f5dbce84649 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_7/EfiEthernetInterfaceV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_0_7_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_0_7/Redfish_EthernetInterface_v1_0_7_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_0_7 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_0_7_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_8/EfiEthernetInterfaceV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_8/EfiEthernetInterfaceV1_0_8.h new file mode 100644 index 00000000000..938a5c7efb3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_8/EfiEthernetInterfaceV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_0_8_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_0_8/Redfish_EthernetInterface_v1_0_8_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_0_8 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_0_8_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_9/EfiEthernetInterfaceV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_9/EfiEthernetInterfaceV1_0_9.h new file mode 100644 index 00000000000..b408ad39ebc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_0_9/EfiEthernetInterfaceV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_0_9_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_0_9/Redfish_EthernetInterface_v1_0_9_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_0_9 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_0_9_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_0/EfiEthernetInterfaceV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_0/EfiEthernetInterfaceV1_1_0.h new file mode 100644 index 00000000000..ba08088997d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_0/EfiEthernetInterfaceV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_1_0_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_1_0/Redfish_EthernetInterface_v1_1_0_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_1_0 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_1_0_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_1/EfiEthernetInterfaceV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_1/EfiEthernetInterfaceV1_1_1.h new file mode 100644 index 00000000000..191ccee13db --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_1/EfiEthernetInterfaceV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_1_1_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_1_1/Redfish_EthernetInterface_v1_1_1_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_1_1 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_1_1_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_10/EfiEthernetInterfaceV1_1_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_10/EfiEthernetInterfaceV1_1_10.h new file mode 100644 index 00000000000..0cb34f33f2d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_10/EfiEthernetInterfaceV1_1_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_1_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_1_10_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_1_10_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_1_10/Redfish_EthernetInterface_v1_1_10_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_1_10 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_1_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_1_10_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_1_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_2/EfiEthernetInterfaceV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_2/EfiEthernetInterfaceV1_1_2.h new file mode 100644 index 00000000000..6aad790fa51 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_2/EfiEthernetInterfaceV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_1_2_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_1_2/Redfish_EthernetInterface_v1_1_2_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_1_2 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_1_2_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_3/EfiEthernetInterfaceV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_3/EfiEthernetInterfaceV1_1_3.h new file mode 100644 index 00000000000..5ff4999d863 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_3/EfiEthernetInterfaceV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_1_3_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_1_3/Redfish_EthernetInterface_v1_1_3_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_1_3 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_1_3_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_4/EfiEthernetInterfaceV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_4/EfiEthernetInterfaceV1_1_4.h new file mode 100644 index 00000000000..68c6b3d314d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_4/EfiEthernetInterfaceV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_1_4_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_1_4/Redfish_EthernetInterface_v1_1_4_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_1_4 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_1_4_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_5/EfiEthernetInterfaceV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_5/EfiEthernetInterfaceV1_1_5.h new file mode 100644 index 00000000000..b482f5ebeaa --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_5/EfiEthernetInterfaceV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_1_5_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_1_5/Redfish_EthernetInterface_v1_1_5_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_1_5 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_1_5_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_6/EfiEthernetInterfaceV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_6/EfiEthernetInterfaceV1_1_6.h new file mode 100644 index 00000000000..a6f1b9242f2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_6/EfiEthernetInterfaceV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_1_6_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_1_6/Redfish_EthernetInterface_v1_1_6_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_1_6 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_1_6_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_7/EfiEthernetInterfaceV1_1_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_7/EfiEthernetInterfaceV1_1_7.h new file mode 100644 index 00000000000..68ead369ca0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_7/EfiEthernetInterfaceV1_1_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_1_7_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_1_7_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_1_7/Redfish_EthernetInterface_v1_1_7_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_1_7 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_1_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_1_7_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_1_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_8/EfiEthernetInterfaceV1_1_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_8/EfiEthernetInterfaceV1_1_8.h new file mode 100644 index 00000000000..490f3140e4b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_8/EfiEthernetInterfaceV1_1_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_1_8_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_1_8_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_1_8/Redfish_EthernetInterface_v1_1_8_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_1_8 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_1_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_1_8_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_1_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_9/EfiEthernetInterfaceV1_1_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_9/EfiEthernetInterfaceV1_1_9.h new file mode 100644 index 00000000000..60c067e540f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_1_9/EfiEthernetInterfaceV1_1_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_1_9_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_1_9_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_1_9/Redfish_EthernetInterface_v1_1_9_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_1_9 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_1_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_1_9_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_1_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_0/EfiEthernetInterfaceV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_0/EfiEthernetInterfaceV1_2_0.h new file mode 100644 index 00000000000..c91e5e9bc1c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_0/EfiEthernetInterfaceV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_2_0_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_2_0/Redfish_EthernetInterface_v1_2_0_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_2_0 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_2_0_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_1/EfiEthernetInterfaceV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_1/EfiEthernetInterfaceV1_2_1.h new file mode 100644 index 00000000000..06b1ba9f2ee --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_1/EfiEthernetInterfaceV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_2_1_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_2_1/Redfish_EthernetInterface_v1_2_1_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_2_1 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_2_1_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_2/EfiEthernetInterfaceV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_2/EfiEthernetInterfaceV1_2_2.h new file mode 100644 index 00000000000..c7e0b4a5f77 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_2/EfiEthernetInterfaceV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_2_2_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_2_2/Redfish_EthernetInterface_v1_2_2_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_2_2 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_2_2_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_3/EfiEthernetInterfaceV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_3/EfiEthernetInterfaceV1_2_3.h new file mode 100644 index 00000000000..a3184dcf043 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_3/EfiEthernetInterfaceV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_2_3_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_2_3/Redfish_EthernetInterface_v1_2_3_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_2_3 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_2_3_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_4/EfiEthernetInterfaceV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_4/EfiEthernetInterfaceV1_2_4.h new file mode 100644 index 00000000000..49d2ee2565c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_4/EfiEthernetInterfaceV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_2_4_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_2_4/Redfish_EthernetInterface_v1_2_4_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_2_4 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_2_4_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_5/EfiEthernetInterfaceV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_5/EfiEthernetInterfaceV1_2_5.h new file mode 100644 index 00000000000..b211712f056 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_5/EfiEthernetInterfaceV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_2_5_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_2_5/Redfish_EthernetInterface_v1_2_5_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_2_5 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_2_5_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_6/EfiEthernetInterfaceV1_2_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_6/EfiEthernetInterfaceV1_2_6.h new file mode 100644 index 00000000000..763cba08e7b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_6/EfiEthernetInterfaceV1_2_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_2_6_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_2_6_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_2_6/Redfish_EthernetInterface_v1_2_6_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_2_6 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_2_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_2_6_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_2_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_7/EfiEthernetInterfaceV1_2_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_7/EfiEthernetInterfaceV1_2_7.h new file mode 100644 index 00000000000..27312018b38 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_7/EfiEthernetInterfaceV1_2_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_2_7_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_2_7_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_2_7/Redfish_EthernetInterface_v1_2_7_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_2_7 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_2_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_2_7_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_2_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_8/EfiEthernetInterfaceV1_2_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_8/EfiEthernetInterfaceV1_2_8.h new file mode 100644 index 00000000000..0727ee087ea --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_8/EfiEthernetInterfaceV1_2_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_2_8_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_2_8_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_2_8/Redfish_EthernetInterface_v1_2_8_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_2_8 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_2_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_2_8_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_2_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_9/EfiEthernetInterfaceV1_2_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_9/EfiEthernetInterfaceV1_2_9.h new file mode 100644 index 00000000000..ca4fe4b430e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_2_9/EfiEthernetInterfaceV1_2_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_2_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_2_9_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_2_9_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_2_9/Redfish_EthernetInterface_v1_2_9_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_2_9 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_2_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_2_9_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_2_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_0/EfiEthernetInterfaceV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_0/EfiEthernetInterfaceV1_3_0.h new file mode 100644 index 00000000000..377020ffdab --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_0/EfiEthernetInterfaceV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_3_0_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_3_0/Redfish_EthernetInterface_v1_3_0_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_3_0 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_3_0_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_1/EfiEthernetInterfaceV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_1/EfiEthernetInterfaceV1_3_1.h new file mode 100644 index 00000000000..c1505988c93 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_1/EfiEthernetInterfaceV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_3_1_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_3_1/Redfish_EthernetInterface_v1_3_1_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_3_1 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_3_1_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_2/EfiEthernetInterfaceV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_2/EfiEthernetInterfaceV1_3_2.h new file mode 100644 index 00000000000..7dc075b2243 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_2/EfiEthernetInterfaceV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_3_2_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_3_2/Redfish_EthernetInterface_v1_3_2_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_3_2 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_3_2_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_3/EfiEthernetInterfaceV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_3/EfiEthernetInterfaceV1_3_3.h new file mode 100644 index 00000000000..718f658d98d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_3/EfiEthernetInterfaceV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_3_3_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_3_3/Redfish_EthernetInterface_v1_3_3_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_3_3 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_3_3_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_4/EfiEthernetInterfaceV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_4/EfiEthernetInterfaceV1_3_4.h new file mode 100644 index 00000000000..1d09a9e6e51 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_4/EfiEthernetInterfaceV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_3_4_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_3_4/Redfish_EthernetInterface_v1_3_4_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_3_4 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_3_4_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_5/EfiEthernetInterfaceV1_3_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_5/EfiEthernetInterfaceV1_3_5.h new file mode 100644 index 00000000000..2dc0112bb87 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_5/EfiEthernetInterfaceV1_3_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_3_5_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_3_5_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_3_5/Redfish_EthernetInterface_v1_3_5_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_3_5 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_3_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_3_5_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_3_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_6/EfiEthernetInterfaceV1_3_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_6/EfiEthernetInterfaceV1_3_6.h new file mode 100644 index 00000000000..162d1e45a90 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_6/EfiEthernetInterfaceV1_3_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_3_6_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_3_6_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_3_6/Redfish_EthernetInterface_v1_3_6_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_3_6 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_3_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_3_6_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_3_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_7/EfiEthernetInterfaceV1_3_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_7/EfiEthernetInterfaceV1_3_7.h new file mode 100644 index 00000000000..3821e6b834e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_7/EfiEthernetInterfaceV1_3_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_3_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_3_7_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_3_7_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_3_7/Redfish_EthernetInterface_v1_3_7_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_3_7 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_3_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_3_7_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_3_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_8/EfiEthernetInterfaceV1_3_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_8/EfiEthernetInterfaceV1_3_8.h new file mode 100644 index 00000000000..75133268170 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_3_8/EfiEthernetInterfaceV1_3_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_3_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_3_8_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_3_8_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_3_8/Redfish_EthernetInterface_v1_3_8_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_3_8 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_3_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_3_8_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_3_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_0/EfiEthernetInterfaceV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_0/EfiEthernetInterfaceV1_4_0.h new file mode 100644 index 00000000000..1bfd5f49c9b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_0/EfiEthernetInterfaceV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_4_0_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_4_0/Redfish_EthernetInterface_v1_4_0_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_4_0 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_4_0_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_1/EfiEthernetInterfaceV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_1/EfiEthernetInterfaceV1_4_1.h new file mode 100644 index 00000000000..735021526b5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_1/EfiEthernetInterfaceV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_4_1_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_4_1/Redfish_EthernetInterface_v1_4_1_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_4_1 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_4_1_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_2/EfiEthernetInterfaceV1_4_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_2/EfiEthernetInterfaceV1_4_2.h new file mode 100644 index 00000000000..890cc57574c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_2/EfiEthernetInterfaceV1_4_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_4_2_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_4_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_4_2/Redfish_EthernetInterface_v1_4_2_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_4_2 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_4_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_4_2_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_4_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_3/EfiEthernetInterfaceV1_4_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_3/EfiEthernetInterfaceV1_4_3.h new file mode 100644 index 00000000000..6282050cce2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_3/EfiEthernetInterfaceV1_4_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_4_3_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_4_3_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_4_3/Redfish_EthernetInterface_v1_4_3_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_4_3 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_4_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_4_3_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_4_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_4/EfiEthernetInterfaceV1_4_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_4/EfiEthernetInterfaceV1_4_4.h new file mode 100644 index 00000000000..a2f599da134 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_4/EfiEthernetInterfaceV1_4_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_4_4_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_4_4_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_4_4/Redfish_EthernetInterface_v1_4_4_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_4_4 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_4_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_4_4_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_4_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_5/EfiEthernetInterfaceV1_4_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_5/EfiEthernetInterfaceV1_4_5.h new file mode 100644 index 00000000000..6793f880466 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_5/EfiEthernetInterfaceV1_4_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_4_5_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_4_5_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_4_5/Redfish_EthernetInterface_v1_4_5_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_4_5 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_4_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_4_5_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_4_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_6/EfiEthernetInterfaceV1_4_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_6/EfiEthernetInterfaceV1_4_6.h new file mode 100644 index 00000000000..31b43c0d874 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_6/EfiEthernetInterfaceV1_4_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_4_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_4_6_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_4_6_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_4_6/Redfish_EthernetInterface_v1_4_6_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_4_6 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_4_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_4_6_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_4_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_7/EfiEthernetInterfaceV1_4_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_7/EfiEthernetInterfaceV1_4_7.h new file mode 100644 index 00000000000..57fb3a43bb0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_4_7/EfiEthernetInterfaceV1_4_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_4_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_4_7_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_4_7_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_4_7/Redfish_EthernetInterface_v1_4_7_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_4_7 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_4_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_4_7_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_4_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_5_0/EfiEthernetInterfaceV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_5_0/EfiEthernetInterfaceV1_5_0.h new file mode 100644 index 00000000000..e168843615e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_5_0/EfiEthernetInterfaceV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_5_0_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_5_0/Redfish_EthernetInterface_v1_5_0_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_5_0 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_5_0_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_5_1/EfiEthernetInterfaceV1_5_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_5_1/EfiEthernetInterfaceV1_5_1.h new file mode 100644 index 00000000000..a0e48ca9c10 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_5_1/EfiEthernetInterfaceV1_5_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_5_1_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_5_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_5_1/Redfish_EthernetInterface_v1_5_1_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_5_1 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_5_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_5_1_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_5_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_5_2/EfiEthernetInterfaceV1_5_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_5_2/EfiEthernetInterfaceV1_5_2.h new file mode 100644 index 00000000000..ee92c979e0e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_5_2/EfiEthernetInterfaceV1_5_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_5_2_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_5_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_5_2/Redfish_EthernetInterface_v1_5_2_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_5_2 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_5_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_5_2_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_5_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_5_3/EfiEthernetInterfaceV1_5_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_5_3/EfiEthernetInterfaceV1_5_3.h new file mode 100644 index 00000000000..da0661e4ca4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_5_3/EfiEthernetInterfaceV1_5_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_5_3_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_5_3_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_5_3/Redfish_EthernetInterface_v1_5_3_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_5_3 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_5_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_5_3_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_5_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_5_4/EfiEthernetInterfaceV1_5_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_5_4/EfiEthernetInterfaceV1_5_4.h new file mode 100644 index 00000000000..e7b7d32abac --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_5_4/EfiEthernetInterfaceV1_5_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_5_4_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_5_4_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_5_4/Redfish_EthernetInterface_v1_5_4_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_5_4 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_5_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_5_4_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_5_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_5_5/EfiEthernetInterfaceV1_5_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_5_5/EfiEthernetInterfaceV1_5_5.h new file mode 100644 index 00000000000..0e8707d14fc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_5_5/EfiEthernetInterfaceV1_5_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_5_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_5_5_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_5_5_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_5_5/Redfish_EthernetInterface_v1_5_5_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_5_5 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_5_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_5_5_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_5_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_6_0/EfiEthernetInterfaceV1_6_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_6_0/EfiEthernetInterfaceV1_6_0.h new file mode 100644 index 00000000000..81927b0cc91 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_6_0/EfiEthernetInterfaceV1_6_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_6_0_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_6_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_6_0/Redfish_EthernetInterface_v1_6_0_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_6_0 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_6_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_6_0_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_6_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_6_1/EfiEthernetInterfaceV1_6_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_6_1/EfiEthernetInterfaceV1_6_1.h new file mode 100644 index 00000000000..48f226048a8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_6_1/EfiEthernetInterfaceV1_6_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_6_1_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_6_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_6_1/Redfish_EthernetInterface_v1_6_1_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_6_1 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_6_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_6_1_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_6_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_6_2/EfiEthernetInterfaceV1_6_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_6_2/EfiEthernetInterfaceV1_6_2.h new file mode 100644 index 00000000000..0c182fc7ad2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_6_2/EfiEthernetInterfaceV1_6_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_6_2_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_6_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_6_2/Redfish_EthernetInterface_v1_6_2_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_6_2 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_6_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_6_2_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_6_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_6_3/EfiEthernetInterfaceV1_6_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_6_3/EfiEthernetInterfaceV1_6_3.h new file mode 100644 index 00000000000..eb0826edd30 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterface/v1_6_3/EfiEthernetInterfaceV1_6_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterface v1_6_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_6_3_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACE_V1_6_3_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterface/v1_6_3/Redfish_EthernetInterface_v1_6_3_CS.h" +// +// EFI structure of Redfish EthernetInterface v1_6_3 +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACE_V1_6_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACE_V1_6_3_CS *EthernetInterface; +} EFI_REDFISH_ETHERNETINTERFACE_V1_6_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterfaceCollection/EfiEthernetInterfaceCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterfaceCollection/EfiEthernetInterfaceCollection.h new file mode 100644 index 00000000000..a8f376bcb41 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EthernetInterfaceCollection/EfiEthernetInterfaceCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EthernetInterfaceCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ETHERNETINTERFACECOLLECTION_H__ +#define EFI_REDFISH_INTERP_ETHERNETINTERFACECOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/EthernetInterfaceCollection/Redfish_EthernetInterfaceCollection_CS.h" +// +// EFI structure of Redfish EthernetInterfaceCollection +// +typedef struct _EFI_REDFISH_ETHERNETINTERFACECOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ETHERNETINTERFACECOLLECTION_CS *EthernetInterfaceCollection; +} EFI_REDFISH_ETHERNETINTERFACECOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_0/EfiEventV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_0/EfiEventV1_0_0.h new file mode 100644 index 00000000000..77a490e3b0f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_0/EfiEventV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_0_0_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_0_0/Redfish_Event_v1_0_0_CS.h" +// +// EFI structure of Redfish Event v1_0_0 +// +typedef struct _EFI_REDFISH_EVENT_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_0_0_CS *Event; +} EFI_REDFISH_EVENT_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_10/EfiEventV1_0_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_10/EfiEventV1_0_10.h new file mode 100644 index 00000000000..0adab82229b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_10/EfiEventV1_0_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_0_10_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_0_10_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_0_10/Redfish_Event_v1_0_10_CS.h" +// +// EFI structure of Redfish Event v1_0_10 +// +typedef struct _EFI_REDFISH_EVENT_V1_0_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_0_10_CS *Event; +} EFI_REDFISH_EVENT_V1_0_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_11/EfiEventV1_0_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_11/EfiEventV1_0_11.h new file mode 100644 index 00000000000..cdf13281586 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_11/EfiEventV1_0_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_0_11_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_0_11_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_0_11/Redfish_Event_v1_0_11_CS.h" +// +// EFI structure of Redfish Event v1_0_11 +// +typedef struct _EFI_REDFISH_EVENT_V1_0_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_0_11_CS *Event; +} EFI_REDFISH_EVENT_V1_0_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_12/EfiEventV1_0_12.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_12/EfiEventV1_0_12.h new file mode 100644 index 00000000000..e0ec52a0abf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_12/EfiEventV1_0_12.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_0_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_0_12_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_0_12_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_0_12/Redfish_Event_v1_0_12_CS.h" +// +// EFI structure of Redfish Event v1_0_12 +// +typedef struct _EFI_REDFISH_EVENT_V1_0_12 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_0_12_CS *Event; +} EFI_REDFISH_EVENT_V1_0_12; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_13/EfiEventV1_0_13.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_13/EfiEventV1_0_13.h new file mode 100644 index 00000000000..3e60a545e94 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_13/EfiEventV1_0_13.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_0_13 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_0_13_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_0_13_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_0_13/Redfish_Event_v1_0_13_CS.h" +// +// EFI structure of Redfish Event v1_0_13 +// +typedef struct _EFI_REDFISH_EVENT_V1_0_13 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_0_13_CS *Event; +} EFI_REDFISH_EVENT_V1_0_13; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_2/EfiEventV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_2/EfiEventV1_0_2.h new file mode 100644 index 00000000000..3094ca8b957 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_2/EfiEventV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_0_2_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_0_2/Redfish_Event_v1_0_2_CS.h" +// +// EFI structure of Redfish Event v1_0_2 +// +typedef struct _EFI_REDFISH_EVENT_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_0_2_CS *Event; +} EFI_REDFISH_EVENT_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_3/EfiEventV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_3/EfiEventV1_0_3.h new file mode 100644 index 00000000000..e171e42eb31 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_3/EfiEventV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_0_3_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_0_3/Redfish_Event_v1_0_3_CS.h" +// +// EFI structure of Redfish Event v1_0_3 +// +typedef struct _EFI_REDFISH_EVENT_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_0_3_CS *Event; +} EFI_REDFISH_EVENT_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_4/EfiEventV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_4/EfiEventV1_0_4.h new file mode 100644 index 00000000000..755b8c42595 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_4/EfiEventV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_0_4_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_0_4/Redfish_Event_v1_0_4_CS.h" +// +// EFI structure of Redfish Event v1_0_4 +// +typedef struct _EFI_REDFISH_EVENT_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_0_4_CS *Event; +} EFI_REDFISH_EVENT_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_5/EfiEventV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_5/EfiEventV1_0_5.h new file mode 100644 index 00000000000..469abe54da8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_5/EfiEventV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_0_5_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_0_5/Redfish_Event_v1_0_5_CS.h" +// +// EFI structure of Redfish Event v1_0_5 +// +typedef struct _EFI_REDFISH_EVENT_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_0_5_CS *Event; +} EFI_REDFISH_EVENT_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_6/EfiEventV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_6/EfiEventV1_0_6.h new file mode 100644 index 00000000000..1ce5a0bfe03 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_6/EfiEventV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_0_6_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_0_6/Redfish_Event_v1_0_6_CS.h" +// +// EFI structure of Redfish Event v1_0_6 +// +typedef struct _EFI_REDFISH_EVENT_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_0_6_CS *Event; +} EFI_REDFISH_EVENT_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_7/EfiEventV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_7/EfiEventV1_0_7.h new file mode 100644 index 00000000000..267ec74d1a4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_7/EfiEventV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_0_7_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_0_7/Redfish_Event_v1_0_7_CS.h" +// +// EFI structure of Redfish Event v1_0_7 +// +typedef struct _EFI_REDFISH_EVENT_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_0_7_CS *Event; +} EFI_REDFISH_EVENT_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_8/EfiEventV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_8/EfiEventV1_0_8.h new file mode 100644 index 00000000000..91b8a85bc51 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_8/EfiEventV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_0_8_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_0_8/Redfish_Event_v1_0_8_CS.h" +// +// EFI structure of Redfish Event v1_0_8 +// +typedef struct _EFI_REDFISH_EVENT_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_0_8_CS *Event; +} EFI_REDFISH_EVENT_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_9/EfiEventV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_9/EfiEventV1_0_9.h new file mode 100644 index 00000000000..b18f609f531 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_0_9/EfiEventV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_0_9_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_0_9/Redfish_Event_v1_0_9_CS.h" +// +// EFI structure of Redfish Event v1_0_9 +// +typedef struct _EFI_REDFISH_EVENT_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_0_9_CS *Event; +} EFI_REDFISH_EVENT_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_0/EfiEventV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_0/EfiEventV1_1_0.h new file mode 100644 index 00000000000..90c6b42704d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_0/EfiEventV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_1_0_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_1_0/Redfish_Event_v1_1_0_CS.h" +// +// EFI structure of Redfish Event v1_1_0 +// +typedef struct _EFI_REDFISH_EVENT_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_1_0_CS *Event; +} EFI_REDFISH_EVENT_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_1/EfiEventV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_1/EfiEventV1_1_1.h new file mode 100644 index 00000000000..95972f748c6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_1/EfiEventV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_1_1_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_1_1/Redfish_Event_v1_1_1_CS.h" +// +// EFI structure of Redfish Event v1_1_1 +// +typedef struct _EFI_REDFISH_EVENT_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_1_1_CS *Event; +} EFI_REDFISH_EVENT_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_10/EfiEventV1_1_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_10/EfiEventV1_1_10.h new file mode 100644 index 00000000000..e0bd4cfc822 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_10/EfiEventV1_1_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_1_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_1_10_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_1_10_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_1_10/Redfish_Event_v1_1_10_CS.h" +// +// EFI structure of Redfish Event v1_1_10 +// +typedef struct _EFI_REDFISH_EVENT_V1_1_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_1_10_CS *Event; +} EFI_REDFISH_EVENT_V1_1_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_11/EfiEventV1_1_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_11/EfiEventV1_1_11.h new file mode 100644 index 00000000000..00a86ddfce0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_11/EfiEventV1_1_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_1_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_1_11_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_1_11_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_1_11/Redfish_Event_v1_1_11_CS.h" +// +// EFI structure of Redfish Event v1_1_11 +// +typedef struct _EFI_REDFISH_EVENT_V1_1_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_1_11_CS *Event; +} EFI_REDFISH_EVENT_V1_1_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_2/EfiEventV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_2/EfiEventV1_1_2.h new file mode 100644 index 00000000000..ca1deb098f9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_2/EfiEventV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_1_2_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_1_2/Redfish_Event_v1_1_2_CS.h" +// +// EFI structure of Redfish Event v1_1_2 +// +typedef struct _EFI_REDFISH_EVENT_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_1_2_CS *Event; +} EFI_REDFISH_EVENT_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_3/EfiEventV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_3/EfiEventV1_1_3.h new file mode 100644 index 00000000000..37546e12199 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_3/EfiEventV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_1_3_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_1_3/Redfish_Event_v1_1_3_CS.h" +// +// EFI structure of Redfish Event v1_1_3 +// +typedef struct _EFI_REDFISH_EVENT_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_1_3_CS *Event; +} EFI_REDFISH_EVENT_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_4/EfiEventV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_4/EfiEventV1_1_4.h new file mode 100644 index 00000000000..053b80950b4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_4/EfiEventV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_1_4_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_1_4/Redfish_Event_v1_1_4_CS.h" +// +// EFI structure of Redfish Event v1_1_4 +// +typedef struct _EFI_REDFISH_EVENT_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_1_4_CS *Event; +} EFI_REDFISH_EVENT_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_5/EfiEventV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_5/EfiEventV1_1_5.h new file mode 100644 index 00000000000..39270ecfbf9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_5/EfiEventV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_1_5_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_1_5/Redfish_Event_v1_1_5_CS.h" +// +// EFI structure of Redfish Event v1_1_5 +// +typedef struct _EFI_REDFISH_EVENT_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_1_5_CS *Event; +} EFI_REDFISH_EVENT_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_6/EfiEventV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_6/EfiEventV1_1_6.h new file mode 100644 index 00000000000..79b05eda22f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_6/EfiEventV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_1_6_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_1_6/Redfish_Event_v1_1_6_CS.h" +// +// EFI structure of Redfish Event v1_1_6 +// +typedef struct _EFI_REDFISH_EVENT_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_1_6_CS *Event; +} EFI_REDFISH_EVENT_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_7/EfiEventV1_1_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_7/EfiEventV1_1_7.h new file mode 100644 index 00000000000..8b81501ce63 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_7/EfiEventV1_1_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_1_7_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_1_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_1_7/Redfish_Event_v1_1_7_CS.h" +// +// EFI structure of Redfish Event v1_1_7 +// +typedef struct _EFI_REDFISH_EVENT_V1_1_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_1_7_CS *Event; +} EFI_REDFISH_EVENT_V1_1_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_8/EfiEventV1_1_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_8/EfiEventV1_1_8.h new file mode 100644 index 00000000000..6cdab2cc6d9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_8/EfiEventV1_1_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_1_8_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_1_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_1_8/Redfish_Event_v1_1_8_CS.h" +// +// EFI structure of Redfish Event v1_1_8 +// +typedef struct _EFI_REDFISH_EVENT_V1_1_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_1_8_CS *Event; +} EFI_REDFISH_EVENT_V1_1_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_9/EfiEventV1_1_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_9/EfiEventV1_1_9.h new file mode 100644 index 00000000000..849094a2d7f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_1_9/EfiEventV1_1_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_1_9_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_1_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_1_9/Redfish_Event_v1_1_9_CS.h" +// +// EFI structure of Redfish Event v1_1_9 +// +typedef struct _EFI_REDFISH_EVENT_V1_1_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_1_9_CS *Event; +} EFI_REDFISH_EVENT_V1_1_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_0/EfiEventV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_0/EfiEventV1_2_0.h new file mode 100644 index 00000000000..9a8bd50949f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_0/EfiEventV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_2_0_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_2_0/Redfish_Event_v1_2_0_CS.h" +// +// EFI structure of Redfish Event v1_2_0 +// +typedef struct _EFI_REDFISH_EVENT_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_2_0_CS *Event; +} EFI_REDFISH_EVENT_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_1/EfiEventV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_1/EfiEventV1_2_1.h new file mode 100644 index 00000000000..b48623cba77 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_1/EfiEventV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_2_1_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_2_1/Redfish_Event_v1_2_1_CS.h" +// +// EFI structure of Redfish Event v1_2_1 +// +typedef struct _EFI_REDFISH_EVENT_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_2_1_CS *Event; +} EFI_REDFISH_EVENT_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_2/EfiEventV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_2/EfiEventV1_2_2.h new file mode 100644 index 00000000000..e5cb56ae3b9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_2/EfiEventV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_2_2_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_2_2/Redfish_Event_v1_2_2_CS.h" +// +// EFI structure of Redfish Event v1_2_2 +// +typedef struct _EFI_REDFISH_EVENT_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_2_2_CS *Event; +} EFI_REDFISH_EVENT_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_3/EfiEventV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_3/EfiEventV1_2_3.h new file mode 100644 index 00000000000..039071551c2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_3/EfiEventV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_2_3_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_2_3/Redfish_Event_v1_2_3_CS.h" +// +// EFI structure of Redfish Event v1_2_3 +// +typedef struct _EFI_REDFISH_EVENT_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_2_3_CS *Event; +} EFI_REDFISH_EVENT_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_4/EfiEventV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_4/EfiEventV1_2_4.h new file mode 100644 index 00000000000..d05285511bb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_4/EfiEventV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_2_4_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_2_4/Redfish_Event_v1_2_4_CS.h" +// +// EFI structure of Redfish Event v1_2_4 +// +typedef struct _EFI_REDFISH_EVENT_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_2_4_CS *Event; +} EFI_REDFISH_EVENT_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_5/EfiEventV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_5/EfiEventV1_2_5.h new file mode 100644 index 00000000000..4fd4d15ee57 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_5/EfiEventV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_2_5_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_2_5/Redfish_Event_v1_2_5_CS.h" +// +// EFI structure of Redfish Event v1_2_5 +// +typedef struct _EFI_REDFISH_EVENT_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_2_5_CS *Event; +} EFI_REDFISH_EVENT_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_6/EfiEventV1_2_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_6/EfiEventV1_2_6.h new file mode 100644 index 00000000000..9aabf784147 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_6/EfiEventV1_2_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_2_6_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_2_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_2_6/Redfish_Event_v1_2_6_CS.h" +// +// EFI structure of Redfish Event v1_2_6 +// +typedef struct _EFI_REDFISH_EVENT_V1_2_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_2_6_CS *Event; +} EFI_REDFISH_EVENT_V1_2_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_7/EfiEventV1_2_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_7/EfiEventV1_2_7.h new file mode 100644 index 00000000000..31f67b1ef55 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_7/EfiEventV1_2_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_2_7_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_2_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_2_7/Redfish_Event_v1_2_7_CS.h" +// +// EFI structure of Redfish Event v1_2_7 +// +typedef struct _EFI_REDFISH_EVENT_V1_2_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_2_7_CS *Event; +} EFI_REDFISH_EVENT_V1_2_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_8/EfiEventV1_2_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_8/EfiEventV1_2_8.h new file mode 100644 index 00000000000..ead4ebfb1fc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_2_8/EfiEventV1_2_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_2_8_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_2_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_2_8/Redfish_Event_v1_2_8_CS.h" +// +// EFI structure of Redfish Event v1_2_8 +// +typedef struct _EFI_REDFISH_EVENT_V1_2_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_2_8_CS *Event; +} EFI_REDFISH_EVENT_V1_2_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_0/EfiEventV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_0/EfiEventV1_3_0.h new file mode 100644 index 00000000000..9d54538af45 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_0/EfiEventV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_3_0_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_3_0/Redfish_Event_v1_3_0_CS.h" +// +// EFI structure of Redfish Event v1_3_0 +// +typedef struct _EFI_REDFISH_EVENT_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_3_0_CS *Event; +} EFI_REDFISH_EVENT_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_1/EfiEventV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_1/EfiEventV1_3_1.h new file mode 100644 index 00000000000..27a2fa9d042 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_1/EfiEventV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_3_1_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_3_1/Redfish_Event_v1_3_1_CS.h" +// +// EFI structure of Redfish Event v1_3_1 +// +typedef struct _EFI_REDFISH_EVENT_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_3_1_CS *Event; +} EFI_REDFISH_EVENT_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_2/EfiEventV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_2/EfiEventV1_3_2.h new file mode 100644 index 00000000000..ec67a9843bb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_2/EfiEventV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_3_2_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_3_2/Redfish_Event_v1_3_2_CS.h" +// +// EFI structure of Redfish Event v1_3_2 +// +typedef struct _EFI_REDFISH_EVENT_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_3_2_CS *Event; +} EFI_REDFISH_EVENT_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_3/EfiEventV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_3/EfiEventV1_3_3.h new file mode 100644 index 00000000000..94e41d87060 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_3/EfiEventV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_3_3_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_3_3/Redfish_Event_v1_3_3_CS.h" +// +// EFI structure of Redfish Event v1_3_3 +// +typedef struct _EFI_REDFISH_EVENT_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_3_3_CS *Event; +} EFI_REDFISH_EVENT_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_4/EfiEventV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_4/EfiEventV1_3_4.h new file mode 100644 index 00000000000..a818f528873 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_4/EfiEventV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_3_4_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_3_4/Redfish_Event_v1_3_4_CS.h" +// +// EFI structure of Redfish Event v1_3_4 +// +typedef struct _EFI_REDFISH_EVENT_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_3_4_CS *Event; +} EFI_REDFISH_EVENT_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_5/EfiEventV1_3_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_5/EfiEventV1_3_5.h new file mode 100644 index 00000000000..d059fd1027b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_5/EfiEventV1_3_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_3_5_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_3_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_3_5/Redfish_Event_v1_3_5_CS.h" +// +// EFI structure of Redfish Event v1_3_5 +// +typedef struct _EFI_REDFISH_EVENT_V1_3_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_3_5_CS *Event; +} EFI_REDFISH_EVENT_V1_3_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_6/EfiEventV1_3_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_6/EfiEventV1_3_6.h new file mode 100644 index 00000000000..20a28ac5e68 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_3_6/EfiEventV1_3_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_3_6_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_3_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_3_6/Redfish_Event_v1_3_6_CS.h" +// +// EFI structure of Redfish Event v1_3_6 +// +typedef struct _EFI_REDFISH_EVENT_V1_3_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_3_6_CS *Event; +} EFI_REDFISH_EVENT_V1_3_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_4_0/EfiEventV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_4_0/EfiEventV1_4_0.h new file mode 100644 index 00000000000..b1eea4ea706 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_4_0/EfiEventV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_4_0_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_4_0/Redfish_Event_v1_4_0_CS.h" +// +// EFI structure of Redfish Event v1_4_0 +// +typedef struct _EFI_REDFISH_EVENT_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_4_0_CS *Event; +} EFI_REDFISH_EVENT_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_4_1/EfiEventV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_4_1/EfiEventV1_4_1.h new file mode 100644 index 00000000000..c6edb8b7852 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_4_1/EfiEventV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_4_1_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_4_1/Redfish_Event_v1_4_1_CS.h" +// +// EFI structure of Redfish Event v1_4_1 +// +typedef struct _EFI_REDFISH_EVENT_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_4_1_CS *Event; +} EFI_REDFISH_EVENT_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_4_2/EfiEventV1_4_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_4_2/EfiEventV1_4_2.h new file mode 100644 index 00000000000..763af67e065 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_4_2/EfiEventV1_4_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_4_2_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_4_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_4_2/Redfish_Event_v1_4_2_CS.h" +// +// EFI structure of Redfish Event v1_4_2 +// +typedef struct _EFI_REDFISH_EVENT_V1_4_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_4_2_CS *Event; +} EFI_REDFISH_EVENT_V1_4_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_4_3/EfiEventV1_4_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_4_3/EfiEventV1_4_3.h new file mode 100644 index 00000000000..bb2b51c1c05 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_4_3/EfiEventV1_4_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_4_3_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_4_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_4_3/Redfish_Event_v1_4_3_CS.h" +// +// EFI structure of Redfish Event v1_4_3 +// +typedef struct _EFI_REDFISH_EVENT_V1_4_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_4_3_CS *Event; +} EFI_REDFISH_EVENT_V1_4_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_4_4/EfiEventV1_4_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_4_4/EfiEventV1_4_4.h new file mode 100644 index 00000000000..d2315eb6d87 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_4_4/EfiEventV1_4_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_4_4_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_4_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_4_4/Redfish_Event_v1_4_4_CS.h" +// +// EFI structure of Redfish Event v1_4_4 +// +typedef struct _EFI_REDFISH_EVENT_V1_4_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_4_4_CS *Event; +} EFI_REDFISH_EVENT_V1_4_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_5_0/EfiEventV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_5_0/EfiEventV1_5_0.h new file mode 100644 index 00000000000..a46cae01e13 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_5_0/EfiEventV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_5_0_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_5_0/Redfish_Event_v1_5_0_CS.h" +// +// EFI structure of Redfish Event v1_5_0 +// +typedef struct _EFI_REDFISH_EVENT_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_5_0_CS *Event; +} EFI_REDFISH_EVENT_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_5_1/EfiEventV1_5_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_5_1/EfiEventV1_5_1.h new file mode 100644 index 00000000000..2bca5915bac --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_5_1/EfiEventV1_5_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_5_1_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_5_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_5_1/Redfish_Event_v1_5_1_CS.h" +// +// EFI structure of Redfish Event v1_5_1 +// +typedef struct _EFI_REDFISH_EVENT_V1_5_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_5_1_CS *Event; +} EFI_REDFISH_EVENT_V1_5_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_5_2/EfiEventV1_5_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_5_2/EfiEventV1_5_2.h new file mode 100644 index 00000000000..a22717c5382 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_5_2/EfiEventV1_5_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_5_2_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_5_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_5_2/Redfish_Event_v1_5_2_CS.h" +// +// EFI structure of Redfish Event v1_5_2 +// +typedef struct _EFI_REDFISH_EVENT_V1_5_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_5_2_CS *Event; +} EFI_REDFISH_EVENT_V1_5_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_6_0/EfiEventV1_6_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_6_0/EfiEventV1_6_0.h new file mode 100644 index 00000000000..3533af4a073 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_6_0/EfiEventV1_6_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_6_0_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_6_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_6_0/Redfish_Event_v1_6_0_CS.h" +// +// EFI structure of Redfish Event v1_6_0 +// +typedef struct _EFI_REDFISH_EVENT_V1_6_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_6_0_CS *Event; +} EFI_REDFISH_EVENT_V1_6_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_6_1/EfiEventV1_6_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_6_1/EfiEventV1_6_1.h new file mode 100644 index 00000000000..2ea43fb3d8b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Event/v1_6_1/EfiEventV1_6_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Event v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENT_V1_6_1_H__ +#define EFI_REDFISH_INTERP_EVENT_V1_6_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Event/v1_6_1/Redfish_Event_v1_6_1_CS.h" +// +// EFI structure of Redfish Event v1_6_1 +// +typedef struct _EFI_REDFISH_EVENT_V1_6_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENT_V1_6_1_CS *Event; +} EFI_REDFISH_EVENT_V1_6_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_0/EfiEventDestinationV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_0/EfiEventDestinationV1_0_0.h new file mode 100644 index 00000000000..767c041d16a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_0/EfiEventDestinationV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_0_0_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_0_0/Redfish_EventDestination_v1_0_0_CS.h" +// +// EFI structure of Redfish EventDestination v1_0_0 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_0_0_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_2/EfiEventDestinationV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_2/EfiEventDestinationV1_0_2.h new file mode 100644 index 00000000000..d0453c0a033 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_2/EfiEventDestinationV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_0_2_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_0_2/Redfish_EventDestination_v1_0_2_CS.h" +// +// EFI structure of Redfish EventDestination v1_0_2 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_0_2_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_3/EfiEventDestinationV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_3/EfiEventDestinationV1_0_3.h new file mode 100644 index 00000000000..a71599aac9c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_3/EfiEventDestinationV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_0_3_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_0_3/Redfish_EventDestination_v1_0_3_CS.h" +// +// EFI structure of Redfish EventDestination v1_0_3 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_0_3_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_4/EfiEventDestinationV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_4/EfiEventDestinationV1_0_4.h new file mode 100644 index 00000000000..dee3badf7f1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_4/EfiEventDestinationV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_0_4_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_0_4/Redfish_EventDestination_v1_0_4_CS.h" +// +// EFI structure of Redfish EventDestination v1_0_4 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_0_4_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_5/EfiEventDestinationV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_5/EfiEventDestinationV1_0_5.h new file mode 100644 index 00000000000..d304b17e746 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_5/EfiEventDestinationV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_0_5_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_0_5/Redfish_EventDestination_v1_0_5_CS.h" +// +// EFI structure of Redfish EventDestination v1_0_5 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_0_5_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_6/EfiEventDestinationV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_6/EfiEventDestinationV1_0_6.h new file mode 100644 index 00000000000..69156467e3b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_6/EfiEventDestinationV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_0_6_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_0_6/Redfish_EventDestination_v1_0_6_CS.h" +// +// EFI structure of Redfish EventDestination v1_0_6 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_0_6_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_7/EfiEventDestinationV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_7/EfiEventDestinationV1_0_7.h new file mode 100644 index 00000000000..1bc996b609b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_7/EfiEventDestinationV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_0_7_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_0_7/Redfish_EventDestination_v1_0_7_CS.h" +// +// EFI structure of Redfish EventDestination v1_0_7 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_0_7_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_8/EfiEventDestinationV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_8/EfiEventDestinationV1_0_8.h new file mode 100644 index 00000000000..b45c7a8452d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_8/EfiEventDestinationV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_0_8_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_0_8/Redfish_EventDestination_v1_0_8_CS.h" +// +// EFI structure of Redfish EventDestination v1_0_8 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_0_8_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_9/EfiEventDestinationV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_9/EfiEventDestinationV1_0_9.h new file mode 100644 index 00000000000..747a7b23ae6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_0_9/EfiEventDestinationV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_0_9_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_0_9/Redfish_EventDestination_v1_0_9_CS.h" +// +// EFI structure of Redfish EventDestination v1_0_9 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_0_9_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_10_0/EfiEventDestinationV1_10_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_10_0/EfiEventDestinationV1_10_0.h new file mode 100644 index 00000000000..b399344273b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_10_0/EfiEventDestinationV1_10_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_10_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_10_0_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_10_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_10_0/Redfish_EventDestination_v1_10_0_CS.h" +// +// EFI structure of Redfish EventDestination v1_10_0 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_10_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_10_0_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_10_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_0/EfiEventDestinationV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_0/EfiEventDestinationV1_1_0.h new file mode 100644 index 00000000000..b8f694ac707 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_0/EfiEventDestinationV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_1_0_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_1_0/Redfish_EventDestination_v1_1_0_CS.h" +// +// EFI structure of Redfish EventDestination v1_1_0 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_1_0_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_1/EfiEventDestinationV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_1/EfiEventDestinationV1_1_1.h new file mode 100644 index 00000000000..7246fb13d91 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_1/EfiEventDestinationV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_1_1_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_1_1/Redfish_EventDestination_v1_1_1_CS.h" +// +// EFI structure of Redfish EventDestination v1_1_1 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_1_1_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_2/EfiEventDestinationV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_2/EfiEventDestinationV1_1_2.h new file mode 100644 index 00000000000..d4b8b2e908f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_2/EfiEventDestinationV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_1_2_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_1_2/Redfish_EventDestination_v1_1_2_CS.h" +// +// EFI structure of Redfish EventDestination v1_1_2 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_1_2_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_3/EfiEventDestinationV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_3/EfiEventDestinationV1_1_3.h new file mode 100644 index 00000000000..c0554457f58 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_3/EfiEventDestinationV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_1_3_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_1_3/Redfish_EventDestination_v1_1_3_CS.h" +// +// EFI structure of Redfish EventDestination v1_1_3 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_1_3_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_4/EfiEventDestinationV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_4/EfiEventDestinationV1_1_4.h new file mode 100644 index 00000000000..7d0e5b0084d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_4/EfiEventDestinationV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_1_4_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_1_4/Redfish_EventDestination_v1_1_4_CS.h" +// +// EFI structure of Redfish EventDestination v1_1_4 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_1_4_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_5/EfiEventDestinationV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_5/EfiEventDestinationV1_1_5.h new file mode 100644 index 00000000000..62e7bc59730 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_5/EfiEventDestinationV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_1_5_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_1_5/Redfish_EventDestination_v1_1_5_CS.h" +// +// EFI structure of Redfish EventDestination v1_1_5 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_1_5_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_6/EfiEventDestinationV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_6/EfiEventDestinationV1_1_6.h new file mode 100644 index 00000000000..079272524d0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_6/EfiEventDestinationV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_1_6_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_1_6/Redfish_EventDestination_v1_1_6_CS.h" +// +// EFI structure of Redfish EventDestination v1_1_6 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_1_6_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_7/EfiEventDestinationV1_1_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_7/EfiEventDestinationV1_1_7.h new file mode 100644 index 00000000000..9b916309b2f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_7/EfiEventDestinationV1_1_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_1_7_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_1_7_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_1_7/Redfish_EventDestination_v1_1_7_CS.h" +// +// EFI structure of Redfish EventDestination v1_1_7 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_1_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_1_7_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_1_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_8/EfiEventDestinationV1_1_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_8/EfiEventDestinationV1_1_8.h new file mode 100644 index 00000000000..ab79e7be1b2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_1_8/EfiEventDestinationV1_1_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_1_8_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_1_8_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_1_8/Redfish_EventDestination_v1_1_8_CS.h" +// +// EFI structure of Redfish EventDestination v1_1_8 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_1_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_1_8_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_1_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_0/EfiEventDestinationV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_0/EfiEventDestinationV1_2_0.h new file mode 100644 index 00000000000..2fbcc1c4b01 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_0/EfiEventDestinationV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_2_0_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_2_0/Redfish_EventDestination_v1_2_0_CS.h" +// +// EFI structure of Redfish EventDestination v1_2_0 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_2_0_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_1/EfiEventDestinationV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_1/EfiEventDestinationV1_2_1.h new file mode 100644 index 00000000000..d33271de121 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_1/EfiEventDestinationV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_2_1_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_2_1/Redfish_EventDestination_v1_2_1_CS.h" +// +// EFI structure of Redfish EventDestination v1_2_1 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_2_1_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_2/EfiEventDestinationV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_2/EfiEventDestinationV1_2_2.h new file mode 100644 index 00000000000..cefd81e3924 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_2/EfiEventDestinationV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_2_2_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_2_2/Redfish_EventDestination_v1_2_2_CS.h" +// +// EFI structure of Redfish EventDestination v1_2_2 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_2_2_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_3/EfiEventDestinationV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_3/EfiEventDestinationV1_2_3.h new file mode 100644 index 00000000000..6888cbd7b43 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_3/EfiEventDestinationV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_2_3_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_2_3/Redfish_EventDestination_v1_2_3_CS.h" +// +// EFI structure of Redfish EventDestination v1_2_3 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_2_3_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_4/EfiEventDestinationV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_4/EfiEventDestinationV1_2_4.h new file mode 100644 index 00000000000..e53967c85e0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_4/EfiEventDestinationV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_2_4_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_2_4/Redfish_EventDestination_v1_2_4_CS.h" +// +// EFI structure of Redfish EventDestination v1_2_4 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_2_4_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_5/EfiEventDestinationV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_5/EfiEventDestinationV1_2_5.h new file mode 100644 index 00000000000..d00e18f733b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_5/EfiEventDestinationV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_2_5_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_2_5/Redfish_EventDestination_v1_2_5_CS.h" +// +// EFI structure of Redfish EventDestination v1_2_5 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_2_5_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_6/EfiEventDestinationV1_2_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_6/EfiEventDestinationV1_2_6.h new file mode 100644 index 00000000000..a2bb2ef9f0c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_2_6/EfiEventDestinationV1_2_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_2_6_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_2_6_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_2_6/Redfish_EventDestination_v1_2_6_CS.h" +// +// EFI structure of Redfish EventDestination v1_2_6 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_2_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_2_6_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_2_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_3_0/EfiEventDestinationV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_3_0/EfiEventDestinationV1_3_0.h new file mode 100644 index 00000000000..2eed0ca623a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_3_0/EfiEventDestinationV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_3_0_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_3_0/Redfish_EventDestination_v1_3_0_CS.h" +// +// EFI structure of Redfish EventDestination v1_3_0 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_3_0_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_3_1/EfiEventDestinationV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_3_1/EfiEventDestinationV1_3_1.h new file mode 100644 index 00000000000..ad5fa4f5c67 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_3_1/EfiEventDestinationV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_3_1_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_3_1/Redfish_EventDestination_v1_3_1_CS.h" +// +// EFI structure of Redfish EventDestination v1_3_1 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_3_1_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_3_2/EfiEventDestinationV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_3_2/EfiEventDestinationV1_3_2.h new file mode 100644 index 00000000000..d77a658e61a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_3_2/EfiEventDestinationV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_3_2_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_3_2/Redfish_EventDestination_v1_3_2_CS.h" +// +// EFI structure of Redfish EventDestination v1_3_2 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_3_2_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_3_3/EfiEventDestinationV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_3_3/EfiEventDestinationV1_3_3.h new file mode 100644 index 00000000000..db9e2155e34 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_3_3/EfiEventDestinationV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_3_3_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_3_3/Redfish_EventDestination_v1_3_3_CS.h" +// +// EFI structure of Redfish EventDestination v1_3_3 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_3_3_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_3_4/EfiEventDestinationV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_3_4/EfiEventDestinationV1_3_4.h new file mode 100644 index 00000000000..7e8eceea7a0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_3_4/EfiEventDestinationV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_3_4_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_3_4/Redfish_EventDestination_v1_3_4_CS.h" +// +// EFI structure of Redfish EventDestination v1_3_4 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_3_4_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_4_0/EfiEventDestinationV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_4_0/EfiEventDestinationV1_4_0.h new file mode 100644 index 00000000000..91c867cbf60 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_4_0/EfiEventDestinationV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_4_0_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_4_0/Redfish_EventDestination_v1_4_0_CS.h" +// +// EFI structure of Redfish EventDestination v1_4_0 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_4_0_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_4_1/EfiEventDestinationV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_4_1/EfiEventDestinationV1_4_1.h new file mode 100644 index 00000000000..681c483c056 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_4_1/EfiEventDestinationV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_4_1_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_4_1/Redfish_EventDestination_v1_4_1_CS.h" +// +// EFI structure of Redfish EventDestination v1_4_1 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_4_1_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_4_2/EfiEventDestinationV1_4_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_4_2/EfiEventDestinationV1_4_2.h new file mode 100644 index 00000000000..e3c8735c4bc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_4_2/EfiEventDestinationV1_4_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_4_2_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_4_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_4_2/Redfish_EventDestination_v1_4_2_CS.h" +// +// EFI structure of Redfish EventDestination v1_4_2 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_4_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_4_2_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_4_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_4_3/EfiEventDestinationV1_4_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_4_3/EfiEventDestinationV1_4_3.h new file mode 100644 index 00000000000..b973e24418d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_4_3/EfiEventDestinationV1_4_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_4_3_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_4_3_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_4_3/Redfish_EventDestination_v1_4_3_CS.h" +// +// EFI structure of Redfish EventDestination v1_4_3 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_4_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_4_3_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_4_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_5_0/EfiEventDestinationV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_5_0/EfiEventDestinationV1_5_0.h new file mode 100644 index 00000000000..5e21d92c13d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_5_0/EfiEventDestinationV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_5_0_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_5_0/Redfish_EventDestination_v1_5_0_CS.h" +// +// EFI structure of Redfish EventDestination v1_5_0 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_5_0_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_5_1/EfiEventDestinationV1_5_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_5_1/EfiEventDestinationV1_5_1.h new file mode 100644 index 00000000000..87608ac40ec --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_5_1/EfiEventDestinationV1_5_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_5_1_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_5_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_5_1/Redfish_EventDestination_v1_5_1_CS.h" +// +// EFI structure of Redfish EventDestination v1_5_1 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_5_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_5_1_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_5_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_5_2/EfiEventDestinationV1_5_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_5_2/EfiEventDestinationV1_5_2.h new file mode 100644 index 00000000000..dcb56044dfd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_5_2/EfiEventDestinationV1_5_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_5_2_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_5_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_5_2/Redfish_EventDestination_v1_5_2_CS.h" +// +// EFI structure of Redfish EventDestination v1_5_2 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_5_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_5_2_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_5_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_6_0/EfiEventDestinationV1_6_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_6_0/EfiEventDestinationV1_6_0.h new file mode 100644 index 00000000000..f09244cd282 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_6_0/EfiEventDestinationV1_6_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_6_0_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_6_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_6_0/Redfish_EventDestination_v1_6_0_CS.h" +// +// EFI structure of Redfish EventDestination v1_6_0 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_6_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_6_0_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_6_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_6_1/EfiEventDestinationV1_6_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_6_1/EfiEventDestinationV1_6_1.h new file mode 100644 index 00000000000..7a2c68291b7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_6_1/EfiEventDestinationV1_6_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_6_1_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_6_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_6_1/Redfish_EventDestination_v1_6_1_CS.h" +// +// EFI structure of Redfish EventDestination v1_6_1 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_6_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_6_1_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_6_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_6_2/EfiEventDestinationV1_6_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_6_2/EfiEventDestinationV1_6_2.h new file mode 100644 index 00000000000..0c2dc79c21a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_6_2/EfiEventDestinationV1_6_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_6_2_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_6_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_6_2/Redfish_EventDestination_v1_6_2_CS.h" +// +// EFI structure of Redfish EventDestination v1_6_2 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_6_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_6_2_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_6_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_7_0/EfiEventDestinationV1_7_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_7_0/EfiEventDestinationV1_7_0.h new file mode 100644 index 00000000000..384485704d9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_7_0/EfiEventDestinationV1_7_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_7_0_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_7_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_7_0/Redfish_EventDestination_v1_7_0_CS.h" +// +// EFI structure of Redfish EventDestination v1_7_0 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_7_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_7_0_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_7_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_7_1/EfiEventDestinationV1_7_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_7_1/EfiEventDestinationV1_7_1.h new file mode 100644 index 00000000000..81cb66d04bf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_7_1/EfiEventDestinationV1_7_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_7_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_7_1_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_7_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_7_1/Redfish_EventDestination_v1_7_1_CS.h" +// +// EFI structure of Redfish EventDestination v1_7_1 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_7_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_7_1_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_7_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_7_2/EfiEventDestinationV1_7_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_7_2/EfiEventDestinationV1_7_2.h new file mode 100644 index 00000000000..32a83f104eb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_7_2/EfiEventDestinationV1_7_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_7_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_7_2_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_7_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_7_2/Redfish_EventDestination_v1_7_2_CS.h" +// +// EFI structure of Redfish EventDestination v1_7_2 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_7_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_7_2_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_7_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_8_0/EfiEventDestinationV1_8_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_8_0/EfiEventDestinationV1_8_0.h new file mode 100644 index 00000000000..6624fff1c39 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_8_0/EfiEventDestinationV1_8_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_8_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_8_0_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_8_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_8_0/Redfish_EventDestination_v1_8_0_CS.h" +// +// EFI structure of Redfish EventDestination v1_8_0 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_8_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_8_0_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_8_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_8_1/EfiEventDestinationV1_8_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_8_1/EfiEventDestinationV1_8_1.h new file mode 100644 index 00000000000..a70c2be016e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_8_1/EfiEventDestinationV1_8_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_8_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_8_1_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_8_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_8_1/Redfish_EventDestination_v1_8_1_CS.h" +// +// EFI structure of Redfish EventDestination v1_8_1 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_8_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_8_1_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_8_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_8_2/EfiEventDestinationV1_8_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_8_2/EfiEventDestinationV1_8_2.h new file mode 100644 index 00000000000..53a5eb6e2d4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_8_2/EfiEventDestinationV1_8_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_8_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_8_2_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_8_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_8_2/Redfish_EventDestination_v1_8_2_CS.h" +// +// EFI structure of Redfish EventDestination v1_8_2 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_8_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_8_2_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_8_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_9_0/EfiEventDestinationV1_9_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_9_0/EfiEventDestinationV1_9_0.h new file mode 100644 index 00000000000..350d9f0fcfe --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_9_0/EfiEventDestinationV1_9_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_9_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_9_0_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_9_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_9_0/Redfish_EventDestination_v1_9_0_CS.h" +// +// EFI structure of Redfish EventDestination v1_9_0 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_9_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_9_0_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_9_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_9_1/EfiEventDestinationV1_9_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_9_1/EfiEventDestinationV1_9_1.h new file mode 100644 index 00000000000..d70e4944bb2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestination/v1_9_1/EfiEventDestinationV1_9_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestination v1_9_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATION_V1_9_1_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATION_V1_9_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestination/v1_9_1/Redfish_EventDestination_v1_9_1_CS.h" +// +// EFI structure of Redfish EventDestination v1_9_1 +// +typedef struct _EFI_REDFISH_EVENTDESTINATION_V1_9_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATION_V1_9_1_CS *EventDestination; +} EFI_REDFISH_EVENTDESTINATION_V1_9_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventDestinationCollection/EfiEventDestinationCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestinationCollection/EfiEventDestinationCollection.h new file mode 100644 index 00000000000..dd79c98eda5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventDestinationCollection/EfiEventDestinationCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventDestinationCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTDESTINATIONCOLLECTION_H__ +#define EFI_REDFISH_INTERP_EVENTDESTINATIONCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/EventDestinationCollection/Redfish_EventDestinationCollection_CS.h" +// +// EFI structure of Redfish EventDestinationCollection +// +typedef struct _EFI_REDFISH_EVENTDESTINATIONCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTDESTINATIONCOLLECTION_CS *EventDestinationCollection; +} EFI_REDFISH_EVENTDESTINATIONCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_0/EfiEventServiceV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_0/EfiEventServiceV1_0_0.h new file mode 100644 index 00000000000..8ac3b971ae2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_0/EfiEventServiceV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_0_0/Redfish_EventService_v1_0_0_CS.h" +// +// EFI structure of Redfish EventService v1_0_0 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_0_0_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_10/EfiEventServiceV1_0_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_10/EfiEventServiceV1_0_10.h new file mode 100644 index 00000000000..6a542f5a45e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_10/EfiEventServiceV1_0_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_10_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_10_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_0_10/Redfish_EventService_v1_0_10_CS.h" +// +// EFI structure of Redfish EventService v1_0_10 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_0_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_0_10_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_0_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_11/EfiEventServiceV1_0_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_11/EfiEventServiceV1_0_11.h new file mode 100644 index 00000000000..2d27ced97e8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_11/EfiEventServiceV1_0_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_11_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_11_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_0_11/Redfish_EventService_v1_0_11_CS.h" +// +// EFI structure of Redfish EventService v1_0_11 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_0_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_0_11_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_0_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_12/EfiEventServiceV1_0_12.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_12/EfiEventServiceV1_0_12.h new file mode 100644 index 00000000000..f9c0a0162b9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_12/EfiEventServiceV1_0_12.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_0_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_12_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_12_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_0_12/Redfish_EventService_v1_0_12_CS.h" +// +// EFI structure of Redfish EventService v1_0_12 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_0_12 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_0_12_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_0_12; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_13/EfiEventServiceV1_0_13.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_13/EfiEventServiceV1_0_13.h new file mode 100644 index 00000000000..452a15547b1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_13/EfiEventServiceV1_0_13.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_0_13 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_13_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_13_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_0_13/Redfish_EventService_v1_0_13_CS.h" +// +// EFI structure of Redfish EventService v1_0_13 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_0_13 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_0_13_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_0_13; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_2/EfiEventServiceV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_2/EfiEventServiceV1_0_2.h new file mode 100644 index 00000000000..4344ec161fb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_2/EfiEventServiceV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_2_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_0_2/Redfish_EventService_v1_0_2_CS.h" +// +// EFI structure of Redfish EventService v1_0_2 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_0_2_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_3/EfiEventServiceV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_3/EfiEventServiceV1_0_3.h new file mode 100644 index 00000000000..01902403672 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_3/EfiEventServiceV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_3_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_0_3/Redfish_EventService_v1_0_3_CS.h" +// +// EFI structure of Redfish EventService v1_0_3 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_0_3_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_4/EfiEventServiceV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_4/EfiEventServiceV1_0_4.h new file mode 100644 index 00000000000..c97bf3dba69 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_4/EfiEventServiceV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_4_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_0_4/Redfish_EventService_v1_0_4_CS.h" +// +// EFI structure of Redfish EventService v1_0_4 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_0_4_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_5/EfiEventServiceV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_5/EfiEventServiceV1_0_5.h new file mode 100644 index 00000000000..13c5c7043a4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_5/EfiEventServiceV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_5_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_0_5/Redfish_EventService_v1_0_5_CS.h" +// +// EFI structure of Redfish EventService v1_0_5 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_0_5_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_6/EfiEventServiceV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_6/EfiEventServiceV1_0_6.h new file mode 100644 index 00000000000..afcf3a7d72f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_6/EfiEventServiceV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_6_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_0_6/Redfish_EventService_v1_0_6_CS.h" +// +// EFI structure of Redfish EventService v1_0_6 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_0_6_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_7/EfiEventServiceV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_7/EfiEventServiceV1_0_7.h new file mode 100644 index 00000000000..000d7ef50fc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_7/EfiEventServiceV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_7_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_0_7/Redfish_EventService_v1_0_7_CS.h" +// +// EFI structure of Redfish EventService v1_0_7 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_0_7_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_8/EfiEventServiceV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_8/EfiEventServiceV1_0_8.h new file mode 100644 index 00000000000..2a0efff820c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_8/EfiEventServiceV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_8_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_0_8/Redfish_EventService_v1_0_8_CS.h" +// +// EFI structure of Redfish EventService v1_0_8 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_0_8_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_9/EfiEventServiceV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_9/EfiEventServiceV1_0_9.h new file mode 100644 index 00000000000..85daa8e869c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_0_9/EfiEventServiceV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_9_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_0_9/Redfish_EventService_v1_0_9_CS.h" +// +// EFI structure of Redfish EventService v1_0_9 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_0_9_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_0/EfiEventServiceV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_0/EfiEventServiceV1_1_0.h new file mode 100644 index 00000000000..598d0312284 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_0/EfiEventServiceV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_1_0_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_1_0/Redfish_EventService_v1_1_0_CS.h" +// +// EFI structure of Redfish EventService v1_1_0 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_1_0_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_1/EfiEventServiceV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_1/EfiEventServiceV1_1_1.h new file mode 100644 index 00000000000..8a6e66049c4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_1/EfiEventServiceV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_1_1_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_1_1/Redfish_EventService_v1_1_1_CS.h" +// +// EFI structure of Redfish EventService v1_1_1 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_1_1_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_2/EfiEventServiceV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_2/EfiEventServiceV1_1_2.h new file mode 100644 index 00000000000..b6606460030 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_2/EfiEventServiceV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_1_2_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_1_2/Redfish_EventService_v1_1_2_CS.h" +// +// EFI structure of Redfish EventService v1_1_2 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_1_2_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_3/EfiEventServiceV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_3/EfiEventServiceV1_1_3.h new file mode 100644 index 00000000000..88f1bc594b9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_3/EfiEventServiceV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_1_3_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_1_3/Redfish_EventService_v1_1_3_CS.h" +// +// EFI structure of Redfish EventService v1_1_3 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_1_3_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_4/EfiEventServiceV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_4/EfiEventServiceV1_1_4.h new file mode 100644 index 00000000000..aaf6072b87e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_4/EfiEventServiceV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_1_4_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_1_4/Redfish_EventService_v1_1_4_CS.h" +// +// EFI structure of Redfish EventService v1_1_4 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_1_4_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_5/EfiEventServiceV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_5/EfiEventServiceV1_1_5.h new file mode 100644 index 00000000000..1d4ad7bab74 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_5/EfiEventServiceV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_1_5_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_1_5/Redfish_EventService_v1_1_5_CS.h" +// +// EFI structure of Redfish EventService v1_1_5 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_1_5_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_6/EfiEventServiceV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_6/EfiEventServiceV1_1_6.h new file mode 100644 index 00000000000..9eab80f6942 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_1_6/EfiEventServiceV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_1_6_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_1_6/Redfish_EventService_v1_1_6_CS.h" +// +// EFI structure of Redfish EventService v1_1_6 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_1_6_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_2_0/EfiEventServiceV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_2_0/EfiEventServiceV1_2_0.h new file mode 100644 index 00000000000..ae75a3ccc46 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_2_0/EfiEventServiceV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_2_0_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_2_0/Redfish_EventService_v1_2_0_CS.h" +// +// EFI structure of Redfish EventService v1_2_0 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_2_0_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_2_1/EfiEventServiceV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_2_1/EfiEventServiceV1_2_1.h new file mode 100644 index 00000000000..de37171a6be --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_2_1/EfiEventServiceV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_2_1_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_2_1/Redfish_EventService_v1_2_1_CS.h" +// +// EFI structure of Redfish EventService v1_2_1 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_2_1_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_2_2/EfiEventServiceV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_2_2/EfiEventServiceV1_2_2.h new file mode 100644 index 00000000000..ae4051299bc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_2_2/EfiEventServiceV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_2_2_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_2_2/Redfish_EventService_v1_2_2_CS.h" +// +// EFI structure of Redfish EventService v1_2_2 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_2_2_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_2_3/EfiEventServiceV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_2_3/EfiEventServiceV1_2_3.h new file mode 100644 index 00000000000..b6e1044631e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_2_3/EfiEventServiceV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_2_3_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_2_3/Redfish_EventService_v1_2_3_CS.h" +// +// EFI structure of Redfish EventService v1_2_3 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_2_3_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_2_4/EfiEventServiceV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_2_4/EfiEventServiceV1_2_4.h new file mode 100644 index 00000000000..24de0a1e230 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_2_4/EfiEventServiceV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_2_4_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_2_4/Redfish_EventService_v1_2_4_CS.h" +// +// EFI structure of Redfish EventService v1_2_4 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_2_4_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_2_5/EfiEventServiceV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_2_5/EfiEventServiceV1_2_5.h new file mode 100644 index 00000000000..1b11182a8b8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_2_5/EfiEventServiceV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_2_5_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_2_5/Redfish_EventService_v1_2_5_CS.h" +// +// EFI structure of Redfish EventService v1_2_5 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_2_5_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_3_0/EfiEventServiceV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_3_0/EfiEventServiceV1_3_0.h new file mode 100644 index 00000000000..9d737ec3a32 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_3_0/EfiEventServiceV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_3_0_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_3_0/Redfish_EventService_v1_3_0_CS.h" +// +// EFI structure of Redfish EventService v1_3_0 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_3_0_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_3_1/EfiEventServiceV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_3_1/EfiEventServiceV1_3_1.h new file mode 100644 index 00000000000..4eeea34335e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_3_1/EfiEventServiceV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_3_1_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_3_1/Redfish_EventService_v1_3_1_CS.h" +// +// EFI structure of Redfish EventService v1_3_1 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_3_1_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_3_2/EfiEventServiceV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_3_2/EfiEventServiceV1_3_2.h new file mode 100644 index 00000000000..909d854a2e4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_3_2/EfiEventServiceV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_3_2_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_3_2/Redfish_EventService_v1_3_2_CS.h" +// +// EFI structure of Redfish EventService v1_3_2 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_3_2_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_3_3/EfiEventServiceV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_3_3/EfiEventServiceV1_3_3.h new file mode 100644 index 00000000000..4d461aa0350 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_3_3/EfiEventServiceV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_3_3_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_3_3/Redfish_EventService_v1_3_3_CS.h" +// +// EFI structure of Redfish EventService v1_3_3 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_3_3_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_3_4/EfiEventServiceV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_3_4/EfiEventServiceV1_3_4.h new file mode 100644 index 00000000000..734f8a9c905 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_3_4/EfiEventServiceV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_3_4_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_3_4/Redfish_EventService_v1_3_4_CS.h" +// +// EFI structure of Redfish EventService v1_3_4 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_3_4_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_4_0/EfiEventServiceV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_4_0/EfiEventServiceV1_4_0.h new file mode 100644 index 00000000000..a0de121fa1c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_4_0/EfiEventServiceV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_4_0_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_4_0/Redfish_EventService_v1_4_0_CS.h" +// +// EFI structure of Redfish EventService v1_4_0 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_4_0_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_4_1/EfiEventServiceV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_4_1/EfiEventServiceV1_4_1.h new file mode 100644 index 00000000000..ea5a02fe1f0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_4_1/EfiEventServiceV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_4_1_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_4_1/Redfish_EventService_v1_4_1_CS.h" +// +// EFI structure of Redfish EventService v1_4_1 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_4_1_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_4_2/EfiEventServiceV1_4_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_4_2/EfiEventServiceV1_4_2.h new file mode 100644 index 00000000000..4afe782daa3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_4_2/EfiEventServiceV1_4_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_4_2_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_4_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_4_2/Redfish_EventService_v1_4_2_CS.h" +// +// EFI structure of Redfish EventService v1_4_2 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_4_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_4_2_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_4_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_4_3/EfiEventServiceV1_4_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_4_3/EfiEventServiceV1_4_3.h new file mode 100644 index 00000000000..73ca628ec5d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_4_3/EfiEventServiceV1_4_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_4_3_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_4_3_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_4_3/Redfish_EventService_v1_4_3_CS.h" +// +// EFI structure of Redfish EventService v1_4_3 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_4_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_4_3_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_4_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_5_0/EfiEventServiceV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_5_0/EfiEventServiceV1_5_0.h new file mode 100644 index 00000000000..aacb0893c96 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_5_0/EfiEventServiceV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_5_0_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_5_0/Redfish_EventService_v1_5_0_CS.h" +// +// EFI structure of Redfish EventService v1_5_0 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_5_0_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_5_1/EfiEventServiceV1_5_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_5_1/EfiEventServiceV1_5_1.h new file mode 100644 index 00000000000..fe9cb4f2e65 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_5_1/EfiEventServiceV1_5_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_5_1_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_5_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_5_1/Redfish_EventService_v1_5_1_CS.h" +// +// EFI structure of Redfish EventService v1_5_1 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_5_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_5_1_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_5_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_5_2/EfiEventServiceV1_5_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_5_2/EfiEventServiceV1_5_2.h new file mode 100644 index 00000000000..b5b78391632 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_5_2/EfiEventServiceV1_5_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_5_2_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_5_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_5_2/Redfish_EventService_v1_5_2_CS.h" +// +// EFI structure of Redfish EventService v1_5_2 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_5_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_5_2_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_5_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_5_3/EfiEventServiceV1_5_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_5_3/EfiEventServiceV1_5_3.h new file mode 100644 index 00000000000..67f11497d70 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_5_3/EfiEventServiceV1_5_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_5_3_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_5_3_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_5_3/Redfish_EventService_v1_5_3_CS.h" +// +// EFI structure of Redfish EventService v1_5_3 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_5_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_5_3_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_5_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_6_0/EfiEventServiceV1_6_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_6_0/EfiEventServiceV1_6_0.h new file mode 100644 index 00000000000..b6d0a4fe67c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_6_0/EfiEventServiceV1_6_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_6_0_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_6_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_6_0/Redfish_EventService_v1_6_0_CS.h" +// +// EFI structure of Redfish EventService v1_6_0 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_6_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_6_0_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_6_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_6_1/EfiEventServiceV1_6_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_6_1/EfiEventServiceV1_6_1.h new file mode 100644 index 00000000000..4b5e085e928 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_6_1/EfiEventServiceV1_6_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_6_1_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_6_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_6_1/Redfish_EventService_v1_6_1_CS.h" +// +// EFI structure of Redfish EventService v1_6_1 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_6_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_6_1_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_6_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_6_2/EfiEventServiceV1_6_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_6_2/EfiEventServiceV1_6_2.h new file mode 100644 index 00000000000..4a7488a9555 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_6_2/EfiEventServiceV1_6_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_6_2_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_6_2_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_6_2/Redfish_EventService_v1_6_2_CS.h" +// +// EFI structure of Redfish EventService v1_6_2 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_6_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_6_2_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_6_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_7_0/EfiEventServiceV1_7_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_7_0/EfiEventServiceV1_7_0.h new file mode 100644 index 00000000000..eb8522d44a1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_7_0/EfiEventServiceV1_7_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_7_0_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_7_0_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_7_0/Redfish_EventService_v1_7_0_CS.h" +// +// EFI structure of Redfish EventService v1_7_0 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_7_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_7_0_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_7_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_7_1/EfiEventServiceV1_7_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_7_1/EfiEventServiceV1_7_1.h new file mode 100644 index 00000000000..0b7b8ef259f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/EventService/v1_7_1/EfiEventServiceV1_7_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for EventService v1_7_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EVENTSERVICE_V1_7_1_H__ +#define EFI_REDFISH_INTERP_EVENTSERVICE_V1_7_1_H__ + +#include +#include +#include "ConverterLib/edk2library/EventService/v1_7_1/Redfish_EventService_v1_7_1_CS.h" +// +// EFI structure of Redfish EventService v1_7_1 +// +typedef struct _EFI_REDFISH_EVENTSERVICE_V1_7_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EVENTSERVICE_V1_7_1_CS *EventService; +} EFI_REDFISH_EVENTSERVICE_V1_7_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_0_0/EfiExternalAccountProviderV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_0_0/EfiExternalAccountProviderV1_0_0.h new file mode 100644 index 00000000000..95e20833ef7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_0_0/EfiExternalAccountProviderV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ExternalAccountProvider v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDER_V1_0_0_H__ +#define EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDER_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ExternalAccountProvider/v1_0_0/Redfish_ExternalAccountProvider_v1_0_0_CS.h" +// +// EFI structure of Redfish ExternalAccountProvider v1_0_0 +// +typedef struct _EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_0_CS *ExternalAccountProvider; +} EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_0_1/EfiExternalAccountProviderV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_0_1/EfiExternalAccountProviderV1_0_1.h new file mode 100644 index 00000000000..1b94d8ba567 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_0_1/EfiExternalAccountProviderV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ExternalAccountProvider v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDER_V1_0_1_H__ +#define EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDER_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ExternalAccountProvider/v1_0_1/Redfish_ExternalAccountProvider_v1_0_1_CS.h" +// +// EFI structure of Redfish ExternalAccountProvider v1_0_1 +// +typedef struct _EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_1_CS *ExternalAccountProvider; +} EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_0_2/EfiExternalAccountProviderV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_0_2/EfiExternalAccountProviderV1_0_2.h new file mode 100644 index 00000000000..22689741403 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_0_2/EfiExternalAccountProviderV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ExternalAccountProvider v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDER_V1_0_2_H__ +#define EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDER_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ExternalAccountProvider/v1_0_2/Redfish_ExternalAccountProvider_v1_0_2_CS.h" +// +// EFI structure of Redfish ExternalAccountProvider v1_0_2 +// +typedef struct _EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_2_CS *ExternalAccountProvider; +} EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_0_3/EfiExternalAccountProviderV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_0_3/EfiExternalAccountProviderV1_0_3.h new file mode 100644 index 00000000000..ee535745603 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_0_3/EfiExternalAccountProviderV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ExternalAccountProvider v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDER_V1_0_3_H__ +#define EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDER_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ExternalAccountProvider/v1_0_3/Redfish_ExternalAccountProvider_v1_0_3_CS.h" +// +// EFI structure of Redfish ExternalAccountProvider v1_0_3 +// +typedef struct _EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_3_CS *ExternalAccountProvider; +} EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_0_4/EfiExternalAccountProviderV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_0_4/EfiExternalAccountProviderV1_0_4.h new file mode 100644 index 00000000000..c7f2b9a4a10 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_0_4/EfiExternalAccountProviderV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ExternalAccountProvider v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDER_V1_0_4_H__ +#define EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDER_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ExternalAccountProvider/v1_0_4/Redfish_ExternalAccountProvider_v1_0_4_CS.h" +// +// EFI structure of Redfish ExternalAccountProvider v1_0_4 +// +typedef struct _EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_4_CS *ExternalAccountProvider; +} EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_0_5/EfiExternalAccountProviderV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_0_5/EfiExternalAccountProviderV1_0_5.h new file mode 100644 index 00000000000..722e3642a0b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_0_5/EfiExternalAccountProviderV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ExternalAccountProvider v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDER_V1_0_5_H__ +#define EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDER_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/ExternalAccountProvider/v1_0_5/Redfish_ExternalAccountProvider_v1_0_5_CS.h" +// +// EFI structure of Redfish ExternalAccountProvider v1_0_5 +// +typedef struct _EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_5_CS *ExternalAccountProvider; +} EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_1_0/EfiExternalAccountProviderV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_1_0/EfiExternalAccountProviderV1_1_0.h new file mode 100644 index 00000000000..0a5bc520121 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_1_0/EfiExternalAccountProviderV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ExternalAccountProvider v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDER_V1_1_0_H__ +#define EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDER_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ExternalAccountProvider/v1_1_0/Redfish_ExternalAccountProvider_v1_1_0_CS.h" +// +// EFI structure of Redfish ExternalAccountProvider v1_1_0 +// +typedef struct _EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_0_CS *ExternalAccountProvider; +} EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_1_1/EfiExternalAccountProviderV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_1_1/EfiExternalAccountProviderV1_1_1.h new file mode 100644 index 00000000000..cd12a0e6c13 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_1_1/EfiExternalAccountProviderV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ExternalAccountProvider v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDER_V1_1_1_H__ +#define EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDER_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ExternalAccountProvider/v1_1_1/Redfish_ExternalAccountProvider_v1_1_1_CS.h" +// +// EFI structure of Redfish ExternalAccountProvider v1_1_1 +// +typedef struct _EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_1_CS *ExternalAccountProvider; +} EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_1_2/EfiExternalAccountProviderV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_1_2/EfiExternalAccountProviderV1_1_2.h new file mode 100644 index 00000000000..3908a199e61 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_1_2/EfiExternalAccountProviderV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ExternalAccountProvider v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDER_V1_1_2_H__ +#define EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDER_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ExternalAccountProvider/v1_1_2/Redfish_ExternalAccountProvider_v1_1_2_CS.h" +// +// EFI structure of Redfish ExternalAccountProvider v1_1_2 +// +typedef struct _EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_2_CS *ExternalAccountProvider; +} EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_1_3/EfiExternalAccountProviderV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_1_3/EfiExternalAccountProviderV1_1_3.h new file mode 100644 index 00000000000..f9a57d8cb78 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_1_3/EfiExternalAccountProviderV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ExternalAccountProvider v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDER_V1_1_3_H__ +#define EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDER_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ExternalAccountProvider/v1_1_3/Redfish_ExternalAccountProvider_v1_1_3_CS.h" +// +// EFI structure of Redfish ExternalAccountProvider v1_1_3 +// +typedef struct _EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_3_CS *ExternalAccountProvider; +} EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_1_4/EfiExternalAccountProviderV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_1_4/EfiExternalAccountProviderV1_1_4.h new file mode 100644 index 00000000000..a4d362cfb79 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_1_4/EfiExternalAccountProviderV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ExternalAccountProvider v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDER_V1_1_4_H__ +#define EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDER_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ExternalAccountProvider/v1_1_4/Redfish_ExternalAccountProvider_v1_1_4_CS.h" +// +// EFI structure of Redfish ExternalAccountProvider v1_1_4 +// +typedef struct _EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_4_CS *ExternalAccountProvider; +} EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_2_0/EfiExternalAccountProviderV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_2_0/EfiExternalAccountProviderV1_2_0.h new file mode 100644 index 00000000000..884d2c28bd4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProvider/v1_2_0/EfiExternalAccountProviderV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ExternalAccountProvider v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDER_V1_2_0_H__ +#define EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDER_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ExternalAccountProvider/v1_2_0/Redfish_ExternalAccountProvider_v1_2_0_CS.h" +// +// EFI structure of Redfish ExternalAccountProvider v1_2_0 +// +typedef struct _EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_2_0_CS *ExternalAccountProvider; +} EFI_REDFISH_EXTERNALACCOUNTPROVIDER_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProviderCollection/EfiExternalAccountProviderCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProviderCollection/EfiExternalAccountProviderCollection.h new file mode 100644 index 00000000000..a38c8a5998c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ExternalAccountProviderCollection/EfiExternalAccountProviderCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ExternalAccountProviderCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDERCOLLECTION_H__ +#define EFI_REDFISH_INTERP_EXTERNALACCOUNTPROVIDERCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/ExternalAccountProviderCollection/Redfish_ExternalAccountProviderCollection_CS.h" +// +// EFI structure of Redfish ExternalAccountProviderCollection +// +typedef struct _EFI_REDFISH_EXTERNALACCOUNTPROVIDERCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_EXTERNALACCOUNTPROVIDERCOLLECTION_CS *ExternalAccountProviderCollection; +} EFI_REDFISH_EXTERNALACCOUNTPROVIDERCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_0/EfiFabricV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_0/EfiFabricV1_0_0.h new file mode 100644 index 00000000000..a501b0b030c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_0/EfiFabricV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Fabric v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_FABRIC_V1_0_0_H__ +#define EFI_REDFISH_INTERP_FABRIC_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Fabric/v1_0_0/Redfish_Fabric_v1_0_0_CS.h" +// +// EFI structure of Redfish Fabric v1_0_0 +// +typedef struct _EFI_REDFISH_FABRIC_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_FABRIC_V1_0_0_CS *Fabric; +} EFI_REDFISH_FABRIC_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_1/EfiFabricV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_1/EfiFabricV1_0_1.h new file mode 100644 index 00000000000..8d572708ae1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_1/EfiFabricV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Fabric v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_FABRIC_V1_0_1_H__ +#define EFI_REDFISH_INTERP_FABRIC_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Fabric/v1_0_1/Redfish_Fabric_v1_0_1_CS.h" +// +// EFI structure of Redfish Fabric v1_0_1 +// +typedef struct _EFI_REDFISH_FABRIC_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_FABRIC_V1_0_1_CS *Fabric; +} EFI_REDFISH_FABRIC_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_2/EfiFabricV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_2/EfiFabricV1_0_2.h new file mode 100644 index 00000000000..d98852260f2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_2/EfiFabricV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Fabric v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_FABRIC_V1_0_2_H__ +#define EFI_REDFISH_INTERP_FABRIC_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Fabric/v1_0_2/Redfish_Fabric_v1_0_2_CS.h" +// +// EFI structure of Redfish Fabric v1_0_2 +// +typedef struct _EFI_REDFISH_FABRIC_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_FABRIC_V1_0_2_CS *Fabric; +} EFI_REDFISH_FABRIC_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_3/EfiFabricV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_3/EfiFabricV1_0_3.h new file mode 100644 index 00000000000..f469d4aae91 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_3/EfiFabricV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Fabric v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_FABRIC_V1_0_3_H__ +#define EFI_REDFISH_INTERP_FABRIC_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Fabric/v1_0_3/Redfish_Fabric_v1_0_3_CS.h" +// +// EFI structure of Redfish Fabric v1_0_3 +// +typedef struct _EFI_REDFISH_FABRIC_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_FABRIC_V1_0_3_CS *Fabric; +} EFI_REDFISH_FABRIC_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_4/EfiFabricV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_4/EfiFabricV1_0_4.h new file mode 100644 index 00000000000..03a005b7eea --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_4/EfiFabricV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Fabric v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_FABRIC_V1_0_4_H__ +#define EFI_REDFISH_INTERP_FABRIC_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Fabric/v1_0_4/Redfish_Fabric_v1_0_4_CS.h" +// +// EFI structure of Redfish Fabric v1_0_4 +// +typedef struct _EFI_REDFISH_FABRIC_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_FABRIC_V1_0_4_CS *Fabric; +} EFI_REDFISH_FABRIC_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_5/EfiFabricV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_5/EfiFabricV1_0_5.h new file mode 100644 index 00000000000..93facc47bdd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_5/EfiFabricV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Fabric v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_FABRIC_V1_0_5_H__ +#define EFI_REDFISH_INTERP_FABRIC_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Fabric/v1_0_5/Redfish_Fabric_v1_0_5_CS.h" +// +// EFI structure of Redfish Fabric v1_0_5 +// +typedef struct _EFI_REDFISH_FABRIC_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_FABRIC_V1_0_5_CS *Fabric; +} EFI_REDFISH_FABRIC_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_6/EfiFabricV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_6/EfiFabricV1_0_6.h new file mode 100644 index 00000000000..29dd2d8a7e7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_6/EfiFabricV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Fabric v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_FABRIC_V1_0_6_H__ +#define EFI_REDFISH_INTERP_FABRIC_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Fabric/v1_0_6/Redfish_Fabric_v1_0_6_CS.h" +// +// EFI structure of Redfish Fabric v1_0_6 +// +typedef struct _EFI_REDFISH_FABRIC_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_FABRIC_V1_0_6_CS *Fabric; +} EFI_REDFISH_FABRIC_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_7/EfiFabricV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_7/EfiFabricV1_0_7.h new file mode 100644 index 00000000000..75774223e5a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_7/EfiFabricV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Fabric v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_FABRIC_V1_0_7_H__ +#define EFI_REDFISH_INTERP_FABRIC_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Fabric/v1_0_7/Redfish_Fabric_v1_0_7_CS.h" +// +// EFI structure of Redfish Fabric v1_0_7 +// +typedef struct _EFI_REDFISH_FABRIC_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_FABRIC_V1_0_7_CS *Fabric; +} EFI_REDFISH_FABRIC_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_8/EfiFabricV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_8/EfiFabricV1_0_8.h new file mode 100644 index 00000000000..99516d7d7ae --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_0_8/EfiFabricV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Fabric v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_FABRIC_V1_0_8_H__ +#define EFI_REDFISH_INTERP_FABRIC_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Fabric/v1_0_8/Redfish_Fabric_v1_0_8_CS.h" +// +// EFI structure of Redfish Fabric v1_0_8 +// +typedef struct _EFI_REDFISH_FABRIC_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_FABRIC_V1_0_8_CS *Fabric; +} EFI_REDFISH_FABRIC_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_1_0/EfiFabricV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_1_0/EfiFabricV1_1_0.h new file mode 100644 index 00000000000..fc808066942 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_1_0/EfiFabricV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Fabric v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_FABRIC_V1_1_0_H__ +#define EFI_REDFISH_INTERP_FABRIC_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Fabric/v1_1_0/Redfish_Fabric_v1_1_0_CS.h" +// +// EFI structure of Redfish Fabric v1_1_0 +// +typedef struct _EFI_REDFISH_FABRIC_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_FABRIC_V1_1_0_CS *Fabric; +} EFI_REDFISH_FABRIC_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_1_1/EfiFabricV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_1_1/EfiFabricV1_1_1.h new file mode 100644 index 00000000000..c7db6431665 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_1_1/EfiFabricV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Fabric v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_FABRIC_V1_1_1_H__ +#define EFI_REDFISH_INTERP_FABRIC_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Fabric/v1_1_1/Redfish_Fabric_v1_1_1_CS.h" +// +// EFI structure of Redfish Fabric v1_1_1 +// +typedef struct _EFI_REDFISH_FABRIC_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_FABRIC_V1_1_1_CS *Fabric; +} EFI_REDFISH_FABRIC_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_1_2/EfiFabricV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_1_2/EfiFabricV1_1_2.h new file mode 100644 index 00000000000..d14eef54864 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_1_2/EfiFabricV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Fabric v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_FABRIC_V1_1_2_H__ +#define EFI_REDFISH_INTERP_FABRIC_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Fabric/v1_1_2/Redfish_Fabric_v1_1_2_CS.h" +// +// EFI structure of Redfish Fabric v1_1_2 +// +typedef struct _EFI_REDFISH_FABRIC_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_FABRIC_V1_1_2_CS *Fabric; +} EFI_REDFISH_FABRIC_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_2_0/EfiFabricV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_2_0/EfiFabricV1_2_0.h new file mode 100644 index 00000000000..3b9821c7743 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_2_0/EfiFabricV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Fabric v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_FABRIC_V1_2_0_H__ +#define EFI_REDFISH_INTERP_FABRIC_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Fabric/v1_2_0/Redfish_Fabric_v1_2_0_CS.h" +// +// EFI structure of Redfish Fabric v1_2_0 +// +typedef struct _EFI_REDFISH_FABRIC_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_FABRIC_V1_2_0_CS *Fabric; +} EFI_REDFISH_FABRIC_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_2_1/EfiFabricV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_2_1/EfiFabricV1_2_1.h new file mode 100644 index 00000000000..0e040f821e2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Fabric/v1_2_1/EfiFabricV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Fabric v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_FABRIC_V1_2_1_H__ +#define EFI_REDFISH_INTERP_FABRIC_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Fabric/v1_2_1/Redfish_Fabric_v1_2_1_CS.h" +// +// EFI structure of Redfish Fabric v1_2_1 +// +typedef struct _EFI_REDFISH_FABRIC_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_FABRIC_V1_2_1_CS *Fabric; +} EFI_REDFISH_FABRIC_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/FabricAdapter/v1_0_0/EfiFabricAdapterV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/FabricAdapter/v1_0_0/EfiFabricAdapterV1_0_0.h new file mode 100644 index 00000000000..3b299f9eecd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/FabricAdapter/v1_0_0/EfiFabricAdapterV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for FabricAdapter v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_FABRICADAPTER_V1_0_0_H__ +#define EFI_REDFISH_INTERP_FABRICADAPTER_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/FabricAdapter/v1_0_0/Redfish_FabricAdapter_v1_0_0_CS.h" +// +// EFI structure of Redfish FabricAdapter v1_0_0 +// +typedef struct _EFI_REDFISH_FABRICADAPTER_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_FABRICADAPTER_V1_0_0_CS *FabricAdapter; +} EFI_REDFISH_FABRICADAPTER_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/FabricAdapterCollection/EfiFabricAdapterCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/FabricAdapterCollection/EfiFabricAdapterCollection.h new file mode 100644 index 00000000000..5b23d74e79f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/FabricAdapterCollection/EfiFabricAdapterCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for FabricAdapterCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_FABRICADAPTERCOLLECTION_H__ +#define EFI_REDFISH_INTERP_FABRICADAPTERCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/FabricAdapterCollection/Redfish_FabricAdapterCollection_CS.h" +// +// EFI structure of Redfish FabricAdapterCollection +// +typedef struct _EFI_REDFISH_FABRICADAPTERCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_FABRICADAPTERCOLLECTION_CS *FabricAdapterCollection; +} EFI_REDFISH_FABRICADAPTERCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/FabricCollection/EfiFabricCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/FabricCollection/EfiFabricCollection.h new file mode 100644 index 00000000000..9e6e6613755 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/FabricCollection/EfiFabricCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for FabricCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_FABRICCOLLECTION_H__ +#define EFI_REDFISH_INTERP_FABRICCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/FabricCollection/Redfish_FabricCollection_CS.h" +// +// EFI structure of Redfish FabricCollection +// +typedef struct _EFI_REDFISH_FABRICCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_FABRICCOLLECTION_CS *FabricCollection; +} EFI_REDFISH_FABRICCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Facility/v1_0_0/EfiFacilityV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Facility/v1_0_0/EfiFacilityV1_0_0.h new file mode 100644 index 00000000000..6914c865279 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Facility/v1_0_0/EfiFacilityV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Facility v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_FACILITY_V1_0_0_H__ +#define EFI_REDFISH_INTERP_FACILITY_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Facility/v1_0_0/Redfish_Facility_v1_0_0_CS.h" +// +// EFI structure of Redfish Facility v1_0_0 +// +typedef struct _EFI_REDFISH_FACILITY_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_FACILITY_V1_0_0_CS *Facility; +} EFI_REDFISH_FACILITY_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Facility/v1_0_1/EfiFacilityV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Facility/v1_0_1/EfiFacilityV1_0_1.h new file mode 100644 index 00000000000..37e8042eb76 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Facility/v1_0_1/EfiFacilityV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Facility v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_FACILITY_V1_0_1_H__ +#define EFI_REDFISH_INTERP_FACILITY_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Facility/v1_0_1/Redfish_Facility_v1_0_1_CS.h" +// +// EFI structure of Redfish Facility v1_0_1 +// +typedef struct _EFI_REDFISH_FACILITY_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_FACILITY_V1_0_1_CS *Facility; +} EFI_REDFISH_FACILITY_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Facility/v1_1_0/EfiFacilityV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Facility/v1_1_0/EfiFacilityV1_1_0.h new file mode 100644 index 00000000000..727d7b6448a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Facility/v1_1_0/EfiFacilityV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Facility v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_FACILITY_V1_1_0_H__ +#define EFI_REDFISH_INTERP_FACILITY_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Facility/v1_1_0/Redfish_Facility_v1_1_0_CS.h" +// +// EFI structure of Redfish Facility v1_1_0 +// +typedef struct _EFI_REDFISH_FACILITY_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_FACILITY_V1_1_0_CS *Facility; +} EFI_REDFISH_FACILITY_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/FacilityCollection/EfiFacilityCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/FacilityCollection/EfiFacilityCollection.h new file mode 100644 index 00000000000..50454f8361b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/FacilityCollection/EfiFacilityCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for FacilityCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_FACILITYCOLLECTION_H__ +#define EFI_REDFISH_INTERP_FACILITYCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/FacilityCollection/Redfish_FacilityCollection_CS.h" +// +// EFI structure of Redfish FacilityCollection +// +typedef struct _EFI_REDFISH_FACILITYCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_FACILITYCOLLECTION_CS *FacilityCollection; +} EFI_REDFISH_FACILITYCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Fan/v1_0_0/EfiFanV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Fan/v1_0_0/EfiFanV1_0_0.h new file mode 100644 index 00000000000..5f6842fa013 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Fan/v1_0_0/EfiFanV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Fan v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_FAN_V1_0_0_H__ +#define EFI_REDFISH_INTERP_FAN_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Fan/v1_0_0/Redfish_Fan_v1_0_0_CS.h" +// +// EFI structure of Redfish Fan v1_0_0 +// +typedef struct _EFI_REDFISH_FAN_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_FAN_V1_0_0_CS *Fan; +} EFI_REDFISH_FAN_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/FanCollection/EfiFanCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/FanCollection/EfiFanCollection.h new file mode 100644 index 00000000000..f165dc303b9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/FanCollection/EfiFanCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for FanCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_FANCOLLECTION_H__ +#define EFI_REDFISH_INTERP_FANCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/FanCollection/Redfish_FanCollection_CS.h" +// +// EFI structure of Redfish FanCollection +// +typedef struct _EFI_REDFISH_FANCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_FANCOLLECTION_CS *FanCollection; +} EFI_REDFISH_FANCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_0_0/EfiHostInterfaceV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_0_0/EfiHostInterfaceV1_0_0.h new file mode 100644 index 00000000000..7d8442d8f77 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_0_0/EfiHostInterfaceV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for HostInterface v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_HOSTINTERFACE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_HOSTINTERFACE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/HostInterface/v1_0_0/Redfish_HostInterface_v1_0_0_CS.h" +// +// EFI structure of Redfish HostInterface v1_0_0 +// +typedef struct _EFI_REDFISH_HOSTINTERFACE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_HOSTINTERFACE_V1_0_0_CS *HostInterface; +} EFI_REDFISH_HOSTINTERFACE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_0_1/EfiHostInterfaceV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_0_1/EfiHostInterfaceV1_0_1.h new file mode 100644 index 00000000000..dfc3929484d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_0_1/EfiHostInterfaceV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for HostInterface v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_HOSTINTERFACE_V1_0_1_H__ +#define EFI_REDFISH_INTERP_HOSTINTERFACE_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/HostInterface/v1_0_1/Redfish_HostInterface_v1_0_1_CS.h" +// +// EFI structure of Redfish HostInterface v1_0_1 +// +typedef struct _EFI_REDFISH_HOSTINTERFACE_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_HOSTINTERFACE_V1_0_1_CS *HostInterface; +} EFI_REDFISH_HOSTINTERFACE_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_0_2/EfiHostInterfaceV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_0_2/EfiHostInterfaceV1_0_2.h new file mode 100644 index 00000000000..44ff42ebd0f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_0_2/EfiHostInterfaceV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for HostInterface v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_HOSTINTERFACE_V1_0_2_H__ +#define EFI_REDFISH_INTERP_HOSTINTERFACE_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/HostInterface/v1_0_2/Redfish_HostInterface_v1_0_2_CS.h" +// +// EFI structure of Redfish HostInterface v1_0_2 +// +typedef struct _EFI_REDFISH_HOSTINTERFACE_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_HOSTINTERFACE_V1_0_2_CS *HostInterface; +} EFI_REDFISH_HOSTINTERFACE_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_0_3/EfiHostInterfaceV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_0_3/EfiHostInterfaceV1_0_3.h new file mode 100644 index 00000000000..53fba804b0b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_0_3/EfiHostInterfaceV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for HostInterface v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_HOSTINTERFACE_V1_0_3_H__ +#define EFI_REDFISH_INTERP_HOSTINTERFACE_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/HostInterface/v1_0_3/Redfish_HostInterface_v1_0_3_CS.h" +// +// EFI structure of Redfish HostInterface v1_0_3 +// +typedef struct _EFI_REDFISH_HOSTINTERFACE_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_HOSTINTERFACE_V1_0_3_CS *HostInterface; +} EFI_REDFISH_HOSTINTERFACE_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_0_4/EfiHostInterfaceV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_0_4/EfiHostInterfaceV1_0_4.h new file mode 100644 index 00000000000..cf29bbcc390 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_0_4/EfiHostInterfaceV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for HostInterface v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_HOSTINTERFACE_V1_0_4_H__ +#define EFI_REDFISH_INTERP_HOSTINTERFACE_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/HostInterface/v1_0_4/Redfish_HostInterface_v1_0_4_CS.h" +// +// EFI structure of Redfish HostInterface v1_0_4 +// +typedef struct _EFI_REDFISH_HOSTINTERFACE_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_HOSTINTERFACE_V1_0_4_CS *HostInterface; +} EFI_REDFISH_HOSTINTERFACE_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_0_5/EfiHostInterfaceV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_0_5/EfiHostInterfaceV1_0_5.h new file mode 100644 index 00000000000..2ea48e56963 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_0_5/EfiHostInterfaceV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for HostInterface v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_HOSTINTERFACE_V1_0_5_H__ +#define EFI_REDFISH_INTERP_HOSTINTERFACE_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/HostInterface/v1_0_5/Redfish_HostInterface_v1_0_5_CS.h" +// +// EFI structure of Redfish HostInterface v1_0_5 +// +typedef struct _EFI_REDFISH_HOSTINTERFACE_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_HOSTINTERFACE_V1_0_5_CS *HostInterface; +} EFI_REDFISH_HOSTINTERFACE_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_1_0/EfiHostInterfaceV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_1_0/EfiHostInterfaceV1_1_0.h new file mode 100644 index 00000000000..b97b9f8a987 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_1_0/EfiHostInterfaceV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for HostInterface v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_HOSTINTERFACE_V1_1_0_H__ +#define EFI_REDFISH_INTERP_HOSTINTERFACE_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/HostInterface/v1_1_0/Redfish_HostInterface_v1_1_0_CS.h" +// +// EFI structure of Redfish HostInterface v1_1_0 +// +typedef struct _EFI_REDFISH_HOSTINTERFACE_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_HOSTINTERFACE_V1_1_0_CS *HostInterface; +} EFI_REDFISH_HOSTINTERFACE_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_1_1/EfiHostInterfaceV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_1_1/EfiHostInterfaceV1_1_1.h new file mode 100644 index 00000000000..50342a4aa30 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_1_1/EfiHostInterfaceV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for HostInterface v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_HOSTINTERFACE_V1_1_1_H__ +#define EFI_REDFISH_INTERP_HOSTINTERFACE_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/HostInterface/v1_1_1/Redfish_HostInterface_v1_1_1_CS.h" +// +// EFI structure of Redfish HostInterface v1_1_1 +// +typedef struct _EFI_REDFISH_HOSTINTERFACE_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_HOSTINTERFACE_V1_1_1_CS *HostInterface; +} EFI_REDFISH_HOSTINTERFACE_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_1_2/EfiHostInterfaceV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_1_2/EfiHostInterfaceV1_1_2.h new file mode 100644 index 00000000000..752a8def257 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_1_2/EfiHostInterfaceV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for HostInterface v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_HOSTINTERFACE_V1_1_2_H__ +#define EFI_REDFISH_INTERP_HOSTINTERFACE_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/HostInterface/v1_1_2/Redfish_HostInterface_v1_1_2_CS.h" +// +// EFI structure of Redfish HostInterface v1_1_2 +// +typedef struct _EFI_REDFISH_HOSTINTERFACE_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_HOSTINTERFACE_V1_1_2_CS *HostInterface; +} EFI_REDFISH_HOSTINTERFACE_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_1_3/EfiHostInterfaceV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_1_3/EfiHostInterfaceV1_1_3.h new file mode 100644 index 00000000000..1883228dae5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_1_3/EfiHostInterfaceV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for HostInterface v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_HOSTINTERFACE_V1_1_3_H__ +#define EFI_REDFISH_INTERP_HOSTINTERFACE_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/HostInterface/v1_1_3/Redfish_HostInterface_v1_1_3_CS.h" +// +// EFI structure of Redfish HostInterface v1_1_3 +// +typedef struct _EFI_REDFISH_HOSTINTERFACE_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_HOSTINTERFACE_V1_1_3_CS *HostInterface; +} EFI_REDFISH_HOSTINTERFACE_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_1_4/EfiHostInterfaceV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_1_4/EfiHostInterfaceV1_1_4.h new file mode 100644 index 00000000000..070973873bc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_1_4/EfiHostInterfaceV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for HostInterface v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_HOSTINTERFACE_V1_1_4_H__ +#define EFI_REDFISH_INTERP_HOSTINTERFACE_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/HostInterface/v1_1_4/Redfish_HostInterface_v1_1_4_CS.h" +// +// EFI structure of Redfish HostInterface v1_1_4 +// +typedef struct _EFI_REDFISH_HOSTINTERFACE_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_HOSTINTERFACE_V1_1_4_CS *HostInterface; +} EFI_REDFISH_HOSTINTERFACE_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_1_5/EfiHostInterfaceV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_1_5/EfiHostInterfaceV1_1_5.h new file mode 100644 index 00000000000..d760e046b61 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_1_5/EfiHostInterfaceV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for HostInterface v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_HOSTINTERFACE_V1_1_5_H__ +#define EFI_REDFISH_INTERP_HOSTINTERFACE_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/HostInterface/v1_1_5/Redfish_HostInterface_v1_1_5_CS.h" +// +// EFI structure of Redfish HostInterface v1_1_5 +// +typedef struct _EFI_REDFISH_HOSTINTERFACE_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_HOSTINTERFACE_V1_1_5_CS *HostInterface; +} EFI_REDFISH_HOSTINTERFACE_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_2_0/EfiHostInterfaceV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_2_0/EfiHostInterfaceV1_2_0.h new file mode 100644 index 00000000000..b973e17aa24 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_2_0/EfiHostInterfaceV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for HostInterface v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_HOSTINTERFACE_V1_2_0_H__ +#define EFI_REDFISH_INTERP_HOSTINTERFACE_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/HostInterface/v1_2_0/Redfish_HostInterface_v1_2_0_CS.h" +// +// EFI structure of Redfish HostInterface v1_2_0 +// +typedef struct _EFI_REDFISH_HOSTINTERFACE_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_HOSTINTERFACE_V1_2_0_CS *HostInterface; +} EFI_REDFISH_HOSTINTERFACE_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_2_1/EfiHostInterfaceV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_2_1/EfiHostInterfaceV1_2_1.h new file mode 100644 index 00000000000..14b882fbf8c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_2_1/EfiHostInterfaceV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for HostInterface v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_HOSTINTERFACE_V1_2_1_H__ +#define EFI_REDFISH_INTERP_HOSTINTERFACE_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/HostInterface/v1_2_1/Redfish_HostInterface_v1_2_1_CS.h" +// +// EFI structure of Redfish HostInterface v1_2_1 +// +typedef struct _EFI_REDFISH_HOSTINTERFACE_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_HOSTINTERFACE_V1_2_1_CS *HostInterface; +} EFI_REDFISH_HOSTINTERFACE_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_2_2/EfiHostInterfaceV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_2_2/EfiHostInterfaceV1_2_2.h new file mode 100644 index 00000000000..7bc19f24999 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_2_2/EfiHostInterfaceV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for HostInterface v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_HOSTINTERFACE_V1_2_2_H__ +#define EFI_REDFISH_INTERP_HOSTINTERFACE_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/HostInterface/v1_2_2/Redfish_HostInterface_v1_2_2_CS.h" +// +// EFI structure of Redfish HostInterface v1_2_2 +// +typedef struct _EFI_REDFISH_HOSTINTERFACE_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_HOSTINTERFACE_V1_2_2_CS *HostInterface; +} EFI_REDFISH_HOSTINTERFACE_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_3_0/EfiHostInterfaceV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_3_0/EfiHostInterfaceV1_3_0.h new file mode 100644 index 00000000000..ccdbda854dc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterface/v1_3_0/EfiHostInterfaceV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for HostInterface v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_HOSTINTERFACE_V1_3_0_H__ +#define EFI_REDFISH_INTERP_HOSTINTERFACE_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/HostInterface/v1_3_0/Redfish_HostInterface_v1_3_0_CS.h" +// +// EFI structure of Redfish HostInterface v1_3_0 +// +typedef struct _EFI_REDFISH_HOSTINTERFACE_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_HOSTINTERFACE_V1_3_0_CS *HostInterface; +} EFI_REDFISH_HOSTINTERFACE_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/HostInterfaceCollection/EfiHostInterfaceCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterfaceCollection/EfiHostInterfaceCollection.h new file mode 100644 index 00000000000..0faeff63ba2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/HostInterfaceCollection/EfiHostInterfaceCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for HostInterfaceCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_HOSTINTERFACECOLLECTION_H__ +#define EFI_REDFISH_INTERP_HOSTINTERFACECOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/HostInterfaceCollection/Redfish_HostInterfaceCollection_CS.h" +// +// EFI structure of Redfish HostInterfaceCollection +// +typedef struct _EFI_REDFISH_HOSTINTERFACECOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_HOSTINTERFACECOLLECTION_CS *HostInterfaceCollection; +} EFI_REDFISH_HOSTINTERFACECOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_0/EfiJobV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_0/EfiJobV1_0_0.h new file mode 100644 index 00000000000..14172e02087 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_0/EfiJobV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Job v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JOB_V1_0_0_H__ +#define EFI_REDFISH_INTERP_JOB_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Job/v1_0_0/Redfish_Job_v1_0_0_CS.h" +// +// EFI structure of Redfish Job v1_0_0 +// +typedef struct _EFI_REDFISH_JOB_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JOB_V1_0_0_CS *Job; +} EFI_REDFISH_JOB_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_1/EfiJobV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_1/EfiJobV1_0_1.h new file mode 100644 index 00000000000..adad4bd17da --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_1/EfiJobV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Job v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JOB_V1_0_1_H__ +#define EFI_REDFISH_INTERP_JOB_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Job/v1_0_1/Redfish_Job_v1_0_1_CS.h" +// +// EFI structure of Redfish Job v1_0_1 +// +typedef struct _EFI_REDFISH_JOB_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JOB_V1_0_1_CS *Job; +} EFI_REDFISH_JOB_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_2/EfiJobV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_2/EfiJobV1_0_2.h new file mode 100644 index 00000000000..c177b292217 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_2/EfiJobV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Job v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JOB_V1_0_2_H__ +#define EFI_REDFISH_INTERP_JOB_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Job/v1_0_2/Redfish_Job_v1_0_2_CS.h" +// +// EFI structure of Redfish Job v1_0_2 +// +typedef struct _EFI_REDFISH_JOB_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JOB_V1_0_2_CS *Job; +} EFI_REDFISH_JOB_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_3/EfiJobV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_3/EfiJobV1_0_3.h new file mode 100644 index 00000000000..14506b99c35 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_3/EfiJobV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Job v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JOB_V1_0_3_H__ +#define EFI_REDFISH_INTERP_JOB_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Job/v1_0_3/Redfish_Job_v1_0_3_CS.h" +// +// EFI structure of Redfish Job v1_0_3 +// +typedef struct _EFI_REDFISH_JOB_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JOB_V1_0_3_CS *Job; +} EFI_REDFISH_JOB_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_4/EfiJobV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_4/EfiJobV1_0_4.h new file mode 100644 index 00000000000..317aa4bdb35 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_4/EfiJobV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Job v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JOB_V1_0_4_H__ +#define EFI_REDFISH_INTERP_JOB_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Job/v1_0_4/Redfish_Job_v1_0_4_CS.h" +// +// EFI structure of Redfish Job v1_0_4 +// +typedef struct _EFI_REDFISH_JOB_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JOB_V1_0_4_CS *Job; +} EFI_REDFISH_JOB_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_5/EfiJobV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_5/EfiJobV1_0_5.h new file mode 100644 index 00000000000..9e2a84c83a7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_5/EfiJobV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Job v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JOB_V1_0_5_H__ +#define EFI_REDFISH_INTERP_JOB_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Job/v1_0_5/Redfish_Job_v1_0_5_CS.h" +// +// EFI structure of Redfish Job v1_0_5 +// +typedef struct _EFI_REDFISH_JOB_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JOB_V1_0_5_CS *Job; +} EFI_REDFISH_JOB_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_6/EfiJobV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_6/EfiJobV1_0_6.h new file mode 100644 index 00000000000..76d808178ee --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Job/v1_0_6/EfiJobV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Job v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JOB_V1_0_6_H__ +#define EFI_REDFISH_INTERP_JOB_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Job/v1_0_6/Redfish_Job_v1_0_6_CS.h" +// +// EFI structure of Redfish Job v1_0_6 +// +typedef struct _EFI_REDFISH_JOB_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JOB_V1_0_6_CS *Job; +} EFI_REDFISH_JOB_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/JobCollection/EfiJobCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/JobCollection/EfiJobCollection.h new file mode 100644 index 00000000000..07c02ad3e0d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/JobCollection/EfiJobCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for JobCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JOBCOLLECTION_H__ +#define EFI_REDFISH_INTERP_JOBCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/JobCollection/Redfish_JobCollection_CS.h" +// +// EFI structure of Redfish JobCollection +// +typedef struct _EFI_REDFISH_JOBCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JOBCOLLECTION_CS *JobCollection; +} EFI_REDFISH_JOBCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/JobService/v1_0_0/EfiJobServiceV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/JobService/v1_0_0/EfiJobServiceV1_0_0.h new file mode 100644 index 00000000000..443611668f3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/JobService/v1_0_0/EfiJobServiceV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for JobService v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JOBSERVICE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_JOBSERVICE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/JobService/v1_0_0/Redfish_JobService_v1_0_0_CS.h" +// +// EFI structure of Redfish JobService v1_0_0 +// +typedef struct _EFI_REDFISH_JOBSERVICE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JOBSERVICE_V1_0_0_CS *JobService; +} EFI_REDFISH_JOBSERVICE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/JobService/v1_0_1/EfiJobServiceV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/JobService/v1_0_1/EfiJobServiceV1_0_1.h new file mode 100644 index 00000000000..d7c50ae3c95 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/JobService/v1_0_1/EfiJobServiceV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for JobService v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JOBSERVICE_V1_0_1_H__ +#define EFI_REDFISH_INTERP_JOBSERVICE_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/JobService/v1_0_1/Redfish_JobService_v1_0_1_CS.h" +// +// EFI structure of Redfish JobService v1_0_1 +// +typedef struct _EFI_REDFISH_JOBSERVICE_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JOBSERVICE_V1_0_1_CS *JobService; +} EFI_REDFISH_JOBSERVICE_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/JobService/v1_0_2/EfiJobServiceV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/JobService/v1_0_2/EfiJobServiceV1_0_2.h new file mode 100644 index 00000000000..852aa80f6a1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/JobService/v1_0_2/EfiJobServiceV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for JobService v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JOBSERVICE_V1_0_2_H__ +#define EFI_REDFISH_INTERP_JOBSERVICE_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/JobService/v1_0_2/Redfish_JobService_v1_0_2_CS.h" +// +// EFI structure of Redfish JobService v1_0_2 +// +typedef struct _EFI_REDFISH_JOBSERVICE_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JOBSERVICE_V1_0_2_CS *JobService; +} EFI_REDFISH_JOBSERVICE_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/JobService/v1_0_3/EfiJobServiceV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/JobService/v1_0_3/EfiJobServiceV1_0_3.h new file mode 100644 index 00000000000..2ccce059d0d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/JobService/v1_0_3/EfiJobServiceV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for JobService v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JOBSERVICE_V1_0_3_H__ +#define EFI_REDFISH_INTERP_JOBSERVICE_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/JobService/v1_0_3/Redfish_JobService_v1_0_3_CS.h" +// +// EFI structure of Redfish JobService v1_0_3 +// +typedef struct _EFI_REDFISH_JOBSERVICE_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JOBSERVICE_V1_0_3_CS *JobService; +} EFI_REDFISH_JOBSERVICE_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/JobService/v1_0_4/EfiJobServiceV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/JobService/v1_0_4/EfiJobServiceV1_0_4.h new file mode 100644 index 00000000000..d12b562a2dc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/JobService/v1_0_4/EfiJobServiceV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for JobService v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JOBSERVICE_V1_0_4_H__ +#define EFI_REDFISH_INTERP_JOBSERVICE_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/JobService/v1_0_4/Redfish_JobService_v1_0_4_CS.h" +// +// EFI structure of Redfish JobService v1_0_4 +// +typedef struct _EFI_REDFISH_JOBSERVICE_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JOBSERVICE_V1_0_4_CS *JobService; +} EFI_REDFISH_JOBSERVICE_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_0/EfiJsonSchemaFileV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_0/EfiJsonSchemaFileV1_0_0.h new file mode 100644 index 00000000000..44dc3cda9d4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_0/EfiJsonSchemaFileV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for JsonSchemaFile v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/JsonSchemaFile/v1_0_0/Redfish_JsonSchemaFile_v1_0_0_CS.h" +// +// EFI structure of Redfish JsonSchemaFile v1_0_0 +// +typedef struct _EFI_REDFISH_JSONSCHEMAFILE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JSONSCHEMAFILE_V1_0_0_CS *JsonSchemaFile; +} EFI_REDFISH_JSONSCHEMAFILE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_2/EfiJsonSchemaFileV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_2/EfiJsonSchemaFileV1_0_2.h new file mode 100644 index 00000000000..91a61f96dd4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_2/EfiJsonSchemaFileV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for JsonSchemaFile v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_0_2_H__ +#define EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/JsonSchemaFile/v1_0_2/Redfish_JsonSchemaFile_v1_0_2_CS.h" +// +// EFI structure of Redfish JsonSchemaFile v1_0_2 +// +typedef struct _EFI_REDFISH_JSONSCHEMAFILE_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JSONSCHEMAFILE_V1_0_2_CS *JsonSchemaFile; +} EFI_REDFISH_JSONSCHEMAFILE_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_3/EfiJsonSchemaFileV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_3/EfiJsonSchemaFileV1_0_3.h new file mode 100644 index 00000000000..b0f670b98c8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_3/EfiJsonSchemaFileV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for JsonSchemaFile v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_0_3_H__ +#define EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/JsonSchemaFile/v1_0_3/Redfish_JsonSchemaFile_v1_0_3_CS.h" +// +// EFI structure of Redfish JsonSchemaFile v1_0_3 +// +typedef struct _EFI_REDFISH_JSONSCHEMAFILE_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JSONSCHEMAFILE_V1_0_3_CS *JsonSchemaFile; +} EFI_REDFISH_JSONSCHEMAFILE_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_4/EfiJsonSchemaFileV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_4/EfiJsonSchemaFileV1_0_4.h new file mode 100644 index 00000000000..1aa4eec68c9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_4/EfiJsonSchemaFileV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for JsonSchemaFile v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_0_4_H__ +#define EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/JsonSchemaFile/v1_0_4/Redfish_JsonSchemaFile_v1_0_4_CS.h" +// +// EFI structure of Redfish JsonSchemaFile v1_0_4 +// +typedef struct _EFI_REDFISH_JSONSCHEMAFILE_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JSONSCHEMAFILE_V1_0_4_CS *JsonSchemaFile; +} EFI_REDFISH_JSONSCHEMAFILE_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_5/EfiJsonSchemaFileV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_5/EfiJsonSchemaFileV1_0_5.h new file mode 100644 index 00000000000..880c3d022b3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_5/EfiJsonSchemaFileV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for JsonSchemaFile v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_0_5_H__ +#define EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/JsonSchemaFile/v1_0_5/Redfish_JsonSchemaFile_v1_0_5_CS.h" +// +// EFI structure of Redfish JsonSchemaFile v1_0_5 +// +typedef struct _EFI_REDFISH_JSONSCHEMAFILE_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JSONSCHEMAFILE_V1_0_5_CS *JsonSchemaFile; +} EFI_REDFISH_JSONSCHEMAFILE_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_6/EfiJsonSchemaFileV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_6/EfiJsonSchemaFileV1_0_6.h new file mode 100644 index 00000000000..531cf7ea230 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_6/EfiJsonSchemaFileV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for JsonSchemaFile v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_0_6_H__ +#define EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/JsonSchemaFile/v1_0_6/Redfish_JsonSchemaFile_v1_0_6_CS.h" +// +// EFI structure of Redfish JsonSchemaFile v1_0_6 +// +typedef struct _EFI_REDFISH_JSONSCHEMAFILE_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JSONSCHEMAFILE_V1_0_6_CS *JsonSchemaFile; +} EFI_REDFISH_JSONSCHEMAFILE_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_7/EfiJsonSchemaFileV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_7/EfiJsonSchemaFileV1_0_7.h new file mode 100644 index 00000000000..d778d448c46 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_7/EfiJsonSchemaFileV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for JsonSchemaFile v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_0_7_H__ +#define EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/JsonSchemaFile/v1_0_7/Redfish_JsonSchemaFile_v1_0_7_CS.h" +// +// EFI structure of Redfish JsonSchemaFile v1_0_7 +// +typedef struct _EFI_REDFISH_JSONSCHEMAFILE_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JSONSCHEMAFILE_V1_0_7_CS *JsonSchemaFile; +} EFI_REDFISH_JSONSCHEMAFILE_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_8/EfiJsonSchemaFileV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_8/EfiJsonSchemaFileV1_0_8.h new file mode 100644 index 00000000000..9e6bc90ddb0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_0_8/EfiJsonSchemaFileV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for JsonSchemaFile v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_0_8_H__ +#define EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/JsonSchemaFile/v1_0_8/Redfish_JsonSchemaFile_v1_0_8_CS.h" +// +// EFI structure of Redfish JsonSchemaFile v1_0_8 +// +typedef struct _EFI_REDFISH_JSONSCHEMAFILE_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JSONSCHEMAFILE_V1_0_8_CS *JsonSchemaFile; +} EFI_REDFISH_JSONSCHEMAFILE_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_1_0/EfiJsonSchemaFileV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_1_0/EfiJsonSchemaFileV1_1_0.h new file mode 100644 index 00000000000..cc9662be3aa --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_1_0/EfiJsonSchemaFileV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for JsonSchemaFile v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_1_0_H__ +#define EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/JsonSchemaFile/v1_1_0/Redfish_JsonSchemaFile_v1_1_0_CS.h" +// +// EFI structure of Redfish JsonSchemaFile v1_1_0 +// +typedef struct _EFI_REDFISH_JSONSCHEMAFILE_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JSONSCHEMAFILE_V1_1_0_CS *JsonSchemaFile; +} EFI_REDFISH_JSONSCHEMAFILE_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_1_1/EfiJsonSchemaFileV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_1_1/EfiJsonSchemaFileV1_1_1.h new file mode 100644 index 00000000000..2e6dca80645 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_1_1/EfiJsonSchemaFileV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for JsonSchemaFile v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_1_1_H__ +#define EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/JsonSchemaFile/v1_1_1/Redfish_JsonSchemaFile_v1_1_1_CS.h" +// +// EFI structure of Redfish JsonSchemaFile v1_1_1 +// +typedef struct _EFI_REDFISH_JSONSCHEMAFILE_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JSONSCHEMAFILE_V1_1_1_CS *JsonSchemaFile; +} EFI_REDFISH_JSONSCHEMAFILE_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_1_2/EfiJsonSchemaFileV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_1_2/EfiJsonSchemaFileV1_1_2.h new file mode 100644 index 00000000000..e569c35c083 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_1_2/EfiJsonSchemaFileV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for JsonSchemaFile v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_1_2_H__ +#define EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/JsonSchemaFile/v1_1_2/Redfish_JsonSchemaFile_v1_1_2_CS.h" +// +// EFI structure of Redfish JsonSchemaFile v1_1_2 +// +typedef struct _EFI_REDFISH_JSONSCHEMAFILE_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JSONSCHEMAFILE_V1_1_2_CS *JsonSchemaFile; +} EFI_REDFISH_JSONSCHEMAFILE_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_1_3/EfiJsonSchemaFileV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_1_3/EfiJsonSchemaFileV1_1_3.h new file mode 100644 index 00000000000..a39a1d35d43 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_1_3/EfiJsonSchemaFileV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for JsonSchemaFile v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_1_3_H__ +#define EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/JsonSchemaFile/v1_1_3/Redfish_JsonSchemaFile_v1_1_3_CS.h" +// +// EFI structure of Redfish JsonSchemaFile v1_1_3 +// +typedef struct _EFI_REDFISH_JSONSCHEMAFILE_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JSONSCHEMAFILE_V1_1_3_CS *JsonSchemaFile; +} EFI_REDFISH_JSONSCHEMAFILE_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_1_4/EfiJsonSchemaFileV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_1_4/EfiJsonSchemaFileV1_1_4.h new file mode 100644 index 00000000000..a71c1b7c860 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFile/v1_1_4/EfiJsonSchemaFileV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for JsonSchemaFile v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_1_4_H__ +#define EFI_REDFISH_INTERP_JSONSCHEMAFILE_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/JsonSchemaFile/v1_1_4/Redfish_JsonSchemaFile_v1_1_4_CS.h" +// +// EFI structure of Redfish JsonSchemaFile v1_1_4 +// +typedef struct _EFI_REDFISH_JSONSCHEMAFILE_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JSONSCHEMAFILE_V1_1_4_CS *JsonSchemaFile; +} EFI_REDFISH_JSONSCHEMAFILE_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFileCollection/EfiJsonSchemaFileCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFileCollection/EfiJsonSchemaFileCollection.h new file mode 100644 index 00000000000..0bad3f5af0e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/JsonSchemaFileCollection/EfiJsonSchemaFileCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for JsonSchemaFileCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_JSONSCHEMAFILECOLLECTION_H__ +#define EFI_REDFISH_INTERP_JSONSCHEMAFILECOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/JsonSchemaFileCollection/Redfish_JsonSchemaFileCollection_CS.h" +// +// EFI structure of Redfish JsonSchemaFileCollection +// +typedef struct _EFI_REDFISH_JSONSCHEMAFILECOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_JSONSCHEMAFILECOLLECTION_CS *JsonSchemaFileCollection; +} EFI_REDFISH_JSONSCHEMAFILECOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_0/EfiLogEntryV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_0/EfiLogEntryV1_0_0.h new file mode 100644 index 00000000000..ff41b931062 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_0/EfiLogEntryV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_0_0_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_0_0/Redfish_LogEntry_v1_0_0_CS.h" +// +// EFI structure of Redfish LogEntry v1_0_0 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_0_0_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_10/EfiLogEntryV1_0_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_10/EfiLogEntryV1_0_10.h new file mode 100644 index 00000000000..f378d4440a4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_10/EfiLogEntryV1_0_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_0_10_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_0_10_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_0_10/Redfish_LogEntry_v1_0_10_CS.h" +// +// EFI structure of Redfish LogEntry v1_0_10 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_0_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_0_10_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_0_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_11/EfiLogEntryV1_0_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_11/EfiLogEntryV1_0_11.h new file mode 100644 index 00000000000..90b30c2c9ce --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_11/EfiLogEntryV1_0_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_0_11_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_0_11_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_0_11/Redfish_LogEntry_v1_0_11_CS.h" +// +// EFI structure of Redfish LogEntry v1_0_11 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_0_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_0_11_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_0_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_12/EfiLogEntryV1_0_12.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_12/EfiLogEntryV1_0_12.h new file mode 100644 index 00000000000..5c9816787a3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_12/EfiLogEntryV1_0_12.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_0_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_0_12_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_0_12_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_0_12/Redfish_LogEntry_v1_0_12_CS.h" +// +// EFI structure of Redfish LogEntry v1_0_12 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_0_12 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_0_12_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_0_12; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_13/EfiLogEntryV1_0_13.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_13/EfiLogEntryV1_0_13.h new file mode 100644 index 00000000000..0982fee757a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_13/EfiLogEntryV1_0_13.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_0_13 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_0_13_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_0_13_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_0_13/Redfish_LogEntry_v1_0_13_CS.h" +// +// EFI structure of Redfish LogEntry v1_0_13 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_0_13 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_0_13_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_0_13; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_14/EfiLogEntryV1_0_14.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_14/EfiLogEntryV1_0_14.h new file mode 100644 index 00000000000..bdb2e25c558 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_14/EfiLogEntryV1_0_14.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_0_14 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_0_14_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_0_14_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_0_14/Redfish_LogEntry_v1_0_14_CS.h" +// +// EFI structure of Redfish LogEntry v1_0_14 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_0_14 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_0_14_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_0_14; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_2/EfiLogEntryV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_2/EfiLogEntryV1_0_2.h new file mode 100644 index 00000000000..cb3a8fd892d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_2/EfiLogEntryV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_0_2_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_0_2/Redfish_LogEntry_v1_0_2_CS.h" +// +// EFI structure of Redfish LogEntry v1_0_2 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_0_2_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_3/EfiLogEntryV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_3/EfiLogEntryV1_0_3.h new file mode 100644 index 00000000000..18e953d3edf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_3/EfiLogEntryV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_0_3_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_0_3/Redfish_LogEntry_v1_0_3_CS.h" +// +// EFI structure of Redfish LogEntry v1_0_3 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_0_3_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_4/EfiLogEntryV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_4/EfiLogEntryV1_0_4.h new file mode 100644 index 00000000000..8ba6ca4d70c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_4/EfiLogEntryV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_0_4_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_0_4/Redfish_LogEntry_v1_0_4_CS.h" +// +// EFI structure of Redfish LogEntry v1_0_4 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_0_4_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_5/EfiLogEntryV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_5/EfiLogEntryV1_0_5.h new file mode 100644 index 00000000000..7bd802fd6ef --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_5/EfiLogEntryV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_0_5_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_0_5/Redfish_LogEntry_v1_0_5_CS.h" +// +// EFI structure of Redfish LogEntry v1_0_5 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_0_5_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_6/EfiLogEntryV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_6/EfiLogEntryV1_0_6.h new file mode 100644 index 00000000000..123cfacc20c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_6/EfiLogEntryV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_0_6_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_0_6/Redfish_LogEntry_v1_0_6_CS.h" +// +// EFI structure of Redfish LogEntry v1_0_6 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_0_6_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_7/EfiLogEntryV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_7/EfiLogEntryV1_0_7.h new file mode 100644 index 00000000000..909b11ec35c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_7/EfiLogEntryV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_0_7_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_0_7/Redfish_LogEntry_v1_0_7_CS.h" +// +// EFI structure of Redfish LogEntry v1_0_7 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_0_7_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_8/EfiLogEntryV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_8/EfiLogEntryV1_0_8.h new file mode 100644 index 00000000000..d3143eaeb4b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_8/EfiLogEntryV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_0_8_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_0_8/Redfish_LogEntry_v1_0_8_CS.h" +// +// EFI structure of Redfish LogEntry v1_0_8 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_0_8_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_9/EfiLogEntryV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_9/EfiLogEntryV1_0_9.h new file mode 100644 index 00000000000..f7b36e232f2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_0_9/EfiLogEntryV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_0_9_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_0_9/Redfish_LogEntry_v1_0_9_CS.h" +// +// EFI structure of Redfish LogEntry v1_0_9 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_0_9_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_0/EfiLogEntryV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_0/EfiLogEntryV1_1_0.h new file mode 100644 index 00000000000..029aa2c1050 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_0/EfiLogEntryV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_1_0_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_1_0/Redfish_LogEntry_v1_1_0_CS.h" +// +// EFI structure of Redfish LogEntry v1_1_0 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_1_0_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_1/EfiLogEntryV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_1/EfiLogEntryV1_1_1.h new file mode 100644 index 00000000000..2b9674435d3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_1/EfiLogEntryV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_1_1_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_1_1/Redfish_LogEntry_v1_1_1_CS.h" +// +// EFI structure of Redfish LogEntry v1_1_1 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_1_1_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_10/EfiLogEntryV1_1_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_10/EfiLogEntryV1_1_10.h new file mode 100644 index 00000000000..3fde846d22c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_10/EfiLogEntryV1_1_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_1_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_1_10_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_1_10_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_1_10/Redfish_LogEntry_v1_1_10_CS.h" +// +// EFI structure of Redfish LogEntry v1_1_10 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_1_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_1_10_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_1_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_11/EfiLogEntryV1_1_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_11/EfiLogEntryV1_1_11.h new file mode 100644 index 00000000000..7d798c1b293 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_11/EfiLogEntryV1_1_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_1_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_1_11_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_1_11_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_1_11/Redfish_LogEntry_v1_1_11_CS.h" +// +// EFI structure of Redfish LogEntry v1_1_11 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_1_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_1_11_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_1_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_12/EfiLogEntryV1_1_12.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_12/EfiLogEntryV1_1_12.h new file mode 100644 index 00000000000..1575acd4929 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_12/EfiLogEntryV1_1_12.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_1_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_1_12_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_1_12_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_1_12/Redfish_LogEntry_v1_1_12_CS.h" +// +// EFI structure of Redfish LogEntry v1_1_12 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_1_12 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_1_12_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_1_12; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_2/EfiLogEntryV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_2/EfiLogEntryV1_1_2.h new file mode 100644 index 00000000000..34dd625aa3b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_2/EfiLogEntryV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_1_2_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_1_2/Redfish_LogEntry_v1_1_2_CS.h" +// +// EFI structure of Redfish LogEntry v1_1_2 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_1_2_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_3/EfiLogEntryV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_3/EfiLogEntryV1_1_3.h new file mode 100644 index 00000000000..562d03156ce --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_3/EfiLogEntryV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_1_3_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_1_3/Redfish_LogEntry_v1_1_3_CS.h" +// +// EFI structure of Redfish LogEntry v1_1_3 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_1_3_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_4/EfiLogEntryV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_4/EfiLogEntryV1_1_4.h new file mode 100644 index 00000000000..f53e3ca93b3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_4/EfiLogEntryV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_1_4_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_1_4/Redfish_LogEntry_v1_1_4_CS.h" +// +// EFI structure of Redfish LogEntry v1_1_4 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_1_4_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_5/EfiLogEntryV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_5/EfiLogEntryV1_1_5.h new file mode 100644 index 00000000000..80a223f0f4c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_5/EfiLogEntryV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_1_5_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_1_5/Redfish_LogEntry_v1_1_5_CS.h" +// +// EFI structure of Redfish LogEntry v1_1_5 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_1_5_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_6/EfiLogEntryV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_6/EfiLogEntryV1_1_6.h new file mode 100644 index 00000000000..32b5e298620 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_6/EfiLogEntryV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_1_6_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_1_6/Redfish_LogEntry_v1_1_6_CS.h" +// +// EFI structure of Redfish LogEntry v1_1_6 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_1_6_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_7/EfiLogEntryV1_1_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_7/EfiLogEntryV1_1_7.h new file mode 100644 index 00000000000..593500258c7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_7/EfiLogEntryV1_1_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_1_7_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_1_7_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_1_7/Redfish_LogEntry_v1_1_7_CS.h" +// +// EFI structure of Redfish LogEntry v1_1_7 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_1_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_1_7_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_1_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_8/EfiLogEntryV1_1_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_8/EfiLogEntryV1_1_8.h new file mode 100644 index 00000000000..5add00e26df --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_8/EfiLogEntryV1_1_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_1_8_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_1_8_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_1_8/Redfish_LogEntry_v1_1_8_CS.h" +// +// EFI structure of Redfish LogEntry v1_1_8 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_1_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_1_8_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_1_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_9/EfiLogEntryV1_1_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_9/EfiLogEntryV1_1_9.h new file mode 100644 index 00000000000..a55ac984518 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_1_9/EfiLogEntryV1_1_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_1_9_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_1_9_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_1_9/Redfish_LogEntry_v1_1_9_CS.h" +// +// EFI structure of Redfish LogEntry v1_1_9 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_1_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_1_9_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_1_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_0/EfiLogEntryV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_0/EfiLogEntryV1_2_0.h new file mode 100644 index 00000000000..692bfa04d6c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_0/EfiLogEntryV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_2_0_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_2_0/Redfish_LogEntry_v1_2_0_CS.h" +// +// EFI structure of Redfish LogEntry v1_2_0 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_2_0_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_1/EfiLogEntryV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_1/EfiLogEntryV1_2_1.h new file mode 100644 index 00000000000..01eadf6f668 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_1/EfiLogEntryV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_2_1_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_2_1/Redfish_LogEntry_v1_2_1_CS.h" +// +// EFI structure of Redfish LogEntry v1_2_1 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_2_1_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_10/EfiLogEntryV1_2_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_10/EfiLogEntryV1_2_10.h new file mode 100644 index 00000000000..2069f15dfc5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_10/EfiLogEntryV1_2_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_2_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_2_10_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_2_10_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_2_10/Redfish_LogEntry_v1_2_10_CS.h" +// +// EFI structure of Redfish LogEntry v1_2_10 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_2_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_2_10_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_2_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_2/EfiLogEntryV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_2/EfiLogEntryV1_2_2.h new file mode 100644 index 00000000000..74ecf3f0e22 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_2/EfiLogEntryV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_2_2_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_2_2/Redfish_LogEntry_v1_2_2_CS.h" +// +// EFI structure of Redfish LogEntry v1_2_2 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_2_2_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_3/EfiLogEntryV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_3/EfiLogEntryV1_2_3.h new file mode 100644 index 00000000000..b47f23a342a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_3/EfiLogEntryV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_2_3_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_2_3/Redfish_LogEntry_v1_2_3_CS.h" +// +// EFI structure of Redfish LogEntry v1_2_3 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_2_3_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_4/EfiLogEntryV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_4/EfiLogEntryV1_2_4.h new file mode 100644 index 00000000000..a2457bd5b92 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_4/EfiLogEntryV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_2_4_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_2_4/Redfish_LogEntry_v1_2_4_CS.h" +// +// EFI structure of Redfish LogEntry v1_2_4 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_2_4_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_5/EfiLogEntryV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_5/EfiLogEntryV1_2_5.h new file mode 100644 index 00000000000..eafb9195209 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_5/EfiLogEntryV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_2_5_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_2_5/Redfish_LogEntry_v1_2_5_CS.h" +// +// EFI structure of Redfish LogEntry v1_2_5 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_2_5_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_6/EfiLogEntryV1_2_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_6/EfiLogEntryV1_2_6.h new file mode 100644 index 00000000000..15312f3a3d5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_6/EfiLogEntryV1_2_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_2_6_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_2_6_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_2_6/Redfish_LogEntry_v1_2_6_CS.h" +// +// EFI structure of Redfish LogEntry v1_2_6 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_2_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_2_6_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_2_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_7/EfiLogEntryV1_2_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_7/EfiLogEntryV1_2_7.h new file mode 100644 index 00000000000..a01922069cf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_7/EfiLogEntryV1_2_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_2_7_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_2_7_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_2_7/Redfish_LogEntry_v1_2_7_CS.h" +// +// EFI structure of Redfish LogEntry v1_2_7 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_2_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_2_7_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_2_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_8/EfiLogEntryV1_2_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_8/EfiLogEntryV1_2_8.h new file mode 100644 index 00000000000..9afb122d278 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_8/EfiLogEntryV1_2_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_2_8_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_2_8_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_2_8/Redfish_LogEntry_v1_2_8_CS.h" +// +// EFI structure of Redfish LogEntry v1_2_8 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_2_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_2_8_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_2_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_9/EfiLogEntryV1_2_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_9/EfiLogEntryV1_2_9.h new file mode 100644 index 00000000000..bde415e9293 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_2_9/EfiLogEntryV1_2_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_2_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_2_9_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_2_9_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_2_9/Redfish_LogEntry_v1_2_9_CS.h" +// +// EFI structure of Redfish LogEntry v1_2_9 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_2_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_2_9_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_2_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_0/EfiLogEntryV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_0/EfiLogEntryV1_3_0.h new file mode 100644 index 00000000000..afa0aa6012f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_0/EfiLogEntryV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_3_0_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_3_0/Redfish_LogEntry_v1_3_0_CS.h" +// +// EFI structure of Redfish LogEntry v1_3_0 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_3_0_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_1/EfiLogEntryV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_1/EfiLogEntryV1_3_1.h new file mode 100644 index 00000000000..1c0d80e7efb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_1/EfiLogEntryV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_3_1_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_3_1/Redfish_LogEntry_v1_3_1_CS.h" +// +// EFI structure of Redfish LogEntry v1_3_1 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_3_1_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_2/EfiLogEntryV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_2/EfiLogEntryV1_3_2.h new file mode 100644 index 00000000000..65d3ea068d8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_2/EfiLogEntryV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_3_2_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_3_2/Redfish_LogEntry_v1_3_2_CS.h" +// +// EFI structure of Redfish LogEntry v1_3_2 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_3_2_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_3/EfiLogEntryV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_3/EfiLogEntryV1_3_3.h new file mode 100644 index 00000000000..83fa66b2b92 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_3/EfiLogEntryV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_3_3_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_3_3/Redfish_LogEntry_v1_3_3_CS.h" +// +// EFI structure of Redfish LogEntry v1_3_3 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_3_3_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_4/EfiLogEntryV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_4/EfiLogEntryV1_3_4.h new file mode 100644 index 00000000000..05b7feb03ff --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_4/EfiLogEntryV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_3_4_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_3_4/Redfish_LogEntry_v1_3_4_CS.h" +// +// EFI structure of Redfish LogEntry v1_3_4 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_3_4_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_5/EfiLogEntryV1_3_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_5/EfiLogEntryV1_3_5.h new file mode 100644 index 00000000000..de735043946 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_5/EfiLogEntryV1_3_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_3_5_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_3_5_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_3_5/Redfish_LogEntry_v1_3_5_CS.h" +// +// EFI structure of Redfish LogEntry v1_3_5 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_3_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_3_5_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_3_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_6/EfiLogEntryV1_3_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_6/EfiLogEntryV1_3_6.h new file mode 100644 index 00000000000..cac99d43303 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_6/EfiLogEntryV1_3_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_3_6_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_3_6_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_3_6/Redfish_LogEntry_v1_3_6_CS.h" +// +// EFI structure of Redfish LogEntry v1_3_6 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_3_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_3_6_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_3_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_7/EfiLogEntryV1_3_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_7/EfiLogEntryV1_3_7.h new file mode 100644 index 00000000000..39a3907ad68 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_7/EfiLogEntryV1_3_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_3_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_3_7_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_3_7_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_3_7/Redfish_LogEntry_v1_3_7_CS.h" +// +// EFI structure of Redfish LogEntry v1_3_7 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_3_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_3_7_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_3_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_8/EfiLogEntryV1_3_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_8/EfiLogEntryV1_3_8.h new file mode 100644 index 00000000000..a158d26e68d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_8/EfiLogEntryV1_3_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_3_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_3_8_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_3_8_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_3_8/Redfish_LogEntry_v1_3_8_CS.h" +// +// EFI structure of Redfish LogEntry v1_3_8 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_3_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_3_8_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_3_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_9/EfiLogEntryV1_3_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_9/EfiLogEntryV1_3_9.h new file mode 100644 index 00000000000..8295b139972 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_3_9/EfiLogEntryV1_3_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_3_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_3_9_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_3_9_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_3_9/Redfish_LogEntry_v1_3_9_CS.h" +// +// EFI structure of Redfish LogEntry v1_3_9 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_3_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_3_9_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_3_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_0/EfiLogEntryV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_0/EfiLogEntryV1_4_0.h new file mode 100644 index 00000000000..3b501996582 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_0/EfiLogEntryV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_4_0_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_4_0/Redfish_LogEntry_v1_4_0_CS.h" +// +// EFI structure of Redfish LogEntry v1_4_0 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_4_0_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_1/EfiLogEntryV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_1/EfiLogEntryV1_4_1.h new file mode 100644 index 00000000000..8e92d6c8205 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_1/EfiLogEntryV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_4_1_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_4_1/Redfish_LogEntry_v1_4_1_CS.h" +// +// EFI structure of Redfish LogEntry v1_4_1 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_4_1_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_2/EfiLogEntryV1_4_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_2/EfiLogEntryV1_4_2.h new file mode 100644 index 00000000000..b4e7db509e0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_2/EfiLogEntryV1_4_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_4_2_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_4_2_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_4_2/Redfish_LogEntry_v1_4_2_CS.h" +// +// EFI structure of Redfish LogEntry v1_4_2 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_4_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_4_2_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_4_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_3/EfiLogEntryV1_4_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_3/EfiLogEntryV1_4_3.h new file mode 100644 index 00000000000..7e0dd253557 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_3/EfiLogEntryV1_4_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_4_3_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_4_3_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_4_3/Redfish_LogEntry_v1_4_3_CS.h" +// +// EFI structure of Redfish LogEntry v1_4_3 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_4_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_4_3_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_4_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_4/EfiLogEntryV1_4_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_4/EfiLogEntryV1_4_4.h new file mode 100644 index 00000000000..d71cad3267f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_4/EfiLogEntryV1_4_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_4_4_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_4_4_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_4_4/Redfish_LogEntry_v1_4_4_CS.h" +// +// EFI structure of Redfish LogEntry v1_4_4 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_4_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_4_4_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_4_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_5/EfiLogEntryV1_4_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_5/EfiLogEntryV1_4_5.h new file mode 100644 index 00000000000..232ad9c48e2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_5/EfiLogEntryV1_4_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_4_5_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_4_5_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_4_5/Redfish_LogEntry_v1_4_5_CS.h" +// +// EFI structure of Redfish LogEntry v1_4_5 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_4_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_4_5_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_4_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_6/EfiLogEntryV1_4_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_6/EfiLogEntryV1_4_6.h new file mode 100644 index 00000000000..370da31f2d3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_6/EfiLogEntryV1_4_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_4_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_4_6_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_4_6_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_4_6/Redfish_LogEntry_v1_4_6_CS.h" +// +// EFI structure of Redfish LogEntry v1_4_6 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_4_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_4_6_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_4_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_7/EfiLogEntryV1_4_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_7/EfiLogEntryV1_4_7.h new file mode 100644 index 00000000000..28e3a60539f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_7/EfiLogEntryV1_4_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_4_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_4_7_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_4_7_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_4_7/Redfish_LogEntry_v1_4_7_CS.h" +// +// EFI structure of Redfish LogEntry v1_4_7 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_4_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_4_7_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_4_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_8/EfiLogEntryV1_4_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_8/EfiLogEntryV1_4_8.h new file mode 100644 index 00000000000..948272c6c81 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_4_8/EfiLogEntryV1_4_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_4_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_4_8_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_4_8_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_4_8/Redfish_LogEntry_v1_4_8_CS.h" +// +// EFI structure of Redfish LogEntry v1_4_8 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_4_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_4_8_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_4_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_5_0/EfiLogEntryV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_5_0/EfiLogEntryV1_5_0.h new file mode 100644 index 00000000000..f86a9475a5f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_5_0/EfiLogEntryV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_5_0_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_5_0/Redfish_LogEntry_v1_5_0_CS.h" +// +// EFI structure of Redfish LogEntry v1_5_0 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_5_0_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_5_1/EfiLogEntryV1_5_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_5_1/EfiLogEntryV1_5_1.h new file mode 100644 index 00000000000..1ee2582c251 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_5_1/EfiLogEntryV1_5_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_5_1_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_5_1_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_5_1/Redfish_LogEntry_v1_5_1_CS.h" +// +// EFI structure of Redfish LogEntry v1_5_1 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_5_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_5_1_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_5_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_5_2/EfiLogEntryV1_5_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_5_2/EfiLogEntryV1_5_2.h new file mode 100644 index 00000000000..c94d098fb96 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_5_2/EfiLogEntryV1_5_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_5_2_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_5_2_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_5_2/Redfish_LogEntry_v1_5_2_CS.h" +// +// EFI structure of Redfish LogEntry v1_5_2 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_5_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_5_2_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_5_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_5_3/EfiLogEntryV1_5_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_5_3/EfiLogEntryV1_5_3.h new file mode 100644 index 00000000000..e8c4c45737e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_5_3/EfiLogEntryV1_5_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_5_3_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_5_3_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_5_3/Redfish_LogEntry_v1_5_3_CS.h" +// +// EFI structure of Redfish LogEntry v1_5_3 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_5_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_5_3_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_5_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_5_4/EfiLogEntryV1_5_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_5_4/EfiLogEntryV1_5_4.h new file mode 100644 index 00000000000..454995e0947 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_5_4/EfiLogEntryV1_5_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_5_4_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_5_4_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_5_4/Redfish_LogEntry_v1_5_4_CS.h" +// +// EFI structure of Redfish LogEntry v1_5_4 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_5_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_5_4_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_5_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_6_0/EfiLogEntryV1_6_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_6_0/EfiLogEntryV1_6_0.h new file mode 100644 index 00000000000..d967a7a939e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_6_0/EfiLogEntryV1_6_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_6_0_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_6_0_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_6_0/Redfish_LogEntry_v1_6_0_CS.h" +// +// EFI structure of Redfish LogEntry v1_6_0 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_6_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_6_0_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_6_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_6_1/EfiLogEntryV1_6_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_6_1/EfiLogEntryV1_6_1.h new file mode 100644 index 00000000000..027f76d5843 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_6_1/EfiLogEntryV1_6_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_6_1_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_6_1_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_6_1/Redfish_LogEntry_v1_6_1_CS.h" +// +// EFI structure of Redfish LogEntry v1_6_1 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_6_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_6_1_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_6_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_6_2/EfiLogEntryV1_6_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_6_2/EfiLogEntryV1_6_2.h new file mode 100644 index 00000000000..196012c716c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_6_2/EfiLogEntryV1_6_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_6_2_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_6_2_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_6_2/Redfish_LogEntry_v1_6_2_CS.h" +// +// EFI structure of Redfish LogEntry v1_6_2 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_6_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_6_2_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_6_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_6_3/EfiLogEntryV1_6_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_6_3/EfiLogEntryV1_6_3.h new file mode 100644 index 00000000000..41f7d9a71b4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_6_3/EfiLogEntryV1_6_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_6_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_6_3_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_6_3_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_6_3/Redfish_LogEntry_v1_6_3_CS.h" +// +// EFI structure of Redfish LogEntry v1_6_3 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_6_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_6_3_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_6_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_7_0/EfiLogEntryV1_7_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_7_0/EfiLogEntryV1_7_0.h new file mode 100644 index 00000000000..2c92a18af0a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_7_0/EfiLogEntryV1_7_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_7_0_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_7_0_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_7_0/Redfish_LogEntry_v1_7_0_CS.h" +// +// EFI structure of Redfish LogEntry v1_7_0 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_7_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_7_0_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_7_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_7_1/EfiLogEntryV1_7_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_7_1/EfiLogEntryV1_7_1.h new file mode 100644 index 00000000000..1454758575c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_7_1/EfiLogEntryV1_7_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_7_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_7_1_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_7_1_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_7_1/Redfish_LogEntry_v1_7_1_CS.h" +// +// EFI structure of Redfish LogEntry v1_7_1 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_7_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_7_1_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_7_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_8_0/EfiLogEntryV1_8_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_8_0/EfiLogEntryV1_8_0.h new file mode 100644 index 00000000000..a567cbd5c18 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntry/v1_8_0/EfiLogEntryV1_8_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntry v1_8_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRY_V1_8_0_H__ +#define EFI_REDFISH_INTERP_LOGENTRY_V1_8_0_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntry/v1_8_0/Redfish_LogEntry_v1_8_0_CS.h" +// +// EFI structure of Redfish LogEntry v1_8_0 +// +typedef struct _EFI_REDFISH_LOGENTRY_V1_8_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRY_V1_8_0_CS *LogEntry; +} EFI_REDFISH_LOGENTRY_V1_8_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogEntryCollection/EfiLogEntryCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntryCollection/EfiLogEntryCollection.h new file mode 100644 index 00000000000..aec84a3f478 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogEntryCollection/EfiLogEntryCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogEntryCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGENTRYCOLLECTION_H__ +#define EFI_REDFISH_INTERP_LOGENTRYCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/LogEntryCollection/Redfish_LogEntryCollection_CS.h" +// +// EFI structure of Redfish LogEntryCollection +// +typedef struct _EFI_REDFISH_LOGENTRYCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGENTRYCOLLECTION_CS *LogEntryCollection; +} EFI_REDFISH_LOGENTRYCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_0/EfiLogServiceV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_0/EfiLogServiceV1_0_0.h new file mode 100644 index 00000000000..7f24bff4679 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_0/EfiLogServiceV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogService v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGSERVICE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_LOGSERVICE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/LogService/v1_0_0/Redfish_LogService_v1_0_0_CS.h" +// +// EFI structure of Redfish LogService v1_0_0 +// +typedef struct _EFI_REDFISH_LOGSERVICE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGSERVICE_V1_0_0_CS *LogService; +} EFI_REDFISH_LOGSERVICE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_2/EfiLogServiceV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_2/EfiLogServiceV1_0_2.h new file mode 100644 index 00000000000..6e493e064cf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_2/EfiLogServiceV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogService v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGSERVICE_V1_0_2_H__ +#define EFI_REDFISH_INTERP_LOGSERVICE_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/LogService/v1_0_2/Redfish_LogService_v1_0_2_CS.h" +// +// EFI structure of Redfish LogService v1_0_2 +// +typedef struct _EFI_REDFISH_LOGSERVICE_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGSERVICE_V1_0_2_CS *LogService; +} EFI_REDFISH_LOGSERVICE_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_3/EfiLogServiceV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_3/EfiLogServiceV1_0_3.h new file mode 100644 index 00000000000..eac4b188cd3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_3/EfiLogServiceV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogService v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGSERVICE_V1_0_3_H__ +#define EFI_REDFISH_INTERP_LOGSERVICE_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/LogService/v1_0_3/Redfish_LogService_v1_0_3_CS.h" +// +// EFI structure of Redfish LogService v1_0_3 +// +typedef struct _EFI_REDFISH_LOGSERVICE_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGSERVICE_V1_0_3_CS *LogService; +} EFI_REDFISH_LOGSERVICE_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_4/EfiLogServiceV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_4/EfiLogServiceV1_0_4.h new file mode 100644 index 00000000000..05a22e289a8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_4/EfiLogServiceV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogService v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGSERVICE_V1_0_4_H__ +#define EFI_REDFISH_INTERP_LOGSERVICE_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/LogService/v1_0_4/Redfish_LogService_v1_0_4_CS.h" +// +// EFI structure of Redfish LogService v1_0_4 +// +typedef struct _EFI_REDFISH_LOGSERVICE_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGSERVICE_V1_0_4_CS *LogService; +} EFI_REDFISH_LOGSERVICE_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_5/EfiLogServiceV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_5/EfiLogServiceV1_0_5.h new file mode 100644 index 00000000000..975a0516543 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_5/EfiLogServiceV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogService v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGSERVICE_V1_0_5_H__ +#define EFI_REDFISH_INTERP_LOGSERVICE_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/LogService/v1_0_5/Redfish_LogService_v1_0_5_CS.h" +// +// EFI structure of Redfish LogService v1_0_5 +// +typedef struct _EFI_REDFISH_LOGSERVICE_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGSERVICE_V1_0_5_CS *LogService; +} EFI_REDFISH_LOGSERVICE_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_6/EfiLogServiceV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_6/EfiLogServiceV1_0_6.h new file mode 100644 index 00000000000..4383d91739d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_6/EfiLogServiceV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogService v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGSERVICE_V1_0_6_H__ +#define EFI_REDFISH_INTERP_LOGSERVICE_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/LogService/v1_0_6/Redfish_LogService_v1_0_6_CS.h" +// +// EFI structure of Redfish LogService v1_0_6 +// +typedef struct _EFI_REDFISH_LOGSERVICE_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGSERVICE_V1_0_6_CS *LogService; +} EFI_REDFISH_LOGSERVICE_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_7/EfiLogServiceV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_7/EfiLogServiceV1_0_7.h new file mode 100644 index 00000000000..5238321ab33 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_7/EfiLogServiceV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogService v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGSERVICE_V1_0_7_H__ +#define EFI_REDFISH_INTERP_LOGSERVICE_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/LogService/v1_0_7/Redfish_LogService_v1_0_7_CS.h" +// +// EFI structure of Redfish LogService v1_0_7 +// +typedef struct _EFI_REDFISH_LOGSERVICE_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGSERVICE_V1_0_7_CS *LogService; +} EFI_REDFISH_LOGSERVICE_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_8/EfiLogServiceV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_8/EfiLogServiceV1_0_8.h new file mode 100644 index 00000000000..3d291f66c3d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_0_8/EfiLogServiceV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogService v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGSERVICE_V1_0_8_H__ +#define EFI_REDFISH_INTERP_LOGSERVICE_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/LogService/v1_0_8/Redfish_LogService_v1_0_8_CS.h" +// +// EFI structure of Redfish LogService v1_0_8 +// +typedef struct _EFI_REDFISH_LOGSERVICE_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGSERVICE_V1_0_8_CS *LogService; +} EFI_REDFISH_LOGSERVICE_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_1_0/EfiLogServiceV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_1_0/EfiLogServiceV1_1_0.h new file mode 100644 index 00000000000..e0e9c1fb03b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_1_0/EfiLogServiceV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogService v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGSERVICE_V1_1_0_H__ +#define EFI_REDFISH_INTERP_LOGSERVICE_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/LogService/v1_1_0/Redfish_LogService_v1_1_0_CS.h" +// +// EFI structure of Redfish LogService v1_1_0 +// +typedef struct _EFI_REDFISH_LOGSERVICE_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGSERVICE_V1_1_0_CS *LogService; +} EFI_REDFISH_LOGSERVICE_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_1_1/EfiLogServiceV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_1_1/EfiLogServiceV1_1_1.h new file mode 100644 index 00000000000..aa7c2a94aea --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_1_1/EfiLogServiceV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogService v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGSERVICE_V1_1_1_H__ +#define EFI_REDFISH_INTERP_LOGSERVICE_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/LogService/v1_1_1/Redfish_LogService_v1_1_1_CS.h" +// +// EFI structure of Redfish LogService v1_1_1 +// +typedef struct _EFI_REDFISH_LOGSERVICE_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGSERVICE_V1_1_1_CS *LogService; +} EFI_REDFISH_LOGSERVICE_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_1_2/EfiLogServiceV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_1_2/EfiLogServiceV1_1_2.h new file mode 100644 index 00000000000..02e70274223 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_1_2/EfiLogServiceV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogService v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGSERVICE_V1_1_2_H__ +#define EFI_REDFISH_INTERP_LOGSERVICE_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/LogService/v1_1_2/Redfish_LogService_v1_1_2_CS.h" +// +// EFI structure of Redfish LogService v1_1_2 +// +typedef struct _EFI_REDFISH_LOGSERVICE_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGSERVICE_V1_1_2_CS *LogService; +} EFI_REDFISH_LOGSERVICE_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_1_3/EfiLogServiceV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_1_3/EfiLogServiceV1_1_3.h new file mode 100644 index 00000000000..e8cadff60fd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_1_3/EfiLogServiceV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogService v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGSERVICE_V1_1_3_H__ +#define EFI_REDFISH_INTERP_LOGSERVICE_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/LogService/v1_1_3/Redfish_LogService_v1_1_3_CS.h" +// +// EFI structure of Redfish LogService v1_1_3 +// +typedef struct _EFI_REDFISH_LOGSERVICE_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGSERVICE_V1_1_3_CS *LogService; +} EFI_REDFISH_LOGSERVICE_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_2_0/EfiLogServiceV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_2_0/EfiLogServiceV1_2_0.h new file mode 100644 index 00000000000..c6017465e80 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogService/v1_2_0/EfiLogServiceV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogService v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGSERVICE_V1_2_0_H__ +#define EFI_REDFISH_INTERP_LOGSERVICE_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/LogService/v1_2_0/Redfish_LogService_v1_2_0_CS.h" +// +// EFI structure of Redfish LogService v1_2_0 +// +typedef struct _EFI_REDFISH_LOGSERVICE_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGSERVICE_V1_2_0_CS *LogService; +} EFI_REDFISH_LOGSERVICE_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/LogServiceCollection/EfiLogServiceCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/LogServiceCollection/EfiLogServiceCollection.h new file mode 100644 index 00000000000..08e8c235744 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/LogServiceCollection/EfiLogServiceCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for LogServiceCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_LOGSERVICECOLLECTION_H__ +#define EFI_REDFISH_INTERP_LOGSERVICECOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/LogServiceCollection/Redfish_LogServiceCollection_CS.h" +// +// EFI structure of Redfish LogServiceCollection +// +typedef struct _EFI_REDFISH_LOGSERVICECOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_LOGSERVICECOLLECTION_CS *LogServiceCollection; +} EFI_REDFISH_LOGSERVICECOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_0/EfiManagerV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_0/EfiManagerV1_0_0.h new file mode 100644 index 00000000000..1efc528f951 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_0/EfiManagerV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_0_0_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_0_0/Redfish_Manager_v1_0_0_CS.h" +// +// EFI structure of Redfish Manager v1_0_0 +// +typedef struct _EFI_REDFISH_MANAGER_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_0_0_CS *Manager; +} EFI_REDFISH_MANAGER_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_1/EfiManagerV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_1/EfiManagerV1_0_1.h new file mode 100644 index 00000000000..20bcab9a9fe --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_1/EfiManagerV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_0_1_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_0_1/Redfish_Manager_v1_0_1_CS.h" +// +// EFI structure of Redfish Manager v1_0_1 +// +typedef struct _EFI_REDFISH_MANAGER_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_0_1_CS *Manager; +} EFI_REDFISH_MANAGER_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_10/EfiManagerV1_0_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_10/EfiManagerV1_0_10.h new file mode 100644 index 00000000000..49f0083c6e0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_10/EfiManagerV1_0_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_0_10_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_0_10_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_0_10/Redfish_Manager_v1_0_10_CS.h" +// +// EFI structure of Redfish Manager v1_0_10 +// +typedef struct _EFI_REDFISH_MANAGER_V1_0_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_0_10_CS *Manager; +} EFI_REDFISH_MANAGER_V1_0_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_11/EfiManagerV1_0_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_11/EfiManagerV1_0_11.h new file mode 100644 index 00000000000..85e9897121a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_11/EfiManagerV1_0_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_0_11_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_0_11_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_0_11/Redfish_Manager_v1_0_11_CS.h" +// +// EFI structure of Redfish Manager v1_0_11 +// +typedef struct _EFI_REDFISH_MANAGER_V1_0_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_0_11_CS *Manager; +} EFI_REDFISH_MANAGER_V1_0_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_12/EfiManagerV1_0_12.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_12/EfiManagerV1_0_12.h new file mode 100644 index 00000000000..28990c03efa --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_12/EfiManagerV1_0_12.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_0_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_0_12_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_0_12_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_0_12/Redfish_Manager_v1_0_12_CS.h" +// +// EFI structure of Redfish Manager v1_0_12 +// +typedef struct _EFI_REDFISH_MANAGER_V1_0_12 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_0_12_CS *Manager; +} EFI_REDFISH_MANAGER_V1_0_12; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_13/EfiManagerV1_0_13.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_13/EfiManagerV1_0_13.h new file mode 100644 index 00000000000..710b01bfa30 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_13/EfiManagerV1_0_13.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_0_13 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_0_13_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_0_13_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_0_13/Redfish_Manager_v1_0_13_CS.h" +// +// EFI structure of Redfish Manager v1_0_13 +// +typedef struct _EFI_REDFISH_MANAGER_V1_0_13 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_0_13_CS *Manager; +} EFI_REDFISH_MANAGER_V1_0_13; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_14/EfiManagerV1_0_14.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_14/EfiManagerV1_0_14.h new file mode 100644 index 00000000000..40d8ca36590 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_14/EfiManagerV1_0_14.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_0_14 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_0_14_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_0_14_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_0_14/Redfish_Manager_v1_0_14_CS.h" +// +// EFI structure of Redfish Manager v1_0_14 +// +typedef struct _EFI_REDFISH_MANAGER_V1_0_14 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_0_14_CS *Manager; +} EFI_REDFISH_MANAGER_V1_0_14; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_2/EfiManagerV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_2/EfiManagerV1_0_2.h new file mode 100644 index 00000000000..7cd94766677 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_2/EfiManagerV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_0_2_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_0_2/Redfish_Manager_v1_0_2_CS.h" +// +// EFI structure of Redfish Manager v1_0_2 +// +typedef struct _EFI_REDFISH_MANAGER_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_0_2_CS *Manager; +} EFI_REDFISH_MANAGER_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_3/EfiManagerV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_3/EfiManagerV1_0_3.h new file mode 100644 index 00000000000..77b5b7fdb8c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_3/EfiManagerV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_0_3_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_0_3/Redfish_Manager_v1_0_3_CS.h" +// +// EFI structure of Redfish Manager v1_0_3 +// +typedef struct _EFI_REDFISH_MANAGER_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_0_3_CS *Manager; +} EFI_REDFISH_MANAGER_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_4/EfiManagerV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_4/EfiManagerV1_0_4.h new file mode 100644 index 00000000000..fcba13abc2d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_4/EfiManagerV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_0_4_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_0_4/Redfish_Manager_v1_0_4_CS.h" +// +// EFI structure of Redfish Manager v1_0_4 +// +typedef struct _EFI_REDFISH_MANAGER_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_0_4_CS *Manager; +} EFI_REDFISH_MANAGER_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_5/EfiManagerV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_5/EfiManagerV1_0_5.h new file mode 100644 index 00000000000..9c4fb2a75c0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_5/EfiManagerV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_0_5_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_0_5/Redfish_Manager_v1_0_5_CS.h" +// +// EFI structure of Redfish Manager v1_0_5 +// +typedef struct _EFI_REDFISH_MANAGER_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_0_5_CS *Manager; +} EFI_REDFISH_MANAGER_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_6/EfiManagerV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_6/EfiManagerV1_0_6.h new file mode 100644 index 00000000000..2655807fb01 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_6/EfiManagerV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_0_6_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_0_6/Redfish_Manager_v1_0_6_CS.h" +// +// EFI structure of Redfish Manager v1_0_6 +// +typedef struct _EFI_REDFISH_MANAGER_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_0_6_CS *Manager; +} EFI_REDFISH_MANAGER_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_7/EfiManagerV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_7/EfiManagerV1_0_7.h new file mode 100644 index 00000000000..52346eee083 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_7/EfiManagerV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_0_7_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_0_7/Redfish_Manager_v1_0_7_CS.h" +// +// EFI structure of Redfish Manager v1_0_7 +// +typedef struct _EFI_REDFISH_MANAGER_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_0_7_CS *Manager; +} EFI_REDFISH_MANAGER_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_8/EfiManagerV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_8/EfiManagerV1_0_8.h new file mode 100644 index 00000000000..3872d34f3e5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_8/EfiManagerV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_0_8_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_0_8/Redfish_Manager_v1_0_8_CS.h" +// +// EFI structure of Redfish Manager v1_0_8 +// +typedef struct _EFI_REDFISH_MANAGER_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_0_8_CS *Manager; +} EFI_REDFISH_MANAGER_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_9/EfiManagerV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_9/EfiManagerV1_0_9.h new file mode 100644 index 00000000000..0398fe7b4f3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_0_9/EfiManagerV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_0_9_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_0_9/Redfish_Manager_v1_0_9_CS.h" +// +// EFI structure of Redfish Manager v1_0_9 +// +typedef struct _EFI_REDFISH_MANAGER_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_0_9_CS *Manager; +} EFI_REDFISH_MANAGER_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_10_0/EfiManagerV1_10_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_10_0/EfiManagerV1_10_0.h new file mode 100644 index 00000000000..71d3e855ac7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_10_0/EfiManagerV1_10_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_10_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_10_0_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_10_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_10_0/Redfish_Manager_v1_10_0_CS.h" +// +// EFI structure of Redfish Manager v1_10_0 +// +typedef struct _EFI_REDFISH_MANAGER_V1_10_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_10_0_CS *Manager; +} EFI_REDFISH_MANAGER_V1_10_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_10_1/EfiManagerV1_10_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_10_1/EfiManagerV1_10_1.h new file mode 100644 index 00000000000..c6f0a5ed8ad --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_10_1/EfiManagerV1_10_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_10_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_10_1_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_10_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_10_1/Redfish_Manager_v1_10_1_CS.h" +// +// EFI structure of Redfish Manager v1_10_1 +// +typedef struct _EFI_REDFISH_MANAGER_V1_10_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_10_1_CS *Manager; +} EFI_REDFISH_MANAGER_V1_10_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_11_0/EfiManagerV1_11_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_11_0/EfiManagerV1_11_0.h new file mode 100644 index 00000000000..2bbc44d270b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_11_0/EfiManagerV1_11_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_11_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_11_0_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_11_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_11_0/Redfish_Manager_v1_11_0_CS.h" +// +// EFI structure of Redfish Manager v1_11_0 +// +typedef struct _EFI_REDFISH_MANAGER_V1_11_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_11_0_CS *Manager; +} EFI_REDFISH_MANAGER_V1_11_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_0/EfiManagerV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_0/EfiManagerV1_1_0.h new file mode 100644 index 00000000000..7a28f218a45 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_0/EfiManagerV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_1_0_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_1_0/Redfish_Manager_v1_1_0_CS.h" +// +// EFI structure of Redfish Manager v1_1_0 +// +typedef struct _EFI_REDFISH_MANAGER_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_1_0_CS *Manager; +} EFI_REDFISH_MANAGER_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_1/EfiManagerV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_1/EfiManagerV1_1_1.h new file mode 100644 index 00000000000..885d63e8ec9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_1/EfiManagerV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_1_1_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_1_1/Redfish_Manager_v1_1_1_CS.h" +// +// EFI structure of Redfish Manager v1_1_1 +// +typedef struct _EFI_REDFISH_MANAGER_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_1_1_CS *Manager; +} EFI_REDFISH_MANAGER_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_10/EfiManagerV1_1_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_10/EfiManagerV1_1_10.h new file mode 100644 index 00000000000..9972441f035 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_10/EfiManagerV1_1_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_1_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_1_10_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_1_10_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_1_10/Redfish_Manager_v1_1_10_CS.h" +// +// EFI structure of Redfish Manager v1_1_10 +// +typedef struct _EFI_REDFISH_MANAGER_V1_1_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_1_10_CS *Manager; +} EFI_REDFISH_MANAGER_V1_1_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_11/EfiManagerV1_1_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_11/EfiManagerV1_1_11.h new file mode 100644 index 00000000000..5c9548c0910 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_11/EfiManagerV1_1_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_1_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_1_11_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_1_11_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_1_11/Redfish_Manager_v1_1_11_CS.h" +// +// EFI structure of Redfish Manager v1_1_11 +// +typedef struct _EFI_REDFISH_MANAGER_V1_1_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_1_11_CS *Manager; +} EFI_REDFISH_MANAGER_V1_1_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_12/EfiManagerV1_1_12.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_12/EfiManagerV1_1_12.h new file mode 100644 index 00000000000..5371e7da0e1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_12/EfiManagerV1_1_12.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_1_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_1_12_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_1_12_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_1_12/Redfish_Manager_v1_1_12_CS.h" +// +// EFI structure of Redfish Manager v1_1_12 +// +typedef struct _EFI_REDFISH_MANAGER_V1_1_12 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_1_12_CS *Manager; +} EFI_REDFISH_MANAGER_V1_1_12; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_2/EfiManagerV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_2/EfiManagerV1_1_2.h new file mode 100644 index 00000000000..105f35c32b3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_2/EfiManagerV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_1_2_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_1_2/Redfish_Manager_v1_1_2_CS.h" +// +// EFI structure of Redfish Manager v1_1_2 +// +typedef struct _EFI_REDFISH_MANAGER_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_1_2_CS *Manager; +} EFI_REDFISH_MANAGER_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_3/EfiManagerV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_3/EfiManagerV1_1_3.h new file mode 100644 index 00000000000..b2044338378 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_3/EfiManagerV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_1_3_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_1_3/Redfish_Manager_v1_1_3_CS.h" +// +// EFI structure of Redfish Manager v1_1_3 +// +typedef struct _EFI_REDFISH_MANAGER_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_1_3_CS *Manager; +} EFI_REDFISH_MANAGER_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_4/EfiManagerV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_4/EfiManagerV1_1_4.h new file mode 100644 index 00000000000..3ed9d23164f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_4/EfiManagerV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_1_4_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_1_4/Redfish_Manager_v1_1_4_CS.h" +// +// EFI structure of Redfish Manager v1_1_4 +// +typedef struct _EFI_REDFISH_MANAGER_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_1_4_CS *Manager; +} EFI_REDFISH_MANAGER_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_5/EfiManagerV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_5/EfiManagerV1_1_5.h new file mode 100644 index 00000000000..f3051705a01 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_5/EfiManagerV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_1_5_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_1_5/Redfish_Manager_v1_1_5_CS.h" +// +// EFI structure of Redfish Manager v1_1_5 +// +typedef struct _EFI_REDFISH_MANAGER_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_1_5_CS *Manager; +} EFI_REDFISH_MANAGER_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_6/EfiManagerV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_6/EfiManagerV1_1_6.h new file mode 100644 index 00000000000..3f0aa67920c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_6/EfiManagerV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_1_6_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_1_6/Redfish_Manager_v1_1_6_CS.h" +// +// EFI structure of Redfish Manager v1_1_6 +// +typedef struct _EFI_REDFISH_MANAGER_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_1_6_CS *Manager; +} EFI_REDFISH_MANAGER_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_7/EfiManagerV1_1_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_7/EfiManagerV1_1_7.h new file mode 100644 index 00000000000..a71de88d3e3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_7/EfiManagerV1_1_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_1_7_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_1_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_1_7/Redfish_Manager_v1_1_7_CS.h" +// +// EFI structure of Redfish Manager v1_1_7 +// +typedef struct _EFI_REDFISH_MANAGER_V1_1_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_1_7_CS *Manager; +} EFI_REDFISH_MANAGER_V1_1_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_8/EfiManagerV1_1_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_8/EfiManagerV1_1_8.h new file mode 100644 index 00000000000..23d38b36e7b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_8/EfiManagerV1_1_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_1_8_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_1_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_1_8/Redfish_Manager_v1_1_8_CS.h" +// +// EFI structure of Redfish Manager v1_1_8 +// +typedef struct _EFI_REDFISH_MANAGER_V1_1_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_1_8_CS *Manager; +} EFI_REDFISH_MANAGER_V1_1_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_9/EfiManagerV1_1_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_9/EfiManagerV1_1_9.h new file mode 100644 index 00000000000..7e3f4d2f429 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_1_9/EfiManagerV1_1_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_1_9_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_1_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_1_9/Redfish_Manager_v1_1_9_CS.h" +// +// EFI structure of Redfish Manager v1_1_9 +// +typedef struct _EFI_REDFISH_MANAGER_V1_1_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_1_9_CS *Manager; +} EFI_REDFISH_MANAGER_V1_1_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_0/EfiManagerV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_0/EfiManagerV1_2_0.h new file mode 100644 index 00000000000..80c35a809c3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_0/EfiManagerV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_2_0_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_2_0/Redfish_Manager_v1_2_0_CS.h" +// +// EFI structure of Redfish Manager v1_2_0 +// +typedef struct _EFI_REDFISH_MANAGER_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_2_0_CS *Manager; +} EFI_REDFISH_MANAGER_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_1/EfiManagerV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_1/EfiManagerV1_2_1.h new file mode 100644 index 00000000000..4686487b531 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_1/EfiManagerV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_2_1_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_2_1/Redfish_Manager_v1_2_1_CS.h" +// +// EFI structure of Redfish Manager v1_2_1 +// +typedef struct _EFI_REDFISH_MANAGER_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_2_1_CS *Manager; +} EFI_REDFISH_MANAGER_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_10/EfiManagerV1_2_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_10/EfiManagerV1_2_10.h new file mode 100644 index 00000000000..accf6373046 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_10/EfiManagerV1_2_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_2_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_2_10_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_2_10_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_2_10/Redfish_Manager_v1_2_10_CS.h" +// +// EFI structure of Redfish Manager v1_2_10 +// +typedef struct _EFI_REDFISH_MANAGER_V1_2_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_2_10_CS *Manager; +} EFI_REDFISH_MANAGER_V1_2_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_11/EfiManagerV1_2_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_11/EfiManagerV1_2_11.h new file mode 100644 index 00000000000..686ad48d2cc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_11/EfiManagerV1_2_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_2_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_2_11_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_2_11_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_2_11/Redfish_Manager_v1_2_11_CS.h" +// +// EFI structure of Redfish Manager v1_2_11 +// +typedef struct _EFI_REDFISH_MANAGER_V1_2_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_2_11_CS *Manager; +} EFI_REDFISH_MANAGER_V1_2_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_12/EfiManagerV1_2_12.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_12/EfiManagerV1_2_12.h new file mode 100644 index 00000000000..45b3f0f3f5b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_12/EfiManagerV1_2_12.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_2_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_2_12_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_2_12_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_2_12/Redfish_Manager_v1_2_12_CS.h" +// +// EFI structure of Redfish Manager v1_2_12 +// +typedef struct _EFI_REDFISH_MANAGER_V1_2_12 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_2_12_CS *Manager; +} EFI_REDFISH_MANAGER_V1_2_12; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_2/EfiManagerV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_2/EfiManagerV1_2_2.h new file mode 100644 index 00000000000..52689e43136 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_2/EfiManagerV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_2_2_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_2_2/Redfish_Manager_v1_2_2_CS.h" +// +// EFI structure of Redfish Manager v1_2_2 +// +typedef struct _EFI_REDFISH_MANAGER_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_2_2_CS *Manager; +} EFI_REDFISH_MANAGER_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_3/EfiManagerV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_3/EfiManagerV1_2_3.h new file mode 100644 index 00000000000..a7baa6500a4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_3/EfiManagerV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_2_3_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_2_3/Redfish_Manager_v1_2_3_CS.h" +// +// EFI structure of Redfish Manager v1_2_3 +// +typedef struct _EFI_REDFISH_MANAGER_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_2_3_CS *Manager; +} EFI_REDFISH_MANAGER_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_4/EfiManagerV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_4/EfiManagerV1_2_4.h new file mode 100644 index 00000000000..502e11a010b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_4/EfiManagerV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_2_4_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_2_4/Redfish_Manager_v1_2_4_CS.h" +// +// EFI structure of Redfish Manager v1_2_4 +// +typedef struct _EFI_REDFISH_MANAGER_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_2_4_CS *Manager; +} EFI_REDFISH_MANAGER_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_5/EfiManagerV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_5/EfiManagerV1_2_5.h new file mode 100644 index 00000000000..40eed5347ba --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_5/EfiManagerV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_2_5_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_2_5/Redfish_Manager_v1_2_5_CS.h" +// +// EFI structure of Redfish Manager v1_2_5 +// +typedef struct _EFI_REDFISH_MANAGER_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_2_5_CS *Manager; +} EFI_REDFISH_MANAGER_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_6/EfiManagerV1_2_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_6/EfiManagerV1_2_6.h new file mode 100644 index 00000000000..43b92fe0c48 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_6/EfiManagerV1_2_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_2_6_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_2_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_2_6/Redfish_Manager_v1_2_6_CS.h" +// +// EFI structure of Redfish Manager v1_2_6 +// +typedef struct _EFI_REDFISH_MANAGER_V1_2_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_2_6_CS *Manager; +} EFI_REDFISH_MANAGER_V1_2_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_7/EfiManagerV1_2_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_7/EfiManagerV1_2_7.h new file mode 100644 index 00000000000..5d5ae6a1d26 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_7/EfiManagerV1_2_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_2_7_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_2_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_2_7/Redfish_Manager_v1_2_7_CS.h" +// +// EFI structure of Redfish Manager v1_2_7 +// +typedef struct _EFI_REDFISH_MANAGER_V1_2_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_2_7_CS *Manager; +} EFI_REDFISH_MANAGER_V1_2_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_8/EfiManagerV1_2_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_8/EfiManagerV1_2_8.h new file mode 100644 index 00000000000..e2f875b13ab --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_8/EfiManagerV1_2_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_2_8_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_2_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_2_8/Redfish_Manager_v1_2_8_CS.h" +// +// EFI structure of Redfish Manager v1_2_8 +// +typedef struct _EFI_REDFISH_MANAGER_V1_2_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_2_8_CS *Manager; +} EFI_REDFISH_MANAGER_V1_2_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_9/EfiManagerV1_2_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_9/EfiManagerV1_2_9.h new file mode 100644 index 00000000000..ad60a304316 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_2_9/EfiManagerV1_2_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_2_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_2_9_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_2_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_2_9/Redfish_Manager_v1_2_9_CS.h" +// +// EFI structure of Redfish Manager v1_2_9 +// +typedef struct _EFI_REDFISH_MANAGER_V1_2_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_2_9_CS *Manager; +} EFI_REDFISH_MANAGER_V1_2_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_0/EfiManagerV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_0/EfiManagerV1_3_0.h new file mode 100644 index 00000000000..27cb120e408 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_0/EfiManagerV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_3_0_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_3_0/Redfish_Manager_v1_3_0_CS.h" +// +// EFI structure of Redfish Manager v1_3_0 +// +typedef struct _EFI_REDFISH_MANAGER_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_3_0_CS *Manager; +} EFI_REDFISH_MANAGER_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_1/EfiManagerV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_1/EfiManagerV1_3_1.h new file mode 100644 index 00000000000..114b89b87c2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_1/EfiManagerV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_3_1_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_3_1/Redfish_Manager_v1_3_1_CS.h" +// +// EFI structure of Redfish Manager v1_3_1 +// +typedef struct _EFI_REDFISH_MANAGER_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_3_1_CS *Manager; +} EFI_REDFISH_MANAGER_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_10/EfiManagerV1_3_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_10/EfiManagerV1_3_10.h new file mode 100644 index 00000000000..d9d143e8dc4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_10/EfiManagerV1_3_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_3_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_3_10_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_3_10_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_3_10/Redfish_Manager_v1_3_10_CS.h" +// +// EFI structure of Redfish Manager v1_3_10 +// +typedef struct _EFI_REDFISH_MANAGER_V1_3_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_3_10_CS *Manager; +} EFI_REDFISH_MANAGER_V1_3_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_11/EfiManagerV1_3_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_11/EfiManagerV1_3_11.h new file mode 100644 index 00000000000..0bd7f86dc29 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_11/EfiManagerV1_3_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_3_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_3_11_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_3_11_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_3_11/Redfish_Manager_v1_3_11_CS.h" +// +// EFI structure of Redfish Manager v1_3_11 +// +typedef struct _EFI_REDFISH_MANAGER_V1_3_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_3_11_CS *Manager; +} EFI_REDFISH_MANAGER_V1_3_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_2/EfiManagerV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_2/EfiManagerV1_3_2.h new file mode 100644 index 00000000000..91273d169d8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_2/EfiManagerV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_3_2_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_3_2/Redfish_Manager_v1_3_2_CS.h" +// +// EFI structure of Redfish Manager v1_3_2 +// +typedef struct _EFI_REDFISH_MANAGER_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_3_2_CS *Manager; +} EFI_REDFISH_MANAGER_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_3/EfiManagerV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_3/EfiManagerV1_3_3.h new file mode 100644 index 00000000000..9ff2e1c6942 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_3/EfiManagerV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_3_3_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_3_3/Redfish_Manager_v1_3_3_CS.h" +// +// EFI structure of Redfish Manager v1_3_3 +// +typedef struct _EFI_REDFISH_MANAGER_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_3_3_CS *Manager; +} EFI_REDFISH_MANAGER_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_4/EfiManagerV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_4/EfiManagerV1_3_4.h new file mode 100644 index 00000000000..a6c06751c1b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_4/EfiManagerV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_3_4_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_3_4/Redfish_Manager_v1_3_4_CS.h" +// +// EFI structure of Redfish Manager v1_3_4 +// +typedef struct _EFI_REDFISH_MANAGER_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_3_4_CS *Manager; +} EFI_REDFISH_MANAGER_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_5/EfiManagerV1_3_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_5/EfiManagerV1_3_5.h new file mode 100644 index 00000000000..e78e5b302ac --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_5/EfiManagerV1_3_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_3_5_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_3_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_3_5/Redfish_Manager_v1_3_5_CS.h" +// +// EFI structure of Redfish Manager v1_3_5 +// +typedef struct _EFI_REDFISH_MANAGER_V1_3_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_3_5_CS *Manager; +} EFI_REDFISH_MANAGER_V1_3_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_6/EfiManagerV1_3_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_6/EfiManagerV1_3_6.h new file mode 100644 index 00000000000..71e66f90789 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_6/EfiManagerV1_3_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_3_6_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_3_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_3_6/Redfish_Manager_v1_3_6_CS.h" +// +// EFI structure of Redfish Manager v1_3_6 +// +typedef struct _EFI_REDFISH_MANAGER_V1_3_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_3_6_CS *Manager; +} EFI_REDFISH_MANAGER_V1_3_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_7/EfiManagerV1_3_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_7/EfiManagerV1_3_7.h new file mode 100644 index 00000000000..450a5912f6f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_7/EfiManagerV1_3_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_3_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_3_7_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_3_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_3_7/Redfish_Manager_v1_3_7_CS.h" +// +// EFI structure of Redfish Manager v1_3_7 +// +typedef struct _EFI_REDFISH_MANAGER_V1_3_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_3_7_CS *Manager; +} EFI_REDFISH_MANAGER_V1_3_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_8/EfiManagerV1_3_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_8/EfiManagerV1_3_8.h new file mode 100644 index 00000000000..5a10ff544f9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_8/EfiManagerV1_3_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_3_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_3_8_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_3_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_3_8/Redfish_Manager_v1_3_8_CS.h" +// +// EFI structure of Redfish Manager v1_3_8 +// +typedef struct _EFI_REDFISH_MANAGER_V1_3_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_3_8_CS *Manager; +} EFI_REDFISH_MANAGER_V1_3_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_9/EfiManagerV1_3_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_9/EfiManagerV1_3_9.h new file mode 100644 index 00000000000..06126f15b41 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_3_9/EfiManagerV1_3_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_3_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_3_9_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_3_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_3_9/Redfish_Manager_v1_3_9_CS.h" +// +// EFI structure of Redfish Manager v1_3_9 +// +typedef struct _EFI_REDFISH_MANAGER_V1_3_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_3_9_CS *Manager; +} EFI_REDFISH_MANAGER_V1_3_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_0/EfiManagerV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_0/EfiManagerV1_4_0.h new file mode 100644 index 00000000000..0b4d4cb9ec7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_0/EfiManagerV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_4_0_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_4_0/Redfish_Manager_v1_4_0_CS.h" +// +// EFI structure of Redfish Manager v1_4_0 +// +typedef struct _EFI_REDFISH_MANAGER_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_4_0_CS *Manager; +} EFI_REDFISH_MANAGER_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_1/EfiManagerV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_1/EfiManagerV1_4_1.h new file mode 100644 index 00000000000..24dbdabb78f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_1/EfiManagerV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_4_1_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_4_1/Redfish_Manager_v1_4_1_CS.h" +// +// EFI structure of Redfish Manager v1_4_1 +// +typedef struct _EFI_REDFISH_MANAGER_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_4_1_CS *Manager; +} EFI_REDFISH_MANAGER_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_2/EfiManagerV1_4_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_2/EfiManagerV1_4_2.h new file mode 100644 index 00000000000..20ad7f8a7e3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_2/EfiManagerV1_4_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_4_2_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_4_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_4_2/Redfish_Manager_v1_4_2_CS.h" +// +// EFI structure of Redfish Manager v1_4_2 +// +typedef struct _EFI_REDFISH_MANAGER_V1_4_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_4_2_CS *Manager; +} EFI_REDFISH_MANAGER_V1_4_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_3/EfiManagerV1_4_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_3/EfiManagerV1_4_3.h new file mode 100644 index 00000000000..5448f220084 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_3/EfiManagerV1_4_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_4_3_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_4_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_4_3/Redfish_Manager_v1_4_3_CS.h" +// +// EFI structure of Redfish Manager v1_4_3 +// +typedef struct _EFI_REDFISH_MANAGER_V1_4_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_4_3_CS *Manager; +} EFI_REDFISH_MANAGER_V1_4_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_4/EfiManagerV1_4_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_4/EfiManagerV1_4_4.h new file mode 100644 index 00000000000..354060e8254 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_4/EfiManagerV1_4_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_4_4_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_4_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_4_4/Redfish_Manager_v1_4_4_CS.h" +// +// EFI structure of Redfish Manager v1_4_4 +// +typedef struct _EFI_REDFISH_MANAGER_V1_4_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_4_4_CS *Manager; +} EFI_REDFISH_MANAGER_V1_4_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_5/EfiManagerV1_4_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_5/EfiManagerV1_4_5.h new file mode 100644 index 00000000000..4a1b889f3bd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_5/EfiManagerV1_4_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_4_5_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_4_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_4_5/Redfish_Manager_v1_4_5_CS.h" +// +// EFI structure of Redfish Manager v1_4_5 +// +typedef struct _EFI_REDFISH_MANAGER_V1_4_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_4_5_CS *Manager; +} EFI_REDFISH_MANAGER_V1_4_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_6/EfiManagerV1_4_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_6/EfiManagerV1_4_6.h new file mode 100644 index 00000000000..4bd56da63f1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_6/EfiManagerV1_4_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_4_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_4_6_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_4_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_4_6/Redfish_Manager_v1_4_6_CS.h" +// +// EFI structure of Redfish Manager v1_4_6 +// +typedef struct _EFI_REDFISH_MANAGER_V1_4_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_4_6_CS *Manager; +} EFI_REDFISH_MANAGER_V1_4_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_7/EfiManagerV1_4_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_7/EfiManagerV1_4_7.h new file mode 100644 index 00000000000..c01044080b3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_7/EfiManagerV1_4_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_4_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_4_7_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_4_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_4_7/Redfish_Manager_v1_4_7_CS.h" +// +// EFI structure of Redfish Manager v1_4_7 +// +typedef struct _EFI_REDFISH_MANAGER_V1_4_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_4_7_CS *Manager; +} EFI_REDFISH_MANAGER_V1_4_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_8/EfiManagerV1_4_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_8/EfiManagerV1_4_8.h new file mode 100644 index 00000000000..d3d13b666ab --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_4_8/EfiManagerV1_4_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_4_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_4_8_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_4_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_4_8/Redfish_Manager_v1_4_8_CS.h" +// +// EFI structure of Redfish Manager v1_4_8 +// +typedef struct _EFI_REDFISH_MANAGER_V1_4_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_4_8_CS *Manager; +} EFI_REDFISH_MANAGER_V1_4_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_0/EfiManagerV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_0/EfiManagerV1_5_0.h new file mode 100644 index 00000000000..71d5a7b1e23 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_0/EfiManagerV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_5_0_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_5_0/Redfish_Manager_v1_5_0_CS.h" +// +// EFI structure of Redfish Manager v1_5_0 +// +typedef struct _EFI_REDFISH_MANAGER_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_5_0_CS *Manager; +} EFI_REDFISH_MANAGER_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_1/EfiManagerV1_5_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_1/EfiManagerV1_5_1.h new file mode 100644 index 00000000000..27ab26207cc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_1/EfiManagerV1_5_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_5_1_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_5_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_5_1/Redfish_Manager_v1_5_1_CS.h" +// +// EFI structure of Redfish Manager v1_5_1 +// +typedef struct _EFI_REDFISH_MANAGER_V1_5_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_5_1_CS *Manager; +} EFI_REDFISH_MANAGER_V1_5_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_2/EfiManagerV1_5_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_2/EfiManagerV1_5_2.h new file mode 100644 index 00000000000..f19a24376bd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_2/EfiManagerV1_5_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_5_2_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_5_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_5_2/Redfish_Manager_v1_5_2_CS.h" +// +// EFI structure of Redfish Manager v1_5_2 +// +typedef struct _EFI_REDFISH_MANAGER_V1_5_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_5_2_CS *Manager; +} EFI_REDFISH_MANAGER_V1_5_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_3/EfiManagerV1_5_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_3/EfiManagerV1_5_3.h new file mode 100644 index 00000000000..3f068a38b97 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_3/EfiManagerV1_5_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_5_3_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_5_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_5_3/Redfish_Manager_v1_5_3_CS.h" +// +// EFI structure of Redfish Manager v1_5_3 +// +typedef struct _EFI_REDFISH_MANAGER_V1_5_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_5_3_CS *Manager; +} EFI_REDFISH_MANAGER_V1_5_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_4/EfiManagerV1_5_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_4/EfiManagerV1_5_4.h new file mode 100644 index 00000000000..e7af2e90dcf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_4/EfiManagerV1_5_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_5_4_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_5_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_5_4/Redfish_Manager_v1_5_4_CS.h" +// +// EFI structure of Redfish Manager v1_5_4 +// +typedef struct _EFI_REDFISH_MANAGER_V1_5_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_5_4_CS *Manager; +} EFI_REDFISH_MANAGER_V1_5_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_5/EfiManagerV1_5_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_5/EfiManagerV1_5_5.h new file mode 100644 index 00000000000..a4a2cd0812c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_5/EfiManagerV1_5_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_5_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_5_5_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_5_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_5_5/Redfish_Manager_v1_5_5_CS.h" +// +// EFI structure of Redfish Manager v1_5_5 +// +typedef struct _EFI_REDFISH_MANAGER_V1_5_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_5_5_CS *Manager; +} EFI_REDFISH_MANAGER_V1_5_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_6/EfiManagerV1_5_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_6/EfiManagerV1_5_6.h new file mode 100644 index 00000000000..cb8fe4ff4a2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_6/EfiManagerV1_5_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_5_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_5_6_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_5_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_5_6/Redfish_Manager_v1_5_6_CS.h" +// +// EFI structure of Redfish Manager v1_5_6 +// +typedef struct _EFI_REDFISH_MANAGER_V1_5_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_5_6_CS *Manager; +} EFI_REDFISH_MANAGER_V1_5_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_7/EfiManagerV1_5_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_7/EfiManagerV1_5_7.h new file mode 100644 index 00000000000..0da6017f88d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_5_7/EfiManagerV1_5_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_5_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_5_7_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_5_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_5_7/Redfish_Manager_v1_5_7_CS.h" +// +// EFI structure of Redfish Manager v1_5_7 +// +typedef struct _EFI_REDFISH_MANAGER_V1_5_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_5_7_CS *Manager; +} EFI_REDFISH_MANAGER_V1_5_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_6_0/EfiManagerV1_6_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_6_0/EfiManagerV1_6_0.h new file mode 100644 index 00000000000..382967efe29 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_6_0/EfiManagerV1_6_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_6_0_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_6_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_6_0/Redfish_Manager_v1_6_0_CS.h" +// +// EFI structure of Redfish Manager v1_6_0 +// +typedef struct _EFI_REDFISH_MANAGER_V1_6_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_6_0_CS *Manager; +} EFI_REDFISH_MANAGER_V1_6_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_6_1/EfiManagerV1_6_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_6_1/EfiManagerV1_6_1.h new file mode 100644 index 00000000000..af99b8719f3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_6_1/EfiManagerV1_6_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_6_1_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_6_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_6_1/Redfish_Manager_v1_6_1_CS.h" +// +// EFI structure of Redfish Manager v1_6_1 +// +typedef struct _EFI_REDFISH_MANAGER_V1_6_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_6_1_CS *Manager; +} EFI_REDFISH_MANAGER_V1_6_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_6_2/EfiManagerV1_6_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_6_2/EfiManagerV1_6_2.h new file mode 100644 index 00000000000..31af1781f5f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_6_2/EfiManagerV1_6_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_6_2_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_6_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_6_2/Redfish_Manager_v1_6_2_CS.h" +// +// EFI structure of Redfish Manager v1_6_2 +// +typedef struct _EFI_REDFISH_MANAGER_V1_6_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_6_2_CS *Manager; +} EFI_REDFISH_MANAGER_V1_6_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_6_3/EfiManagerV1_6_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_6_3/EfiManagerV1_6_3.h new file mode 100644 index 00000000000..194539b9600 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_6_3/EfiManagerV1_6_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_6_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_6_3_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_6_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_6_3/Redfish_Manager_v1_6_3_CS.h" +// +// EFI structure of Redfish Manager v1_6_3 +// +typedef struct _EFI_REDFISH_MANAGER_V1_6_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_6_3_CS *Manager; +} EFI_REDFISH_MANAGER_V1_6_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_6_4/EfiManagerV1_6_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_6_4/EfiManagerV1_6_4.h new file mode 100644 index 00000000000..ed94636b27d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_6_4/EfiManagerV1_6_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_6_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_6_4_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_6_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_6_4/Redfish_Manager_v1_6_4_CS.h" +// +// EFI structure of Redfish Manager v1_6_4 +// +typedef struct _EFI_REDFISH_MANAGER_V1_6_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_6_4_CS *Manager; +} EFI_REDFISH_MANAGER_V1_6_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_7_0/EfiManagerV1_7_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_7_0/EfiManagerV1_7_0.h new file mode 100644 index 00000000000..f951fcdc8bc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_7_0/EfiManagerV1_7_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_7_0_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_7_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_7_0/Redfish_Manager_v1_7_0_CS.h" +// +// EFI structure of Redfish Manager v1_7_0 +// +typedef struct _EFI_REDFISH_MANAGER_V1_7_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_7_0_CS *Manager; +} EFI_REDFISH_MANAGER_V1_7_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_7_1/EfiManagerV1_7_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_7_1/EfiManagerV1_7_1.h new file mode 100644 index 00000000000..f0e2264c11c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_7_1/EfiManagerV1_7_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_7_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_7_1_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_7_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_7_1/Redfish_Manager_v1_7_1_CS.h" +// +// EFI structure of Redfish Manager v1_7_1 +// +typedef struct _EFI_REDFISH_MANAGER_V1_7_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_7_1_CS *Manager; +} EFI_REDFISH_MANAGER_V1_7_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_7_2/EfiManagerV1_7_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_7_2/EfiManagerV1_7_2.h new file mode 100644 index 00000000000..489bbe07bde --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_7_2/EfiManagerV1_7_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_7_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_7_2_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_7_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_7_2/Redfish_Manager_v1_7_2_CS.h" +// +// EFI structure of Redfish Manager v1_7_2 +// +typedef struct _EFI_REDFISH_MANAGER_V1_7_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_7_2_CS *Manager; +} EFI_REDFISH_MANAGER_V1_7_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_7_3/EfiManagerV1_7_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_7_3/EfiManagerV1_7_3.h new file mode 100644 index 00000000000..ae0dbad6fa3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_7_3/EfiManagerV1_7_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_7_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_7_3_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_7_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_7_3/Redfish_Manager_v1_7_3_CS.h" +// +// EFI structure of Redfish Manager v1_7_3 +// +typedef struct _EFI_REDFISH_MANAGER_V1_7_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_7_3_CS *Manager; +} EFI_REDFISH_MANAGER_V1_7_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_7_4/EfiManagerV1_7_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_7_4/EfiManagerV1_7_4.h new file mode 100644 index 00000000000..d9787d05627 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_7_4/EfiManagerV1_7_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_7_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_7_4_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_7_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_7_4/Redfish_Manager_v1_7_4_CS.h" +// +// EFI structure of Redfish Manager v1_7_4 +// +typedef struct _EFI_REDFISH_MANAGER_V1_7_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_7_4_CS *Manager; +} EFI_REDFISH_MANAGER_V1_7_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_8_0/EfiManagerV1_8_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_8_0/EfiManagerV1_8_0.h new file mode 100644 index 00000000000..2a6796c3fb8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_8_0/EfiManagerV1_8_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_8_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_8_0_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_8_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_8_0/Redfish_Manager_v1_8_0_CS.h" +// +// EFI structure of Redfish Manager v1_8_0 +// +typedef struct _EFI_REDFISH_MANAGER_V1_8_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_8_0_CS *Manager; +} EFI_REDFISH_MANAGER_V1_8_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_8_1/EfiManagerV1_8_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_8_1/EfiManagerV1_8_1.h new file mode 100644 index 00000000000..5bde8ed2e57 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_8_1/EfiManagerV1_8_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_8_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_8_1_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_8_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_8_1/Redfish_Manager_v1_8_1_CS.h" +// +// EFI structure of Redfish Manager v1_8_1 +// +typedef struct _EFI_REDFISH_MANAGER_V1_8_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_8_1_CS *Manager; +} EFI_REDFISH_MANAGER_V1_8_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_8_2/EfiManagerV1_8_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_8_2/EfiManagerV1_8_2.h new file mode 100644 index 00000000000..fa0e00e7b00 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_8_2/EfiManagerV1_8_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_8_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_8_2_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_8_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_8_2/Redfish_Manager_v1_8_2_CS.h" +// +// EFI structure of Redfish Manager v1_8_2 +// +typedef struct _EFI_REDFISH_MANAGER_V1_8_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_8_2_CS *Manager; +} EFI_REDFISH_MANAGER_V1_8_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_8_3/EfiManagerV1_8_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_8_3/EfiManagerV1_8_3.h new file mode 100644 index 00000000000..e95d1c43f3b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_8_3/EfiManagerV1_8_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_8_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_8_3_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_8_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_8_3/Redfish_Manager_v1_8_3_CS.h" +// +// EFI structure of Redfish Manager v1_8_3 +// +typedef struct _EFI_REDFISH_MANAGER_V1_8_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_8_3_CS *Manager; +} EFI_REDFISH_MANAGER_V1_8_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_9_0/EfiManagerV1_9_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_9_0/EfiManagerV1_9_0.h new file mode 100644 index 00000000000..db356621f06 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_9_0/EfiManagerV1_9_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_9_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_9_0_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_9_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_9_0/Redfish_Manager_v1_9_0_CS.h" +// +// EFI structure of Redfish Manager v1_9_0 +// +typedef struct _EFI_REDFISH_MANAGER_V1_9_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_9_0_CS *Manager; +} EFI_REDFISH_MANAGER_V1_9_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_9_1/EfiManagerV1_9_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_9_1/EfiManagerV1_9_1.h new file mode 100644 index 00000000000..7481e4e99e1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_9_1/EfiManagerV1_9_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_9_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_9_1_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_9_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_9_1/Redfish_Manager_v1_9_1_CS.h" +// +// EFI structure of Redfish Manager v1_9_1 +// +typedef struct _EFI_REDFISH_MANAGER_V1_9_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_9_1_CS *Manager; +} EFI_REDFISH_MANAGER_V1_9_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_9_2/EfiManagerV1_9_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_9_2/EfiManagerV1_9_2.h new file mode 100644 index 00000000000..db5cdab19c1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Manager/v1_9_2/EfiManagerV1_9_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Manager v1_9_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGER_V1_9_2_H__ +#define EFI_REDFISH_INTERP_MANAGER_V1_9_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Manager/v1_9_2/Redfish_Manager_v1_9_2_CS.h" +// +// EFI structure of Redfish Manager v1_9_2 +// +typedef struct _EFI_REDFISH_MANAGER_V1_9_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGER_V1_9_2_CS *Manager; +} EFI_REDFISH_MANAGER_V1_9_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_0/EfiManagerAccountV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_0/EfiManagerAccountV1_0_0.h new file mode 100644 index 00000000000..ccf88f93845 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_0/EfiManagerAccountV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_0_0_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_0_0/Redfish_ManagerAccount_v1_0_0_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_0_0 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_0_0_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_10/EfiManagerAccountV1_0_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_10/EfiManagerAccountV1_0_10.h new file mode 100644 index 00000000000..8495dd1bfdf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_10/EfiManagerAccountV1_0_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_0_10_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_0_10_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_0_10/Redfish_ManagerAccount_v1_0_10_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_0_10 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_0_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_0_10_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_0_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_11/EfiManagerAccountV1_0_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_11/EfiManagerAccountV1_0_11.h new file mode 100644 index 00000000000..aab628e62fe --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_11/EfiManagerAccountV1_0_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_0_11_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_0_11_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_0_11/Redfish_ManagerAccount_v1_0_11_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_0_11 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_0_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_0_11_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_0_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_2/EfiManagerAccountV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_2/EfiManagerAccountV1_0_2.h new file mode 100644 index 00000000000..8104042845c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_2/EfiManagerAccountV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_0_2_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_0_2/Redfish_ManagerAccount_v1_0_2_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_0_2 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_0_2_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_3/EfiManagerAccountV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_3/EfiManagerAccountV1_0_3.h new file mode 100644 index 00000000000..98c2e702802 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_3/EfiManagerAccountV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_0_3_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_0_3/Redfish_ManagerAccount_v1_0_3_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_0_3 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_0_3_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_4/EfiManagerAccountV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_4/EfiManagerAccountV1_0_4.h new file mode 100644 index 00000000000..f363069a588 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_4/EfiManagerAccountV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_0_4_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_0_4/Redfish_ManagerAccount_v1_0_4_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_0_4 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_0_4_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_5/EfiManagerAccountV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_5/EfiManagerAccountV1_0_5.h new file mode 100644 index 00000000000..e17e113eeb0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_5/EfiManagerAccountV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_0_5_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_0_5/Redfish_ManagerAccount_v1_0_5_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_0_5 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_0_5_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_6/EfiManagerAccountV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_6/EfiManagerAccountV1_0_6.h new file mode 100644 index 00000000000..c7ef686fb5a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_6/EfiManagerAccountV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_0_6_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_0_6/Redfish_ManagerAccount_v1_0_6_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_0_6 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_0_6_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_7/EfiManagerAccountV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_7/EfiManagerAccountV1_0_7.h new file mode 100644 index 00000000000..c56dc707a54 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_7/EfiManagerAccountV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_0_7_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_0_7/Redfish_ManagerAccount_v1_0_7_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_0_7 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_0_7_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_8/EfiManagerAccountV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_8/EfiManagerAccountV1_0_8.h new file mode 100644 index 00000000000..3b763c310d6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_8/EfiManagerAccountV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_0_8_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_0_8/Redfish_ManagerAccount_v1_0_8_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_0_8 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_0_8_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_9/EfiManagerAccountV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_9/EfiManagerAccountV1_0_9.h new file mode 100644 index 00000000000..01b46217102 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_0_9/EfiManagerAccountV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_0_9_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_0_9/Redfish_ManagerAccount_v1_0_9_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_0_9 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_0_9_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_0/EfiManagerAccountV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_0/EfiManagerAccountV1_1_0.h new file mode 100644 index 00000000000..3971b6f787f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_0/EfiManagerAccountV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_1_0_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_1_0/Redfish_ManagerAccount_v1_1_0_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_1_0 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_1_0_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_1/EfiManagerAccountV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_1/EfiManagerAccountV1_1_1.h new file mode 100644 index 00000000000..f7a4160e20f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_1/EfiManagerAccountV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_1_1_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_1_1/Redfish_ManagerAccount_v1_1_1_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_1_1 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_1_1_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_2/EfiManagerAccountV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_2/EfiManagerAccountV1_1_2.h new file mode 100644 index 00000000000..9b385a5ab2a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_2/EfiManagerAccountV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_1_2_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_1_2/Redfish_ManagerAccount_v1_1_2_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_1_2 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_1_2_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_3/EfiManagerAccountV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_3/EfiManagerAccountV1_1_3.h new file mode 100644 index 00000000000..e1c1e13fc9f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_3/EfiManagerAccountV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_1_3_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_1_3/Redfish_ManagerAccount_v1_1_3_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_1_3 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_1_3_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_4/EfiManagerAccountV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_4/EfiManagerAccountV1_1_4.h new file mode 100644 index 00000000000..100253b3860 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_4/EfiManagerAccountV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_1_4_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_1_4/Redfish_ManagerAccount_v1_1_4_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_1_4 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_1_4_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_5/EfiManagerAccountV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_5/EfiManagerAccountV1_1_5.h new file mode 100644 index 00000000000..103a89c2878 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_5/EfiManagerAccountV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_1_5_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_1_5/Redfish_ManagerAccount_v1_1_5_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_1_5 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_1_5_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_6/EfiManagerAccountV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_6/EfiManagerAccountV1_1_6.h new file mode 100644 index 00000000000..cbe8d160cb7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_6/EfiManagerAccountV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_1_6_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_1_6/Redfish_ManagerAccount_v1_1_6_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_1_6 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_1_6_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_7/EfiManagerAccountV1_1_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_7/EfiManagerAccountV1_1_7.h new file mode 100644 index 00000000000..44da99d589f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_1_7/EfiManagerAccountV1_1_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_1_7_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_1_7_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_1_7/Redfish_ManagerAccount_v1_1_7_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_1_7 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_1_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_1_7_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_1_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_2_0/EfiManagerAccountV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_2_0/EfiManagerAccountV1_2_0.h new file mode 100644 index 00000000000..b5253333302 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_2_0/EfiManagerAccountV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_2_0_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_2_0/Redfish_ManagerAccount_v1_2_0_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_2_0 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_2_0_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_2_1/EfiManagerAccountV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_2_1/EfiManagerAccountV1_2_1.h new file mode 100644 index 00000000000..542b2c69f57 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_2_1/EfiManagerAccountV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_2_1_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_2_1/Redfish_ManagerAccount_v1_2_1_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_2_1 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_2_1_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_2_2/EfiManagerAccountV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_2_2/EfiManagerAccountV1_2_2.h new file mode 100644 index 00000000000..ad9fc99c99c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_2_2/EfiManagerAccountV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_2_2_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_2_2/Redfish_ManagerAccount_v1_2_2_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_2_2 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_2_2_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_2_3/EfiManagerAccountV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_2_3/EfiManagerAccountV1_2_3.h new file mode 100644 index 00000000000..814b5966ef0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_2_3/EfiManagerAccountV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_2_3_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_2_3/Redfish_ManagerAccount_v1_2_3_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_2_3 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_2_3_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_2_4/EfiManagerAccountV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_2_4/EfiManagerAccountV1_2_4.h new file mode 100644 index 00000000000..17592842978 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_2_4/EfiManagerAccountV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_2_4_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_2_4/Redfish_ManagerAccount_v1_2_4_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_2_4 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_2_4_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_3_0/EfiManagerAccountV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_3_0/EfiManagerAccountV1_3_0.h new file mode 100644 index 00000000000..ab66ba674f7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_3_0/EfiManagerAccountV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_3_0_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_3_0/Redfish_ManagerAccount_v1_3_0_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_3_0 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_3_0_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_3_1/EfiManagerAccountV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_3_1/EfiManagerAccountV1_3_1.h new file mode 100644 index 00000000000..5848817301f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_3_1/EfiManagerAccountV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_3_1_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_3_1/Redfish_ManagerAccount_v1_3_1_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_3_1 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_3_1_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_3_2/EfiManagerAccountV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_3_2/EfiManagerAccountV1_3_2.h new file mode 100644 index 00000000000..d2d9d421c98 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_3_2/EfiManagerAccountV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_3_2_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_3_2/Redfish_ManagerAccount_v1_3_2_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_3_2 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_3_2_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_3_3/EfiManagerAccountV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_3_3/EfiManagerAccountV1_3_3.h new file mode 100644 index 00000000000..2a7743de90b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_3_3/EfiManagerAccountV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_3_3_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_3_3/Redfish_ManagerAccount_v1_3_3_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_3_3 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_3_3_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_4_0/EfiManagerAccountV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_4_0/EfiManagerAccountV1_4_0.h new file mode 100644 index 00000000000..a82830a8a17 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_4_0/EfiManagerAccountV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_4_0_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_4_0/Redfish_ManagerAccount_v1_4_0_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_4_0 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_4_0_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_4_1/EfiManagerAccountV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_4_1/EfiManagerAccountV1_4_1.h new file mode 100644 index 00000000000..ea9d742f580 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_4_1/EfiManagerAccountV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_4_1_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_4_1/Redfish_ManagerAccount_v1_4_1_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_4_1 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_4_1_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_4_2/EfiManagerAccountV1_4_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_4_2/EfiManagerAccountV1_4_2.h new file mode 100644 index 00000000000..51bf0729666 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_4_2/EfiManagerAccountV1_4_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_4_2_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_4_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_4_2/Redfish_ManagerAccount_v1_4_2_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_4_2 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_4_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_4_2_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_4_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_4_3/EfiManagerAccountV1_4_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_4_3/EfiManagerAccountV1_4_3.h new file mode 100644 index 00000000000..de41304a563 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_4_3/EfiManagerAccountV1_4_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_4_3_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_4_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_4_3/Redfish_ManagerAccount_v1_4_3_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_4_3 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_4_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_4_3_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_4_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_4_4/EfiManagerAccountV1_4_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_4_4/EfiManagerAccountV1_4_4.h new file mode 100644 index 00000000000..a9e9bfd7c56 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_4_4/EfiManagerAccountV1_4_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_4_4_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_4_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_4_4/Redfish_ManagerAccount_v1_4_4_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_4_4 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_4_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_4_4_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_4_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_5_0/EfiManagerAccountV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_5_0/EfiManagerAccountV1_5_0.h new file mode 100644 index 00000000000..9bda07c8aea --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_5_0/EfiManagerAccountV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_5_0_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_5_0/Redfish_ManagerAccount_v1_5_0_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_5_0 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_5_0_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_5_1/EfiManagerAccountV1_5_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_5_1/EfiManagerAccountV1_5_1.h new file mode 100644 index 00000000000..cc9fb9c2901 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_5_1/EfiManagerAccountV1_5_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_5_1_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_5_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_5_1/Redfish_ManagerAccount_v1_5_1_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_5_1 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_5_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_5_1_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_5_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_5_2/EfiManagerAccountV1_5_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_5_2/EfiManagerAccountV1_5_2.h new file mode 100644 index 00000000000..f43404eb9e4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_5_2/EfiManagerAccountV1_5_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_5_2_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_5_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_5_2/Redfish_ManagerAccount_v1_5_2_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_5_2 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_5_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_5_2_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_5_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_5_3/EfiManagerAccountV1_5_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_5_3/EfiManagerAccountV1_5_3.h new file mode 100644 index 00000000000..e9f08aa2aa6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_5_3/EfiManagerAccountV1_5_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_5_3_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_5_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_5_3/Redfish_ManagerAccount_v1_5_3_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_5_3 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_5_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_5_3_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_5_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_6_0/EfiManagerAccountV1_6_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_6_0/EfiManagerAccountV1_6_0.h new file mode 100644 index 00000000000..61d357041a2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_6_0/EfiManagerAccountV1_6_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_6_0_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_6_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_6_0/Redfish_ManagerAccount_v1_6_0_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_6_0 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_6_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_6_0_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_6_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_6_1/EfiManagerAccountV1_6_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_6_1/EfiManagerAccountV1_6_1.h new file mode 100644 index 00000000000..9fcd06cf268 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_6_1/EfiManagerAccountV1_6_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_6_1_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_6_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_6_1/Redfish_ManagerAccount_v1_6_1_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_6_1 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_6_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_6_1_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_6_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_6_2/EfiManagerAccountV1_6_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_6_2/EfiManagerAccountV1_6_2.h new file mode 100644 index 00000000000..a674cf0cf0f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_6_2/EfiManagerAccountV1_6_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_6_2_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_6_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_6_2/Redfish_ManagerAccount_v1_6_2_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_6_2 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_6_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_6_2_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_6_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_7_0/EfiManagerAccountV1_7_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_7_0/EfiManagerAccountV1_7_0.h new file mode 100644 index 00000000000..4e47ebaec43 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccount/v1_7_0/EfiManagerAccountV1_7_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccount v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_7_0_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNT_V1_7_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccount/v1_7_0/Redfish_ManagerAccount_v1_7_0_CS.h" +// +// EFI structure of Redfish ManagerAccount v1_7_0 +// +typedef struct _EFI_REDFISH_MANAGERACCOUNT_V1_7_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNT_V1_7_0_CS *ManagerAccount; +} EFI_REDFISH_MANAGERACCOUNT_V1_7_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccountCollection/EfiManagerAccountCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccountCollection/EfiManagerAccountCollection.h new file mode 100644 index 00000000000..ed6e9cba041 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerAccountCollection/EfiManagerAccountCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerAccountCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERACCOUNTCOLLECTION_H__ +#define EFI_REDFISH_INTERP_MANAGERACCOUNTCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerAccountCollection/Redfish_ManagerAccountCollection_CS.h" +// +// EFI structure of Redfish ManagerAccountCollection +// +typedef struct _EFI_REDFISH_MANAGERACCOUNTCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERACCOUNTCOLLECTION_CS *ManagerAccountCollection; +} EFI_REDFISH_MANAGERACCOUNTCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerCollection/EfiManagerCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerCollection/EfiManagerCollection.h new file mode 100644 index 00000000000..b65a529bfc7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerCollection/EfiManagerCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERCOLLECTION_H__ +#define EFI_REDFISH_INTERP_MANAGERCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerCollection/Redfish_ManagerCollection_CS.h" +// +// EFI structure of Redfish ManagerCollection +// +typedef struct _EFI_REDFISH_MANAGERCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERCOLLECTION_CS *ManagerCollection; +} EFI_REDFISH_MANAGERCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_0/EfiManagerNetworkProtocolV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_0/EfiManagerNetworkProtocolV1_0_0.h new file mode 100644 index 00000000000..3ec31d17c03 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_0/EfiManagerNetworkProtocolV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_0_0_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_0_0/Redfish_ManagerNetworkProtocol_v1_0_0_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_0_0 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_0_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_2/EfiManagerNetworkProtocolV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_2/EfiManagerNetworkProtocolV1_0_2.h new file mode 100644 index 00000000000..d32bb31f3d4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_2/EfiManagerNetworkProtocolV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_0_2_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_0_2/Redfish_ManagerNetworkProtocol_v1_0_2_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_0_2 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_2_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_3/EfiManagerNetworkProtocolV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_3/EfiManagerNetworkProtocolV1_0_3.h new file mode 100644 index 00000000000..a9fb25ddf2e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_3/EfiManagerNetworkProtocolV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_0_3_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_0_3/Redfish_ManagerNetworkProtocol_v1_0_3_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_0_3 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_3_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_4/EfiManagerNetworkProtocolV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_4/EfiManagerNetworkProtocolV1_0_4.h new file mode 100644 index 00000000000..67c9cf9f1a7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_4/EfiManagerNetworkProtocolV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_0_4_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_0_4/Redfish_ManagerNetworkProtocol_v1_0_4_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_0_4 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_4_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_5/EfiManagerNetworkProtocolV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_5/EfiManagerNetworkProtocolV1_0_5.h new file mode 100644 index 00000000000..e3d0275f4a8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_5/EfiManagerNetworkProtocolV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_0_5_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_0_5/Redfish_ManagerNetworkProtocol_v1_0_5_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_0_5 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_5_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_6/EfiManagerNetworkProtocolV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_6/EfiManagerNetworkProtocolV1_0_6.h new file mode 100644 index 00000000000..8606f4c9dbb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_6/EfiManagerNetworkProtocolV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_0_6_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_0_6/Redfish_ManagerNetworkProtocol_v1_0_6_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_0_6 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_6_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_7/EfiManagerNetworkProtocolV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_7/EfiManagerNetworkProtocolV1_0_7.h new file mode 100644 index 00000000000..1a9b354de13 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_7/EfiManagerNetworkProtocolV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_0_7_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_0_7/Redfish_ManagerNetworkProtocol_v1_0_7_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_0_7 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_7_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_8/EfiManagerNetworkProtocolV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_8/EfiManagerNetworkProtocolV1_0_8.h new file mode 100644 index 00000000000..45f2ff95a6c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_8/EfiManagerNetworkProtocolV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_0_8_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_0_8/Redfish_ManagerNetworkProtocol_v1_0_8_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_0_8 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_8_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_9/EfiManagerNetworkProtocolV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_9/EfiManagerNetworkProtocolV1_0_9.h new file mode 100644 index 00000000000..c10706e9db3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_0_9/EfiManagerNetworkProtocolV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_0_9_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_0_9/Redfish_ManagerNetworkProtocol_v1_0_9_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_0_9 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_9_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_0/EfiManagerNetworkProtocolV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_0/EfiManagerNetworkProtocolV1_1_0.h new file mode 100644 index 00000000000..bc10ab23d42 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_0/EfiManagerNetworkProtocolV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_1_0_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_1_0/Redfish_ManagerNetworkProtocol_v1_1_0_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_1_0 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_0_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_1/EfiManagerNetworkProtocolV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_1/EfiManagerNetworkProtocolV1_1_1.h new file mode 100644 index 00000000000..15c4aad2f6a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_1/EfiManagerNetworkProtocolV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_1_1_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_1_1/Redfish_ManagerNetworkProtocol_v1_1_1_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_1_1 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_1_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_2/EfiManagerNetworkProtocolV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_2/EfiManagerNetworkProtocolV1_1_2.h new file mode 100644 index 00000000000..56c4d31ba96 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_2/EfiManagerNetworkProtocolV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_1_2_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_1_2/Redfish_ManagerNetworkProtocol_v1_1_2_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_1_2 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_2_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_3/EfiManagerNetworkProtocolV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_3/EfiManagerNetworkProtocolV1_1_3.h new file mode 100644 index 00000000000..b582e5f72d0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_3/EfiManagerNetworkProtocolV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_1_3_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_1_3/Redfish_ManagerNetworkProtocol_v1_1_3_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_1_3 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_3_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_4/EfiManagerNetworkProtocolV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_4/EfiManagerNetworkProtocolV1_1_4.h new file mode 100644 index 00000000000..e592f6c9e31 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_4/EfiManagerNetworkProtocolV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_1_4_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_1_4/Redfish_ManagerNetworkProtocol_v1_1_4_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_1_4 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_4_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_5/EfiManagerNetworkProtocolV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_5/EfiManagerNetworkProtocolV1_1_5.h new file mode 100644 index 00000000000..45540391933 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_5/EfiManagerNetworkProtocolV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_1_5_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_1_5/Redfish_ManagerNetworkProtocol_v1_1_5_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_1_5 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_5_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_6/EfiManagerNetworkProtocolV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_6/EfiManagerNetworkProtocolV1_1_6.h new file mode 100644 index 00000000000..c15fde970d8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_1_6/EfiManagerNetworkProtocolV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_1_6_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_1_6/Redfish_ManagerNetworkProtocol_v1_1_6_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_1_6 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_6_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_2_0/EfiManagerNetworkProtocolV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_2_0/EfiManagerNetworkProtocolV1_2_0.h new file mode 100644 index 00000000000..13f79305be8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_2_0/EfiManagerNetworkProtocolV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_2_0_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_2_0/Redfish_ManagerNetworkProtocol_v1_2_0_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_2_0 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_0_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_2_1/EfiManagerNetworkProtocolV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_2_1/EfiManagerNetworkProtocolV1_2_1.h new file mode 100644 index 00000000000..d6d6f7396ec --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_2_1/EfiManagerNetworkProtocolV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_2_1_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_2_1/Redfish_ManagerNetworkProtocol_v1_2_1_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_2_1 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_1_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_2_2/EfiManagerNetworkProtocolV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_2_2/EfiManagerNetworkProtocolV1_2_2.h new file mode 100644 index 00000000000..7299cbb9ef2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_2_2/EfiManagerNetworkProtocolV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_2_2_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_2_2/Redfish_ManagerNetworkProtocol_v1_2_2_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_2_2 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_2_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_2_3/EfiManagerNetworkProtocolV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_2_3/EfiManagerNetworkProtocolV1_2_3.h new file mode 100644 index 00000000000..8163c3e2110 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_2_3/EfiManagerNetworkProtocolV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_2_3_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_2_3/Redfish_ManagerNetworkProtocol_v1_2_3_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_2_3 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_3_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_2_4/EfiManagerNetworkProtocolV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_2_4/EfiManagerNetworkProtocolV1_2_4.h new file mode 100644 index 00000000000..454973ab4f5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_2_4/EfiManagerNetworkProtocolV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_2_4_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_2_4/Redfish_ManagerNetworkProtocol_v1_2_4_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_2_4 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_4_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_2_5/EfiManagerNetworkProtocolV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_2_5/EfiManagerNetworkProtocolV1_2_5.h new file mode 100644 index 00000000000..12a65edec30 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_2_5/EfiManagerNetworkProtocolV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_2_5_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_2_5/Redfish_ManagerNetworkProtocol_v1_2_5_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_2_5 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_5_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_3_0/EfiManagerNetworkProtocolV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_3_0/EfiManagerNetworkProtocolV1_3_0.h new file mode 100644 index 00000000000..365bb5c834a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_3_0/EfiManagerNetworkProtocolV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_3_0_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_3_0/Redfish_ManagerNetworkProtocol_v1_3_0_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_3_0 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_0_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_3_1/EfiManagerNetworkProtocolV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_3_1/EfiManagerNetworkProtocolV1_3_1.h new file mode 100644 index 00000000000..ab53be6a3fd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_3_1/EfiManagerNetworkProtocolV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_3_1_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_3_1/Redfish_ManagerNetworkProtocol_v1_3_1_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_3_1 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_1_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_3_2/EfiManagerNetworkProtocolV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_3_2/EfiManagerNetworkProtocolV1_3_2.h new file mode 100644 index 00000000000..a11b3843925 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_3_2/EfiManagerNetworkProtocolV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_3_2_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_3_2/Redfish_ManagerNetworkProtocol_v1_3_2_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_3_2 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_2_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_3_3/EfiManagerNetworkProtocolV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_3_3/EfiManagerNetworkProtocolV1_3_3.h new file mode 100644 index 00000000000..109324a22b1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_3_3/EfiManagerNetworkProtocolV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_3_3_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_3_3/Redfish_ManagerNetworkProtocol_v1_3_3_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_3_3 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_3_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_3_4/EfiManagerNetworkProtocolV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_3_4/EfiManagerNetworkProtocolV1_3_4.h new file mode 100644 index 00000000000..9de23cb5a53 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_3_4/EfiManagerNetworkProtocolV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_3_4_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_3_4/Redfish_ManagerNetworkProtocol_v1_3_4_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_3_4 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_4_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_4_0/EfiManagerNetworkProtocolV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_4_0/EfiManagerNetworkProtocolV1_4_0.h new file mode 100644 index 00000000000..272e0700f98 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_4_0/EfiManagerNetworkProtocolV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_4_0_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_4_0/Redfish_ManagerNetworkProtocol_v1_4_0_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_4_0 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_0_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_4_1/EfiManagerNetworkProtocolV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_4_1/EfiManagerNetworkProtocolV1_4_1.h new file mode 100644 index 00000000000..4c41a1b6ea3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_4_1/EfiManagerNetworkProtocolV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_4_1_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_4_1/Redfish_ManagerNetworkProtocol_v1_4_1_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_4_1 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_1_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_4_2/EfiManagerNetworkProtocolV1_4_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_4_2/EfiManagerNetworkProtocolV1_4_2.h new file mode 100644 index 00000000000..0988fb45290 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_4_2/EfiManagerNetworkProtocolV1_4_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_4_2_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_4_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_4_2/Redfish_ManagerNetworkProtocol_v1_4_2_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_4_2 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_2_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_4_3/EfiManagerNetworkProtocolV1_4_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_4_3/EfiManagerNetworkProtocolV1_4_3.h new file mode 100644 index 00000000000..85cfe9c45c0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_4_3/EfiManagerNetworkProtocolV1_4_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_4_3_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_4_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_4_3/Redfish_ManagerNetworkProtocol_v1_4_3_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_4_3 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_3_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_4_4/EfiManagerNetworkProtocolV1_4_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_4_4/EfiManagerNetworkProtocolV1_4_4.h new file mode 100644 index 00000000000..b6d61f2b45f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_4_4/EfiManagerNetworkProtocolV1_4_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_4_4_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_4_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_4_4/Redfish_ManagerNetworkProtocol_v1_4_4_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_4_4 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_4_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_4_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_5_0/EfiManagerNetworkProtocolV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_5_0/EfiManagerNetworkProtocolV1_5_0.h new file mode 100644 index 00000000000..e3d6e4ffb4c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_5_0/EfiManagerNetworkProtocolV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_5_0_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_5_0/Redfish_ManagerNetworkProtocol_v1_5_0_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_5_0 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_0_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_5_1/EfiManagerNetworkProtocolV1_5_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_5_1/EfiManagerNetworkProtocolV1_5_1.h new file mode 100644 index 00000000000..b9e0c14f01a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_5_1/EfiManagerNetworkProtocolV1_5_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_5_1_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_5_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_5_1/Redfish_ManagerNetworkProtocol_v1_5_1_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_5_1 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_1_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_5_2/EfiManagerNetworkProtocolV1_5_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_5_2/EfiManagerNetworkProtocolV1_5_2.h new file mode 100644 index 00000000000..120cda46a70 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_5_2/EfiManagerNetworkProtocolV1_5_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_5_2_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_5_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_5_2/Redfish_ManagerNetworkProtocol_v1_5_2_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_5_2 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_2_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_5_3/EfiManagerNetworkProtocolV1_5_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_5_3/EfiManagerNetworkProtocolV1_5_3.h new file mode 100644 index 00000000000..cd867d278cf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_5_3/EfiManagerNetworkProtocolV1_5_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_5_3_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_5_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_5_3/Redfish_ManagerNetworkProtocol_v1_5_3_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_5_3 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_3_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_5_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_6_0/EfiManagerNetworkProtocolV1_6_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_6_0/EfiManagerNetworkProtocolV1_6_0.h new file mode 100644 index 00000000000..205ebaa20d8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_6_0/EfiManagerNetworkProtocolV1_6_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_6_0_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_6_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_6_0/Redfish_ManagerNetworkProtocol_v1_6_0_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_6_0 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_0_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_6_1/EfiManagerNetworkProtocolV1_6_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_6_1/EfiManagerNetworkProtocolV1_6_1.h new file mode 100644 index 00000000000..b46c8d1a3ee --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_6_1/EfiManagerNetworkProtocolV1_6_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_6_1_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_6_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_6_1/Redfish_ManagerNetworkProtocol_v1_6_1_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_6_1 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_1_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_6_2/EfiManagerNetworkProtocolV1_6_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_6_2/EfiManagerNetworkProtocolV1_6_2.h new file mode 100644 index 00000000000..1c9a1788824 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_6_2/EfiManagerNetworkProtocolV1_6_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_6_2_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_6_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_6_2/Redfish_ManagerNetworkProtocol_v1_6_2_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_6_2 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_2_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_6_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_7_0/EfiManagerNetworkProtocolV1_7_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_7_0/EfiManagerNetworkProtocolV1_7_0.h new file mode 100644 index 00000000000..c18bd1f9222 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ManagerNetworkProtocol/v1_7_0/EfiManagerNetworkProtocolV1_7_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ManagerNetworkProtocol v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_7_0_H__ +#define EFI_REDFISH_INTERP_MANAGERNETWORKPROTOCOL_V1_7_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ManagerNetworkProtocol/v1_7_0/Redfish_ManagerNetworkProtocol_v1_7_0_CS.h" +// +// EFI structure of Redfish ManagerNetworkProtocol v1_7_0 +// +typedef struct _EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_7_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_7_0_CS *ManagerNetworkProtocol; +} EFI_REDFISH_MANAGERNETWORKPROTOCOL_V1_7_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MediaController/v1_0_0/EfiMediaControllerV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MediaController/v1_0_0/EfiMediaControllerV1_0_0.h new file mode 100644 index 00000000000..e569225aaea --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MediaController/v1_0_0/EfiMediaControllerV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MediaController v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEDIACONTROLLER_V1_0_0_H__ +#define EFI_REDFISH_INTERP_MEDIACONTROLLER_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MediaController/v1_0_0/Redfish_MediaController_v1_0_0_CS.h" +// +// EFI structure of Redfish MediaController v1_0_0 +// +typedef struct _EFI_REDFISH_MEDIACONTROLLER_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEDIACONTROLLER_V1_0_0_CS *MediaController; +} EFI_REDFISH_MEDIACONTROLLER_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MediaController/v1_0_1/EfiMediaControllerV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MediaController/v1_0_1/EfiMediaControllerV1_0_1.h new file mode 100644 index 00000000000..e44ad4c4966 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MediaController/v1_0_1/EfiMediaControllerV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MediaController v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEDIACONTROLLER_V1_0_1_H__ +#define EFI_REDFISH_INTERP_MEDIACONTROLLER_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MediaController/v1_0_1/Redfish_MediaController_v1_0_1_CS.h" +// +// EFI structure of Redfish MediaController v1_0_1 +// +typedef struct _EFI_REDFISH_MEDIACONTROLLER_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEDIACONTROLLER_V1_0_1_CS *MediaController; +} EFI_REDFISH_MEDIACONTROLLER_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MediaController/v1_1_0/EfiMediaControllerV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MediaController/v1_1_0/EfiMediaControllerV1_1_0.h new file mode 100644 index 00000000000..7f79164b1d0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MediaController/v1_1_0/EfiMediaControllerV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MediaController v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEDIACONTROLLER_V1_1_0_H__ +#define EFI_REDFISH_INTERP_MEDIACONTROLLER_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MediaController/v1_1_0/Redfish_MediaController_v1_1_0_CS.h" +// +// EFI structure of Redfish MediaController v1_1_0 +// +typedef struct _EFI_REDFISH_MEDIACONTROLLER_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEDIACONTROLLER_V1_1_0_CS *MediaController; +} EFI_REDFISH_MEDIACONTROLLER_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MediaControllerCollection/EfiMediaControllerCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/MediaControllerCollection/EfiMediaControllerCollection.h new file mode 100644 index 00000000000..b66f4b12972 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MediaControllerCollection/EfiMediaControllerCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MediaControllerCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEDIACONTROLLERCOLLECTION_H__ +#define EFI_REDFISH_INTERP_MEDIACONTROLLERCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/MediaControllerCollection/Redfish_MediaControllerCollection_CS.h" +// +// EFI structure of Redfish MediaControllerCollection +// +typedef struct _EFI_REDFISH_MEDIACONTROLLERCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEDIACONTROLLERCOLLECTION_CS *MediaControllerCollection; +} EFI_REDFISH_MEDIACONTROLLERCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_0/EfiMemoryV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_0/EfiMemoryV1_0_0.h new file mode 100644 index 00000000000..6b30fdf2786 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_0/EfiMemoryV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_0_0_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_0_0/Redfish_Memory_v1_0_0_CS.h" +// +// EFI structure of Redfish Memory v1_0_0 +// +typedef struct _EFI_REDFISH_MEMORY_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_0_0_CS *Memory; +} EFI_REDFISH_MEMORY_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_1/EfiMemoryV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_1/EfiMemoryV1_0_1.h new file mode 100644 index 00000000000..dc7525eea71 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_1/EfiMemoryV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_0_1_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_0_1/Redfish_Memory_v1_0_1_CS.h" +// +// EFI structure of Redfish Memory v1_0_1 +// +typedef struct _EFI_REDFISH_MEMORY_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_0_1_CS *Memory; +} EFI_REDFISH_MEMORY_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_10/EfiMemoryV1_0_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_10/EfiMemoryV1_0_10.h new file mode 100644 index 00000000000..b42e7ca5d67 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_10/EfiMemoryV1_0_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_0_10_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_0_10_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_0_10/Redfish_Memory_v1_0_10_CS.h" +// +// EFI structure of Redfish Memory v1_0_10 +// +typedef struct _EFI_REDFISH_MEMORY_V1_0_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_0_10_CS *Memory; +} EFI_REDFISH_MEMORY_V1_0_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_11/EfiMemoryV1_0_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_11/EfiMemoryV1_0_11.h new file mode 100644 index 00000000000..cc141eb6b82 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_11/EfiMemoryV1_0_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_0_11_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_0_11_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_0_11/Redfish_Memory_v1_0_11_CS.h" +// +// EFI structure of Redfish Memory v1_0_11 +// +typedef struct _EFI_REDFISH_MEMORY_V1_0_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_0_11_CS *Memory; +} EFI_REDFISH_MEMORY_V1_0_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_2/EfiMemoryV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_2/EfiMemoryV1_0_2.h new file mode 100644 index 00000000000..940736962d2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_2/EfiMemoryV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_0_2_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_0_2/Redfish_Memory_v1_0_2_CS.h" +// +// EFI structure of Redfish Memory v1_0_2 +// +typedef struct _EFI_REDFISH_MEMORY_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_0_2_CS *Memory; +} EFI_REDFISH_MEMORY_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_3/EfiMemoryV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_3/EfiMemoryV1_0_3.h new file mode 100644 index 00000000000..d91179a92d7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_3/EfiMemoryV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_0_3_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_0_3/Redfish_Memory_v1_0_3_CS.h" +// +// EFI structure of Redfish Memory v1_0_3 +// +typedef struct _EFI_REDFISH_MEMORY_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_0_3_CS *Memory; +} EFI_REDFISH_MEMORY_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_4/EfiMemoryV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_4/EfiMemoryV1_0_4.h new file mode 100644 index 00000000000..b978f76e130 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_4/EfiMemoryV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_0_4_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_0_4/Redfish_Memory_v1_0_4_CS.h" +// +// EFI structure of Redfish Memory v1_0_4 +// +typedef struct _EFI_REDFISH_MEMORY_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_0_4_CS *Memory; +} EFI_REDFISH_MEMORY_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_5/EfiMemoryV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_5/EfiMemoryV1_0_5.h new file mode 100644 index 00000000000..ba97da5fdc3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_5/EfiMemoryV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_0_5_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_0_5/Redfish_Memory_v1_0_5_CS.h" +// +// EFI structure of Redfish Memory v1_0_5 +// +typedef struct _EFI_REDFISH_MEMORY_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_0_5_CS *Memory; +} EFI_REDFISH_MEMORY_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_6/EfiMemoryV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_6/EfiMemoryV1_0_6.h new file mode 100644 index 00000000000..50281a4578d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_6/EfiMemoryV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_0_6_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_0_6/Redfish_Memory_v1_0_6_CS.h" +// +// EFI structure of Redfish Memory v1_0_6 +// +typedef struct _EFI_REDFISH_MEMORY_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_0_6_CS *Memory; +} EFI_REDFISH_MEMORY_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_7/EfiMemoryV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_7/EfiMemoryV1_0_7.h new file mode 100644 index 00000000000..d401066f13c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_7/EfiMemoryV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_0_7_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_0_7/Redfish_Memory_v1_0_7_CS.h" +// +// EFI structure of Redfish Memory v1_0_7 +// +typedef struct _EFI_REDFISH_MEMORY_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_0_7_CS *Memory; +} EFI_REDFISH_MEMORY_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_8/EfiMemoryV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_8/EfiMemoryV1_0_8.h new file mode 100644 index 00000000000..05ff0637a13 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_8/EfiMemoryV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_0_8_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_0_8/Redfish_Memory_v1_0_8_CS.h" +// +// EFI structure of Redfish Memory v1_0_8 +// +typedef struct _EFI_REDFISH_MEMORY_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_0_8_CS *Memory; +} EFI_REDFISH_MEMORY_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_9/EfiMemoryV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_9/EfiMemoryV1_0_9.h new file mode 100644 index 00000000000..89c3de474e1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_0_9/EfiMemoryV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_0_9_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_0_9/Redfish_Memory_v1_0_9_CS.h" +// +// EFI structure of Redfish Memory v1_0_9 +// +typedef struct _EFI_REDFISH_MEMORY_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_0_9_CS *Memory; +} EFI_REDFISH_MEMORY_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_10_0/EfiMemoryV1_10_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_10_0/EfiMemoryV1_10_0.h new file mode 100644 index 00000000000..bafe0468d4e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_10_0/EfiMemoryV1_10_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_10_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_10_0_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_10_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_10_0/Redfish_Memory_v1_10_0_CS.h" +// +// EFI structure of Redfish Memory v1_10_0 +// +typedef struct _EFI_REDFISH_MEMORY_V1_10_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_10_0_CS *Memory; +} EFI_REDFISH_MEMORY_V1_10_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_10_1/EfiMemoryV1_10_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_10_1/EfiMemoryV1_10_1.h new file mode 100644 index 00000000000..81a3b2809c9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_10_1/EfiMemoryV1_10_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_10_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_10_1_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_10_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_10_1/Redfish_Memory_v1_10_1_CS.h" +// +// EFI structure of Redfish Memory v1_10_1 +// +typedef struct _EFI_REDFISH_MEMORY_V1_10_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_10_1_CS *Memory; +} EFI_REDFISH_MEMORY_V1_10_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_11_0/EfiMemoryV1_11_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_11_0/EfiMemoryV1_11_0.h new file mode 100644 index 00000000000..0384bb96d5c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_11_0/EfiMemoryV1_11_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_11_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_11_0_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_11_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_11_0/Redfish_Memory_v1_11_0_CS.h" +// +// EFI structure of Redfish Memory v1_11_0 +// +typedef struct _EFI_REDFISH_MEMORY_V1_11_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_11_0_CS *Memory; +} EFI_REDFISH_MEMORY_V1_11_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_0/EfiMemoryV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_0/EfiMemoryV1_1_0.h new file mode 100644 index 00000000000..14f800c1aad --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_0/EfiMemoryV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_1_0_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_1_0/Redfish_Memory_v1_1_0_CS.h" +// +// EFI structure of Redfish Memory v1_1_0 +// +typedef struct _EFI_REDFISH_MEMORY_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_1_0_CS *Memory; +} EFI_REDFISH_MEMORY_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_1/EfiMemoryV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_1/EfiMemoryV1_1_1.h new file mode 100644 index 00000000000..e1d90fc0107 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_1/EfiMemoryV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_1_1_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_1_1/Redfish_Memory_v1_1_1_CS.h" +// +// EFI structure of Redfish Memory v1_1_1 +// +typedef struct _EFI_REDFISH_MEMORY_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_1_1_CS *Memory; +} EFI_REDFISH_MEMORY_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_10/EfiMemoryV1_1_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_10/EfiMemoryV1_1_10.h new file mode 100644 index 00000000000..66b028772da --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_10/EfiMemoryV1_1_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_1_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_1_10_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_1_10_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_1_10/Redfish_Memory_v1_1_10_CS.h" +// +// EFI structure of Redfish Memory v1_1_10 +// +typedef struct _EFI_REDFISH_MEMORY_V1_1_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_1_10_CS *Memory; +} EFI_REDFISH_MEMORY_V1_1_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_2/EfiMemoryV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_2/EfiMemoryV1_1_2.h new file mode 100644 index 00000000000..e1fd3cb3340 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_2/EfiMemoryV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_1_2_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_1_2/Redfish_Memory_v1_1_2_CS.h" +// +// EFI structure of Redfish Memory v1_1_2 +// +typedef struct _EFI_REDFISH_MEMORY_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_1_2_CS *Memory; +} EFI_REDFISH_MEMORY_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_3/EfiMemoryV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_3/EfiMemoryV1_1_3.h new file mode 100644 index 00000000000..f741f1d7eb9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_3/EfiMemoryV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_1_3_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_1_3/Redfish_Memory_v1_1_3_CS.h" +// +// EFI structure of Redfish Memory v1_1_3 +// +typedef struct _EFI_REDFISH_MEMORY_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_1_3_CS *Memory; +} EFI_REDFISH_MEMORY_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_4/EfiMemoryV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_4/EfiMemoryV1_1_4.h new file mode 100644 index 00000000000..3acd898ad02 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_4/EfiMemoryV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_1_4_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_1_4/Redfish_Memory_v1_1_4_CS.h" +// +// EFI structure of Redfish Memory v1_1_4 +// +typedef struct _EFI_REDFISH_MEMORY_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_1_4_CS *Memory; +} EFI_REDFISH_MEMORY_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_5/EfiMemoryV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_5/EfiMemoryV1_1_5.h new file mode 100644 index 00000000000..523a06228ae --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_5/EfiMemoryV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_1_5_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_1_5/Redfish_Memory_v1_1_5_CS.h" +// +// EFI structure of Redfish Memory v1_1_5 +// +typedef struct _EFI_REDFISH_MEMORY_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_1_5_CS *Memory; +} EFI_REDFISH_MEMORY_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_6/EfiMemoryV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_6/EfiMemoryV1_1_6.h new file mode 100644 index 00000000000..e2f503ae87b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_6/EfiMemoryV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_1_6_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_1_6/Redfish_Memory_v1_1_6_CS.h" +// +// EFI structure of Redfish Memory v1_1_6 +// +typedef struct _EFI_REDFISH_MEMORY_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_1_6_CS *Memory; +} EFI_REDFISH_MEMORY_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_7/EfiMemoryV1_1_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_7/EfiMemoryV1_1_7.h new file mode 100644 index 00000000000..b42b23fbe6e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_7/EfiMemoryV1_1_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_1_7_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_1_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_1_7/Redfish_Memory_v1_1_7_CS.h" +// +// EFI structure of Redfish Memory v1_1_7 +// +typedef struct _EFI_REDFISH_MEMORY_V1_1_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_1_7_CS *Memory; +} EFI_REDFISH_MEMORY_V1_1_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_8/EfiMemoryV1_1_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_8/EfiMemoryV1_1_8.h new file mode 100644 index 00000000000..c95b278eca9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_8/EfiMemoryV1_1_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_1_8_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_1_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_1_8/Redfish_Memory_v1_1_8_CS.h" +// +// EFI structure of Redfish Memory v1_1_8 +// +typedef struct _EFI_REDFISH_MEMORY_V1_1_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_1_8_CS *Memory; +} EFI_REDFISH_MEMORY_V1_1_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_9/EfiMemoryV1_1_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_9/EfiMemoryV1_1_9.h new file mode 100644 index 00000000000..c4faa472f76 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_1_9/EfiMemoryV1_1_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_1_9_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_1_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_1_9/Redfish_Memory_v1_1_9_CS.h" +// +// EFI structure of Redfish Memory v1_1_9 +// +typedef struct _EFI_REDFISH_MEMORY_V1_1_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_1_9_CS *Memory; +} EFI_REDFISH_MEMORY_V1_1_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_0/EfiMemoryV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_0/EfiMemoryV1_2_0.h new file mode 100644 index 00000000000..bd4395d43c1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_0/EfiMemoryV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_2_0_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_2_0/Redfish_Memory_v1_2_0_CS.h" +// +// EFI structure of Redfish Memory v1_2_0 +// +typedef struct _EFI_REDFISH_MEMORY_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_2_0_CS *Memory; +} EFI_REDFISH_MEMORY_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_1/EfiMemoryV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_1/EfiMemoryV1_2_1.h new file mode 100644 index 00000000000..23fc5f26937 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_1/EfiMemoryV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_2_1_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_2_1/Redfish_Memory_v1_2_1_CS.h" +// +// EFI structure of Redfish Memory v1_2_1 +// +typedef struct _EFI_REDFISH_MEMORY_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_2_1_CS *Memory; +} EFI_REDFISH_MEMORY_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_2/EfiMemoryV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_2/EfiMemoryV1_2_2.h new file mode 100644 index 00000000000..241efc0520a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_2/EfiMemoryV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_2_2_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_2_2/Redfish_Memory_v1_2_2_CS.h" +// +// EFI structure of Redfish Memory v1_2_2 +// +typedef struct _EFI_REDFISH_MEMORY_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_2_2_CS *Memory; +} EFI_REDFISH_MEMORY_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_3/EfiMemoryV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_3/EfiMemoryV1_2_3.h new file mode 100644 index 00000000000..8a272f4371f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_3/EfiMemoryV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_2_3_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_2_3/Redfish_Memory_v1_2_3_CS.h" +// +// EFI structure of Redfish Memory v1_2_3 +// +typedef struct _EFI_REDFISH_MEMORY_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_2_3_CS *Memory; +} EFI_REDFISH_MEMORY_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_4/EfiMemoryV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_4/EfiMemoryV1_2_4.h new file mode 100644 index 00000000000..9e374b8f3ff --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_4/EfiMemoryV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_2_4_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_2_4/Redfish_Memory_v1_2_4_CS.h" +// +// EFI structure of Redfish Memory v1_2_4 +// +typedef struct _EFI_REDFISH_MEMORY_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_2_4_CS *Memory; +} EFI_REDFISH_MEMORY_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_5/EfiMemoryV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_5/EfiMemoryV1_2_5.h new file mode 100644 index 00000000000..71277ce3f38 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_5/EfiMemoryV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_2_5_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_2_5/Redfish_Memory_v1_2_5_CS.h" +// +// EFI structure of Redfish Memory v1_2_5 +// +typedef struct _EFI_REDFISH_MEMORY_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_2_5_CS *Memory; +} EFI_REDFISH_MEMORY_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_6/EfiMemoryV1_2_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_6/EfiMemoryV1_2_6.h new file mode 100644 index 00000000000..f68f276f06d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_6/EfiMemoryV1_2_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_2_6_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_2_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_2_6/Redfish_Memory_v1_2_6_CS.h" +// +// EFI structure of Redfish Memory v1_2_6 +// +typedef struct _EFI_REDFISH_MEMORY_V1_2_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_2_6_CS *Memory; +} EFI_REDFISH_MEMORY_V1_2_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_7/EfiMemoryV1_2_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_7/EfiMemoryV1_2_7.h new file mode 100644 index 00000000000..cbbad1eb4d0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_7/EfiMemoryV1_2_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_2_7_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_2_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_2_7/Redfish_Memory_v1_2_7_CS.h" +// +// EFI structure of Redfish Memory v1_2_7 +// +typedef struct _EFI_REDFISH_MEMORY_V1_2_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_2_7_CS *Memory; +} EFI_REDFISH_MEMORY_V1_2_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_8/EfiMemoryV1_2_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_8/EfiMemoryV1_2_8.h new file mode 100644 index 00000000000..76de25656d1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_8/EfiMemoryV1_2_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_2_8_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_2_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_2_8/Redfish_Memory_v1_2_8_CS.h" +// +// EFI structure of Redfish Memory v1_2_8 +// +typedef struct _EFI_REDFISH_MEMORY_V1_2_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_2_8_CS *Memory; +} EFI_REDFISH_MEMORY_V1_2_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_9/EfiMemoryV1_2_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_9/EfiMemoryV1_2_9.h new file mode 100644 index 00000000000..55ea3f7b9be --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_2_9/EfiMemoryV1_2_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_2_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_2_9_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_2_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_2_9/Redfish_Memory_v1_2_9_CS.h" +// +// EFI structure of Redfish Memory v1_2_9 +// +typedef struct _EFI_REDFISH_MEMORY_V1_2_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_2_9_CS *Memory; +} EFI_REDFISH_MEMORY_V1_2_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_0/EfiMemoryV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_0/EfiMemoryV1_3_0.h new file mode 100644 index 00000000000..ade385641fa --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_0/EfiMemoryV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_3_0_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_3_0/Redfish_Memory_v1_3_0_CS.h" +// +// EFI structure of Redfish Memory v1_3_0 +// +typedef struct _EFI_REDFISH_MEMORY_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_3_0_CS *Memory; +} EFI_REDFISH_MEMORY_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_1/EfiMemoryV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_1/EfiMemoryV1_3_1.h new file mode 100644 index 00000000000..5ac49808dce --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_1/EfiMemoryV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_3_1_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_3_1/Redfish_Memory_v1_3_1_CS.h" +// +// EFI structure of Redfish Memory v1_3_1 +// +typedef struct _EFI_REDFISH_MEMORY_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_3_1_CS *Memory; +} EFI_REDFISH_MEMORY_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_2/EfiMemoryV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_2/EfiMemoryV1_3_2.h new file mode 100644 index 00000000000..452efdd7e57 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_2/EfiMemoryV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_3_2_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_3_2/Redfish_Memory_v1_3_2_CS.h" +// +// EFI structure of Redfish Memory v1_3_2 +// +typedef struct _EFI_REDFISH_MEMORY_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_3_2_CS *Memory; +} EFI_REDFISH_MEMORY_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_3/EfiMemoryV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_3/EfiMemoryV1_3_3.h new file mode 100644 index 00000000000..4565a0116be --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_3/EfiMemoryV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_3_3_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_3_3/Redfish_Memory_v1_3_3_CS.h" +// +// EFI structure of Redfish Memory v1_3_3 +// +typedef struct _EFI_REDFISH_MEMORY_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_3_3_CS *Memory; +} EFI_REDFISH_MEMORY_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_4/EfiMemoryV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_4/EfiMemoryV1_3_4.h new file mode 100644 index 00000000000..3e535a116da --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_4/EfiMemoryV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_3_4_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_3_4/Redfish_Memory_v1_3_4_CS.h" +// +// EFI structure of Redfish Memory v1_3_4 +// +typedef struct _EFI_REDFISH_MEMORY_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_3_4_CS *Memory; +} EFI_REDFISH_MEMORY_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_5/EfiMemoryV1_3_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_5/EfiMemoryV1_3_5.h new file mode 100644 index 00000000000..66c094b8357 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_5/EfiMemoryV1_3_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_3_5_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_3_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_3_5/Redfish_Memory_v1_3_5_CS.h" +// +// EFI structure of Redfish Memory v1_3_5 +// +typedef struct _EFI_REDFISH_MEMORY_V1_3_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_3_5_CS *Memory; +} EFI_REDFISH_MEMORY_V1_3_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_6/EfiMemoryV1_3_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_6/EfiMemoryV1_3_6.h new file mode 100644 index 00000000000..c40fabe96b3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_6/EfiMemoryV1_3_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_3_6_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_3_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_3_6/Redfish_Memory_v1_3_6_CS.h" +// +// EFI structure of Redfish Memory v1_3_6 +// +typedef struct _EFI_REDFISH_MEMORY_V1_3_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_3_6_CS *Memory; +} EFI_REDFISH_MEMORY_V1_3_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_7/EfiMemoryV1_3_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_7/EfiMemoryV1_3_7.h new file mode 100644 index 00000000000..d4031fbc54d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_7/EfiMemoryV1_3_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_3_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_3_7_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_3_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_3_7/Redfish_Memory_v1_3_7_CS.h" +// +// EFI structure of Redfish Memory v1_3_7 +// +typedef struct _EFI_REDFISH_MEMORY_V1_3_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_3_7_CS *Memory; +} EFI_REDFISH_MEMORY_V1_3_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_8/EfiMemoryV1_3_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_8/EfiMemoryV1_3_8.h new file mode 100644 index 00000000000..59e64a5479c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_8/EfiMemoryV1_3_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_3_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_3_8_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_3_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_3_8/Redfish_Memory_v1_3_8_CS.h" +// +// EFI structure of Redfish Memory v1_3_8 +// +typedef struct _EFI_REDFISH_MEMORY_V1_3_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_3_8_CS *Memory; +} EFI_REDFISH_MEMORY_V1_3_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_9/EfiMemoryV1_3_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_9/EfiMemoryV1_3_9.h new file mode 100644 index 00000000000..0e3f6875b47 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_3_9/EfiMemoryV1_3_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_3_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_3_9_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_3_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_3_9/Redfish_Memory_v1_3_9_CS.h" +// +// EFI structure of Redfish Memory v1_3_9 +// +typedef struct _EFI_REDFISH_MEMORY_V1_3_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_3_9_CS *Memory; +} EFI_REDFISH_MEMORY_V1_3_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_0/EfiMemoryV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_0/EfiMemoryV1_4_0.h new file mode 100644 index 00000000000..dd2b269cae5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_0/EfiMemoryV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_4_0_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_4_0/Redfish_Memory_v1_4_0_CS.h" +// +// EFI structure of Redfish Memory v1_4_0 +// +typedef struct _EFI_REDFISH_MEMORY_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_4_0_CS *Memory; +} EFI_REDFISH_MEMORY_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_1/EfiMemoryV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_1/EfiMemoryV1_4_1.h new file mode 100644 index 00000000000..ee7e5aa4376 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_1/EfiMemoryV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_4_1_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_4_1/Redfish_Memory_v1_4_1_CS.h" +// +// EFI structure of Redfish Memory v1_4_1 +// +typedef struct _EFI_REDFISH_MEMORY_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_4_1_CS *Memory; +} EFI_REDFISH_MEMORY_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_2/EfiMemoryV1_4_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_2/EfiMemoryV1_4_2.h new file mode 100644 index 00000000000..1837dc97e96 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_2/EfiMemoryV1_4_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_4_2_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_4_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_4_2/Redfish_Memory_v1_4_2_CS.h" +// +// EFI structure of Redfish Memory v1_4_2 +// +typedef struct _EFI_REDFISH_MEMORY_V1_4_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_4_2_CS *Memory; +} EFI_REDFISH_MEMORY_V1_4_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_3/EfiMemoryV1_4_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_3/EfiMemoryV1_4_3.h new file mode 100644 index 00000000000..25f21d23884 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_3/EfiMemoryV1_4_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_4_3_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_4_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_4_3/Redfish_Memory_v1_4_3_CS.h" +// +// EFI structure of Redfish Memory v1_4_3 +// +typedef struct _EFI_REDFISH_MEMORY_V1_4_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_4_3_CS *Memory; +} EFI_REDFISH_MEMORY_V1_4_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_4/EfiMemoryV1_4_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_4/EfiMemoryV1_4_4.h new file mode 100644 index 00000000000..95bb19c38be --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_4/EfiMemoryV1_4_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_4_4_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_4_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_4_4/Redfish_Memory_v1_4_4_CS.h" +// +// EFI structure of Redfish Memory v1_4_4 +// +typedef struct _EFI_REDFISH_MEMORY_V1_4_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_4_4_CS *Memory; +} EFI_REDFISH_MEMORY_V1_4_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_5/EfiMemoryV1_4_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_5/EfiMemoryV1_4_5.h new file mode 100644 index 00000000000..015014fcc32 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_5/EfiMemoryV1_4_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_4_5_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_4_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_4_5/Redfish_Memory_v1_4_5_CS.h" +// +// EFI structure of Redfish Memory v1_4_5 +// +typedef struct _EFI_REDFISH_MEMORY_V1_4_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_4_5_CS *Memory; +} EFI_REDFISH_MEMORY_V1_4_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_6/EfiMemoryV1_4_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_6/EfiMemoryV1_4_6.h new file mode 100644 index 00000000000..cd18e0cc9cf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_6/EfiMemoryV1_4_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_4_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_4_6_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_4_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_4_6/Redfish_Memory_v1_4_6_CS.h" +// +// EFI structure of Redfish Memory v1_4_6 +// +typedef struct _EFI_REDFISH_MEMORY_V1_4_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_4_6_CS *Memory; +} EFI_REDFISH_MEMORY_V1_4_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_7/EfiMemoryV1_4_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_7/EfiMemoryV1_4_7.h new file mode 100644 index 00000000000..603aa39d557 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_7/EfiMemoryV1_4_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_4_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_4_7_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_4_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_4_7/Redfish_Memory_v1_4_7_CS.h" +// +// EFI structure of Redfish Memory v1_4_7 +// +typedef struct _EFI_REDFISH_MEMORY_V1_4_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_4_7_CS *Memory; +} EFI_REDFISH_MEMORY_V1_4_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_8/EfiMemoryV1_4_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_8/EfiMemoryV1_4_8.h new file mode 100644 index 00000000000..d5633937137 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_8/EfiMemoryV1_4_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_4_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_4_8_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_4_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_4_8/Redfish_Memory_v1_4_8_CS.h" +// +// EFI structure of Redfish Memory v1_4_8 +// +typedef struct _EFI_REDFISH_MEMORY_V1_4_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_4_8_CS *Memory; +} EFI_REDFISH_MEMORY_V1_4_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_9/EfiMemoryV1_4_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_9/EfiMemoryV1_4_9.h new file mode 100644 index 00000000000..2fa6983d5d2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_4_9/EfiMemoryV1_4_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_4_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_4_9_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_4_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_4_9/Redfish_Memory_v1_4_9_CS.h" +// +// EFI structure of Redfish Memory v1_4_9 +// +typedef struct _EFI_REDFISH_MEMORY_V1_4_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_4_9_CS *Memory; +} EFI_REDFISH_MEMORY_V1_4_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_0/EfiMemoryV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_0/EfiMemoryV1_5_0.h new file mode 100644 index 00000000000..73ebfc948e7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_0/EfiMemoryV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_5_0_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_5_0/Redfish_Memory_v1_5_0_CS.h" +// +// EFI structure of Redfish Memory v1_5_0 +// +typedef struct _EFI_REDFISH_MEMORY_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_5_0_CS *Memory; +} EFI_REDFISH_MEMORY_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_1/EfiMemoryV1_5_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_1/EfiMemoryV1_5_1.h new file mode 100644 index 00000000000..29e6b79801b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_1/EfiMemoryV1_5_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_5_1_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_5_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_5_1/Redfish_Memory_v1_5_1_CS.h" +// +// EFI structure of Redfish Memory v1_5_1 +// +typedef struct _EFI_REDFISH_MEMORY_V1_5_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_5_1_CS *Memory; +} EFI_REDFISH_MEMORY_V1_5_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_2/EfiMemoryV1_5_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_2/EfiMemoryV1_5_2.h new file mode 100644 index 00000000000..6f24a0412af --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_2/EfiMemoryV1_5_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_5_2_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_5_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_5_2/Redfish_Memory_v1_5_2_CS.h" +// +// EFI structure of Redfish Memory v1_5_2 +// +typedef struct _EFI_REDFISH_MEMORY_V1_5_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_5_2_CS *Memory; +} EFI_REDFISH_MEMORY_V1_5_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_3/EfiMemoryV1_5_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_3/EfiMemoryV1_5_3.h new file mode 100644 index 00000000000..521be866dc4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_3/EfiMemoryV1_5_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_5_3_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_5_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_5_3/Redfish_Memory_v1_5_3_CS.h" +// +// EFI structure of Redfish Memory v1_5_3 +// +typedef struct _EFI_REDFISH_MEMORY_V1_5_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_5_3_CS *Memory; +} EFI_REDFISH_MEMORY_V1_5_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_4/EfiMemoryV1_5_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_4/EfiMemoryV1_5_4.h new file mode 100644 index 00000000000..06b1d1759ce --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_4/EfiMemoryV1_5_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_5_4_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_5_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_5_4/Redfish_Memory_v1_5_4_CS.h" +// +// EFI structure of Redfish Memory v1_5_4 +// +typedef struct _EFI_REDFISH_MEMORY_V1_5_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_5_4_CS *Memory; +} EFI_REDFISH_MEMORY_V1_5_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_5/EfiMemoryV1_5_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_5/EfiMemoryV1_5_5.h new file mode 100644 index 00000000000..0ec52fdf9b0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_5/EfiMemoryV1_5_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_5_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_5_5_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_5_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_5_5/Redfish_Memory_v1_5_5_CS.h" +// +// EFI structure of Redfish Memory v1_5_5 +// +typedef struct _EFI_REDFISH_MEMORY_V1_5_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_5_5_CS *Memory; +} EFI_REDFISH_MEMORY_V1_5_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_6/EfiMemoryV1_5_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_6/EfiMemoryV1_5_6.h new file mode 100644 index 00000000000..be2ee081b7a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_6/EfiMemoryV1_5_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_5_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_5_6_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_5_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_5_6/Redfish_Memory_v1_5_6_CS.h" +// +// EFI structure of Redfish Memory v1_5_6 +// +typedef struct _EFI_REDFISH_MEMORY_V1_5_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_5_6_CS *Memory; +} EFI_REDFISH_MEMORY_V1_5_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_7/EfiMemoryV1_5_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_7/EfiMemoryV1_5_7.h new file mode 100644 index 00000000000..095e7a71837 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_7/EfiMemoryV1_5_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_5_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_5_7_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_5_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_5_7/Redfish_Memory_v1_5_7_CS.h" +// +// EFI structure of Redfish Memory v1_5_7 +// +typedef struct _EFI_REDFISH_MEMORY_V1_5_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_5_7_CS *Memory; +} EFI_REDFISH_MEMORY_V1_5_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_8/EfiMemoryV1_5_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_8/EfiMemoryV1_5_8.h new file mode 100644 index 00000000000..5bad919a2d8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_5_8/EfiMemoryV1_5_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_5_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_5_8_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_5_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_5_8/Redfish_Memory_v1_5_8_CS.h" +// +// EFI structure of Redfish Memory v1_5_8 +// +typedef struct _EFI_REDFISH_MEMORY_V1_5_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_5_8_CS *Memory; +} EFI_REDFISH_MEMORY_V1_5_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_0/EfiMemoryV1_6_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_0/EfiMemoryV1_6_0.h new file mode 100644 index 00000000000..c7901560d1c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_0/EfiMemoryV1_6_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_6_0_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_6_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_6_0/Redfish_Memory_v1_6_0_CS.h" +// +// EFI structure of Redfish Memory v1_6_0 +// +typedef struct _EFI_REDFISH_MEMORY_V1_6_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_6_0_CS *Memory; +} EFI_REDFISH_MEMORY_V1_6_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_1/EfiMemoryV1_6_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_1/EfiMemoryV1_6_1.h new file mode 100644 index 00000000000..99daddb5ed2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_1/EfiMemoryV1_6_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_6_1_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_6_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_6_1/Redfish_Memory_v1_6_1_CS.h" +// +// EFI structure of Redfish Memory v1_6_1 +// +typedef struct _EFI_REDFISH_MEMORY_V1_6_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_6_1_CS *Memory; +} EFI_REDFISH_MEMORY_V1_6_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_2/EfiMemoryV1_6_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_2/EfiMemoryV1_6_2.h new file mode 100644 index 00000000000..a0b950345f6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_2/EfiMemoryV1_6_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_6_2_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_6_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_6_2/Redfish_Memory_v1_6_2_CS.h" +// +// EFI structure of Redfish Memory v1_6_2 +// +typedef struct _EFI_REDFISH_MEMORY_V1_6_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_6_2_CS *Memory; +} EFI_REDFISH_MEMORY_V1_6_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_3/EfiMemoryV1_6_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_3/EfiMemoryV1_6_3.h new file mode 100644 index 00000000000..36e30f14b87 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_3/EfiMemoryV1_6_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_6_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_6_3_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_6_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_6_3/Redfish_Memory_v1_6_3_CS.h" +// +// EFI structure of Redfish Memory v1_6_3 +// +typedef struct _EFI_REDFISH_MEMORY_V1_6_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_6_3_CS *Memory; +} EFI_REDFISH_MEMORY_V1_6_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_4/EfiMemoryV1_6_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_4/EfiMemoryV1_6_4.h new file mode 100644 index 00000000000..f46476d5f01 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_4/EfiMemoryV1_6_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_6_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_6_4_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_6_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_6_4/Redfish_Memory_v1_6_4_CS.h" +// +// EFI structure of Redfish Memory v1_6_4 +// +typedef struct _EFI_REDFISH_MEMORY_V1_6_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_6_4_CS *Memory; +} EFI_REDFISH_MEMORY_V1_6_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_5/EfiMemoryV1_6_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_5/EfiMemoryV1_6_5.h new file mode 100644 index 00000000000..49ed0bbc291 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_5/EfiMemoryV1_6_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_6_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_6_5_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_6_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_6_5/Redfish_Memory_v1_6_5_CS.h" +// +// EFI structure of Redfish Memory v1_6_5 +// +typedef struct _EFI_REDFISH_MEMORY_V1_6_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_6_5_CS *Memory; +} EFI_REDFISH_MEMORY_V1_6_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_6/EfiMemoryV1_6_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_6/EfiMemoryV1_6_6.h new file mode 100644 index 00000000000..6ba26575676 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_6/EfiMemoryV1_6_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_6_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_6_6_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_6_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_6_6/Redfish_Memory_v1_6_6_CS.h" +// +// EFI structure of Redfish Memory v1_6_6 +// +typedef struct _EFI_REDFISH_MEMORY_V1_6_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_6_6_CS *Memory; +} EFI_REDFISH_MEMORY_V1_6_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_7/EfiMemoryV1_6_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_7/EfiMemoryV1_6_7.h new file mode 100644 index 00000000000..36963c98e58 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_6_7/EfiMemoryV1_6_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_6_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_6_7_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_6_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_6_7/Redfish_Memory_v1_6_7_CS.h" +// +// EFI structure of Redfish Memory v1_6_7 +// +typedef struct _EFI_REDFISH_MEMORY_V1_6_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_6_7_CS *Memory; +} EFI_REDFISH_MEMORY_V1_6_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_0/EfiMemoryV1_7_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_0/EfiMemoryV1_7_0.h new file mode 100644 index 00000000000..b9aa4d923dd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_0/EfiMemoryV1_7_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_7_0_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_7_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_7_0/Redfish_Memory_v1_7_0_CS.h" +// +// EFI structure of Redfish Memory v1_7_0 +// +typedef struct _EFI_REDFISH_MEMORY_V1_7_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_7_0_CS *Memory; +} EFI_REDFISH_MEMORY_V1_7_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_1/EfiMemoryV1_7_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_1/EfiMemoryV1_7_1.h new file mode 100644 index 00000000000..6e2bd803422 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_1/EfiMemoryV1_7_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_7_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_7_1_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_7_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_7_1/Redfish_Memory_v1_7_1_CS.h" +// +// EFI structure of Redfish Memory v1_7_1 +// +typedef struct _EFI_REDFISH_MEMORY_V1_7_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_7_1_CS *Memory; +} EFI_REDFISH_MEMORY_V1_7_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_2/EfiMemoryV1_7_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_2/EfiMemoryV1_7_2.h new file mode 100644 index 00000000000..fa055afa5b0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_2/EfiMemoryV1_7_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_7_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_7_2_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_7_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_7_2/Redfish_Memory_v1_7_2_CS.h" +// +// EFI structure of Redfish Memory v1_7_2 +// +typedef struct _EFI_REDFISH_MEMORY_V1_7_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_7_2_CS *Memory; +} EFI_REDFISH_MEMORY_V1_7_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_3/EfiMemoryV1_7_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_3/EfiMemoryV1_7_3.h new file mode 100644 index 00000000000..09b47af7abe --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_3/EfiMemoryV1_7_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_7_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_7_3_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_7_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_7_3/Redfish_Memory_v1_7_3_CS.h" +// +// EFI structure of Redfish Memory v1_7_3 +// +typedef struct _EFI_REDFISH_MEMORY_V1_7_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_7_3_CS *Memory; +} EFI_REDFISH_MEMORY_V1_7_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_4/EfiMemoryV1_7_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_4/EfiMemoryV1_7_4.h new file mode 100644 index 00000000000..b0ee9384b29 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_4/EfiMemoryV1_7_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_7_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_7_4_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_7_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_7_4/Redfish_Memory_v1_7_4_CS.h" +// +// EFI structure of Redfish Memory v1_7_4 +// +typedef struct _EFI_REDFISH_MEMORY_V1_7_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_7_4_CS *Memory; +} EFI_REDFISH_MEMORY_V1_7_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_5/EfiMemoryV1_7_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_5/EfiMemoryV1_7_5.h new file mode 100644 index 00000000000..f8e702995d8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_5/EfiMemoryV1_7_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_7_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_7_5_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_7_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_7_5/Redfish_Memory_v1_7_5_CS.h" +// +// EFI structure of Redfish Memory v1_7_5 +// +typedef struct _EFI_REDFISH_MEMORY_V1_7_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_7_5_CS *Memory; +} EFI_REDFISH_MEMORY_V1_7_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_6/EfiMemoryV1_7_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_6/EfiMemoryV1_7_6.h new file mode 100644 index 00000000000..10140fedfe2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_7_6/EfiMemoryV1_7_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_7_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_7_6_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_7_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_7_6/Redfish_Memory_v1_7_6_CS.h" +// +// EFI structure of Redfish Memory v1_7_6 +// +typedef struct _EFI_REDFISH_MEMORY_V1_7_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_7_6_CS *Memory; +} EFI_REDFISH_MEMORY_V1_7_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_8_0/EfiMemoryV1_8_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_8_0/EfiMemoryV1_8_0.h new file mode 100644 index 00000000000..4c6910db290 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_8_0/EfiMemoryV1_8_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_8_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_8_0_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_8_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_8_0/Redfish_Memory_v1_8_0_CS.h" +// +// EFI structure of Redfish Memory v1_8_0 +// +typedef struct _EFI_REDFISH_MEMORY_V1_8_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_8_0_CS *Memory; +} EFI_REDFISH_MEMORY_V1_8_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_8_1/EfiMemoryV1_8_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_8_1/EfiMemoryV1_8_1.h new file mode 100644 index 00000000000..987275ebed8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_8_1/EfiMemoryV1_8_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_8_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_8_1_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_8_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_8_1/Redfish_Memory_v1_8_1_CS.h" +// +// EFI structure of Redfish Memory v1_8_1 +// +typedef struct _EFI_REDFISH_MEMORY_V1_8_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_8_1_CS *Memory; +} EFI_REDFISH_MEMORY_V1_8_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_8_2/EfiMemoryV1_8_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_8_2/EfiMemoryV1_8_2.h new file mode 100644 index 00000000000..fa63e4db323 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_8_2/EfiMemoryV1_8_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_8_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_8_2_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_8_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_8_2/Redfish_Memory_v1_8_2_CS.h" +// +// EFI structure of Redfish Memory v1_8_2 +// +typedef struct _EFI_REDFISH_MEMORY_V1_8_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_8_2_CS *Memory; +} EFI_REDFISH_MEMORY_V1_8_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_8_3/EfiMemoryV1_8_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_8_3/EfiMemoryV1_8_3.h new file mode 100644 index 00000000000..0b28e8a91c8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_8_3/EfiMemoryV1_8_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_8_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_8_3_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_8_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_8_3/Redfish_Memory_v1_8_3_CS.h" +// +// EFI structure of Redfish Memory v1_8_3 +// +typedef struct _EFI_REDFISH_MEMORY_V1_8_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_8_3_CS *Memory; +} EFI_REDFISH_MEMORY_V1_8_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_8_4/EfiMemoryV1_8_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_8_4/EfiMemoryV1_8_4.h new file mode 100644 index 00000000000..84ef03b2479 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_8_4/EfiMemoryV1_8_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_8_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_8_4_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_8_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_8_4/Redfish_Memory_v1_8_4_CS.h" +// +// EFI structure of Redfish Memory v1_8_4 +// +typedef struct _EFI_REDFISH_MEMORY_V1_8_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_8_4_CS *Memory; +} EFI_REDFISH_MEMORY_V1_8_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_9_0/EfiMemoryV1_9_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_9_0/EfiMemoryV1_9_0.h new file mode 100644 index 00000000000..7b90434f54d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_9_0/EfiMemoryV1_9_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_9_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_9_0_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_9_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_9_0/Redfish_Memory_v1_9_0_CS.h" +// +// EFI structure of Redfish Memory v1_9_0 +// +typedef struct _EFI_REDFISH_MEMORY_V1_9_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_9_0_CS *Memory; +} EFI_REDFISH_MEMORY_V1_9_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_9_1/EfiMemoryV1_9_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_9_1/EfiMemoryV1_9_1.h new file mode 100644 index 00000000000..b4d812649c1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_9_1/EfiMemoryV1_9_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_9_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_9_1_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_9_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_9_1/Redfish_Memory_v1_9_1_CS.h" +// +// EFI structure of Redfish Memory v1_9_1 +// +typedef struct _EFI_REDFISH_MEMORY_V1_9_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_9_1_CS *Memory; +} EFI_REDFISH_MEMORY_V1_9_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_9_2/EfiMemoryV1_9_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_9_2/EfiMemoryV1_9_2.h new file mode 100644 index 00000000000..5d0ad82573f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_9_2/EfiMemoryV1_9_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_9_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_9_2_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_9_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_9_2/Redfish_Memory_v1_9_2_CS.h" +// +// EFI structure of Redfish Memory v1_9_2 +// +typedef struct _EFI_REDFISH_MEMORY_V1_9_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_9_2_CS *Memory; +} EFI_REDFISH_MEMORY_V1_9_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_9_3/EfiMemoryV1_9_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_9_3/EfiMemoryV1_9_3.h new file mode 100644 index 00000000000..ce7b9cf393c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_9_3/EfiMemoryV1_9_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_9_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_9_3_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_9_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_9_3/Redfish_Memory_v1_9_3_CS.h" +// +// EFI structure of Redfish Memory v1_9_3 +// +typedef struct _EFI_REDFISH_MEMORY_V1_9_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_9_3_CS *Memory; +} EFI_REDFISH_MEMORY_V1_9_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_9_4/EfiMemoryV1_9_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_9_4/EfiMemoryV1_9_4.h new file mode 100644 index 00000000000..e9c8246ba6d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Memory/v1_9_4/EfiMemoryV1_9_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Memory v1_9_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORY_V1_9_4_H__ +#define EFI_REDFISH_INTERP_MEMORY_V1_9_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Memory/v1_9_4/Redfish_Memory_v1_9_4_CS.h" +// +// EFI structure of Redfish Memory v1_9_4 +// +typedef struct _EFI_REDFISH_MEMORY_V1_9_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORY_V1_9_4_CS *Memory; +} EFI_REDFISH_MEMORY_V1_9_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_0/EfiMemoryChunksV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_0/EfiMemoryChunksV1_0_0.h new file mode 100644 index 00000000000..41a940a7e09 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_0/EfiMemoryChunksV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_0_0_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_0_0/Redfish_MemoryChunks_v1_0_0_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_0_0 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_0_0_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_1/EfiMemoryChunksV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_1/EfiMemoryChunksV1_0_1.h new file mode 100644 index 00000000000..d9efacb81d9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_1/EfiMemoryChunksV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_0_1_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_0_1/Redfish_MemoryChunks_v1_0_1_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_0_1 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_0_1_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_2/EfiMemoryChunksV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_2/EfiMemoryChunksV1_0_2.h new file mode 100644 index 00000000000..2caff3195d8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_2/EfiMemoryChunksV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_0_2_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_0_2/Redfish_MemoryChunks_v1_0_2_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_0_2 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_0_2_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_3/EfiMemoryChunksV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_3/EfiMemoryChunksV1_0_3.h new file mode 100644 index 00000000000..ffad30d7662 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_3/EfiMemoryChunksV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_0_3_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_0_3/Redfish_MemoryChunks_v1_0_3_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_0_3 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_0_3_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_4/EfiMemoryChunksV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_4/EfiMemoryChunksV1_0_4.h new file mode 100644 index 00000000000..c732e0c83c1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_4/EfiMemoryChunksV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_0_4_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_0_4/Redfish_MemoryChunks_v1_0_4_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_0_4 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_0_4_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_5/EfiMemoryChunksV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_5/EfiMemoryChunksV1_0_5.h new file mode 100644 index 00000000000..6f211219a22 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_5/EfiMemoryChunksV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_0_5_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_0_5/Redfish_MemoryChunks_v1_0_5_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_0_5 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_0_5_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_6/EfiMemoryChunksV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_6/EfiMemoryChunksV1_0_6.h new file mode 100644 index 00000000000..4a45831bb38 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_6/EfiMemoryChunksV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_0_6_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_0_6/Redfish_MemoryChunks_v1_0_6_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_0_6 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_0_6_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_7/EfiMemoryChunksV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_7/EfiMemoryChunksV1_0_7.h new file mode 100644 index 00000000000..35315e195a5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_0_7/EfiMemoryChunksV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_0_7_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_0_7/Redfish_MemoryChunks_v1_0_7_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_0_7 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_0_7_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_1_0/EfiMemoryChunksV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_1_0/EfiMemoryChunksV1_1_0.h new file mode 100644 index 00000000000..17d7bfecd3e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_1_0/EfiMemoryChunksV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_1_0_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_1_0/Redfish_MemoryChunks_v1_1_0_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_1_0 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_1_0_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_1_1/EfiMemoryChunksV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_1_1/EfiMemoryChunksV1_1_1.h new file mode 100644 index 00000000000..42a999bf0e5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_1_1/EfiMemoryChunksV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_1_1_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_1_1/Redfish_MemoryChunks_v1_1_1_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_1_1 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_1_1_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_1_2/EfiMemoryChunksV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_1_2/EfiMemoryChunksV1_1_2.h new file mode 100644 index 00000000000..39126b3c93e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_1_2/EfiMemoryChunksV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_1_2_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_1_2/Redfish_MemoryChunks_v1_1_2_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_1_2 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_1_2_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_1_3/EfiMemoryChunksV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_1_3/EfiMemoryChunksV1_1_3.h new file mode 100644 index 00000000000..6eaa2698fce --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_1_3/EfiMemoryChunksV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_1_3_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_1_3/Redfish_MemoryChunks_v1_1_3_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_1_3 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_1_3_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_1_4/EfiMemoryChunksV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_1_4/EfiMemoryChunksV1_1_4.h new file mode 100644 index 00000000000..e6b5b1e6e2f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_1_4/EfiMemoryChunksV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_1_4_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_1_4/Redfish_MemoryChunks_v1_1_4_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_1_4 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_1_4_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_1_5/EfiMemoryChunksV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_1_5/EfiMemoryChunksV1_1_5.h new file mode 100644 index 00000000000..874c63935b2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_1_5/EfiMemoryChunksV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_1_5_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_1_5/Redfish_MemoryChunks_v1_1_5_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_1_5 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_1_5_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_0/EfiMemoryChunksV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_0/EfiMemoryChunksV1_2_0.h new file mode 100644 index 00000000000..d62b69696c1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_0/EfiMemoryChunksV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_2_0_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_2_0/Redfish_MemoryChunks_v1_2_0_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_2_0 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_2_0_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_1/EfiMemoryChunksV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_1/EfiMemoryChunksV1_2_1.h new file mode 100644 index 00000000000..95d91e7a1ed --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_1/EfiMemoryChunksV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_2_1_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_2_1/Redfish_MemoryChunks_v1_2_1_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_2_1 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_2_1_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_2/EfiMemoryChunksV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_2/EfiMemoryChunksV1_2_2.h new file mode 100644 index 00000000000..6446d5215e1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_2/EfiMemoryChunksV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_2_2_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_2_2/Redfish_MemoryChunks_v1_2_2_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_2_2 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_2_2_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_3/EfiMemoryChunksV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_3/EfiMemoryChunksV1_2_3.h new file mode 100644 index 00000000000..8ae183a3bb5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_3/EfiMemoryChunksV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_2_3_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_2_3/Redfish_MemoryChunks_v1_2_3_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_2_3 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_2_3_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_4/EfiMemoryChunksV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_4/EfiMemoryChunksV1_2_4.h new file mode 100644 index 00000000000..dfe4f13f7e8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_4/EfiMemoryChunksV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_2_4_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_2_4/Redfish_MemoryChunks_v1_2_4_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_2_4 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_2_4_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_5/EfiMemoryChunksV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_5/EfiMemoryChunksV1_2_5.h new file mode 100644 index 00000000000..d2e9196c28a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_5/EfiMemoryChunksV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_2_5_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_2_5/Redfish_MemoryChunks_v1_2_5_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_2_5 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_2_5_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_6/EfiMemoryChunksV1_2_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_6/EfiMemoryChunksV1_2_6.h new file mode 100644 index 00000000000..d6d88dcf266 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_2_6/EfiMemoryChunksV1_2_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_2_6_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_2_6_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_2_6/Redfish_MemoryChunks_v1_2_6_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_2_6 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_2_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_2_6_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_2_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_3_0/EfiMemoryChunksV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_3_0/EfiMemoryChunksV1_3_0.h new file mode 100644 index 00000000000..1a39e96e506 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_3_0/EfiMemoryChunksV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_3_0_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_3_0/Redfish_MemoryChunks_v1_3_0_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_3_0 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_3_0_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_3_1/EfiMemoryChunksV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_3_1/EfiMemoryChunksV1_3_1.h new file mode 100644 index 00000000000..d6890892741 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_3_1/EfiMemoryChunksV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_3_1_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_3_1/Redfish_MemoryChunks_v1_3_1_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_3_1 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_3_1_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_3_2/EfiMemoryChunksV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_3_2/EfiMemoryChunksV1_3_2.h new file mode 100644 index 00000000000..bbf9e6fd53d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_3_2/EfiMemoryChunksV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_3_2_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_3_2/Redfish_MemoryChunks_v1_3_2_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_3_2 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_3_2_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_4_0/EfiMemoryChunksV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_4_0/EfiMemoryChunksV1_4_0.h new file mode 100644 index 00000000000..34e3b016d4f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_4_0/EfiMemoryChunksV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_4_0_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_4_0/Redfish_MemoryChunks_v1_4_0_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_4_0 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_4_0_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_4_1/EfiMemoryChunksV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_4_1/EfiMemoryChunksV1_4_1.h new file mode 100644 index 00000000000..f3f8dd18688 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunks/v1_4_1/EfiMemoryChunksV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunks v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_4_1_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKS_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunks/v1_4_1/Redfish_MemoryChunks_v1_4_1_CS.h" +// +// EFI structure of Redfish MemoryChunks v1_4_1 +// +typedef struct _EFI_REDFISH_MEMORYCHUNKS_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKS_V1_4_1_CS *MemoryChunks; +} EFI_REDFISH_MEMORYCHUNKS_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunksCollection/EfiMemoryChunksCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunksCollection/EfiMemoryChunksCollection.h new file mode 100644 index 00000000000..018b5899fae --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryChunksCollection/EfiMemoryChunksCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryChunksCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCHUNKSCOLLECTION_H__ +#define EFI_REDFISH_INTERP_MEMORYCHUNKSCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryChunksCollection/Redfish_MemoryChunksCollection_CS.h" +// +// EFI structure of Redfish MemoryChunksCollection +// +typedef struct _EFI_REDFISH_MEMORYCHUNKSCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCHUNKSCOLLECTION_CS *MemoryChunksCollection; +} EFI_REDFISH_MEMORYCHUNKSCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryCollection/EfiMemoryCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryCollection/EfiMemoryCollection.h new file mode 100644 index 00000000000..94eb20d7152 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryCollection/EfiMemoryCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYCOLLECTION_H__ +#define EFI_REDFISH_INTERP_MEMORYCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryCollection/Redfish_MemoryCollection_CS.h" +// +// EFI structure of Redfish MemoryCollection +// +typedef struct _EFI_REDFISH_MEMORYCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYCOLLECTION_CS *MemoryCollection; +} EFI_REDFISH_MEMORYCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_0_0/EfiMemoryDomainV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_0_0/EfiMemoryDomainV1_0_0.h new file mode 100644 index 00000000000..ca659c0a374 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_0_0/EfiMemoryDomainV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryDomain v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_0_0_H__ +#define EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryDomain/v1_0_0/Redfish_MemoryDomain_v1_0_0_CS.h" +// +// EFI structure of Redfish MemoryDomain v1_0_0 +// +typedef struct _EFI_REDFISH_MEMORYDOMAIN_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYDOMAIN_V1_0_0_CS *MemoryDomain; +} EFI_REDFISH_MEMORYDOMAIN_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_0_1/EfiMemoryDomainV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_0_1/EfiMemoryDomainV1_0_1.h new file mode 100644 index 00000000000..5d61f2c5327 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_0_1/EfiMemoryDomainV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryDomain v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_0_1_H__ +#define EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryDomain/v1_0_1/Redfish_MemoryDomain_v1_0_1_CS.h" +// +// EFI structure of Redfish MemoryDomain v1_0_1 +// +typedef struct _EFI_REDFISH_MEMORYDOMAIN_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYDOMAIN_V1_0_1_CS *MemoryDomain; +} EFI_REDFISH_MEMORYDOMAIN_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_0_2/EfiMemoryDomainV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_0_2/EfiMemoryDomainV1_0_2.h new file mode 100644 index 00000000000..f122db0e688 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_0_2/EfiMemoryDomainV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryDomain v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_0_2_H__ +#define EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryDomain/v1_0_2/Redfish_MemoryDomain_v1_0_2_CS.h" +// +// EFI structure of Redfish MemoryDomain v1_0_2 +// +typedef struct _EFI_REDFISH_MEMORYDOMAIN_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYDOMAIN_V1_0_2_CS *MemoryDomain; +} EFI_REDFISH_MEMORYDOMAIN_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_0_3/EfiMemoryDomainV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_0_3/EfiMemoryDomainV1_0_3.h new file mode 100644 index 00000000000..26638380886 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_0_3/EfiMemoryDomainV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryDomain v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_0_3_H__ +#define EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryDomain/v1_0_3/Redfish_MemoryDomain_v1_0_3_CS.h" +// +// EFI structure of Redfish MemoryDomain v1_0_3 +// +typedef struct _EFI_REDFISH_MEMORYDOMAIN_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYDOMAIN_V1_0_3_CS *MemoryDomain; +} EFI_REDFISH_MEMORYDOMAIN_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_0_4/EfiMemoryDomainV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_0_4/EfiMemoryDomainV1_0_4.h new file mode 100644 index 00000000000..11a54b0d672 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_0_4/EfiMemoryDomainV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryDomain v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_0_4_H__ +#define EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryDomain/v1_0_4/Redfish_MemoryDomain_v1_0_4_CS.h" +// +// EFI structure of Redfish MemoryDomain v1_0_4 +// +typedef struct _EFI_REDFISH_MEMORYDOMAIN_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYDOMAIN_V1_0_4_CS *MemoryDomain; +} EFI_REDFISH_MEMORYDOMAIN_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_0_5/EfiMemoryDomainV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_0_5/EfiMemoryDomainV1_0_5.h new file mode 100644 index 00000000000..9f9302e5422 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_0_5/EfiMemoryDomainV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryDomain v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_0_5_H__ +#define EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryDomain/v1_0_5/Redfish_MemoryDomain_v1_0_5_CS.h" +// +// EFI structure of Redfish MemoryDomain v1_0_5 +// +typedef struct _EFI_REDFISH_MEMORYDOMAIN_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYDOMAIN_V1_0_5_CS *MemoryDomain; +} EFI_REDFISH_MEMORYDOMAIN_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_1_0/EfiMemoryDomainV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_1_0/EfiMemoryDomainV1_1_0.h new file mode 100644 index 00000000000..8c76aaf21c3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_1_0/EfiMemoryDomainV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryDomain v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_1_0_H__ +#define EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryDomain/v1_1_0/Redfish_MemoryDomain_v1_1_0_CS.h" +// +// EFI structure of Redfish MemoryDomain v1_1_0 +// +typedef struct _EFI_REDFISH_MEMORYDOMAIN_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYDOMAIN_V1_1_0_CS *MemoryDomain; +} EFI_REDFISH_MEMORYDOMAIN_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_1_1/EfiMemoryDomainV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_1_1/EfiMemoryDomainV1_1_1.h new file mode 100644 index 00000000000..c5d00f93f43 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_1_1/EfiMemoryDomainV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryDomain v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_1_1_H__ +#define EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryDomain/v1_1_1/Redfish_MemoryDomain_v1_1_1_CS.h" +// +// EFI structure of Redfish MemoryDomain v1_1_1 +// +typedef struct _EFI_REDFISH_MEMORYDOMAIN_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYDOMAIN_V1_1_1_CS *MemoryDomain; +} EFI_REDFISH_MEMORYDOMAIN_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_1_2/EfiMemoryDomainV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_1_2/EfiMemoryDomainV1_1_2.h new file mode 100644 index 00000000000..2e4461e2693 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_1_2/EfiMemoryDomainV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryDomain v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_1_2_H__ +#define EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryDomain/v1_1_2/Redfish_MemoryDomain_v1_1_2_CS.h" +// +// EFI structure of Redfish MemoryDomain v1_1_2 +// +typedef struct _EFI_REDFISH_MEMORYDOMAIN_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYDOMAIN_V1_1_2_CS *MemoryDomain; +} EFI_REDFISH_MEMORYDOMAIN_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_1_3/EfiMemoryDomainV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_1_3/EfiMemoryDomainV1_1_3.h new file mode 100644 index 00000000000..9b944ecd156 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_1_3/EfiMemoryDomainV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryDomain v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_1_3_H__ +#define EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryDomain/v1_1_3/Redfish_MemoryDomain_v1_1_3_CS.h" +// +// EFI structure of Redfish MemoryDomain v1_1_3 +// +typedef struct _EFI_REDFISH_MEMORYDOMAIN_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYDOMAIN_V1_1_3_CS *MemoryDomain; +} EFI_REDFISH_MEMORYDOMAIN_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_1_4/EfiMemoryDomainV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_1_4/EfiMemoryDomainV1_1_4.h new file mode 100644 index 00000000000..25d68452a4c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_1_4/EfiMemoryDomainV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryDomain v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_1_4_H__ +#define EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryDomain/v1_1_4/Redfish_MemoryDomain_v1_1_4_CS.h" +// +// EFI structure of Redfish MemoryDomain v1_1_4 +// +typedef struct _EFI_REDFISH_MEMORYDOMAIN_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYDOMAIN_V1_1_4_CS *MemoryDomain; +} EFI_REDFISH_MEMORYDOMAIN_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_2_0/EfiMemoryDomainV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_2_0/EfiMemoryDomainV1_2_0.h new file mode 100644 index 00000000000..1c71cf0676e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_2_0/EfiMemoryDomainV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryDomain v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_2_0_H__ +#define EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryDomain/v1_2_0/Redfish_MemoryDomain_v1_2_0_CS.h" +// +// EFI structure of Redfish MemoryDomain v1_2_0 +// +typedef struct _EFI_REDFISH_MEMORYDOMAIN_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYDOMAIN_V1_2_0_CS *MemoryDomain; +} EFI_REDFISH_MEMORYDOMAIN_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_2_1/EfiMemoryDomainV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_2_1/EfiMemoryDomainV1_2_1.h new file mode 100644 index 00000000000..81a11be1503 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_2_1/EfiMemoryDomainV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryDomain v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_2_1_H__ +#define EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryDomain/v1_2_1/Redfish_MemoryDomain_v1_2_1_CS.h" +// +// EFI structure of Redfish MemoryDomain v1_2_1 +// +typedef struct _EFI_REDFISH_MEMORYDOMAIN_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYDOMAIN_V1_2_1_CS *MemoryDomain; +} EFI_REDFISH_MEMORYDOMAIN_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_2_2/EfiMemoryDomainV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_2_2/EfiMemoryDomainV1_2_2.h new file mode 100644 index 00000000000..a1c509eb072 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_2_2/EfiMemoryDomainV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryDomain v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_2_2_H__ +#define EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryDomain/v1_2_2/Redfish_MemoryDomain_v1_2_2_CS.h" +// +// EFI structure of Redfish MemoryDomain v1_2_2 +// +typedef struct _EFI_REDFISH_MEMORYDOMAIN_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYDOMAIN_V1_2_2_CS *MemoryDomain; +} EFI_REDFISH_MEMORYDOMAIN_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_2_3/EfiMemoryDomainV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_2_3/EfiMemoryDomainV1_2_3.h new file mode 100644 index 00000000000..a181474aae6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_2_3/EfiMemoryDomainV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryDomain v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_2_3_H__ +#define EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryDomain/v1_2_3/Redfish_MemoryDomain_v1_2_3_CS.h" +// +// EFI structure of Redfish MemoryDomain v1_2_3 +// +typedef struct _EFI_REDFISH_MEMORYDOMAIN_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYDOMAIN_V1_2_3_CS *MemoryDomain; +} EFI_REDFISH_MEMORYDOMAIN_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_3_0/EfiMemoryDomainV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_3_0/EfiMemoryDomainV1_3_0.h new file mode 100644 index 00000000000..ade9b10e5bc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomain/v1_3_0/EfiMemoryDomainV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryDomain v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_3_0_H__ +#define EFI_REDFISH_INTERP_MEMORYDOMAIN_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryDomain/v1_3_0/Redfish_MemoryDomain_v1_3_0_CS.h" +// +// EFI structure of Redfish MemoryDomain v1_3_0 +// +typedef struct _EFI_REDFISH_MEMORYDOMAIN_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYDOMAIN_V1_3_0_CS *MemoryDomain; +} EFI_REDFISH_MEMORYDOMAIN_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomainCollection/EfiMemoryDomainCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomainCollection/EfiMemoryDomainCollection.h new file mode 100644 index 00000000000..cf9808fb0ef --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryDomainCollection/EfiMemoryDomainCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryDomainCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYDOMAINCOLLECTION_H__ +#define EFI_REDFISH_INTERP_MEMORYDOMAINCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryDomainCollection/Redfish_MemoryDomainCollection_CS.h" +// +// EFI structure of Redfish MemoryDomainCollection +// +typedef struct _EFI_REDFISH_MEMORYDOMAINCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYDOMAINCOLLECTION_CS *MemoryDomainCollection; +} EFI_REDFISH_MEMORYDOMAINCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_0/EfiMemoryMetricsV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_0/EfiMemoryMetricsV1_0_0.h new file mode 100644 index 00000000000..2dc3ce798d0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_0/EfiMemoryMetricsV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryMetrics v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYMETRICS_V1_0_0_H__ +#define EFI_REDFISH_INTERP_MEMORYMETRICS_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryMetrics/v1_0_0/Redfish_MemoryMetrics_v1_0_0_CS.h" +// +// EFI structure of Redfish MemoryMetrics v1_0_0 +// +typedef struct _EFI_REDFISH_MEMORYMETRICS_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYMETRICS_V1_0_0_CS *MemoryMetrics; +} EFI_REDFISH_MEMORYMETRICS_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_1/EfiMemoryMetricsV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_1/EfiMemoryMetricsV1_0_1.h new file mode 100644 index 00000000000..47943c336f6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_1/EfiMemoryMetricsV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryMetrics v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYMETRICS_V1_0_1_H__ +#define EFI_REDFISH_INTERP_MEMORYMETRICS_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryMetrics/v1_0_1/Redfish_MemoryMetrics_v1_0_1_CS.h" +// +// EFI structure of Redfish MemoryMetrics v1_0_1 +// +typedef struct _EFI_REDFISH_MEMORYMETRICS_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYMETRICS_V1_0_1_CS *MemoryMetrics; +} EFI_REDFISH_MEMORYMETRICS_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_2/EfiMemoryMetricsV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_2/EfiMemoryMetricsV1_0_2.h new file mode 100644 index 00000000000..88b89d922ff --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_2/EfiMemoryMetricsV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryMetrics v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYMETRICS_V1_0_2_H__ +#define EFI_REDFISH_INTERP_MEMORYMETRICS_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryMetrics/v1_0_2/Redfish_MemoryMetrics_v1_0_2_CS.h" +// +// EFI structure of Redfish MemoryMetrics v1_0_2 +// +typedef struct _EFI_REDFISH_MEMORYMETRICS_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYMETRICS_V1_0_2_CS *MemoryMetrics; +} EFI_REDFISH_MEMORYMETRICS_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_3/EfiMemoryMetricsV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_3/EfiMemoryMetricsV1_0_3.h new file mode 100644 index 00000000000..e8a60566d02 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_3/EfiMemoryMetricsV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryMetrics v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYMETRICS_V1_0_3_H__ +#define EFI_REDFISH_INTERP_MEMORYMETRICS_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryMetrics/v1_0_3/Redfish_MemoryMetrics_v1_0_3_CS.h" +// +// EFI structure of Redfish MemoryMetrics v1_0_3 +// +typedef struct _EFI_REDFISH_MEMORYMETRICS_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYMETRICS_V1_0_3_CS *MemoryMetrics; +} EFI_REDFISH_MEMORYMETRICS_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_4/EfiMemoryMetricsV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_4/EfiMemoryMetricsV1_0_4.h new file mode 100644 index 00000000000..142de828206 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_4/EfiMemoryMetricsV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryMetrics v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYMETRICS_V1_0_4_H__ +#define EFI_REDFISH_INTERP_MEMORYMETRICS_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryMetrics/v1_0_4/Redfish_MemoryMetrics_v1_0_4_CS.h" +// +// EFI structure of Redfish MemoryMetrics v1_0_4 +// +typedef struct _EFI_REDFISH_MEMORYMETRICS_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYMETRICS_V1_0_4_CS *MemoryMetrics; +} EFI_REDFISH_MEMORYMETRICS_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_5/EfiMemoryMetricsV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_5/EfiMemoryMetricsV1_0_5.h new file mode 100644 index 00000000000..e8fc8923f0e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_5/EfiMemoryMetricsV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryMetrics v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYMETRICS_V1_0_5_H__ +#define EFI_REDFISH_INTERP_MEMORYMETRICS_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryMetrics/v1_0_5/Redfish_MemoryMetrics_v1_0_5_CS.h" +// +// EFI structure of Redfish MemoryMetrics v1_0_5 +// +typedef struct _EFI_REDFISH_MEMORYMETRICS_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYMETRICS_V1_0_5_CS *MemoryMetrics; +} EFI_REDFISH_MEMORYMETRICS_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_6/EfiMemoryMetricsV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_6/EfiMemoryMetricsV1_0_6.h new file mode 100644 index 00000000000..7361a226be4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_6/EfiMemoryMetricsV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryMetrics v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYMETRICS_V1_0_6_H__ +#define EFI_REDFISH_INTERP_MEMORYMETRICS_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryMetrics/v1_0_6/Redfish_MemoryMetrics_v1_0_6_CS.h" +// +// EFI structure of Redfish MemoryMetrics v1_0_6 +// +typedef struct _EFI_REDFISH_MEMORYMETRICS_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYMETRICS_V1_0_6_CS *MemoryMetrics; +} EFI_REDFISH_MEMORYMETRICS_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_7/EfiMemoryMetricsV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_7/EfiMemoryMetricsV1_0_7.h new file mode 100644 index 00000000000..f6a62b44c23 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_7/EfiMemoryMetricsV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryMetrics v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYMETRICS_V1_0_7_H__ +#define EFI_REDFISH_INTERP_MEMORYMETRICS_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryMetrics/v1_0_7/Redfish_MemoryMetrics_v1_0_7_CS.h" +// +// EFI structure of Redfish MemoryMetrics v1_0_7 +// +typedef struct _EFI_REDFISH_MEMORYMETRICS_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYMETRICS_V1_0_7_CS *MemoryMetrics; +} EFI_REDFISH_MEMORYMETRICS_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_8/EfiMemoryMetricsV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_8/EfiMemoryMetricsV1_0_8.h new file mode 100644 index 00000000000..b52f652c742 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_0_8/EfiMemoryMetricsV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryMetrics v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYMETRICS_V1_0_8_H__ +#define EFI_REDFISH_INTERP_MEMORYMETRICS_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryMetrics/v1_0_8/Redfish_MemoryMetrics_v1_0_8_CS.h" +// +// EFI structure of Redfish MemoryMetrics v1_0_8 +// +typedef struct _EFI_REDFISH_MEMORYMETRICS_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYMETRICS_V1_0_8_CS *MemoryMetrics; +} EFI_REDFISH_MEMORYMETRICS_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_1/EfiMemoryMetricsV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_1/EfiMemoryMetricsV1_1_1.h new file mode 100644 index 00000000000..bf489bae936 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_1/EfiMemoryMetricsV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryMetrics v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYMETRICS_V1_1_1_H__ +#define EFI_REDFISH_INTERP_MEMORYMETRICS_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryMetrics/v1_1_1/Redfish_MemoryMetrics_v1_1_1_CS.h" +// +// EFI structure of Redfish MemoryMetrics v1_1_1 +// +typedef struct _EFI_REDFISH_MEMORYMETRICS_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYMETRICS_V1_1_1_CS *MemoryMetrics; +} EFI_REDFISH_MEMORYMETRICS_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_2/EfiMemoryMetricsV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_2/EfiMemoryMetricsV1_1_2.h new file mode 100644 index 00000000000..436bfea0a8e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_2/EfiMemoryMetricsV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryMetrics v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYMETRICS_V1_1_2_H__ +#define EFI_REDFISH_INTERP_MEMORYMETRICS_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryMetrics/v1_1_2/Redfish_MemoryMetrics_v1_1_2_CS.h" +// +// EFI structure of Redfish MemoryMetrics v1_1_2 +// +typedef struct _EFI_REDFISH_MEMORYMETRICS_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYMETRICS_V1_1_2_CS *MemoryMetrics; +} EFI_REDFISH_MEMORYMETRICS_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_3/EfiMemoryMetricsV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_3/EfiMemoryMetricsV1_1_3.h new file mode 100644 index 00000000000..9b759e6b734 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_3/EfiMemoryMetricsV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryMetrics v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYMETRICS_V1_1_3_H__ +#define EFI_REDFISH_INTERP_MEMORYMETRICS_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryMetrics/v1_1_3/Redfish_MemoryMetrics_v1_1_3_CS.h" +// +// EFI structure of Redfish MemoryMetrics v1_1_3 +// +typedef struct _EFI_REDFISH_MEMORYMETRICS_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYMETRICS_V1_1_3_CS *MemoryMetrics; +} EFI_REDFISH_MEMORYMETRICS_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_4/EfiMemoryMetricsV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_4/EfiMemoryMetricsV1_1_4.h new file mode 100644 index 00000000000..a72d3bc736b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_4/EfiMemoryMetricsV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryMetrics v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYMETRICS_V1_1_4_H__ +#define EFI_REDFISH_INTERP_MEMORYMETRICS_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryMetrics/v1_1_4/Redfish_MemoryMetrics_v1_1_4_CS.h" +// +// EFI structure of Redfish MemoryMetrics v1_1_4 +// +typedef struct _EFI_REDFISH_MEMORYMETRICS_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYMETRICS_V1_1_4_CS *MemoryMetrics; +} EFI_REDFISH_MEMORYMETRICS_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_5/EfiMemoryMetricsV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_5/EfiMemoryMetricsV1_1_5.h new file mode 100644 index 00000000000..eacbd7b75b1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_5/EfiMemoryMetricsV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryMetrics v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYMETRICS_V1_1_5_H__ +#define EFI_REDFISH_INTERP_MEMORYMETRICS_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryMetrics/v1_1_5/Redfish_MemoryMetrics_v1_1_5_CS.h" +// +// EFI structure of Redfish MemoryMetrics v1_1_5 +// +typedef struct _EFI_REDFISH_MEMORYMETRICS_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYMETRICS_V1_1_5_CS *MemoryMetrics; +} EFI_REDFISH_MEMORYMETRICS_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_6/EfiMemoryMetricsV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_6/EfiMemoryMetricsV1_1_6.h new file mode 100644 index 00000000000..fbfc09636d7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_6/EfiMemoryMetricsV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryMetrics v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYMETRICS_V1_1_6_H__ +#define EFI_REDFISH_INTERP_MEMORYMETRICS_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryMetrics/v1_1_6/Redfish_MemoryMetrics_v1_1_6_CS.h" +// +// EFI structure of Redfish MemoryMetrics v1_1_6 +// +typedef struct _EFI_REDFISH_MEMORYMETRICS_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYMETRICS_V1_1_6_CS *MemoryMetrics; +} EFI_REDFISH_MEMORYMETRICS_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_7/EfiMemoryMetricsV1_1_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_7/EfiMemoryMetricsV1_1_7.h new file mode 100644 index 00000000000..4835da04529 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_7/EfiMemoryMetricsV1_1_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryMetrics v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYMETRICS_V1_1_7_H__ +#define EFI_REDFISH_INTERP_MEMORYMETRICS_V1_1_7_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryMetrics/v1_1_7/Redfish_MemoryMetrics_v1_1_7_CS.h" +// +// EFI structure of Redfish MemoryMetrics v1_1_7 +// +typedef struct _EFI_REDFISH_MEMORYMETRICS_V1_1_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYMETRICS_V1_1_7_CS *MemoryMetrics; +} EFI_REDFISH_MEMORYMETRICS_V1_1_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_8/EfiMemoryMetricsV1_1_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_8/EfiMemoryMetricsV1_1_8.h new file mode 100644 index 00000000000..fcc2a8e33d5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_1_8/EfiMemoryMetricsV1_1_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryMetrics v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYMETRICS_V1_1_8_H__ +#define EFI_REDFISH_INTERP_MEMORYMETRICS_V1_1_8_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryMetrics/v1_1_8/Redfish_MemoryMetrics_v1_1_8_CS.h" +// +// EFI structure of Redfish MemoryMetrics v1_1_8 +// +typedef struct _EFI_REDFISH_MEMORYMETRICS_V1_1_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYMETRICS_V1_1_8_CS *MemoryMetrics; +} EFI_REDFISH_MEMORYMETRICS_V1_1_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_2_0/EfiMemoryMetricsV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_2_0/EfiMemoryMetricsV1_2_0.h new file mode 100644 index 00000000000..169792e8eae --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_2_0/EfiMemoryMetricsV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryMetrics v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYMETRICS_V1_2_0_H__ +#define EFI_REDFISH_INTERP_MEMORYMETRICS_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryMetrics/v1_2_0/Redfish_MemoryMetrics_v1_2_0_CS.h" +// +// EFI structure of Redfish MemoryMetrics v1_2_0 +// +typedef struct _EFI_REDFISH_MEMORYMETRICS_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYMETRICS_V1_2_0_CS *MemoryMetrics; +} EFI_REDFISH_MEMORYMETRICS_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_2_1/EfiMemoryMetricsV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_2_1/EfiMemoryMetricsV1_2_1.h new file mode 100644 index 00000000000..451b2eeff74 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_2_1/EfiMemoryMetricsV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryMetrics v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYMETRICS_V1_2_1_H__ +#define EFI_REDFISH_INTERP_MEMORYMETRICS_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryMetrics/v1_2_1/Redfish_MemoryMetrics_v1_2_1_CS.h" +// +// EFI structure of Redfish MemoryMetrics v1_2_1 +// +typedef struct _EFI_REDFISH_MEMORYMETRICS_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYMETRICS_V1_2_1_CS *MemoryMetrics; +} EFI_REDFISH_MEMORYMETRICS_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_2_2/EfiMemoryMetricsV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_2_2/EfiMemoryMetricsV1_2_2.h new file mode 100644 index 00000000000..f8b58c1be3f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_2_2/EfiMemoryMetricsV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryMetrics v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYMETRICS_V1_2_2_H__ +#define EFI_REDFISH_INTERP_MEMORYMETRICS_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryMetrics/v1_2_2/Redfish_MemoryMetrics_v1_2_2_CS.h" +// +// EFI structure of Redfish MemoryMetrics v1_2_2 +// +typedef struct _EFI_REDFISH_MEMORYMETRICS_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYMETRICS_V1_2_2_CS *MemoryMetrics; +} EFI_REDFISH_MEMORYMETRICS_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_3_0/EfiMemoryMetricsV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_3_0/EfiMemoryMetricsV1_3_0.h new file mode 100644 index 00000000000..69869d78a5f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_3_0/EfiMemoryMetricsV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryMetrics v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYMETRICS_V1_3_0_H__ +#define EFI_REDFISH_INTERP_MEMORYMETRICS_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryMetrics/v1_3_0/Redfish_MemoryMetrics_v1_3_0_CS.h" +// +// EFI structure of Redfish MemoryMetrics v1_3_0 +// +typedef struct _EFI_REDFISH_MEMORYMETRICS_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYMETRICS_V1_3_0_CS *MemoryMetrics; +} EFI_REDFISH_MEMORYMETRICS_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_3_1/EfiMemoryMetricsV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_3_1/EfiMemoryMetricsV1_3_1.h new file mode 100644 index 00000000000..c8a8e1cdd42 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_3_1/EfiMemoryMetricsV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryMetrics v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYMETRICS_V1_3_1_H__ +#define EFI_REDFISH_INTERP_MEMORYMETRICS_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryMetrics/v1_3_1/Redfish_MemoryMetrics_v1_3_1_CS.h" +// +// EFI structure of Redfish MemoryMetrics v1_3_1 +// +typedef struct _EFI_REDFISH_MEMORYMETRICS_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYMETRICS_V1_3_1_CS *MemoryMetrics; +} EFI_REDFISH_MEMORYMETRICS_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_4_0/EfiMemoryMetricsV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_4_0/EfiMemoryMetricsV1_4_0.h new file mode 100644 index 00000000000..fb06d450a08 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_4_0/EfiMemoryMetricsV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryMetrics v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYMETRICS_V1_4_0_H__ +#define EFI_REDFISH_INTERP_MEMORYMETRICS_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryMetrics/v1_4_0/Redfish_MemoryMetrics_v1_4_0_CS.h" +// +// EFI structure of Redfish MemoryMetrics v1_4_0 +// +typedef struct _EFI_REDFISH_MEMORYMETRICS_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYMETRICS_V1_4_0_CS *MemoryMetrics; +} EFI_REDFISH_MEMORYMETRICS_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_4_1/EfiMemoryMetricsV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_4_1/EfiMemoryMetricsV1_4_1.h new file mode 100644 index 00000000000..64e386c177e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MemoryMetrics/v1_4_1/EfiMemoryMetricsV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MemoryMetrics v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MEMORYMETRICS_V1_4_1_H__ +#define EFI_REDFISH_INTERP_MEMORYMETRICS_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MemoryMetrics/v1_4_1/Redfish_MemoryMetrics_v1_4_1_CS.h" +// +// EFI structure of Redfish MemoryMetrics v1_4_1 +// +typedef struct _EFI_REDFISH_MEMORYMETRICS_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MEMORYMETRICS_V1_4_1_CS *MemoryMetrics; +} EFI_REDFISH_MEMORYMETRICS_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_0/EfiMessageRegistryV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_0/EfiMessageRegistryV1_0_0.h new file mode 100644 index 00000000000..c4e65b72d0b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_0/EfiMessageRegistryV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_0_0_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_0_0/Redfish_MessageRegistry_v1_0_0_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_0_0 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_0_0_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_10/EfiMessageRegistryV1_0_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_10/EfiMessageRegistryV1_0_10.h new file mode 100644 index 00000000000..5fedc931581 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_10/EfiMessageRegistryV1_0_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_0_10_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_0_10_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_0_10/Redfish_MessageRegistry_v1_0_10_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_0_10 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_0_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_0_10_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_0_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_2/EfiMessageRegistryV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_2/EfiMessageRegistryV1_0_2.h new file mode 100644 index 00000000000..3e7af01dbfa --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_2/EfiMessageRegistryV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_0_2_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_0_2/Redfish_MessageRegistry_v1_0_2_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_0_2 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_0_2_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_3/EfiMessageRegistryV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_3/EfiMessageRegistryV1_0_3.h new file mode 100644 index 00000000000..e2865c7c0ba --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_3/EfiMessageRegistryV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_0_3_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_0_3/Redfish_MessageRegistry_v1_0_3_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_0_3 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_0_3_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_4/EfiMessageRegistryV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_4/EfiMessageRegistryV1_0_4.h new file mode 100644 index 00000000000..38684e08e84 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_4/EfiMessageRegistryV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_0_4_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_0_4/Redfish_MessageRegistry_v1_0_4_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_0_4 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_0_4_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_5/EfiMessageRegistryV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_5/EfiMessageRegistryV1_0_5.h new file mode 100644 index 00000000000..383c882d3cf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_5/EfiMessageRegistryV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_0_5_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_0_5/Redfish_MessageRegistry_v1_0_5_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_0_5 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_0_5_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_6/EfiMessageRegistryV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_6/EfiMessageRegistryV1_0_6.h new file mode 100644 index 00000000000..5f1f7ad2c30 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_6/EfiMessageRegistryV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_0_6_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_0_6/Redfish_MessageRegistry_v1_0_6_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_0_6 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_0_6_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_7/EfiMessageRegistryV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_7/EfiMessageRegistryV1_0_7.h new file mode 100644 index 00000000000..0cf309ca1bd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_7/EfiMessageRegistryV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_0_7_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_0_7/Redfish_MessageRegistry_v1_0_7_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_0_7 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_0_7_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_8/EfiMessageRegistryV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_8/EfiMessageRegistryV1_0_8.h new file mode 100644 index 00000000000..12dbad12890 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_8/EfiMessageRegistryV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_0_8_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_0_8/Redfish_MessageRegistry_v1_0_8_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_0_8 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_0_8_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_9/EfiMessageRegistryV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_9/EfiMessageRegistryV1_0_9.h new file mode 100644 index 00000000000..29968dc053a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_0_9/EfiMessageRegistryV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_0_9_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_0_9/Redfish_MessageRegistry_v1_0_9_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_0_9 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_0_9_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_0/EfiMessageRegistryV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_0/EfiMessageRegistryV1_1_0.h new file mode 100644 index 00000000000..15982487e33 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_0/EfiMessageRegistryV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_1_0_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_1_0/Redfish_MessageRegistry_v1_1_0_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_1_0 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_1_0_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_1/EfiMessageRegistryV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_1/EfiMessageRegistryV1_1_1.h new file mode 100644 index 00000000000..c9cd84bf0ca --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_1/EfiMessageRegistryV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_1_1_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_1_1/Redfish_MessageRegistry_v1_1_1_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_1_1 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_1_1_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_2/EfiMessageRegistryV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_2/EfiMessageRegistryV1_1_2.h new file mode 100644 index 00000000000..606cc07ab7a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_2/EfiMessageRegistryV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_1_2_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_1_2/Redfish_MessageRegistry_v1_1_2_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_1_2 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_1_2_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_3/EfiMessageRegistryV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_3/EfiMessageRegistryV1_1_3.h new file mode 100644 index 00000000000..ef113ab76fc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_3/EfiMessageRegistryV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_1_3_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_1_3/Redfish_MessageRegistry_v1_1_3_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_1_3 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_1_3_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_4/EfiMessageRegistryV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_4/EfiMessageRegistryV1_1_4.h new file mode 100644 index 00000000000..0dc6c3a7562 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_4/EfiMessageRegistryV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_1_4_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_1_4/Redfish_MessageRegistry_v1_1_4_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_1_4 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_1_4_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_5/EfiMessageRegistryV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_5/EfiMessageRegistryV1_1_5.h new file mode 100644 index 00000000000..300ed98f4f5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_5/EfiMessageRegistryV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_1_5_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_1_5/Redfish_MessageRegistry_v1_1_5_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_1_5 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_1_5_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_6/EfiMessageRegistryV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_6/EfiMessageRegistryV1_1_6.h new file mode 100644 index 00000000000..7cadf72b96b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_1_6/EfiMessageRegistryV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_1_6_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_1_6/Redfish_MessageRegistry_v1_1_6_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_1_6 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_1_6_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_2_0/EfiMessageRegistryV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_2_0/EfiMessageRegistryV1_2_0.h new file mode 100644 index 00000000000..a995050b72d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_2_0/EfiMessageRegistryV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_2_0_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_2_0/Redfish_MessageRegistry_v1_2_0_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_2_0 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_2_0_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_2_1/EfiMessageRegistryV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_2_1/EfiMessageRegistryV1_2_1.h new file mode 100644 index 00000000000..40205a26d2b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_2_1/EfiMessageRegistryV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_2_1_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_2_1/Redfish_MessageRegistry_v1_2_1_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_2_1 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_2_1_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_2_2/EfiMessageRegistryV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_2_2/EfiMessageRegistryV1_2_2.h new file mode 100644 index 00000000000..08c22819011 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_2_2/EfiMessageRegistryV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_2_2_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_2_2/Redfish_MessageRegistry_v1_2_2_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_2_2 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_2_2_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_2_3/EfiMessageRegistryV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_2_3/EfiMessageRegistryV1_2_3.h new file mode 100644 index 00000000000..4839bdd9c1a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_2_3/EfiMessageRegistryV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_2_3_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_2_3/Redfish_MessageRegistry_v1_2_3_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_2_3 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_2_3_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_2_4/EfiMessageRegistryV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_2_4/EfiMessageRegistryV1_2_4.h new file mode 100644 index 00000000000..d2f10dad518 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_2_4/EfiMessageRegistryV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_2_4_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_2_4/Redfish_MessageRegistry_v1_2_4_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_2_4 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_2_4_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_3_0/EfiMessageRegistryV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_3_0/EfiMessageRegistryV1_3_0.h new file mode 100644 index 00000000000..82c098d21be --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_3_0/EfiMessageRegistryV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_3_0_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_3_0/Redfish_MessageRegistry_v1_3_0_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_3_0 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_3_0_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_3_1/EfiMessageRegistryV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_3_1/EfiMessageRegistryV1_3_1.h new file mode 100644 index 00000000000..b2d83539816 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_3_1/EfiMessageRegistryV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_3_1_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_3_1/Redfish_MessageRegistry_v1_3_1_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_3_1 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_3_1_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_3_2/EfiMessageRegistryV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_3_2/EfiMessageRegistryV1_3_2.h new file mode 100644 index 00000000000..f72c6b2eba4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_3_2/EfiMessageRegistryV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_3_2_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_3_2/Redfish_MessageRegistry_v1_3_2_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_3_2 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_3_2_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_3_3/EfiMessageRegistryV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_3_3/EfiMessageRegistryV1_3_3.h new file mode 100644 index 00000000000..0a5503d9305 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_3_3/EfiMessageRegistryV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_3_3_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_3_3/Redfish_MessageRegistry_v1_3_3_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_3_3 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_3_3_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_4_0/EfiMessageRegistryV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_4_0/EfiMessageRegistryV1_4_0.h new file mode 100644 index 00000000000..874c3b2f7ae --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_4_0/EfiMessageRegistryV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_4_0_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_4_0/Redfish_MessageRegistry_v1_4_0_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_4_0 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_4_0_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_4_1/EfiMessageRegistryV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_4_1/EfiMessageRegistryV1_4_1.h new file mode 100644 index 00000000000..e6de2be354d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_4_1/EfiMessageRegistryV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_4_1_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_4_1/Redfish_MessageRegistry_v1_4_1_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_4_1 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_4_1_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_4_2/EfiMessageRegistryV1_4_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_4_2/EfiMessageRegistryV1_4_2.h new file mode 100644 index 00000000000..9f8631a6425 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistry/v1_4_2/EfiMessageRegistryV1_4_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistry v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_4_2_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRY_V1_4_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistry/v1_4_2/Redfish_MessageRegistry_v1_4_2_CS.h" +// +// EFI structure of Redfish MessageRegistry v1_4_2 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRY_V1_4_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRY_V1_4_2_CS *MessageRegistry; +} EFI_REDFISH_MESSAGEREGISTRY_V1_4_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryCollection/EfiMessageRegistryCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryCollection/EfiMessageRegistryCollection.h new file mode 100644 index 00000000000..11d7f1a36e8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryCollection/EfiMessageRegistryCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistryCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRYCOLLECTION_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRYCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistryCollection/Redfish_MessageRegistryCollection_CS.h" +// +// EFI structure of Redfish MessageRegistryCollection +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRYCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRYCOLLECTION_CS *MessageRegistryCollection; +} EFI_REDFISH_MESSAGEREGISTRYCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_0/EfiMessageRegistryFileV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_0/EfiMessageRegistryFileV1_0_0.h new file mode 100644 index 00000000000..2786e05cdf1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_0/EfiMessageRegistryFileV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistryFile v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRYFILE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRYFILE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistryFile/v1_0_0/Redfish_MessageRegistryFile_v1_0_0_CS.h" +// +// EFI structure of Redfish MessageRegistryFile v1_0_0 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_0_CS *MessageRegistryFile; +} EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_2/EfiMessageRegistryFileV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_2/EfiMessageRegistryFileV1_0_2.h new file mode 100644 index 00000000000..da9e79bfa6e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_2/EfiMessageRegistryFileV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistryFile v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRYFILE_V1_0_2_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRYFILE_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistryFile/v1_0_2/Redfish_MessageRegistryFile_v1_0_2_CS.h" +// +// EFI structure of Redfish MessageRegistryFile v1_0_2 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_2_CS *MessageRegistryFile; +} EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_3/EfiMessageRegistryFileV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_3/EfiMessageRegistryFileV1_0_3.h new file mode 100644 index 00000000000..640efdb49ea --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_3/EfiMessageRegistryFileV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistryFile v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRYFILE_V1_0_3_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRYFILE_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistryFile/v1_0_3/Redfish_MessageRegistryFile_v1_0_3_CS.h" +// +// EFI structure of Redfish MessageRegistryFile v1_0_3 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_3_CS *MessageRegistryFile; +} EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_4/EfiMessageRegistryFileV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_4/EfiMessageRegistryFileV1_0_4.h new file mode 100644 index 00000000000..08dbe59045b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_4/EfiMessageRegistryFileV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistryFile v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRYFILE_V1_0_4_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRYFILE_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistryFile/v1_0_4/Redfish_MessageRegistryFile_v1_0_4_CS.h" +// +// EFI structure of Redfish MessageRegistryFile v1_0_4 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_4_CS *MessageRegistryFile; +} EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_5/EfiMessageRegistryFileV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_5/EfiMessageRegistryFileV1_0_5.h new file mode 100644 index 00000000000..b6703e52728 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_5/EfiMessageRegistryFileV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistryFile v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRYFILE_V1_0_5_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRYFILE_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistryFile/v1_0_5/Redfish_MessageRegistryFile_v1_0_5_CS.h" +// +// EFI structure of Redfish MessageRegistryFile v1_0_5 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_5_CS *MessageRegistryFile; +} EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_6/EfiMessageRegistryFileV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_6/EfiMessageRegistryFileV1_0_6.h new file mode 100644 index 00000000000..d90405e4e56 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_6/EfiMessageRegistryFileV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistryFile v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRYFILE_V1_0_6_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRYFILE_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistryFile/v1_0_6/Redfish_MessageRegistryFile_v1_0_6_CS.h" +// +// EFI structure of Redfish MessageRegistryFile v1_0_6 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_6_CS *MessageRegistryFile; +} EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_7/EfiMessageRegistryFileV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_7/EfiMessageRegistryFileV1_0_7.h new file mode 100644 index 00000000000..7329a26437b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_0_7/EfiMessageRegistryFileV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistryFile v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRYFILE_V1_0_7_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRYFILE_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistryFile/v1_0_7/Redfish_MessageRegistryFile_v1_0_7_CS.h" +// +// EFI structure of Redfish MessageRegistryFile v1_0_7 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_7_CS *MessageRegistryFile; +} EFI_REDFISH_MESSAGEREGISTRYFILE_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_1_0/EfiMessageRegistryFileV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_1_0/EfiMessageRegistryFileV1_1_0.h new file mode 100644 index 00000000000..35e02051265 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_1_0/EfiMessageRegistryFileV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistryFile v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRYFILE_V1_1_0_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRYFILE_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistryFile/v1_1_0/Redfish_MessageRegistryFile_v1_1_0_CS.h" +// +// EFI structure of Redfish MessageRegistryFile v1_1_0 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_0_CS *MessageRegistryFile; +} EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_1_1/EfiMessageRegistryFileV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_1_1/EfiMessageRegistryFileV1_1_1.h new file mode 100644 index 00000000000..0571c8063c2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_1_1/EfiMessageRegistryFileV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistryFile v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRYFILE_V1_1_1_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRYFILE_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistryFile/v1_1_1/Redfish_MessageRegistryFile_v1_1_1_CS.h" +// +// EFI structure of Redfish MessageRegistryFile v1_1_1 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_1_CS *MessageRegistryFile; +} EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_1_2/EfiMessageRegistryFileV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_1_2/EfiMessageRegistryFileV1_1_2.h new file mode 100644 index 00000000000..4be7b38329b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_1_2/EfiMessageRegistryFileV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistryFile v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRYFILE_V1_1_2_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRYFILE_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistryFile/v1_1_2/Redfish_MessageRegistryFile_v1_1_2_CS.h" +// +// EFI structure of Redfish MessageRegistryFile v1_1_2 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_2_CS *MessageRegistryFile; +} EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_1_3/EfiMessageRegistryFileV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_1_3/EfiMessageRegistryFileV1_1_3.h new file mode 100644 index 00000000000..96b59eb386d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFile/v1_1_3/EfiMessageRegistryFileV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistryFile v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRYFILE_V1_1_3_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRYFILE_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistryFile/v1_1_3/Redfish_MessageRegistryFile_v1_1_3_CS.h" +// +// EFI structure of Redfish MessageRegistryFile v1_1_3 +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_3_CS *MessageRegistryFile; +} EFI_REDFISH_MESSAGEREGISTRYFILE_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFileCollection/EfiMessageRegistryFileCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFileCollection/EfiMessageRegistryFileCollection.h new file mode 100644 index 00000000000..d0d71f18f8b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MessageRegistryFileCollection/EfiMessageRegistryFileCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MessageRegistryFileCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_MESSAGEREGISTRYFILECOLLECTION_H__ +#define EFI_REDFISH_INTERP_MESSAGEREGISTRYFILECOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/MessageRegistryFileCollection/Redfish_MessageRegistryFileCollection_CS.h" +// +// EFI structure of Redfish MessageRegistryFileCollection +// +typedef struct _EFI_REDFISH_MESSAGEREGISTRYFILECOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_MESSAGEREGISTRYFILECOLLECTION_CS *MessageRegistryFileCollection; +} EFI_REDFISH_MESSAGEREGISTRYFILECOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_0/EfiMetricDefinitionV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_0/EfiMetricDefinitionV1_0_0.h new file mode 100644 index 00000000000..581c65b3525 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_0/EfiMetricDefinitionV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricDefinition v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICDEFINITION_V1_0_0_H__ +#define EFI_REDFISH_INTERP_METRICDEFINITION_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricDefinition/v1_0_0/Redfish_MetricDefinition_v1_0_0_CS.h" +// +// EFI structure of Redfish MetricDefinition v1_0_0 +// +typedef struct _EFI_REDFISH_METRICDEFINITION_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICDEFINITION_V1_0_0_CS *MetricDefinition; +} EFI_REDFISH_METRICDEFINITION_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_1/EfiMetricDefinitionV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_1/EfiMetricDefinitionV1_0_1.h new file mode 100644 index 00000000000..fc38435a32b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_1/EfiMetricDefinitionV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricDefinition v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICDEFINITION_V1_0_1_H__ +#define EFI_REDFISH_INTERP_METRICDEFINITION_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricDefinition/v1_0_1/Redfish_MetricDefinition_v1_0_1_CS.h" +// +// EFI structure of Redfish MetricDefinition v1_0_1 +// +typedef struct _EFI_REDFISH_METRICDEFINITION_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICDEFINITION_V1_0_1_CS *MetricDefinition; +} EFI_REDFISH_METRICDEFINITION_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_2/EfiMetricDefinitionV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_2/EfiMetricDefinitionV1_0_2.h new file mode 100644 index 00000000000..f9ed98b2b04 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_2/EfiMetricDefinitionV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricDefinition v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICDEFINITION_V1_0_2_H__ +#define EFI_REDFISH_INTERP_METRICDEFINITION_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricDefinition/v1_0_2/Redfish_MetricDefinition_v1_0_2_CS.h" +// +// EFI structure of Redfish MetricDefinition v1_0_2 +// +typedef struct _EFI_REDFISH_METRICDEFINITION_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICDEFINITION_V1_0_2_CS *MetricDefinition; +} EFI_REDFISH_METRICDEFINITION_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_3/EfiMetricDefinitionV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_3/EfiMetricDefinitionV1_0_3.h new file mode 100644 index 00000000000..cf5fe15d5ed --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_3/EfiMetricDefinitionV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricDefinition v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICDEFINITION_V1_0_3_H__ +#define EFI_REDFISH_INTERP_METRICDEFINITION_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricDefinition/v1_0_3/Redfish_MetricDefinition_v1_0_3_CS.h" +// +// EFI structure of Redfish MetricDefinition v1_0_3 +// +typedef struct _EFI_REDFISH_METRICDEFINITION_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICDEFINITION_V1_0_3_CS *MetricDefinition; +} EFI_REDFISH_METRICDEFINITION_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_4/EfiMetricDefinitionV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_4/EfiMetricDefinitionV1_0_4.h new file mode 100644 index 00000000000..e3bd9b901e2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_4/EfiMetricDefinitionV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricDefinition v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICDEFINITION_V1_0_4_H__ +#define EFI_REDFISH_INTERP_METRICDEFINITION_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricDefinition/v1_0_4/Redfish_MetricDefinition_v1_0_4_CS.h" +// +// EFI structure of Redfish MetricDefinition v1_0_4 +// +typedef struct _EFI_REDFISH_METRICDEFINITION_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICDEFINITION_V1_0_4_CS *MetricDefinition; +} EFI_REDFISH_METRICDEFINITION_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_5/EfiMetricDefinitionV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_5/EfiMetricDefinitionV1_0_5.h new file mode 100644 index 00000000000..85054b5f9bd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_5/EfiMetricDefinitionV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricDefinition v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICDEFINITION_V1_0_5_H__ +#define EFI_REDFISH_INTERP_METRICDEFINITION_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricDefinition/v1_0_5/Redfish_MetricDefinition_v1_0_5_CS.h" +// +// EFI structure of Redfish MetricDefinition v1_0_5 +// +typedef struct _EFI_REDFISH_METRICDEFINITION_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICDEFINITION_V1_0_5_CS *MetricDefinition; +} EFI_REDFISH_METRICDEFINITION_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_6/EfiMetricDefinitionV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_6/EfiMetricDefinitionV1_0_6.h new file mode 100644 index 00000000000..0546379a049 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_0_6/EfiMetricDefinitionV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricDefinition v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICDEFINITION_V1_0_6_H__ +#define EFI_REDFISH_INTERP_METRICDEFINITION_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricDefinition/v1_0_6/Redfish_MetricDefinition_v1_0_6_CS.h" +// +// EFI structure of Redfish MetricDefinition v1_0_6 +// +typedef struct _EFI_REDFISH_METRICDEFINITION_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICDEFINITION_V1_0_6_CS *MetricDefinition; +} EFI_REDFISH_METRICDEFINITION_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_1_0/EfiMetricDefinitionV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_1_0/EfiMetricDefinitionV1_1_0.h new file mode 100644 index 00000000000..1ff1f52078f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_1_0/EfiMetricDefinitionV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricDefinition v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICDEFINITION_V1_1_0_H__ +#define EFI_REDFISH_INTERP_METRICDEFINITION_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricDefinition/v1_1_0/Redfish_MetricDefinition_v1_1_0_CS.h" +// +// EFI structure of Redfish MetricDefinition v1_1_0 +// +typedef struct _EFI_REDFISH_METRICDEFINITION_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICDEFINITION_V1_1_0_CS *MetricDefinition; +} EFI_REDFISH_METRICDEFINITION_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_1_1/EfiMetricDefinitionV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_1_1/EfiMetricDefinitionV1_1_1.h new file mode 100644 index 00000000000..c97a8f71cb4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinition/v1_1_1/EfiMetricDefinitionV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricDefinition v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICDEFINITION_V1_1_1_H__ +#define EFI_REDFISH_INTERP_METRICDEFINITION_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricDefinition/v1_1_1/Redfish_MetricDefinition_v1_1_1_CS.h" +// +// EFI structure of Redfish MetricDefinition v1_1_1 +// +typedef struct _EFI_REDFISH_METRICDEFINITION_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICDEFINITION_V1_1_1_CS *MetricDefinition; +} EFI_REDFISH_METRICDEFINITION_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinitionCollection/EfiMetricDefinitionCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinitionCollection/EfiMetricDefinitionCollection.h new file mode 100644 index 00000000000..465d4a5a8d5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricDefinitionCollection/EfiMetricDefinitionCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricDefinitionCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICDEFINITIONCOLLECTION_H__ +#define EFI_REDFISH_INTERP_METRICDEFINITIONCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricDefinitionCollection/Redfish_MetricDefinitionCollection_CS.h" +// +// EFI structure of Redfish MetricDefinitionCollection +// +typedef struct _EFI_REDFISH_METRICDEFINITIONCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICDEFINITIONCOLLECTION_CS *MetricDefinitionCollection; +} EFI_REDFISH_METRICDEFINITIONCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_0/EfiMetricReportV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_0/EfiMetricReportV1_0_0.h new file mode 100644 index 00000000000..2ec84ad3f1a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_0/EfiMetricReportV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReport v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORT_V1_0_0_H__ +#define EFI_REDFISH_INTERP_METRICREPORT_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReport/v1_0_0/Redfish_MetricReport_v1_0_0_CS.h" +// +// EFI structure of Redfish MetricReport v1_0_0 +// +typedef struct _EFI_REDFISH_METRICREPORT_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORT_V1_0_0_CS *MetricReport; +} EFI_REDFISH_METRICREPORT_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_1/EfiMetricReportV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_1/EfiMetricReportV1_0_1.h new file mode 100644 index 00000000000..e2213439ff7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_1/EfiMetricReportV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReport v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORT_V1_0_1_H__ +#define EFI_REDFISH_INTERP_METRICREPORT_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReport/v1_0_1/Redfish_MetricReport_v1_0_1_CS.h" +// +// EFI structure of Redfish MetricReport v1_0_1 +// +typedef struct _EFI_REDFISH_METRICREPORT_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORT_V1_0_1_CS *MetricReport; +} EFI_REDFISH_METRICREPORT_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_2/EfiMetricReportV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_2/EfiMetricReportV1_0_2.h new file mode 100644 index 00000000000..4ca94599083 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_2/EfiMetricReportV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReport v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORT_V1_0_2_H__ +#define EFI_REDFISH_INTERP_METRICREPORT_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReport/v1_0_2/Redfish_MetricReport_v1_0_2_CS.h" +// +// EFI structure of Redfish MetricReport v1_0_2 +// +typedef struct _EFI_REDFISH_METRICREPORT_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORT_V1_0_2_CS *MetricReport; +} EFI_REDFISH_METRICREPORT_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_3/EfiMetricReportV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_3/EfiMetricReportV1_0_3.h new file mode 100644 index 00000000000..684cc37ce74 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_3/EfiMetricReportV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReport v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORT_V1_0_3_H__ +#define EFI_REDFISH_INTERP_METRICREPORT_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReport/v1_0_3/Redfish_MetricReport_v1_0_3_CS.h" +// +// EFI structure of Redfish MetricReport v1_0_3 +// +typedef struct _EFI_REDFISH_METRICREPORT_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORT_V1_0_3_CS *MetricReport; +} EFI_REDFISH_METRICREPORT_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_4/EfiMetricReportV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_4/EfiMetricReportV1_0_4.h new file mode 100644 index 00000000000..ed30a67d905 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_4/EfiMetricReportV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReport v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORT_V1_0_4_H__ +#define EFI_REDFISH_INTERP_METRICREPORT_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReport/v1_0_4/Redfish_MetricReport_v1_0_4_CS.h" +// +// EFI structure of Redfish MetricReport v1_0_4 +// +typedef struct _EFI_REDFISH_METRICREPORT_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORT_V1_0_4_CS *MetricReport; +} EFI_REDFISH_METRICREPORT_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_5/EfiMetricReportV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_5/EfiMetricReportV1_0_5.h new file mode 100644 index 00000000000..bdf16048114 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_5/EfiMetricReportV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReport v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORT_V1_0_5_H__ +#define EFI_REDFISH_INTERP_METRICREPORT_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReport/v1_0_5/Redfish_MetricReport_v1_0_5_CS.h" +// +// EFI structure of Redfish MetricReport v1_0_5 +// +typedef struct _EFI_REDFISH_METRICREPORT_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORT_V1_0_5_CS *MetricReport; +} EFI_REDFISH_METRICREPORT_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_6/EfiMetricReportV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_6/EfiMetricReportV1_0_6.h new file mode 100644 index 00000000000..5f3a098f9ac --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_0_6/EfiMetricReportV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReport v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORT_V1_0_6_H__ +#define EFI_REDFISH_INTERP_METRICREPORT_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReport/v1_0_6/Redfish_MetricReport_v1_0_6_CS.h" +// +// EFI structure of Redfish MetricReport v1_0_6 +// +typedef struct _EFI_REDFISH_METRICREPORT_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORT_V1_0_6_CS *MetricReport; +} EFI_REDFISH_METRICREPORT_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_1_0/EfiMetricReportV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_1_0/EfiMetricReportV1_1_0.h new file mode 100644 index 00000000000..9c272370f24 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_1_0/EfiMetricReportV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReport v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORT_V1_1_0_H__ +#define EFI_REDFISH_INTERP_METRICREPORT_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReport/v1_1_0/Redfish_MetricReport_v1_1_0_CS.h" +// +// EFI structure of Redfish MetricReport v1_1_0 +// +typedef struct _EFI_REDFISH_METRICREPORT_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORT_V1_1_0_CS *MetricReport; +} EFI_REDFISH_METRICREPORT_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_1_1/EfiMetricReportV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_1_1/EfiMetricReportV1_1_1.h new file mode 100644 index 00000000000..ea3892de902 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_1_1/EfiMetricReportV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReport v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORT_V1_1_1_H__ +#define EFI_REDFISH_INTERP_METRICREPORT_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReport/v1_1_1/Redfish_MetricReport_v1_1_1_CS.h" +// +// EFI structure of Redfish MetricReport v1_1_1 +// +typedef struct _EFI_REDFISH_METRICREPORT_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORT_V1_1_1_CS *MetricReport; +} EFI_REDFISH_METRICREPORT_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_1_2/EfiMetricReportV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_1_2/EfiMetricReportV1_1_2.h new file mode 100644 index 00000000000..e69d48bd79f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_1_2/EfiMetricReportV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReport v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORT_V1_1_2_H__ +#define EFI_REDFISH_INTERP_METRICREPORT_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReport/v1_1_2/Redfish_MetricReport_v1_1_2_CS.h" +// +// EFI structure of Redfish MetricReport v1_1_2 +// +typedef struct _EFI_REDFISH_METRICREPORT_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORT_V1_1_2_CS *MetricReport; +} EFI_REDFISH_METRICREPORT_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_1_3/EfiMetricReportV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_1_3/EfiMetricReportV1_1_3.h new file mode 100644 index 00000000000..7cd5be831aa --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_1_3/EfiMetricReportV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReport v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORT_V1_1_3_H__ +#define EFI_REDFISH_INTERP_METRICREPORT_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReport/v1_1_3/Redfish_MetricReport_v1_1_3_CS.h" +// +// EFI structure of Redfish MetricReport v1_1_3 +// +typedef struct _EFI_REDFISH_METRICREPORT_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORT_V1_1_3_CS *MetricReport; +} EFI_REDFISH_METRICREPORT_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_1_4/EfiMetricReportV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_1_4/EfiMetricReportV1_1_4.h new file mode 100644 index 00000000000..4ca7f4c2bef --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_1_4/EfiMetricReportV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReport v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORT_V1_1_4_H__ +#define EFI_REDFISH_INTERP_METRICREPORT_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReport/v1_1_4/Redfish_MetricReport_v1_1_4_CS.h" +// +// EFI structure of Redfish MetricReport v1_1_4 +// +typedef struct _EFI_REDFISH_METRICREPORT_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORT_V1_1_4_CS *MetricReport; +} EFI_REDFISH_METRICREPORT_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_1_5/EfiMetricReportV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_1_5/EfiMetricReportV1_1_5.h new file mode 100644 index 00000000000..435cb9c820f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_1_5/EfiMetricReportV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReport v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORT_V1_1_5_H__ +#define EFI_REDFISH_INTERP_METRICREPORT_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReport/v1_1_5/Redfish_MetricReport_v1_1_5_CS.h" +// +// EFI structure of Redfish MetricReport v1_1_5 +// +typedef struct _EFI_REDFISH_METRICREPORT_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORT_V1_1_5_CS *MetricReport; +} EFI_REDFISH_METRICREPORT_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_2_0/EfiMetricReportV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_2_0/EfiMetricReportV1_2_0.h new file mode 100644 index 00000000000..5164f81dbe9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_2_0/EfiMetricReportV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReport v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORT_V1_2_0_H__ +#define EFI_REDFISH_INTERP_METRICREPORT_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReport/v1_2_0/Redfish_MetricReport_v1_2_0_CS.h" +// +// EFI structure of Redfish MetricReport v1_2_0 +// +typedef struct _EFI_REDFISH_METRICREPORT_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORT_V1_2_0_CS *MetricReport; +} EFI_REDFISH_METRICREPORT_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_2_1/EfiMetricReportV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_2_1/EfiMetricReportV1_2_1.h new file mode 100644 index 00000000000..efbcdee8468 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_2_1/EfiMetricReportV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReport v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORT_V1_2_1_H__ +#define EFI_REDFISH_INTERP_METRICREPORT_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReport/v1_2_1/Redfish_MetricReport_v1_2_1_CS.h" +// +// EFI structure of Redfish MetricReport v1_2_1 +// +typedef struct _EFI_REDFISH_METRICREPORT_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORT_V1_2_1_CS *MetricReport; +} EFI_REDFISH_METRICREPORT_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_2_2/EfiMetricReportV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_2_2/EfiMetricReportV1_2_2.h new file mode 100644 index 00000000000..b1e7af25670 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_2_2/EfiMetricReportV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReport v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORT_V1_2_2_H__ +#define EFI_REDFISH_INTERP_METRICREPORT_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReport/v1_2_2/Redfish_MetricReport_v1_2_2_CS.h" +// +// EFI structure of Redfish MetricReport v1_2_2 +// +typedef struct _EFI_REDFISH_METRICREPORT_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORT_V1_2_2_CS *MetricReport; +} EFI_REDFISH_METRICREPORT_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_2_3/EfiMetricReportV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_2_3/EfiMetricReportV1_2_3.h new file mode 100644 index 00000000000..0316e8be1d9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_2_3/EfiMetricReportV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReport v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORT_V1_2_3_H__ +#define EFI_REDFISH_INTERP_METRICREPORT_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReport/v1_2_3/Redfish_MetricReport_v1_2_3_CS.h" +// +// EFI structure of Redfish MetricReport v1_2_3 +// +typedef struct _EFI_REDFISH_METRICREPORT_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORT_V1_2_3_CS *MetricReport; +} EFI_REDFISH_METRICREPORT_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_3_0/EfiMetricReportV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_3_0/EfiMetricReportV1_3_0.h new file mode 100644 index 00000000000..a7d6af8b9ad --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_3_0/EfiMetricReportV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReport v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORT_V1_3_0_H__ +#define EFI_REDFISH_INTERP_METRICREPORT_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReport/v1_3_0/Redfish_MetricReport_v1_3_0_CS.h" +// +// EFI structure of Redfish MetricReport v1_3_0 +// +typedef struct _EFI_REDFISH_METRICREPORT_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORT_V1_3_0_CS *MetricReport; +} EFI_REDFISH_METRICREPORT_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_3_1/EfiMetricReportV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_3_1/EfiMetricReportV1_3_1.h new file mode 100644 index 00000000000..565f2346a39 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_3_1/EfiMetricReportV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReport v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORT_V1_3_1_H__ +#define EFI_REDFISH_INTERP_METRICREPORT_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReport/v1_3_1/Redfish_MetricReport_v1_3_1_CS.h" +// +// EFI structure of Redfish MetricReport v1_3_1 +// +typedef struct _EFI_REDFISH_METRICREPORT_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORT_V1_3_1_CS *MetricReport; +} EFI_REDFISH_METRICREPORT_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_3_2/EfiMetricReportV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_3_2/EfiMetricReportV1_3_2.h new file mode 100644 index 00000000000..61b6b7306d0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_3_2/EfiMetricReportV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReport v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORT_V1_3_2_H__ +#define EFI_REDFISH_INTERP_METRICREPORT_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReport/v1_3_2/Redfish_MetricReport_v1_3_2_CS.h" +// +// EFI structure of Redfish MetricReport v1_3_2 +// +typedef struct _EFI_REDFISH_METRICREPORT_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORT_V1_3_2_CS *MetricReport; +} EFI_REDFISH_METRICREPORT_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_4_0/EfiMetricReportV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_4_0/EfiMetricReportV1_4_0.h new file mode 100644 index 00000000000..515e1d26ead --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_4_0/EfiMetricReportV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReport v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORT_V1_4_0_H__ +#define EFI_REDFISH_INTERP_METRICREPORT_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReport/v1_4_0/Redfish_MetricReport_v1_4_0_CS.h" +// +// EFI structure of Redfish MetricReport v1_4_0 +// +typedef struct _EFI_REDFISH_METRICREPORT_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORT_V1_4_0_CS *MetricReport; +} EFI_REDFISH_METRICREPORT_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_4_1/EfiMetricReportV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_4_1/EfiMetricReportV1_4_1.h new file mode 100644 index 00000000000..db24c9f1f28 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReport/v1_4_1/EfiMetricReportV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReport v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORT_V1_4_1_H__ +#define EFI_REDFISH_INTERP_METRICREPORT_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReport/v1_4_1/Redfish_MetricReport_v1_4_1_CS.h" +// +// EFI structure of Redfish MetricReport v1_4_1 +// +typedef struct _EFI_REDFISH_METRICREPORT_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORT_V1_4_1_CS *MetricReport; +} EFI_REDFISH_METRICREPORT_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportCollection/EfiMetricReportCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportCollection/EfiMetricReportCollection.h new file mode 100644 index 00000000000..c710b3fcf64 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportCollection/EfiMetricReportCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTCOLLECTION_H__ +#define EFI_REDFISH_INTERP_METRICREPORTCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportCollection/Redfish_MetricReportCollection_CS.h" +// +// EFI structure of Redfish MetricReportCollection +// +typedef struct _EFI_REDFISH_METRICREPORTCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTCOLLECTION_CS *MetricReportCollection; +} EFI_REDFISH_METRICREPORTCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_0/EfiMetricReportDefinitionV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_0/EfiMetricReportDefinitionV1_0_0.h new file mode 100644 index 00000000000..8df28fec691 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_0/EfiMetricReportDefinitionV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_0_0_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_0_0/Redfish_MetricReportDefinition_v1_0_0_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_0_0 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_0_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_1/EfiMetricReportDefinitionV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_1/EfiMetricReportDefinitionV1_0_1.h new file mode 100644 index 00000000000..e9a5a011884 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_1/EfiMetricReportDefinitionV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_0_1_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_0_1/Redfish_MetricReportDefinition_v1_0_1_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_0_1 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_1_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_2/EfiMetricReportDefinitionV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_2/EfiMetricReportDefinitionV1_0_2.h new file mode 100644 index 00000000000..55f0c8335bf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_2/EfiMetricReportDefinitionV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_0_2_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_0_2/Redfish_MetricReportDefinition_v1_0_2_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_0_2 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_2_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_3/EfiMetricReportDefinitionV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_3/EfiMetricReportDefinitionV1_0_3.h new file mode 100644 index 00000000000..e724e8b5995 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_3/EfiMetricReportDefinitionV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_0_3_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_0_3/Redfish_MetricReportDefinition_v1_0_3_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_0_3 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_3_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_4/EfiMetricReportDefinitionV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_4/EfiMetricReportDefinitionV1_0_4.h new file mode 100644 index 00000000000..a9d88ceb1db --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_4/EfiMetricReportDefinitionV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_0_4_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_0_4/Redfish_MetricReportDefinition_v1_0_4_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_0_4 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_4_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_5/EfiMetricReportDefinitionV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_5/EfiMetricReportDefinitionV1_0_5.h new file mode 100644 index 00000000000..bdd71bea619 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_5/EfiMetricReportDefinitionV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_0_5_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_0_5/Redfish_MetricReportDefinition_v1_0_5_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_0_5 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_5_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_6/EfiMetricReportDefinitionV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_6/EfiMetricReportDefinitionV1_0_6.h new file mode 100644 index 00000000000..1d68bc19be0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_6/EfiMetricReportDefinitionV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_0_6_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_0_6/Redfish_MetricReportDefinition_v1_0_6_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_0_6 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_6_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_7/EfiMetricReportDefinitionV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_7/EfiMetricReportDefinitionV1_0_7.h new file mode 100644 index 00000000000..444d82329e0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_0_7/EfiMetricReportDefinitionV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_0_7_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_0_7/Redfish_MetricReportDefinition_v1_0_7_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_0_7 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_0_7_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_0/EfiMetricReportDefinitionV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_0/EfiMetricReportDefinitionV1_1_0.h new file mode 100644 index 00000000000..a27095d4760 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_0/EfiMetricReportDefinitionV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_1_0_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_1_0/Redfish_MetricReportDefinition_v1_1_0_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_1_0 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_0_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_1/EfiMetricReportDefinitionV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_1/EfiMetricReportDefinitionV1_1_1.h new file mode 100644 index 00000000000..604f24d3a7a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_1/EfiMetricReportDefinitionV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_1_1_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_1_1/Redfish_MetricReportDefinition_v1_1_1_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_1_1 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_1_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_2/EfiMetricReportDefinitionV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_2/EfiMetricReportDefinitionV1_1_2.h new file mode 100644 index 00000000000..614d7e9f7a3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_2/EfiMetricReportDefinitionV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_1_2_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_1_2/Redfish_MetricReportDefinition_v1_1_2_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_1_2 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_2_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_3/EfiMetricReportDefinitionV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_3/EfiMetricReportDefinitionV1_1_3.h new file mode 100644 index 00000000000..132ab03564b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_3/EfiMetricReportDefinitionV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_1_3_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_1_3/Redfish_MetricReportDefinition_v1_1_3_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_1_3 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_3_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_4/EfiMetricReportDefinitionV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_4/EfiMetricReportDefinitionV1_1_4.h new file mode 100644 index 00000000000..de529fede94 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_4/EfiMetricReportDefinitionV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_1_4_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_1_4/Redfish_MetricReportDefinition_v1_1_4_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_1_4 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_4_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_5/EfiMetricReportDefinitionV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_5/EfiMetricReportDefinitionV1_1_5.h new file mode 100644 index 00000000000..59c1d0790eb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_5/EfiMetricReportDefinitionV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_1_5_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_1_5/Redfish_MetricReportDefinition_v1_1_5_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_1_5 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_5_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_6/EfiMetricReportDefinitionV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_6/EfiMetricReportDefinitionV1_1_6.h new file mode 100644 index 00000000000..43570ec3236 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_1_6/EfiMetricReportDefinitionV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_1_6_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_1_6/Redfish_MetricReportDefinition_v1_1_6_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_1_6 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_1_6_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_2_0/EfiMetricReportDefinitionV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_2_0/EfiMetricReportDefinitionV1_2_0.h new file mode 100644 index 00000000000..9cff73c30a0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_2_0/EfiMetricReportDefinitionV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_2_0_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_2_0/Redfish_MetricReportDefinition_v1_2_0_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_2_0 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_2_0_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_2_1/EfiMetricReportDefinitionV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_2_1/EfiMetricReportDefinitionV1_2_1.h new file mode 100644 index 00000000000..3a99a444dff --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_2_1/EfiMetricReportDefinitionV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_2_1_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_2_1/Redfish_MetricReportDefinition_v1_2_1_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_2_1 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_2_1_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_2_2/EfiMetricReportDefinitionV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_2_2/EfiMetricReportDefinitionV1_2_2.h new file mode 100644 index 00000000000..e33fa973751 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_2_2/EfiMetricReportDefinitionV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_2_2_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_2_2/Redfish_MetricReportDefinition_v1_2_2_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_2_2 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_2_2_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_2_3/EfiMetricReportDefinitionV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_2_3/EfiMetricReportDefinitionV1_2_3.h new file mode 100644 index 00000000000..8653ef070de --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_2_3/EfiMetricReportDefinitionV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_2_3_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_2_3/Redfish_MetricReportDefinition_v1_2_3_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_2_3 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_2_3_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_2_4/EfiMetricReportDefinitionV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_2_4/EfiMetricReportDefinitionV1_2_4.h new file mode 100644 index 00000000000..40262bb4fd2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_2_4/EfiMetricReportDefinitionV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_2_4_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_2_4/Redfish_MetricReportDefinition_v1_2_4_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_2_4 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_2_4_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_2_5/EfiMetricReportDefinitionV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_2_5/EfiMetricReportDefinitionV1_2_5.h new file mode 100644 index 00000000000..8b96b51c396 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_2_5/EfiMetricReportDefinitionV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_2_5_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_2_5/Redfish_MetricReportDefinition_v1_2_5_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_2_5 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_2_5_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_3_0/EfiMetricReportDefinitionV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_3_0/EfiMetricReportDefinitionV1_3_0.h new file mode 100644 index 00000000000..90d8dd855be --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_3_0/EfiMetricReportDefinitionV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_3_0_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_3_0/Redfish_MetricReportDefinition_v1_3_0_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_3_0 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_3_0_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_3_1/EfiMetricReportDefinitionV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_3_1/EfiMetricReportDefinitionV1_3_1.h new file mode 100644 index 00000000000..83d6be4ec63 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_3_1/EfiMetricReportDefinitionV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_3_1_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_3_1/Redfish_MetricReportDefinition_v1_3_1_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_3_1 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_3_1_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_3_2/EfiMetricReportDefinitionV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_3_2/EfiMetricReportDefinitionV1_3_2.h new file mode 100644 index 00000000000..586465b7fb7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_3_2/EfiMetricReportDefinitionV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_3_2_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_3_2/Redfish_MetricReportDefinition_v1_3_2_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_3_2 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_3_2_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_3_3/EfiMetricReportDefinitionV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_3_3/EfiMetricReportDefinitionV1_3_3.h new file mode 100644 index 00000000000..9fee28e0bae --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_3_3/EfiMetricReportDefinitionV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_3_3_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_3_3/Redfish_MetricReportDefinition_v1_3_3_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_3_3 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_3_3_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_3_4/EfiMetricReportDefinitionV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_3_4/EfiMetricReportDefinitionV1_3_4.h new file mode 100644 index 00000000000..90c6abb3301 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_3_4/EfiMetricReportDefinitionV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_3_4_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_3_4/Redfish_MetricReportDefinition_v1_3_4_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_3_4 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_3_4_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_4_0/EfiMetricReportDefinitionV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_4_0/EfiMetricReportDefinitionV1_4_0.h new file mode 100644 index 00000000000..a972095577e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinition/v1_4_0/EfiMetricReportDefinitionV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinition v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_4_0_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITION_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinition/v1_4_0/Redfish_MetricReportDefinition_v1_4_0_CS.h" +// +// EFI structure of Redfish MetricReportDefinition v1_4_0 +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITION_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITION_V1_4_0_CS *MetricReportDefinition; +} EFI_REDFISH_METRICREPORTDEFINITION_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinitionCollection/EfiMetricReportDefinitionCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinitionCollection/EfiMetricReportDefinitionCollection.h new file mode 100644 index 00000000000..0820b83bebb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/MetricReportDefinitionCollection/EfiMetricReportDefinitionCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for MetricReportDefinitionCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_METRICREPORTDEFINITIONCOLLECTION_H__ +#define EFI_REDFISH_INTERP_METRICREPORTDEFINITIONCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/MetricReportDefinitionCollection/Redfish_MetricReportDefinitionCollection_CS.h" +// +// EFI structure of Redfish MetricReportDefinitionCollection +// +typedef struct _EFI_REDFISH_METRICREPORTDEFINITIONCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_METRICREPORTDEFINITIONCOLLECTION_CS *MetricReportDefinitionCollection; +} EFI_REDFISH_METRICREPORTDEFINITIONCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_0/EfiNetworkAdapterV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_0/EfiNetworkAdapterV1_0_0.h new file mode 100644 index 00000000000..3b7452b8cca --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_0/EfiNetworkAdapterV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_0_0_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_0_0/Redfish_NetworkAdapter_v1_0_0_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_0_0 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_0_0_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_1/EfiNetworkAdapterV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_1/EfiNetworkAdapterV1_0_1.h new file mode 100644 index 00000000000..1ab6277fbe5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_1/EfiNetworkAdapterV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_0_1_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_0_1/Redfish_NetworkAdapter_v1_0_1_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_0_1 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_0_1_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_2/EfiNetworkAdapterV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_2/EfiNetworkAdapterV1_0_2.h new file mode 100644 index 00000000000..c14f520c87a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_2/EfiNetworkAdapterV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_0_2_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_0_2/Redfish_NetworkAdapter_v1_0_2_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_0_2 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_0_2_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_3/EfiNetworkAdapterV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_3/EfiNetworkAdapterV1_0_3.h new file mode 100644 index 00000000000..8e374391d6f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_3/EfiNetworkAdapterV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_0_3_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_0_3/Redfish_NetworkAdapter_v1_0_3_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_0_3 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_0_3_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_4/EfiNetworkAdapterV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_4/EfiNetworkAdapterV1_0_4.h new file mode 100644 index 00000000000..cc3f59e965b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_4/EfiNetworkAdapterV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_0_4_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_0_4/Redfish_NetworkAdapter_v1_0_4_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_0_4 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_0_4_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_5/EfiNetworkAdapterV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_5/EfiNetworkAdapterV1_0_5.h new file mode 100644 index 00000000000..b767b8e6ad5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_5/EfiNetworkAdapterV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_0_5_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_0_5/Redfish_NetworkAdapter_v1_0_5_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_0_5 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_0_5_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_6/EfiNetworkAdapterV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_6/EfiNetworkAdapterV1_0_6.h new file mode 100644 index 00000000000..ceb13796295 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_6/EfiNetworkAdapterV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_0_6_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_0_6/Redfish_NetworkAdapter_v1_0_6_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_0_6 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_0_6_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_7/EfiNetworkAdapterV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_7/EfiNetworkAdapterV1_0_7.h new file mode 100644 index 00000000000..2ea70c94f49 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_0_7/EfiNetworkAdapterV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_0_7_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_0_7/Redfish_NetworkAdapter_v1_0_7_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_0_7 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_0_7_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_0/EfiNetworkAdapterV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_0/EfiNetworkAdapterV1_1_0.h new file mode 100644 index 00000000000..9bd3d1b0c97 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_0/EfiNetworkAdapterV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_1_0_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_1_0/Redfish_NetworkAdapter_v1_1_0_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_1_0 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_1_0_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_1/EfiNetworkAdapterV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_1/EfiNetworkAdapterV1_1_1.h new file mode 100644 index 00000000000..7b03c716c0b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_1/EfiNetworkAdapterV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_1_1_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_1_1/Redfish_NetworkAdapter_v1_1_1_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_1_1 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_1_1_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_2/EfiNetworkAdapterV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_2/EfiNetworkAdapterV1_1_2.h new file mode 100644 index 00000000000..b42ea7b60d0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_2/EfiNetworkAdapterV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_1_2_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_1_2/Redfish_NetworkAdapter_v1_1_2_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_1_2 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_1_2_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_3/EfiNetworkAdapterV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_3/EfiNetworkAdapterV1_1_3.h new file mode 100644 index 00000000000..624fd34217c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_3/EfiNetworkAdapterV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_1_3_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_1_3/Redfish_NetworkAdapter_v1_1_3_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_1_3 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_1_3_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_4/EfiNetworkAdapterV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_4/EfiNetworkAdapterV1_1_4.h new file mode 100644 index 00000000000..eb794062f14 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_4/EfiNetworkAdapterV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_1_4_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_1_4/Redfish_NetworkAdapter_v1_1_4_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_1_4 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_1_4_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_5/EfiNetworkAdapterV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_5/EfiNetworkAdapterV1_1_5.h new file mode 100644 index 00000000000..cb80b256a4e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_5/EfiNetworkAdapterV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_1_5_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_1_5/Redfish_NetworkAdapter_v1_1_5_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_1_5 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_1_5_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_6/EfiNetworkAdapterV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_6/EfiNetworkAdapterV1_1_6.h new file mode 100644 index 00000000000..ff43c0e4f83 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_1_6/EfiNetworkAdapterV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_1_6_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_1_6/Redfish_NetworkAdapter_v1_1_6_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_1_6 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_1_6_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_2_0/EfiNetworkAdapterV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_2_0/EfiNetworkAdapterV1_2_0.h new file mode 100644 index 00000000000..e2e199e9a20 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_2_0/EfiNetworkAdapterV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_2_0_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_2_0/Redfish_NetworkAdapter_v1_2_0_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_2_0 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_2_0_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_2_1/EfiNetworkAdapterV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_2_1/EfiNetworkAdapterV1_2_1.h new file mode 100644 index 00000000000..7f01214e5cd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_2_1/EfiNetworkAdapterV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_2_1_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_2_1/Redfish_NetworkAdapter_v1_2_1_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_2_1 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_2_1_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_2_2/EfiNetworkAdapterV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_2_2/EfiNetworkAdapterV1_2_2.h new file mode 100644 index 00000000000..38f1280d651 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_2_2/EfiNetworkAdapterV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_2_2_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_2_2/Redfish_NetworkAdapter_v1_2_2_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_2_2 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_2_2_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_2_3/EfiNetworkAdapterV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_2_3/EfiNetworkAdapterV1_2_3.h new file mode 100644 index 00000000000..b0d13634f38 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_2_3/EfiNetworkAdapterV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_2_3_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_2_3/Redfish_NetworkAdapter_v1_2_3_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_2_3 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_2_3_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_2_4/EfiNetworkAdapterV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_2_4/EfiNetworkAdapterV1_2_4.h new file mode 100644 index 00000000000..dde39c9e04c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_2_4/EfiNetworkAdapterV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_2_4_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_2_4/Redfish_NetworkAdapter_v1_2_4_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_2_4 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_2_4_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_2_5/EfiNetworkAdapterV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_2_5/EfiNetworkAdapterV1_2_5.h new file mode 100644 index 00000000000..60a06952e32 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_2_5/EfiNetworkAdapterV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_2_5_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_2_5/Redfish_NetworkAdapter_v1_2_5_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_2_5 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_2_5_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_3_0/EfiNetworkAdapterV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_3_0/EfiNetworkAdapterV1_3_0.h new file mode 100644 index 00000000000..aa88c2e2404 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_3_0/EfiNetworkAdapterV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_3_0_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_3_0/Redfish_NetworkAdapter_v1_3_0_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_3_0 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_3_0_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_3_1/EfiNetworkAdapterV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_3_1/EfiNetworkAdapterV1_3_1.h new file mode 100644 index 00000000000..64b466d361a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_3_1/EfiNetworkAdapterV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_3_1_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_3_1/Redfish_NetworkAdapter_v1_3_1_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_3_1 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_3_1_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_3_2/EfiNetworkAdapterV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_3_2/EfiNetworkAdapterV1_3_2.h new file mode 100644 index 00000000000..7d6a123cc8d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_3_2/EfiNetworkAdapterV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_3_2_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_3_2/Redfish_NetworkAdapter_v1_3_2_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_3_2 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_3_2_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_3_3/EfiNetworkAdapterV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_3_3/EfiNetworkAdapterV1_3_3.h new file mode 100644 index 00000000000..41e523d9c80 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_3_3/EfiNetworkAdapterV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_3_3_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_3_3/Redfish_NetworkAdapter_v1_3_3_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_3_3 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_3_3_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_3_4/EfiNetworkAdapterV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_3_4/EfiNetworkAdapterV1_3_4.h new file mode 100644 index 00000000000..e5461af3215 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_3_4/EfiNetworkAdapterV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_3_4_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_3_4/Redfish_NetworkAdapter_v1_3_4_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_3_4 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_3_4_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_4_0/EfiNetworkAdapterV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_4_0/EfiNetworkAdapterV1_4_0.h new file mode 100644 index 00000000000..76b7be5db70 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_4_0/EfiNetworkAdapterV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_4_0_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_4_0/Redfish_NetworkAdapter_v1_4_0_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_4_0 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_4_0_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_4_1/EfiNetworkAdapterV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_4_1/EfiNetworkAdapterV1_4_1.h new file mode 100644 index 00000000000..81ece085816 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_4_1/EfiNetworkAdapterV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_4_1_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_4_1/Redfish_NetworkAdapter_v1_4_1_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_4_1 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_4_1_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_5_0/EfiNetworkAdapterV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_5_0/EfiNetworkAdapterV1_5_0.h new file mode 100644 index 00000000000..671551b1889 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_5_0/EfiNetworkAdapterV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_5_0_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_5_0/Redfish_NetworkAdapter_v1_5_0_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_5_0 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_5_0_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_5_1/EfiNetworkAdapterV1_5_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_5_1/EfiNetworkAdapterV1_5_1.h new file mode 100644 index 00000000000..a253b6969af --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_5_1/EfiNetworkAdapterV1_5_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_5_1_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_5_1_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_5_1/Redfish_NetworkAdapter_v1_5_1_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_5_1 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_5_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_5_1_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_5_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_6_0/EfiNetworkAdapterV1_6_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_6_0/EfiNetworkAdapterV1_6_0.h new file mode 100644 index 00000000000..91c172d8c51 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapter/v1_6_0/EfiNetworkAdapterV1_6_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapter v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTER_V1_6_0_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTER_V1_6_0_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapter/v1_6_0/Redfish_NetworkAdapter_v1_6_0_CS.h" +// +// EFI structure of Redfish NetworkAdapter v1_6_0 +// +typedef struct _EFI_REDFISH_NETWORKADAPTER_V1_6_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTER_V1_6_0_CS *NetworkAdapter; +} EFI_REDFISH_NETWORKADAPTER_V1_6_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapterCollection/EfiNetworkAdapterCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapterCollection/EfiNetworkAdapterCollection.h new file mode 100644 index 00000000000..78e7cf99c22 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkAdapterCollection/EfiNetworkAdapterCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkAdapterCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKADAPTERCOLLECTION_H__ +#define EFI_REDFISH_INTERP_NETWORKADAPTERCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkAdapterCollection/Redfish_NetworkAdapterCollection_CS.h" +// +// EFI structure of Redfish NetworkAdapterCollection +// +typedef struct _EFI_REDFISH_NETWORKADAPTERCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKADAPTERCOLLECTION_CS *NetworkAdapterCollection; +} EFI_REDFISH_NETWORKADAPTERCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_0/EfiNetworkDeviceFunctionV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_0/EfiNetworkDeviceFunctionV1_0_0.h new file mode 100644 index 00000000000..c48a2506c0e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_0/EfiNetworkDeviceFunctionV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_0_0_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_0_0/Redfish_NetworkDeviceFunction_v1_0_0_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_0_0 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_0_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_1/EfiNetworkDeviceFunctionV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_1/EfiNetworkDeviceFunctionV1_0_1.h new file mode 100644 index 00000000000..577169bf9c4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_1/EfiNetworkDeviceFunctionV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_0_1_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_0_1/Redfish_NetworkDeviceFunction_v1_0_1_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_0_1 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_1_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_2/EfiNetworkDeviceFunctionV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_2/EfiNetworkDeviceFunctionV1_0_2.h new file mode 100644 index 00000000000..cff3ee92d9f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_2/EfiNetworkDeviceFunctionV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_0_2_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_0_2/Redfish_NetworkDeviceFunction_v1_0_2_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_0_2 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_2_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_3/EfiNetworkDeviceFunctionV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_3/EfiNetworkDeviceFunctionV1_0_3.h new file mode 100644 index 00000000000..78863bd280a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_3/EfiNetworkDeviceFunctionV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_0_3_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_0_3/Redfish_NetworkDeviceFunction_v1_0_3_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_0_3 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_3_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_4/EfiNetworkDeviceFunctionV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_4/EfiNetworkDeviceFunctionV1_0_4.h new file mode 100644 index 00000000000..2426630d89e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_4/EfiNetworkDeviceFunctionV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_0_4_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_0_4/Redfish_NetworkDeviceFunction_v1_0_4_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_0_4 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_4_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_5/EfiNetworkDeviceFunctionV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_5/EfiNetworkDeviceFunctionV1_0_5.h new file mode 100644 index 00000000000..70888852384 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_5/EfiNetworkDeviceFunctionV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_0_5_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_0_5/Redfish_NetworkDeviceFunction_v1_0_5_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_0_5 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_5_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_6/EfiNetworkDeviceFunctionV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_6/EfiNetworkDeviceFunctionV1_0_6.h new file mode 100644 index 00000000000..f81bedbe9bc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_6/EfiNetworkDeviceFunctionV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_0_6_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_0_6/Redfish_NetworkDeviceFunction_v1_0_6_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_0_6 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_6_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_7/EfiNetworkDeviceFunctionV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_7/EfiNetworkDeviceFunctionV1_0_7.h new file mode 100644 index 00000000000..a343316a232 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_7/EfiNetworkDeviceFunctionV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_0_7_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_0_7/Redfish_NetworkDeviceFunction_v1_0_7_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_0_7 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_7_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_8/EfiNetworkDeviceFunctionV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_8/EfiNetworkDeviceFunctionV1_0_8.h new file mode 100644 index 00000000000..460a938b4bc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_0_8/EfiNetworkDeviceFunctionV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_0_8_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_0_8/Redfish_NetworkDeviceFunction_v1_0_8_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_0_8 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_8_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_0/EfiNetworkDeviceFunctionV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_0/EfiNetworkDeviceFunctionV1_1_0.h new file mode 100644 index 00000000000..0206818a876 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_0/EfiNetworkDeviceFunctionV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_1_0_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_1_0/Redfish_NetworkDeviceFunction_v1_1_0_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_1_0 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_0_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_1/EfiNetworkDeviceFunctionV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_1/EfiNetworkDeviceFunctionV1_1_1.h new file mode 100644 index 00000000000..dd7898f465b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_1/EfiNetworkDeviceFunctionV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_1_1_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_1_1/Redfish_NetworkDeviceFunction_v1_1_1_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_1_1 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_1_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_2/EfiNetworkDeviceFunctionV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_2/EfiNetworkDeviceFunctionV1_1_2.h new file mode 100644 index 00000000000..32bbbef3559 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_2/EfiNetworkDeviceFunctionV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_1_2_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_1_2/Redfish_NetworkDeviceFunction_v1_1_2_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_1_2 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_2_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_3/EfiNetworkDeviceFunctionV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_3/EfiNetworkDeviceFunctionV1_1_3.h new file mode 100644 index 00000000000..8e1ea0058cd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_3/EfiNetworkDeviceFunctionV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_1_3_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_1_3/Redfish_NetworkDeviceFunction_v1_1_3_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_1_3 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_3_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_4/EfiNetworkDeviceFunctionV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_4/EfiNetworkDeviceFunctionV1_1_4.h new file mode 100644 index 00000000000..c8ba922a2a5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_4/EfiNetworkDeviceFunctionV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_1_4_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_1_4/Redfish_NetworkDeviceFunction_v1_1_4_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_1_4 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_4_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_5/EfiNetworkDeviceFunctionV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_5/EfiNetworkDeviceFunctionV1_1_5.h new file mode 100644 index 00000000000..c1de2fa917e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_5/EfiNetworkDeviceFunctionV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_1_5_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_1_5/Redfish_NetworkDeviceFunction_v1_1_5_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_1_5 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_5_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_6/EfiNetworkDeviceFunctionV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_6/EfiNetworkDeviceFunctionV1_1_6.h new file mode 100644 index 00000000000..d3867a962a5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_6/EfiNetworkDeviceFunctionV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_1_6_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_1_6/Redfish_NetworkDeviceFunction_v1_1_6_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_1_6 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_6_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_7/EfiNetworkDeviceFunctionV1_1_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_7/EfiNetworkDeviceFunctionV1_1_7.h new file mode 100644 index 00000000000..9ad404cf526 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_1_7/EfiNetworkDeviceFunctionV1_1_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_1_7_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_1_7_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_1_7/Redfish_NetworkDeviceFunction_v1_1_7_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_1_7 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_7_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_1_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_0/EfiNetworkDeviceFunctionV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_0/EfiNetworkDeviceFunctionV1_2_0.h new file mode 100644 index 00000000000..a256326c97b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_0/EfiNetworkDeviceFunctionV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_2_0_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_2_0/Redfish_NetworkDeviceFunction_v1_2_0_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_2_0 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_0_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_1/EfiNetworkDeviceFunctionV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_1/EfiNetworkDeviceFunctionV1_2_1.h new file mode 100644 index 00000000000..d97d41d9bf9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_1/EfiNetworkDeviceFunctionV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_2_1_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_2_1/Redfish_NetworkDeviceFunction_v1_2_1_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_2_1 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_1_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_2/EfiNetworkDeviceFunctionV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_2/EfiNetworkDeviceFunctionV1_2_2.h new file mode 100644 index 00000000000..230d4ba6edd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_2/EfiNetworkDeviceFunctionV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_2_2_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_2_2/Redfish_NetworkDeviceFunction_v1_2_2_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_2_2 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_2_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_3/EfiNetworkDeviceFunctionV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_3/EfiNetworkDeviceFunctionV1_2_3.h new file mode 100644 index 00000000000..eba776ce14c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_3/EfiNetworkDeviceFunctionV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_2_3_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_2_3/Redfish_NetworkDeviceFunction_v1_2_3_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_2_3 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_3_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_4/EfiNetworkDeviceFunctionV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_4/EfiNetworkDeviceFunctionV1_2_4.h new file mode 100644 index 00000000000..f08910b23d7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_4/EfiNetworkDeviceFunctionV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_2_4_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_2_4/Redfish_NetworkDeviceFunction_v1_2_4_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_2_4 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_4_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_5/EfiNetworkDeviceFunctionV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_5/EfiNetworkDeviceFunctionV1_2_5.h new file mode 100644 index 00000000000..8b218ba2fd2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_5/EfiNetworkDeviceFunctionV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_2_5_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_2_5/Redfish_NetworkDeviceFunction_v1_2_5_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_2_5 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_5_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_6/EfiNetworkDeviceFunctionV1_2_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_6/EfiNetworkDeviceFunctionV1_2_6.h new file mode 100644 index 00000000000..6fdb9756d54 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_6/EfiNetworkDeviceFunctionV1_2_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_2_6_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_2_6_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_2_6/Redfish_NetworkDeviceFunction_v1_2_6_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_2_6 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_6_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_7/EfiNetworkDeviceFunctionV1_2_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_7/EfiNetworkDeviceFunctionV1_2_7.h new file mode 100644 index 00000000000..36578c49dca --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_2_7/EfiNetworkDeviceFunctionV1_2_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_2_7_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_2_7_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_2_7/Redfish_NetworkDeviceFunction_v1_2_7_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_2_7 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_7_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_2_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_3_0/EfiNetworkDeviceFunctionV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_3_0/EfiNetworkDeviceFunctionV1_3_0.h new file mode 100644 index 00000000000..816c118c237 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_3_0/EfiNetworkDeviceFunctionV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_3_0_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_3_0/Redfish_NetworkDeviceFunction_v1_3_0_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_3_0 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_0_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_3_1/EfiNetworkDeviceFunctionV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_3_1/EfiNetworkDeviceFunctionV1_3_1.h new file mode 100644 index 00000000000..3e6a475d43c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_3_1/EfiNetworkDeviceFunctionV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_3_1_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_3_1/Redfish_NetworkDeviceFunction_v1_3_1_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_3_1 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_1_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_3_2/EfiNetworkDeviceFunctionV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_3_2/EfiNetworkDeviceFunctionV1_3_2.h new file mode 100644 index 00000000000..46db4ca6ca9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_3_2/EfiNetworkDeviceFunctionV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_3_2_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_3_2/Redfish_NetworkDeviceFunction_v1_3_2_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_3_2 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_2_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_3_3/EfiNetworkDeviceFunctionV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_3_3/EfiNetworkDeviceFunctionV1_3_3.h new file mode 100644 index 00000000000..356475d9754 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_3_3/EfiNetworkDeviceFunctionV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_3_3_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_3_3/Redfish_NetworkDeviceFunction_v1_3_3_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_3_3 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_3_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_3_4/EfiNetworkDeviceFunctionV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_3_4/EfiNetworkDeviceFunctionV1_3_4.h new file mode 100644 index 00000000000..be22eb161c3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_3_4/EfiNetworkDeviceFunctionV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_3_4_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_3_4/Redfish_NetworkDeviceFunction_v1_3_4_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_3_4 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_4_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_3_5/EfiNetworkDeviceFunctionV1_3_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_3_5/EfiNetworkDeviceFunctionV1_3_5.h new file mode 100644 index 00000000000..fd5ef9fbad1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_3_5/EfiNetworkDeviceFunctionV1_3_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_3_5_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_3_5_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_3_5/Redfish_NetworkDeviceFunction_v1_3_5_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_3_5 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_5_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_3_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_4_0/EfiNetworkDeviceFunctionV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_4_0/EfiNetworkDeviceFunctionV1_4_0.h new file mode 100644 index 00000000000..d842e9b3ac2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_4_0/EfiNetworkDeviceFunctionV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_4_0_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_4_0/Redfish_NetworkDeviceFunction_v1_4_0_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_4_0 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_0_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_4_1/EfiNetworkDeviceFunctionV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_4_1/EfiNetworkDeviceFunctionV1_4_1.h new file mode 100644 index 00000000000..65f43b52b13 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_4_1/EfiNetworkDeviceFunctionV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_4_1_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_4_1/Redfish_NetworkDeviceFunction_v1_4_1_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_4_1 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_1_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_4_2/EfiNetworkDeviceFunctionV1_4_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_4_2/EfiNetworkDeviceFunctionV1_4_2.h new file mode 100644 index 00000000000..f782ccfa9b6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_4_2/EfiNetworkDeviceFunctionV1_4_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_4_2_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_4_2_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_4_2/Redfish_NetworkDeviceFunction_v1_4_2_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_4_2 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_2_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_4_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_5_0/EfiNetworkDeviceFunctionV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_5_0/EfiNetworkDeviceFunctionV1_5_0.h new file mode 100644 index 00000000000..ce5dfaf74d8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_5_0/EfiNetworkDeviceFunctionV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_5_0_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_5_0/Redfish_NetworkDeviceFunction_v1_5_0_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_5_0 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_5_0_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_5_1/EfiNetworkDeviceFunctionV1_5_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_5_1/EfiNetworkDeviceFunctionV1_5_1.h new file mode 100644 index 00000000000..ebb21ebbe76 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunction/v1_5_1/EfiNetworkDeviceFunctionV1_5_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunction v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_5_1_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTION_V1_5_1_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunction/v1_5_1/Redfish_NetworkDeviceFunction_v1_5_1_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunction v1_5_1 +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_5_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_5_1_CS *NetworkDeviceFunction; +} EFI_REDFISH_NETWORKDEVICEFUNCTION_V1_5_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunctionCollection/EfiNetworkDeviceFunctionCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunctionCollection/EfiNetworkDeviceFunctionCollection.h new file mode 100644 index 00000000000..6ff3608ed31 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkDeviceFunctionCollection/EfiNetworkDeviceFunctionCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkDeviceFunctionCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTIONCOLLECTION_H__ +#define EFI_REDFISH_INTERP_NETWORKDEVICEFUNCTIONCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkDeviceFunctionCollection/Redfish_NetworkDeviceFunctionCollection_CS.h" +// +// EFI structure of Redfish NetworkDeviceFunctionCollection +// +typedef struct _EFI_REDFISH_NETWORKDEVICEFUNCTIONCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKDEVICEFUNCTIONCOLLECTION_CS *NetworkDeviceFunctionCollection; +} EFI_REDFISH_NETWORKDEVICEFUNCTIONCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_0/EfiNetworkInterfaceV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_0/EfiNetworkInterfaceV1_0_0.h new file mode 100644 index 00000000000..217b896b476 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_0/EfiNetworkInterfaceV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkInterface v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkInterface/v1_0_0/Redfish_NetworkInterface_v1_0_0_CS.h" +// +// EFI structure of Redfish NetworkInterface v1_0_0 +// +typedef struct _EFI_REDFISH_NETWORKINTERFACE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKINTERFACE_V1_0_0_CS *NetworkInterface; +} EFI_REDFISH_NETWORKINTERFACE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_1/EfiNetworkInterfaceV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_1/EfiNetworkInterfaceV1_0_1.h new file mode 100644 index 00000000000..4d94ad13fa9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_1/EfiNetworkInterfaceV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkInterface v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_0_1_H__ +#define EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkInterface/v1_0_1/Redfish_NetworkInterface_v1_0_1_CS.h" +// +// EFI structure of Redfish NetworkInterface v1_0_1 +// +typedef struct _EFI_REDFISH_NETWORKINTERFACE_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKINTERFACE_V1_0_1_CS *NetworkInterface; +} EFI_REDFISH_NETWORKINTERFACE_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_2/EfiNetworkInterfaceV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_2/EfiNetworkInterfaceV1_0_2.h new file mode 100644 index 00000000000..38eb8fb9497 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_2/EfiNetworkInterfaceV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkInterface v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_0_2_H__ +#define EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkInterface/v1_0_2/Redfish_NetworkInterface_v1_0_2_CS.h" +// +// EFI structure of Redfish NetworkInterface v1_0_2 +// +typedef struct _EFI_REDFISH_NETWORKINTERFACE_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKINTERFACE_V1_0_2_CS *NetworkInterface; +} EFI_REDFISH_NETWORKINTERFACE_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_3/EfiNetworkInterfaceV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_3/EfiNetworkInterfaceV1_0_3.h new file mode 100644 index 00000000000..883054c3527 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_3/EfiNetworkInterfaceV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkInterface v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_0_3_H__ +#define EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkInterface/v1_0_3/Redfish_NetworkInterface_v1_0_3_CS.h" +// +// EFI structure of Redfish NetworkInterface v1_0_3 +// +typedef struct _EFI_REDFISH_NETWORKINTERFACE_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKINTERFACE_V1_0_3_CS *NetworkInterface; +} EFI_REDFISH_NETWORKINTERFACE_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_4/EfiNetworkInterfaceV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_4/EfiNetworkInterfaceV1_0_4.h new file mode 100644 index 00000000000..d874a9c583e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_4/EfiNetworkInterfaceV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkInterface v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_0_4_H__ +#define EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkInterface/v1_0_4/Redfish_NetworkInterface_v1_0_4_CS.h" +// +// EFI structure of Redfish NetworkInterface v1_0_4 +// +typedef struct _EFI_REDFISH_NETWORKINTERFACE_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKINTERFACE_V1_0_4_CS *NetworkInterface; +} EFI_REDFISH_NETWORKINTERFACE_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_5/EfiNetworkInterfaceV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_5/EfiNetworkInterfaceV1_0_5.h new file mode 100644 index 00000000000..fca75f06fc3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_5/EfiNetworkInterfaceV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkInterface v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_0_5_H__ +#define EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkInterface/v1_0_5/Redfish_NetworkInterface_v1_0_5_CS.h" +// +// EFI structure of Redfish NetworkInterface v1_0_5 +// +typedef struct _EFI_REDFISH_NETWORKINTERFACE_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKINTERFACE_V1_0_5_CS *NetworkInterface; +} EFI_REDFISH_NETWORKINTERFACE_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_6/EfiNetworkInterfaceV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_6/EfiNetworkInterfaceV1_0_6.h new file mode 100644 index 00000000000..cdeeb13c3ce --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_0_6/EfiNetworkInterfaceV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkInterface v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_0_6_H__ +#define EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkInterface/v1_0_6/Redfish_NetworkInterface_v1_0_6_CS.h" +// +// EFI structure of Redfish NetworkInterface v1_0_6 +// +typedef struct _EFI_REDFISH_NETWORKINTERFACE_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKINTERFACE_V1_0_6_CS *NetworkInterface; +} EFI_REDFISH_NETWORKINTERFACE_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_1_0/EfiNetworkInterfaceV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_1_0/EfiNetworkInterfaceV1_1_0.h new file mode 100644 index 00000000000..99669bf972c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_1_0/EfiNetworkInterfaceV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkInterface v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_1_0_H__ +#define EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkInterface/v1_1_0/Redfish_NetworkInterface_v1_1_0_CS.h" +// +// EFI structure of Redfish NetworkInterface v1_1_0 +// +typedef struct _EFI_REDFISH_NETWORKINTERFACE_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKINTERFACE_V1_1_0_CS *NetworkInterface; +} EFI_REDFISH_NETWORKINTERFACE_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_1_1/EfiNetworkInterfaceV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_1_1/EfiNetworkInterfaceV1_1_1.h new file mode 100644 index 00000000000..584519245a3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_1_1/EfiNetworkInterfaceV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkInterface v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_1_1_H__ +#define EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkInterface/v1_1_1/Redfish_NetworkInterface_v1_1_1_CS.h" +// +// EFI structure of Redfish NetworkInterface v1_1_1 +// +typedef struct _EFI_REDFISH_NETWORKINTERFACE_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKINTERFACE_V1_1_1_CS *NetworkInterface; +} EFI_REDFISH_NETWORKINTERFACE_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_1_2/EfiNetworkInterfaceV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_1_2/EfiNetworkInterfaceV1_1_2.h new file mode 100644 index 00000000000..a6fa87e9765 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_1_2/EfiNetworkInterfaceV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkInterface v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_1_2_H__ +#define EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkInterface/v1_1_2/Redfish_NetworkInterface_v1_1_2_CS.h" +// +// EFI structure of Redfish NetworkInterface v1_1_2 +// +typedef struct _EFI_REDFISH_NETWORKINTERFACE_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKINTERFACE_V1_1_2_CS *NetworkInterface; +} EFI_REDFISH_NETWORKINTERFACE_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_1_3/EfiNetworkInterfaceV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_1_3/EfiNetworkInterfaceV1_1_3.h new file mode 100644 index 00000000000..b4745b2f47c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_1_3/EfiNetworkInterfaceV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkInterface v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_1_3_H__ +#define EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkInterface/v1_1_3/Redfish_NetworkInterface_v1_1_3_CS.h" +// +// EFI structure of Redfish NetworkInterface v1_1_3 +// +typedef struct _EFI_REDFISH_NETWORKINTERFACE_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKINTERFACE_V1_1_3_CS *NetworkInterface; +} EFI_REDFISH_NETWORKINTERFACE_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_1_4/EfiNetworkInterfaceV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_1_4/EfiNetworkInterfaceV1_1_4.h new file mode 100644 index 00000000000..dc79d2231a2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_1_4/EfiNetworkInterfaceV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkInterface v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_1_4_H__ +#define EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkInterface/v1_1_4/Redfish_NetworkInterface_v1_1_4_CS.h" +// +// EFI structure of Redfish NetworkInterface v1_1_4 +// +typedef struct _EFI_REDFISH_NETWORKINTERFACE_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKINTERFACE_V1_1_4_CS *NetworkInterface; +} EFI_REDFISH_NETWORKINTERFACE_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_1_5/EfiNetworkInterfaceV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_1_5/EfiNetworkInterfaceV1_1_5.h new file mode 100644 index 00000000000..47f609c60e3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_1_5/EfiNetworkInterfaceV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkInterface v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_1_5_H__ +#define EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkInterface/v1_1_5/Redfish_NetworkInterface_v1_1_5_CS.h" +// +// EFI structure of Redfish NetworkInterface v1_1_5 +// +typedef struct _EFI_REDFISH_NETWORKINTERFACE_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKINTERFACE_V1_1_5_CS *NetworkInterface; +} EFI_REDFISH_NETWORKINTERFACE_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_2_0/EfiNetworkInterfaceV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_2_0/EfiNetworkInterfaceV1_2_0.h new file mode 100644 index 00000000000..e19038d1053 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_2_0/EfiNetworkInterfaceV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkInterface v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_2_0_H__ +#define EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkInterface/v1_2_0/Redfish_NetworkInterface_v1_2_0_CS.h" +// +// EFI structure of Redfish NetworkInterface v1_2_0 +// +typedef struct _EFI_REDFISH_NETWORKINTERFACE_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKINTERFACE_V1_2_0_CS *NetworkInterface; +} EFI_REDFISH_NETWORKINTERFACE_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_2_1/EfiNetworkInterfaceV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_2_1/EfiNetworkInterfaceV1_2_1.h new file mode 100644 index 00000000000..e1a70aa9770 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterface/v1_2_1/EfiNetworkInterfaceV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkInterface v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_2_1_H__ +#define EFI_REDFISH_INTERP_NETWORKINTERFACE_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkInterface/v1_2_1/Redfish_NetworkInterface_v1_2_1_CS.h" +// +// EFI structure of Redfish NetworkInterface v1_2_1 +// +typedef struct _EFI_REDFISH_NETWORKINTERFACE_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKINTERFACE_V1_2_1_CS *NetworkInterface; +} EFI_REDFISH_NETWORKINTERFACE_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterfaceCollection/EfiNetworkInterfaceCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterfaceCollection/EfiNetworkInterfaceCollection.h new file mode 100644 index 00000000000..80407888357 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkInterfaceCollection/EfiNetworkInterfaceCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkInterfaceCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKINTERFACECOLLECTION_H__ +#define EFI_REDFISH_INTERP_NETWORKINTERFACECOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkInterfaceCollection/Redfish_NetworkInterfaceCollection_CS.h" +// +// EFI structure of Redfish NetworkInterfaceCollection +// +typedef struct _EFI_REDFISH_NETWORKINTERFACECOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKINTERFACECOLLECTION_CS *NetworkInterfaceCollection; +} EFI_REDFISH_NETWORKINTERFACECOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_0/EfiNetworkPortV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_0/EfiNetworkPortV1_0_0.h new file mode 100644 index 00000000000..edbaf66e348 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_0/EfiNetworkPortV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_0_0_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_0_0/Redfish_NetworkPort_v1_0_0_CS.h" +// +// EFI structure of Redfish NetworkPort v1_0_0 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_0_0_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_1/EfiNetworkPortV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_1/EfiNetworkPortV1_0_1.h new file mode 100644 index 00000000000..435611136b8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_1/EfiNetworkPortV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_0_1_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_0_1/Redfish_NetworkPort_v1_0_1_CS.h" +// +// EFI structure of Redfish NetworkPort v1_0_1 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_0_1_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_2/EfiNetworkPortV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_2/EfiNetworkPortV1_0_2.h new file mode 100644 index 00000000000..12ef158f04b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_2/EfiNetworkPortV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_0_2_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_0_2/Redfish_NetworkPort_v1_0_2_CS.h" +// +// EFI structure of Redfish NetworkPort v1_0_2 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_0_2_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_3/EfiNetworkPortV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_3/EfiNetworkPortV1_0_3.h new file mode 100644 index 00000000000..3d897783ff1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_3/EfiNetworkPortV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_0_3_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_0_3/Redfish_NetworkPort_v1_0_3_CS.h" +// +// EFI structure of Redfish NetworkPort v1_0_3 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_0_3_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_4/EfiNetworkPortV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_4/EfiNetworkPortV1_0_4.h new file mode 100644 index 00000000000..a58d2d222dd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_4/EfiNetworkPortV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_0_4_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_0_4/Redfish_NetworkPort_v1_0_4_CS.h" +// +// EFI structure of Redfish NetworkPort v1_0_4 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_0_4_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_5/EfiNetworkPortV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_5/EfiNetworkPortV1_0_5.h new file mode 100644 index 00000000000..42e28459775 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_5/EfiNetworkPortV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_0_5_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_0_5/Redfish_NetworkPort_v1_0_5_CS.h" +// +// EFI structure of Redfish NetworkPort v1_0_5 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_0_5_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_6/EfiNetworkPortV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_6/EfiNetworkPortV1_0_6.h new file mode 100644 index 00000000000..121bff08083 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_6/EfiNetworkPortV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_0_6_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_0_6/Redfish_NetworkPort_v1_0_6_CS.h" +// +// EFI structure of Redfish NetworkPort v1_0_6 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_0_6_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_7/EfiNetworkPortV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_7/EfiNetworkPortV1_0_7.h new file mode 100644 index 00000000000..ec9308be4ba --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_7/EfiNetworkPortV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_0_7_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_0_7/Redfish_NetworkPort_v1_0_7_CS.h" +// +// EFI structure of Redfish NetworkPort v1_0_7 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_0_7_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_8/EfiNetworkPortV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_8/EfiNetworkPortV1_0_8.h new file mode 100644 index 00000000000..7554c93c530 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_0_8/EfiNetworkPortV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_0_8_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_0_8/Redfish_NetworkPort_v1_0_8_CS.h" +// +// EFI structure of Redfish NetworkPort v1_0_8 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_0_8_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_0/EfiNetworkPortV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_0/EfiNetworkPortV1_1_0.h new file mode 100644 index 00000000000..21c1487bf7a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_0/EfiNetworkPortV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_1_0_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_1_0/Redfish_NetworkPort_v1_1_0_CS.h" +// +// EFI structure of Redfish NetworkPort v1_1_0 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_1_0_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_1/EfiNetworkPortV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_1/EfiNetworkPortV1_1_1.h new file mode 100644 index 00000000000..fb98de49bd2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_1/EfiNetworkPortV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_1_1_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_1_1/Redfish_NetworkPort_v1_1_1_CS.h" +// +// EFI structure of Redfish NetworkPort v1_1_1 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_1_1_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_2/EfiNetworkPortV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_2/EfiNetworkPortV1_1_2.h new file mode 100644 index 00000000000..b6cc48ade97 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_2/EfiNetworkPortV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_1_2_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_1_2/Redfish_NetworkPort_v1_1_2_CS.h" +// +// EFI structure of Redfish NetworkPort v1_1_2 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_1_2_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_3/EfiNetworkPortV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_3/EfiNetworkPortV1_1_3.h new file mode 100644 index 00000000000..8af0892a396 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_3/EfiNetworkPortV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_1_3_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_1_3/Redfish_NetworkPort_v1_1_3_CS.h" +// +// EFI structure of Redfish NetworkPort v1_1_3 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_1_3_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_4/EfiNetworkPortV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_4/EfiNetworkPortV1_1_4.h new file mode 100644 index 00000000000..6de56bd151e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_4/EfiNetworkPortV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_1_4_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_1_4/Redfish_NetworkPort_v1_1_4_CS.h" +// +// EFI structure of Redfish NetworkPort v1_1_4 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_1_4_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_5/EfiNetworkPortV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_5/EfiNetworkPortV1_1_5.h new file mode 100644 index 00000000000..6e694cd9e1c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_5/EfiNetworkPortV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_1_5_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_1_5/Redfish_NetworkPort_v1_1_5_CS.h" +// +// EFI structure of Redfish NetworkPort v1_1_5 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_1_5_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_6/EfiNetworkPortV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_6/EfiNetworkPortV1_1_6.h new file mode 100644 index 00000000000..b054b901102 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_6/EfiNetworkPortV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_1_6_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_1_6/Redfish_NetworkPort_v1_1_6_CS.h" +// +// EFI structure of Redfish NetworkPort v1_1_6 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_1_6_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_7/EfiNetworkPortV1_1_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_7/EfiNetworkPortV1_1_7.h new file mode 100644 index 00000000000..84502232837 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_1_7/EfiNetworkPortV1_1_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_1_7_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_1_7_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_1_7/Redfish_NetworkPort_v1_1_7_CS.h" +// +// EFI structure of Redfish NetworkPort v1_1_7 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_1_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_1_7_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_1_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_0/EfiNetworkPortV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_0/EfiNetworkPortV1_2_0.h new file mode 100644 index 00000000000..1cf31daef65 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_0/EfiNetworkPortV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_2_0_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_2_0/Redfish_NetworkPort_v1_2_0_CS.h" +// +// EFI structure of Redfish NetworkPort v1_2_0 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_2_0_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_1/EfiNetworkPortV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_1/EfiNetworkPortV1_2_1.h new file mode 100644 index 00000000000..8ee7e50e4c0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_1/EfiNetworkPortV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_2_1_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_2_1/Redfish_NetworkPort_v1_2_1_CS.h" +// +// EFI structure of Redfish NetworkPort v1_2_1 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_2_1_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_2/EfiNetworkPortV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_2/EfiNetworkPortV1_2_2.h new file mode 100644 index 00000000000..60a10c31df8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_2/EfiNetworkPortV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_2_2_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_2_2/Redfish_NetworkPort_v1_2_2_CS.h" +// +// EFI structure of Redfish NetworkPort v1_2_2 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_2_2_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_3/EfiNetworkPortV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_3/EfiNetworkPortV1_2_3.h new file mode 100644 index 00000000000..ebb7a9d73c9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_3/EfiNetworkPortV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_2_3_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_2_3/Redfish_NetworkPort_v1_2_3_CS.h" +// +// EFI structure of Redfish NetworkPort v1_2_3 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_2_3_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_4/EfiNetworkPortV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_4/EfiNetworkPortV1_2_4.h new file mode 100644 index 00000000000..0587fc1231e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_4/EfiNetworkPortV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_2_4_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_2_4/Redfish_NetworkPort_v1_2_4_CS.h" +// +// EFI structure of Redfish NetworkPort v1_2_4 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_2_4_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_5/EfiNetworkPortV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_5/EfiNetworkPortV1_2_5.h new file mode 100644 index 00000000000..c49420ff479 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_5/EfiNetworkPortV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_2_5_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_2_5/Redfish_NetworkPort_v1_2_5_CS.h" +// +// EFI structure of Redfish NetworkPort v1_2_5 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_2_5_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_6/EfiNetworkPortV1_2_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_6/EfiNetworkPortV1_2_6.h new file mode 100644 index 00000000000..e9e674ca9b6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_2_6/EfiNetworkPortV1_2_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_2_6_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_2_6_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_2_6/Redfish_NetworkPort_v1_2_6_CS.h" +// +// EFI structure of Redfish NetworkPort v1_2_6 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_2_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_2_6_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_2_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_3_0/EfiNetworkPortV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_3_0/EfiNetworkPortV1_3_0.h new file mode 100644 index 00000000000..04602a94720 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_3_0/EfiNetworkPortV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_3_0_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_3_0/Redfish_NetworkPort_v1_3_0_CS.h" +// +// EFI structure of Redfish NetworkPort v1_3_0 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_3_0_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_3_1/EfiNetworkPortV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_3_1/EfiNetworkPortV1_3_1.h new file mode 100644 index 00000000000..cef62fa1643 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_3_1/EfiNetworkPortV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_3_1_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_3_1/Redfish_NetworkPort_v1_3_1_CS.h" +// +// EFI structure of Redfish NetworkPort v1_3_1 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_3_1_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_4_0/EfiNetworkPortV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_4_0/EfiNetworkPortV1_4_0.h new file mode 100644 index 00000000000..48513b2bb2e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPort/v1_4_0/EfiNetworkPortV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPort v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORT_V1_4_0_H__ +#define EFI_REDFISH_INTERP_NETWORKPORT_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPort/v1_4_0/Redfish_NetworkPort_v1_4_0_CS.h" +// +// EFI structure of Redfish NetworkPort v1_4_0 +// +typedef struct _EFI_REDFISH_NETWORKPORT_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORT_V1_4_0_CS *NetworkPort; +} EFI_REDFISH_NETWORKPORT_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPortCollection/EfiNetworkPortCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPortCollection/EfiNetworkPortCollection.h new file mode 100644 index 00000000000..eb3fb37d54e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/NetworkPortCollection/EfiNetworkPortCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for NetworkPortCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_NETWORKPORTCOLLECTION_H__ +#define EFI_REDFISH_INTERP_NETWORKPORTCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/NetworkPortCollection/Redfish_NetworkPortCollection_CS.h" +// +// EFI structure of Redfish NetworkPortCollection +// +typedef struct _EFI_REDFISH_NETWORKPORTCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_NETWORKPORTCOLLECTION_CS *NetworkPortCollection; +} EFI_REDFISH_NETWORKPORTCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/OperatingConfig/v1_0_0/EfiOperatingConfigV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/OperatingConfig/v1_0_0/EfiOperatingConfigV1_0_0.h new file mode 100644 index 00000000000..680fc7f5b14 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/OperatingConfig/v1_0_0/EfiOperatingConfigV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for OperatingConfig v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_OPERATINGCONFIG_V1_0_0_H__ +#define EFI_REDFISH_INTERP_OPERATINGCONFIG_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/OperatingConfig/v1_0_0/Redfish_OperatingConfig_v1_0_0_CS.h" +// +// EFI structure of Redfish OperatingConfig v1_0_0 +// +typedef struct _EFI_REDFISH_OPERATINGCONFIG_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_OPERATINGCONFIG_V1_0_0_CS *OperatingConfig; +} EFI_REDFISH_OPERATINGCONFIG_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/OperatingConfig/v1_0_1/EfiOperatingConfigV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/OperatingConfig/v1_0_1/EfiOperatingConfigV1_0_1.h new file mode 100644 index 00000000000..976e9171746 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/OperatingConfig/v1_0_1/EfiOperatingConfigV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for OperatingConfig v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_OPERATINGCONFIG_V1_0_1_H__ +#define EFI_REDFISH_INTERP_OPERATINGCONFIG_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/OperatingConfig/v1_0_1/Redfish_OperatingConfig_v1_0_1_CS.h" +// +// EFI structure of Redfish OperatingConfig v1_0_1 +// +typedef struct _EFI_REDFISH_OPERATINGCONFIG_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_OPERATINGCONFIG_V1_0_1_CS *OperatingConfig; +} EFI_REDFISH_OPERATINGCONFIG_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/OperatingConfig/v1_0_2/EfiOperatingConfigV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/OperatingConfig/v1_0_2/EfiOperatingConfigV1_0_2.h new file mode 100644 index 00000000000..97d9bb78453 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/OperatingConfig/v1_0_2/EfiOperatingConfigV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for OperatingConfig v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_OPERATINGCONFIG_V1_0_2_H__ +#define EFI_REDFISH_INTERP_OPERATINGCONFIG_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/OperatingConfig/v1_0_2/Redfish_OperatingConfig_v1_0_2_CS.h" +// +// EFI structure of Redfish OperatingConfig v1_0_2 +// +typedef struct _EFI_REDFISH_OPERATINGCONFIG_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_OPERATINGCONFIG_V1_0_2_CS *OperatingConfig; +} EFI_REDFISH_OPERATINGCONFIG_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/OperatingConfigCollection/EfiOperatingConfigCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/OperatingConfigCollection/EfiOperatingConfigCollection.h new file mode 100644 index 00000000000..16cb8c404fd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/OperatingConfigCollection/EfiOperatingConfigCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for OperatingConfigCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_OPERATINGCONFIGCOLLECTION_H__ +#define EFI_REDFISH_INTERP_OPERATINGCONFIGCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/OperatingConfigCollection/Redfish_OperatingConfigCollection_CS.h" +// +// EFI structure of Redfish OperatingConfigCollection +// +typedef struct _EFI_REDFISH_OPERATINGCONFIGCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_OPERATINGCONFIGCOLLECTION_CS *OperatingConfigCollection; +} EFI_REDFISH_OPERATINGCONFIGCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Outlet/v1_0_0/EfiOutletV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Outlet/v1_0_0/EfiOutletV1_0_0.h new file mode 100644 index 00000000000..41f380913a9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Outlet/v1_0_0/EfiOutletV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Outlet v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_OUTLET_V1_0_0_H__ +#define EFI_REDFISH_INTERP_OUTLET_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Outlet/v1_0_0/Redfish_Outlet_v1_0_0_CS.h" +// +// EFI structure of Redfish Outlet v1_0_0 +// +typedef struct _EFI_REDFISH_OUTLET_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_OUTLET_V1_0_0_CS *Outlet; +} EFI_REDFISH_OUTLET_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Outlet/v1_0_1/EfiOutletV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Outlet/v1_0_1/EfiOutletV1_0_1.h new file mode 100644 index 00000000000..44aff3727d6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Outlet/v1_0_1/EfiOutletV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Outlet v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_OUTLET_V1_0_1_H__ +#define EFI_REDFISH_INTERP_OUTLET_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Outlet/v1_0_1/Redfish_Outlet_v1_0_1_CS.h" +// +// EFI structure of Redfish Outlet v1_0_1 +// +typedef struct _EFI_REDFISH_OUTLET_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_OUTLET_V1_0_1_CS *Outlet; +} EFI_REDFISH_OUTLET_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Outlet/v1_0_2/EfiOutletV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Outlet/v1_0_2/EfiOutletV1_0_2.h new file mode 100644 index 00000000000..d0034cbfa68 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Outlet/v1_0_2/EfiOutletV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Outlet v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_OUTLET_V1_0_2_H__ +#define EFI_REDFISH_INTERP_OUTLET_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Outlet/v1_0_2/Redfish_Outlet_v1_0_2_CS.h" +// +// EFI structure of Redfish Outlet v1_0_2 +// +typedef struct _EFI_REDFISH_OUTLET_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_OUTLET_V1_0_2_CS *Outlet; +} EFI_REDFISH_OUTLET_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Outlet/v1_1_0/EfiOutletV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Outlet/v1_1_0/EfiOutletV1_1_0.h new file mode 100644 index 00000000000..9923b3b2f3a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Outlet/v1_1_0/EfiOutletV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Outlet v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_OUTLET_V1_1_0_H__ +#define EFI_REDFISH_INTERP_OUTLET_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Outlet/v1_1_0/Redfish_Outlet_v1_1_0_CS.h" +// +// EFI structure of Redfish Outlet v1_1_0 +// +typedef struct _EFI_REDFISH_OUTLET_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_OUTLET_V1_1_0_CS *Outlet; +} EFI_REDFISH_OUTLET_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Outlet/v1_1_1/EfiOutletV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Outlet/v1_1_1/EfiOutletV1_1_1.h new file mode 100644 index 00000000000..2451de09235 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Outlet/v1_1_1/EfiOutletV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Outlet v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_OUTLET_V1_1_1_H__ +#define EFI_REDFISH_INTERP_OUTLET_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Outlet/v1_1_1/Redfish_Outlet_v1_1_1_CS.h" +// +// EFI structure of Redfish Outlet v1_1_1 +// +typedef struct _EFI_REDFISH_OUTLET_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_OUTLET_V1_1_1_CS *Outlet; +} EFI_REDFISH_OUTLET_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/OutletCollection/EfiOutletCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/OutletCollection/EfiOutletCollection.h new file mode 100644 index 00000000000..480cf3b9d24 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/OutletCollection/EfiOutletCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for OutletCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_OUTLETCOLLECTION_H__ +#define EFI_REDFISH_INTERP_OUTLETCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/OutletCollection/Redfish_OutletCollection_CS.h" +// +// EFI structure of Redfish OutletCollection +// +typedef struct _EFI_REDFISH_OUTLETCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_OUTLETCOLLECTION_CS *OutletCollection; +} EFI_REDFISH_OUTLETCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/OutletGroup/v1_0_0/EfiOutletGroupV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/OutletGroup/v1_0_0/EfiOutletGroupV1_0_0.h new file mode 100644 index 00000000000..a8c6de43e8b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/OutletGroup/v1_0_0/EfiOutletGroupV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for OutletGroup v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_OUTLETGROUP_V1_0_0_H__ +#define EFI_REDFISH_INTERP_OUTLETGROUP_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/OutletGroup/v1_0_0/Redfish_OutletGroup_v1_0_0_CS.h" +// +// EFI structure of Redfish OutletGroup v1_0_0 +// +typedef struct _EFI_REDFISH_OUTLETGROUP_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_OUTLETGROUP_V1_0_0_CS *OutletGroup; +} EFI_REDFISH_OUTLETGROUP_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/OutletGroup/v1_0_1/EfiOutletGroupV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/OutletGroup/v1_0_1/EfiOutletGroupV1_0_1.h new file mode 100644 index 00000000000..5b35a0493cb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/OutletGroup/v1_0_1/EfiOutletGroupV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for OutletGroup v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_OUTLETGROUP_V1_0_1_H__ +#define EFI_REDFISH_INTERP_OUTLETGROUP_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/OutletGroup/v1_0_1/Redfish_OutletGroup_v1_0_1_CS.h" +// +// EFI structure of Redfish OutletGroup v1_0_1 +// +typedef struct _EFI_REDFISH_OUTLETGROUP_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_OUTLETGROUP_V1_0_1_CS *OutletGroup; +} EFI_REDFISH_OUTLETGROUP_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/OutletGroupCollection/EfiOutletGroupCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/OutletGroupCollection/EfiOutletGroupCollection.h new file mode 100644 index 00000000000..44a4cf23630 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/OutletGroupCollection/EfiOutletGroupCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for OutletGroupCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_OUTLETGROUPCOLLECTION_H__ +#define EFI_REDFISH_INTERP_OUTLETGROUPCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/OutletGroupCollection/Redfish_OutletGroupCollection_CS.h" +// +// EFI structure of Redfish OutletGroupCollection +// +typedef struct _EFI_REDFISH_OUTLETGROUPCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_OUTLETGROUPCOLLECTION_CS *OutletGroupCollection; +} EFI_REDFISH_OUTLETGROUPCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_0_0/EfiPCIeDeviceV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_0_0/EfiPCIeDeviceV1_0_0.h new file mode 100644 index 00000000000..a61e8c71104 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_0_0/EfiPCIeDeviceV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeDevice v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEDEVICE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_PCIEDEVICE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeDevice/v1_0_0/Redfish_PCIeDevice_v1_0_0_CS.h" +// +// EFI structure of Redfish PCIeDevice v1_0_0 +// +typedef struct _EFI_REDFISH_PCIEDEVICE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEDEVICE_V1_0_0_CS *PCIeDevice; +} EFI_REDFISH_PCIEDEVICE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_0_1/EfiPCIeDeviceV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_0_1/EfiPCIeDeviceV1_0_1.h new file mode 100644 index 00000000000..8cb97184cd7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_0_1/EfiPCIeDeviceV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeDevice v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEDEVICE_V1_0_1_H__ +#define EFI_REDFISH_INTERP_PCIEDEVICE_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeDevice/v1_0_1/Redfish_PCIeDevice_v1_0_1_CS.h" +// +// EFI structure of Redfish PCIeDevice v1_0_1 +// +typedef struct _EFI_REDFISH_PCIEDEVICE_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEDEVICE_V1_0_1_CS *PCIeDevice; +} EFI_REDFISH_PCIEDEVICE_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_0_2/EfiPCIeDeviceV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_0_2/EfiPCIeDeviceV1_0_2.h new file mode 100644 index 00000000000..21105926391 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_0_2/EfiPCIeDeviceV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeDevice v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEDEVICE_V1_0_2_H__ +#define EFI_REDFISH_INTERP_PCIEDEVICE_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeDevice/v1_0_2/Redfish_PCIeDevice_v1_0_2_CS.h" +// +// EFI structure of Redfish PCIeDevice v1_0_2 +// +typedef struct _EFI_REDFISH_PCIEDEVICE_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEDEVICE_V1_0_2_CS *PCIeDevice; +} EFI_REDFISH_PCIEDEVICE_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_0_3/EfiPCIeDeviceV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_0_3/EfiPCIeDeviceV1_0_3.h new file mode 100644 index 00000000000..d47944b15ea --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_0_3/EfiPCIeDeviceV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeDevice v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEDEVICE_V1_0_3_H__ +#define EFI_REDFISH_INTERP_PCIEDEVICE_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeDevice/v1_0_3/Redfish_PCIeDevice_v1_0_3_CS.h" +// +// EFI structure of Redfish PCIeDevice v1_0_3 +// +typedef struct _EFI_REDFISH_PCIEDEVICE_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEDEVICE_V1_0_3_CS *PCIeDevice; +} EFI_REDFISH_PCIEDEVICE_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_0_4/EfiPCIeDeviceV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_0_4/EfiPCIeDeviceV1_0_4.h new file mode 100644 index 00000000000..c3e529dc67e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_0_4/EfiPCIeDeviceV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeDevice v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEDEVICE_V1_0_4_H__ +#define EFI_REDFISH_INTERP_PCIEDEVICE_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeDevice/v1_0_4/Redfish_PCIeDevice_v1_0_4_CS.h" +// +// EFI structure of Redfish PCIeDevice v1_0_4 +// +typedef struct _EFI_REDFISH_PCIEDEVICE_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEDEVICE_V1_0_4_CS *PCIeDevice; +} EFI_REDFISH_PCIEDEVICE_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_0_5/EfiPCIeDeviceV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_0_5/EfiPCIeDeviceV1_0_5.h new file mode 100644 index 00000000000..3cd83dff6e4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_0_5/EfiPCIeDeviceV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeDevice v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEDEVICE_V1_0_5_H__ +#define EFI_REDFISH_INTERP_PCIEDEVICE_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeDevice/v1_0_5/Redfish_PCIeDevice_v1_0_5_CS.h" +// +// EFI structure of Redfish PCIeDevice v1_0_5 +// +typedef struct _EFI_REDFISH_PCIEDEVICE_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEDEVICE_V1_0_5_CS *PCIeDevice; +} EFI_REDFISH_PCIEDEVICE_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_1_0/EfiPCIeDeviceV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_1_0/EfiPCIeDeviceV1_1_0.h new file mode 100644 index 00000000000..dbf922088d5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_1_0/EfiPCIeDeviceV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeDevice v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEDEVICE_V1_1_0_H__ +#define EFI_REDFISH_INTERP_PCIEDEVICE_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeDevice/v1_1_0/Redfish_PCIeDevice_v1_1_0_CS.h" +// +// EFI structure of Redfish PCIeDevice v1_1_0 +// +typedef struct _EFI_REDFISH_PCIEDEVICE_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEDEVICE_V1_1_0_CS *PCIeDevice; +} EFI_REDFISH_PCIEDEVICE_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_1_1/EfiPCIeDeviceV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_1_1/EfiPCIeDeviceV1_1_1.h new file mode 100644 index 00000000000..f978c7fc730 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_1_1/EfiPCIeDeviceV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeDevice v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEDEVICE_V1_1_1_H__ +#define EFI_REDFISH_INTERP_PCIEDEVICE_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeDevice/v1_1_1/Redfish_PCIeDevice_v1_1_1_CS.h" +// +// EFI structure of Redfish PCIeDevice v1_1_1 +// +typedef struct _EFI_REDFISH_PCIEDEVICE_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEDEVICE_V1_1_1_CS *PCIeDevice; +} EFI_REDFISH_PCIEDEVICE_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_1_2/EfiPCIeDeviceV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_1_2/EfiPCIeDeviceV1_1_2.h new file mode 100644 index 00000000000..6d914bb9cda --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_1_2/EfiPCIeDeviceV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeDevice v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEDEVICE_V1_1_2_H__ +#define EFI_REDFISH_INTERP_PCIEDEVICE_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeDevice/v1_1_2/Redfish_PCIeDevice_v1_1_2_CS.h" +// +// EFI structure of Redfish PCIeDevice v1_1_2 +// +typedef struct _EFI_REDFISH_PCIEDEVICE_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEDEVICE_V1_1_2_CS *PCIeDevice; +} EFI_REDFISH_PCIEDEVICE_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_1_3/EfiPCIeDeviceV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_1_3/EfiPCIeDeviceV1_1_3.h new file mode 100644 index 00000000000..01829f07ff0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_1_3/EfiPCIeDeviceV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeDevice v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEDEVICE_V1_1_3_H__ +#define EFI_REDFISH_INTERP_PCIEDEVICE_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeDevice/v1_1_3/Redfish_PCIeDevice_v1_1_3_CS.h" +// +// EFI structure of Redfish PCIeDevice v1_1_3 +// +typedef struct _EFI_REDFISH_PCIEDEVICE_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEDEVICE_V1_1_3_CS *PCIeDevice; +} EFI_REDFISH_PCIEDEVICE_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_2_0/EfiPCIeDeviceV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_2_0/EfiPCIeDeviceV1_2_0.h new file mode 100644 index 00000000000..330103fb23b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_2_0/EfiPCIeDeviceV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeDevice v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEDEVICE_V1_2_0_H__ +#define EFI_REDFISH_INTERP_PCIEDEVICE_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeDevice/v1_2_0/Redfish_PCIeDevice_v1_2_0_CS.h" +// +// EFI structure of Redfish PCIeDevice v1_2_0 +// +typedef struct _EFI_REDFISH_PCIEDEVICE_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEDEVICE_V1_2_0_CS *PCIeDevice; +} EFI_REDFISH_PCIEDEVICE_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_2_1/EfiPCIeDeviceV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_2_1/EfiPCIeDeviceV1_2_1.h new file mode 100644 index 00000000000..a292bd06c9e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_2_1/EfiPCIeDeviceV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeDevice v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEDEVICE_V1_2_1_H__ +#define EFI_REDFISH_INTERP_PCIEDEVICE_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeDevice/v1_2_1/Redfish_PCIeDevice_v1_2_1_CS.h" +// +// EFI structure of Redfish PCIeDevice v1_2_1 +// +typedef struct _EFI_REDFISH_PCIEDEVICE_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEDEVICE_V1_2_1_CS *PCIeDevice; +} EFI_REDFISH_PCIEDEVICE_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_2_2/EfiPCIeDeviceV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_2_2/EfiPCIeDeviceV1_2_2.h new file mode 100644 index 00000000000..df09454b410 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_2_2/EfiPCIeDeviceV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeDevice v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEDEVICE_V1_2_2_H__ +#define EFI_REDFISH_INTERP_PCIEDEVICE_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeDevice/v1_2_2/Redfish_PCIeDevice_v1_2_2_CS.h" +// +// EFI structure of Redfish PCIeDevice v1_2_2 +// +typedef struct _EFI_REDFISH_PCIEDEVICE_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEDEVICE_V1_2_2_CS *PCIeDevice; +} EFI_REDFISH_PCIEDEVICE_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_2_3/EfiPCIeDeviceV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_2_3/EfiPCIeDeviceV1_2_3.h new file mode 100644 index 00000000000..2ac962a9723 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_2_3/EfiPCIeDeviceV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeDevice v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEDEVICE_V1_2_3_H__ +#define EFI_REDFISH_INTERP_PCIEDEVICE_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeDevice/v1_2_3/Redfish_PCIeDevice_v1_2_3_CS.h" +// +// EFI structure of Redfish PCIeDevice v1_2_3 +// +typedef struct _EFI_REDFISH_PCIEDEVICE_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEDEVICE_V1_2_3_CS *PCIeDevice; +} EFI_REDFISH_PCIEDEVICE_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_3_0/EfiPCIeDeviceV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_3_0/EfiPCIeDeviceV1_3_0.h new file mode 100644 index 00000000000..4321320072d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_3_0/EfiPCIeDeviceV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeDevice v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEDEVICE_V1_3_0_H__ +#define EFI_REDFISH_INTERP_PCIEDEVICE_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeDevice/v1_3_0/Redfish_PCIeDevice_v1_3_0_CS.h" +// +// EFI structure of Redfish PCIeDevice v1_3_0 +// +typedef struct _EFI_REDFISH_PCIEDEVICE_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEDEVICE_V1_3_0_CS *PCIeDevice; +} EFI_REDFISH_PCIEDEVICE_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_3_1/EfiPCIeDeviceV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_3_1/EfiPCIeDeviceV1_3_1.h new file mode 100644 index 00000000000..95059a669f8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_3_1/EfiPCIeDeviceV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeDevice v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEDEVICE_V1_3_1_H__ +#define EFI_REDFISH_INTERP_PCIEDEVICE_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeDevice/v1_3_1/Redfish_PCIeDevice_v1_3_1_CS.h" +// +// EFI structure of Redfish PCIeDevice v1_3_1 +// +typedef struct _EFI_REDFISH_PCIEDEVICE_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEDEVICE_V1_3_1_CS *PCIeDevice; +} EFI_REDFISH_PCIEDEVICE_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_3_2/EfiPCIeDeviceV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_3_2/EfiPCIeDeviceV1_3_2.h new file mode 100644 index 00000000000..918e9480bc5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_3_2/EfiPCIeDeviceV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeDevice v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEDEVICE_V1_3_2_H__ +#define EFI_REDFISH_INTERP_PCIEDEVICE_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeDevice/v1_3_2/Redfish_PCIeDevice_v1_3_2_CS.h" +// +// EFI structure of Redfish PCIeDevice v1_3_2 +// +typedef struct _EFI_REDFISH_PCIEDEVICE_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEDEVICE_V1_3_2_CS *PCIeDevice; +} EFI_REDFISH_PCIEDEVICE_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_4_0/EfiPCIeDeviceV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_4_0/EfiPCIeDeviceV1_4_0.h new file mode 100644 index 00000000000..7da216aa2de --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_4_0/EfiPCIeDeviceV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeDevice v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEDEVICE_V1_4_0_H__ +#define EFI_REDFISH_INTERP_PCIEDEVICE_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeDevice/v1_4_0/Redfish_PCIeDevice_v1_4_0_CS.h" +// +// EFI structure of Redfish PCIeDevice v1_4_0 +// +typedef struct _EFI_REDFISH_PCIEDEVICE_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEDEVICE_V1_4_0_CS *PCIeDevice; +} EFI_REDFISH_PCIEDEVICE_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_5_0/EfiPCIeDeviceV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_5_0/EfiPCIeDeviceV1_5_0.h new file mode 100644 index 00000000000..aaa37e1ab49 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_5_0/EfiPCIeDeviceV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeDevice v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEDEVICE_V1_5_0_H__ +#define EFI_REDFISH_INTERP_PCIEDEVICE_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeDevice/v1_5_0/Redfish_PCIeDevice_v1_5_0_CS.h" +// +// EFI structure of Redfish PCIeDevice v1_5_0 +// +typedef struct _EFI_REDFISH_PCIEDEVICE_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEDEVICE_V1_5_0_CS *PCIeDevice; +} EFI_REDFISH_PCIEDEVICE_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_6_0/EfiPCIeDeviceV1_6_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_6_0/EfiPCIeDeviceV1_6_0.h new file mode 100644 index 00000000000..5a1aa695e6f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDevice/v1_6_0/EfiPCIeDeviceV1_6_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeDevice v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEDEVICE_V1_6_0_H__ +#define EFI_REDFISH_INTERP_PCIEDEVICE_V1_6_0_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeDevice/v1_6_0/Redfish_PCIeDevice_v1_6_0_CS.h" +// +// EFI structure of Redfish PCIeDevice v1_6_0 +// +typedef struct _EFI_REDFISH_PCIEDEVICE_V1_6_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEDEVICE_V1_6_0_CS *PCIeDevice; +} EFI_REDFISH_PCIEDEVICE_V1_6_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDeviceCollection/EfiPCIeDeviceCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDeviceCollection/EfiPCIeDeviceCollection.h new file mode 100644 index 00000000000..60be9c00e43 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeDeviceCollection/EfiPCIeDeviceCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeDeviceCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEDEVICECOLLECTION_H__ +#define EFI_REDFISH_INTERP_PCIEDEVICECOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeDeviceCollection/Redfish_PCIeDeviceCollection_CS.h" +// +// EFI structure of Redfish PCIeDeviceCollection +// +typedef struct _EFI_REDFISH_PCIEDEVICECOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEDEVICECOLLECTION_CS *PCIeDeviceCollection; +} EFI_REDFISH_PCIEDEVICECOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_0/EfiPCIeFunctionV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_0/EfiPCIeFunctionV1_0_0.h new file mode 100644 index 00000000000..55d5f02bf67 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_0/EfiPCIeFunctionV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeFunction v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEFUNCTION_V1_0_0_H__ +#define EFI_REDFISH_INTERP_PCIEFUNCTION_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeFunction/v1_0_0/Redfish_PCIeFunction_v1_0_0_CS.h" +// +// EFI structure of Redfish PCIeFunction v1_0_0 +// +typedef struct _EFI_REDFISH_PCIEFUNCTION_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEFUNCTION_V1_0_0_CS *PCIeFunction; +} EFI_REDFISH_PCIEFUNCTION_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_1/EfiPCIeFunctionV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_1/EfiPCIeFunctionV1_0_1.h new file mode 100644 index 00000000000..023c7780c73 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_1/EfiPCIeFunctionV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeFunction v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEFUNCTION_V1_0_1_H__ +#define EFI_REDFISH_INTERP_PCIEFUNCTION_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeFunction/v1_0_1/Redfish_PCIeFunction_v1_0_1_CS.h" +// +// EFI structure of Redfish PCIeFunction v1_0_1 +// +typedef struct _EFI_REDFISH_PCIEFUNCTION_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEFUNCTION_V1_0_1_CS *PCIeFunction; +} EFI_REDFISH_PCIEFUNCTION_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_2/EfiPCIeFunctionV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_2/EfiPCIeFunctionV1_0_2.h new file mode 100644 index 00000000000..7dac8608812 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_2/EfiPCIeFunctionV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeFunction v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEFUNCTION_V1_0_2_H__ +#define EFI_REDFISH_INTERP_PCIEFUNCTION_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeFunction/v1_0_2/Redfish_PCIeFunction_v1_0_2_CS.h" +// +// EFI structure of Redfish PCIeFunction v1_0_2 +// +typedef struct _EFI_REDFISH_PCIEFUNCTION_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEFUNCTION_V1_0_2_CS *PCIeFunction; +} EFI_REDFISH_PCIEFUNCTION_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_3/EfiPCIeFunctionV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_3/EfiPCIeFunctionV1_0_3.h new file mode 100644 index 00000000000..e0f0f52f326 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_3/EfiPCIeFunctionV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeFunction v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEFUNCTION_V1_0_3_H__ +#define EFI_REDFISH_INTERP_PCIEFUNCTION_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeFunction/v1_0_3/Redfish_PCIeFunction_v1_0_3_CS.h" +// +// EFI structure of Redfish PCIeFunction v1_0_3 +// +typedef struct _EFI_REDFISH_PCIEFUNCTION_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEFUNCTION_V1_0_3_CS *PCIeFunction; +} EFI_REDFISH_PCIEFUNCTION_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_4/EfiPCIeFunctionV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_4/EfiPCIeFunctionV1_0_4.h new file mode 100644 index 00000000000..88717bf7836 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_4/EfiPCIeFunctionV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeFunction v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEFUNCTION_V1_0_4_H__ +#define EFI_REDFISH_INTERP_PCIEFUNCTION_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeFunction/v1_0_4/Redfish_PCIeFunction_v1_0_4_CS.h" +// +// EFI structure of Redfish PCIeFunction v1_0_4 +// +typedef struct _EFI_REDFISH_PCIEFUNCTION_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEFUNCTION_V1_0_4_CS *PCIeFunction; +} EFI_REDFISH_PCIEFUNCTION_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_5/EfiPCIeFunctionV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_5/EfiPCIeFunctionV1_0_5.h new file mode 100644 index 00000000000..5d45051e973 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_5/EfiPCIeFunctionV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeFunction v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEFUNCTION_V1_0_5_H__ +#define EFI_REDFISH_INTERP_PCIEFUNCTION_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeFunction/v1_0_5/Redfish_PCIeFunction_v1_0_5_CS.h" +// +// EFI structure of Redfish PCIeFunction v1_0_5 +// +typedef struct _EFI_REDFISH_PCIEFUNCTION_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEFUNCTION_V1_0_5_CS *PCIeFunction; +} EFI_REDFISH_PCIEFUNCTION_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_6/EfiPCIeFunctionV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_6/EfiPCIeFunctionV1_0_6.h new file mode 100644 index 00000000000..5a6e84f9229 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_0_6/EfiPCIeFunctionV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeFunction v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEFUNCTION_V1_0_6_H__ +#define EFI_REDFISH_INTERP_PCIEFUNCTION_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeFunction/v1_0_6/Redfish_PCIeFunction_v1_0_6_CS.h" +// +// EFI structure of Redfish PCIeFunction v1_0_6 +// +typedef struct _EFI_REDFISH_PCIEFUNCTION_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEFUNCTION_V1_0_6_CS *PCIeFunction; +} EFI_REDFISH_PCIEFUNCTION_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_1_0/EfiPCIeFunctionV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_1_0/EfiPCIeFunctionV1_1_0.h new file mode 100644 index 00000000000..4faa25fbac4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_1_0/EfiPCIeFunctionV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeFunction v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEFUNCTION_V1_1_0_H__ +#define EFI_REDFISH_INTERP_PCIEFUNCTION_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeFunction/v1_1_0/Redfish_PCIeFunction_v1_1_0_CS.h" +// +// EFI structure of Redfish PCIeFunction v1_1_0 +// +typedef struct _EFI_REDFISH_PCIEFUNCTION_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEFUNCTION_V1_1_0_CS *PCIeFunction; +} EFI_REDFISH_PCIEFUNCTION_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_1_1/EfiPCIeFunctionV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_1_1/EfiPCIeFunctionV1_1_1.h new file mode 100644 index 00000000000..dcc6971ebed --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_1_1/EfiPCIeFunctionV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeFunction v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEFUNCTION_V1_1_1_H__ +#define EFI_REDFISH_INTERP_PCIEFUNCTION_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeFunction/v1_1_1/Redfish_PCIeFunction_v1_1_1_CS.h" +// +// EFI structure of Redfish PCIeFunction v1_1_1 +// +typedef struct _EFI_REDFISH_PCIEFUNCTION_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEFUNCTION_V1_1_1_CS *PCIeFunction; +} EFI_REDFISH_PCIEFUNCTION_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_1_2/EfiPCIeFunctionV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_1_2/EfiPCIeFunctionV1_1_2.h new file mode 100644 index 00000000000..a2901528f24 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_1_2/EfiPCIeFunctionV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeFunction v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEFUNCTION_V1_1_2_H__ +#define EFI_REDFISH_INTERP_PCIEFUNCTION_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeFunction/v1_1_2/Redfish_PCIeFunction_v1_1_2_CS.h" +// +// EFI structure of Redfish PCIeFunction v1_1_2 +// +typedef struct _EFI_REDFISH_PCIEFUNCTION_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEFUNCTION_V1_1_2_CS *PCIeFunction; +} EFI_REDFISH_PCIEFUNCTION_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_1_3/EfiPCIeFunctionV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_1_3/EfiPCIeFunctionV1_1_3.h new file mode 100644 index 00000000000..b7cbb932398 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_1_3/EfiPCIeFunctionV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeFunction v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEFUNCTION_V1_1_3_H__ +#define EFI_REDFISH_INTERP_PCIEFUNCTION_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeFunction/v1_1_3/Redfish_PCIeFunction_v1_1_3_CS.h" +// +// EFI structure of Redfish PCIeFunction v1_1_3 +// +typedef struct _EFI_REDFISH_PCIEFUNCTION_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEFUNCTION_V1_1_3_CS *PCIeFunction; +} EFI_REDFISH_PCIEFUNCTION_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_1_4/EfiPCIeFunctionV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_1_4/EfiPCIeFunctionV1_1_4.h new file mode 100644 index 00000000000..5428ef14ea4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_1_4/EfiPCIeFunctionV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeFunction v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEFUNCTION_V1_1_4_H__ +#define EFI_REDFISH_INTERP_PCIEFUNCTION_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeFunction/v1_1_4/Redfish_PCIeFunction_v1_1_4_CS.h" +// +// EFI structure of Redfish PCIeFunction v1_1_4 +// +typedef struct _EFI_REDFISH_PCIEFUNCTION_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEFUNCTION_V1_1_4_CS *PCIeFunction; +} EFI_REDFISH_PCIEFUNCTION_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_2_0/EfiPCIeFunctionV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_2_0/EfiPCIeFunctionV1_2_0.h new file mode 100644 index 00000000000..2adf0e02d15 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_2_0/EfiPCIeFunctionV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeFunction v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEFUNCTION_V1_2_0_H__ +#define EFI_REDFISH_INTERP_PCIEFUNCTION_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeFunction/v1_2_0/Redfish_PCIeFunction_v1_2_0_CS.h" +// +// EFI structure of Redfish PCIeFunction v1_2_0 +// +typedef struct _EFI_REDFISH_PCIEFUNCTION_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEFUNCTION_V1_2_0_CS *PCIeFunction; +} EFI_REDFISH_PCIEFUNCTION_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_2_1/EfiPCIeFunctionV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_2_1/EfiPCIeFunctionV1_2_1.h new file mode 100644 index 00000000000..faa2da49f99 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_2_1/EfiPCIeFunctionV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeFunction v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEFUNCTION_V1_2_1_H__ +#define EFI_REDFISH_INTERP_PCIEFUNCTION_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeFunction/v1_2_1/Redfish_PCIeFunction_v1_2_1_CS.h" +// +// EFI structure of Redfish PCIeFunction v1_2_1 +// +typedef struct _EFI_REDFISH_PCIEFUNCTION_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEFUNCTION_V1_2_1_CS *PCIeFunction; +} EFI_REDFISH_PCIEFUNCTION_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_2_2/EfiPCIeFunctionV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_2_2/EfiPCIeFunctionV1_2_2.h new file mode 100644 index 00000000000..61323cdb83c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_2_2/EfiPCIeFunctionV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeFunction v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEFUNCTION_V1_2_2_H__ +#define EFI_REDFISH_INTERP_PCIEFUNCTION_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeFunction/v1_2_2/Redfish_PCIeFunction_v1_2_2_CS.h" +// +// EFI structure of Redfish PCIeFunction v1_2_2 +// +typedef struct _EFI_REDFISH_PCIEFUNCTION_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEFUNCTION_V1_2_2_CS *PCIeFunction; +} EFI_REDFISH_PCIEFUNCTION_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_2_3/EfiPCIeFunctionV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_2_3/EfiPCIeFunctionV1_2_3.h new file mode 100644 index 00000000000..69fdb7115c0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunction/v1_2_3/EfiPCIeFunctionV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeFunction v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEFUNCTION_V1_2_3_H__ +#define EFI_REDFISH_INTERP_PCIEFUNCTION_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeFunction/v1_2_3/Redfish_PCIeFunction_v1_2_3_CS.h" +// +// EFI structure of Redfish PCIeFunction v1_2_3 +// +typedef struct _EFI_REDFISH_PCIEFUNCTION_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEFUNCTION_V1_2_3_CS *PCIeFunction; +} EFI_REDFISH_PCIEFUNCTION_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunctionCollection/EfiPCIeFunctionCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunctionCollection/EfiPCIeFunctionCollection.h new file mode 100644 index 00000000000..6d3d904ea0e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeFunctionCollection/EfiPCIeFunctionCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeFunctionCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIEFUNCTIONCOLLECTION_H__ +#define EFI_REDFISH_INTERP_PCIEFUNCTIONCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeFunctionCollection/Redfish_PCIeFunctionCollection_CS.h" +// +// EFI structure of Redfish PCIeFunctionCollection +// +typedef struct _EFI_REDFISH_PCIEFUNCTIONCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIEFUNCTIONCOLLECTION_CS *PCIeFunctionCollection; +} EFI_REDFISH_PCIEFUNCTIONCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_0_0/EfiPCIeSlotsV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_0_0/EfiPCIeSlotsV1_0_0.h new file mode 100644 index 00000000000..758344abeb6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_0_0/EfiPCIeSlotsV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeSlots v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIESLOTS_V1_0_0_H__ +#define EFI_REDFISH_INTERP_PCIESLOTS_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeSlots/v1_0_0/Redfish_PCIeSlots_v1_0_0_CS.h" +// +// EFI structure of Redfish PCIeSlots v1_0_0 +// +typedef struct _EFI_REDFISH_PCIESLOTS_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIESLOTS_V1_0_0_CS *PCIeSlots; +} EFI_REDFISH_PCIESLOTS_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_0_1/EfiPCIeSlotsV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_0_1/EfiPCIeSlotsV1_0_1.h new file mode 100644 index 00000000000..869109a4d1d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_0_1/EfiPCIeSlotsV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeSlots v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIESLOTS_V1_0_1_H__ +#define EFI_REDFISH_INTERP_PCIESLOTS_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeSlots/v1_0_1/Redfish_PCIeSlots_v1_0_1_CS.h" +// +// EFI structure of Redfish PCIeSlots v1_0_1 +// +typedef struct _EFI_REDFISH_PCIESLOTS_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIESLOTS_V1_0_1_CS *PCIeSlots; +} EFI_REDFISH_PCIESLOTS_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_0_2/EfiPCIeSlotsV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_0_2/EfiPCIeSlotsV1_0_2.h new file mode 100644 index 00000000000..0cfdfca756c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_0_2/EfiPCIeSlotsV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeSlots v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIESLOTS_V1_0_2_H__ +#define EFI_REDFISH_INTERP_PCIESLOTS_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeSlots/v1_0_2/Redfish_PCIeSlots_v1_0_2_CS.h" +// +// EFI structure of Redfish PCIeSlots v1_0_2 +// +typedef struct _EFI_REDFISH_PCIESLOTS_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIESLOTS_V1_0_2_CS *PCIeSlots; +} EFI_REDFISH_PCIESLOTS_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_0_3/EfiPCIeSlotsV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_0_3/EfiPCIeSlotsV1_0_3.h new file mode 100644 index 00000000000..31254c0d105 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_0_3/EfiPCIeSlotsV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeSlots v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIESLOTS_V1_0_3_H__ +#define EFI_REDFISH_INTERP_PCIESLOTS_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeSlots/v1_0_3/Redfish_PCIeSlots_v1_0_3_CS.h" +// +// EFI structure of Redfish PCIeSlots v1_0_3 +// +typedef struct _EFI_REDFISH_PCIESLOTS_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIESLOTS_V1_0_3_CS *PCIeSlots; +} EFI_REDFISH_PCIESLOTS_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_1_0/EfiPCIeSlotsV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_1_0/EfiPCIeSlotsV1_1_0.h new file mode 100644 index 00000000000..a388fa2927a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_1_0/EfiPCIeSlotsV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeSlots v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIESLOTS_V1_1_0_H__ +#define EFI_REDFISH_INTERP_PCIESLOTS_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeSlots/v1_1_0/Redfish_PCIeSlots_v1_1_0_CS.h" +// +// EFI structure of Redfish PCIeSlots v1_1_0 +// +typedef struct _EFI_REDFISH_PCIESLOTS_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIESLOTS_V1_1_0_CS *PCIeSlots; +} EFI_REDFISH_PCIESLOTS_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_1_1/EfiPCIeSlotsV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_1_1/EfiPCIeSlotsV1_1_1.h new file mode 100644 index 00000000000..0fe1c5ec089 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_1_1/EfiPCIeSlotsV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeSlots v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIESLOTS_V1_1_1_H__ +#define EFI_REDFISH_INTERP_PCIESLOTS_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeSlots/v1_1_1/Redfish_PCIeSlots_v1_1_1_CS.h" +// +// EFI structure of Redfish PCIeSlots v1_1_1 +// +typedef struct _EFI_REDFISH_PCIESLOTS_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIESLOTS_V1_1_1_CS *PCIeSlots; +} EFI_REDFISH_PCIESLOTS_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_1_2/EfiPCIeSlotsV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_1_2/EfiPCIeSlotsV1_1_2.h new file mode 100644 index 00000000000..1073c4409b8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_1_2/EfiPCIeSlotsV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeSlots v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIESLOTS_V1_1_2_H__ +#define EFI_REDFISH_INTERP_PCIESLOTS_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeSlots/v1_1_2/Redfish_PCIeSlots_v1_1_2_CS.h" +// +// EFI structure of Redfish PCIeSlots v1_1_2 +// +typedef struct _EFI_REDFISH_PCIESLOTS_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIESLOTS_V1_1_2_CS *PCIeSlots; +} EFI_REDFISH_PCIESLOTS_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_2_0/EfiPCIeSlotsV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_2_0/EfiPCIeSlotsV1_2_0.h new file mode 100644 index 00000000000..72617118e94 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_2_0/EfiPCIeSlotsV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeSlots v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIESLOTS_V1_2_0_H__ +#define EFI_REDFISH_INTERP_PCIESLOTS_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeSlots/v1_2_0/Redfish_PCIeSlots_v1_2_0_CS.h" +// +// EFI structure of Redfish PCIeSlots v1_2_0 +// +typedef struct _EFI_REDFISH_PCIESLOTS_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIESLOTS_V1_2_0_CS *PCIeSlots; +} EFI_REDFISH_PCIESLOTS_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_3_0/EfiPCIeSlotsV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_3_0/EfiPCIeSlotsV1_3_0.h new file mode 100644 index 00000000000..96303991049 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_3_0/EfiPCIeSlotsV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeSlots v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIESLOTS_V1_3_0_H__ +#define EFI_REDFISH_INTERP_PCIESLOTS_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeSlots/v1_3_0/Redfish_PCIeSlots_v1_3_0_CS.h" +// +// EFI structure of Redfish PCIeSlots v1_3_0 +// +typedef struct _EFI_REDFISH_PCIESLOTS_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIESLOTS_V1_3_0_CS *PCIeSlots; +} EFI_REDFISH_PCIESLOTS_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_4_0/EfiPCIeSlotsV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_4_0/EfiPCIeSlotsV1_4_0.h new file mode 100644 index 00000000000..1778359b8a2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_4_0/EfiPCIeSlotsV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeSlots v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIESLOTS_V1_4_0_H__ +#define EFI_REDFISH_INTERP_PCIESLOTS_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeSlots/v1_4_0/Redfish_PCIeSlots_v1_4_0_CS.h" +// +// EFI structure of Redfish PCIeSlots v1_4_0 +// +typedef struct _EFI_REDFISH_PCIESLOTS_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIESLOTS_V1_4_0_CS *PCIeSlots; +} EFI_REDFISH_PCIESLOTS_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_4_1/EfiPCIeSlotsV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_4_1/EfiPCIeSlotsV1_4_1.h new file mode 100644 index 00000000000..fb695fc8089 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PCIeSlots/v1_4_1/EfiPCIeSlotsV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PCIeSlots v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PCIESLOTS_V1_4_1_H__ +#define EFI_REDFISH_INTERP_PCIESLOTS_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/PCIeSlots/v1_4_1/Redfish_PCIeSlots_v1_4_1_CS.h" +// +// EFI structure of Redfish PCIeSlots v1_4_1 +// +typedef struct _EFI_REDFISH_PCIESLOTS_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PCIESLOTS_V1_4_1_CS *PCIeSlots; +} EFI_REDFISH_PCIESLOTS_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_0/EfiPortV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_0/EfiPortV1_0_0.h new file mode 100644 index 00000000000..a0503232855 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_0/EfiPortV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Port v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PORT_V1_0_0_H__ +#define EFI_REDFISH_INTERP_PORT_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Port/v1_0_0/Redfish_Port_v1_0_0_CS.h" +// +// EFI structure of Redfish Port v1_0_0 +// +typedef struct _EFI_REDFISH_PORT_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PORT_V1_0_0_CS *Port; +} EFI_REDFISH_PORT_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_1/EfiPortV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_1/EfiPortV1_0_1.h new file mode 100644 index 00000000000..aef9187b796 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_1/EfiPortV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Port v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PORT_V1_0_1_H__ +#define EFI_REDFISH_INTERP_PORT_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Port/v1_0_1/Redfish_Port_v1_0_1_CS.h" +// +// EFI structure of Redfish Port v1_0_1 +// +typedef struct _EFI_REDFISH_PORT_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PORT_V1_0_1_CS *Port; +} EFI_REDFISH_PORT_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_2/EfiPortV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_2/EfiPortV1_0_2.h new file mode 100644 index 00000000000..b24d8361e74 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_2/EfiPortV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Port v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PORT_V1_0_2_H__ +#define EFI_REDFISH_INTERP_PORT_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Port/v1_0_2/Redfish_Port_v1_0_2_CS.h" +// +// EFI structure of Redfish Port v1_0_2 +// +typedef struct _EFI_REDFISH_PORT_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PORT_V1_0_2_CS *Port; +} EFI_REDFISH_PORT_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_3/EfiPortV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_3/EfiPortV1_0_3.h new file mode 100644 index 00000000000..998385e02d5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_3/EfiPortV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Port v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PORT_V1_0_3_H__ +#define EFI_REDFISH_INTERP_PORT_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Port/v1_0_3/Redfish_Port_v1_0_3_CS.h" +// +// EFI structure of Redfish Port v1_0_3 +// +typedef struct _EFI_REDFISH_PORT_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PORT_V1_0_3_CS *Port; +} EFI_REDFISH_PORT_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_4/EfiPortV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_4/EfiPortV1_0_4.h new file mode 100644 index 00000000000..8846d84b882 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_4/EfiPortV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Port v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PORT_V1_0_4_H__ +#define EFI_REDFISH_INTERP_PORT_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Port/v1_0_4/Redfish_Port_v1_0_4_CS.h" +// +// EFI structure of Redfish Port v1_0_4 +// +typedef struct _EFI_REDFISH_PORT_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PORT_V1_0_4_CS *Port; +} EFI_REDFISH_PORT_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_5/EfiPortV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_5/EfiPortV1_0_5.h new file mode 100644 index 00000000000..303dda8c0da --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_5/EfiPortV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Port v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PORT_V1_0_5_H__ +#define EFI_REDFISH_INTERP_PORT_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Port/v1_0_5/Redfish_Port_v1_0_5_CS.h" +// +// EFI structure of Redfish Port v1_0_5 +// +typedef struct _EFI_REDFISH_PORT_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PORT_V1_0_5_CS *Port; +} EFI_REDFISH_PORT_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_6/EfiPortV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_6/EfiPortV1_0_6.h new file mode 100644 index 00000000000..edd116a411d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_6/EfiPortV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Port v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PORT_V1_0_6_H__ +#define EFI_REDFISH_INTERP_PORT_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Port/v1_0_6/Redfish_Port_v1_0_6_CS.h" +// +// EFI structure of Redfish Port v1_0_6 +// +typedef struct _EFI_REDFISH_PORT_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PORT_V1_0_6_CS *Port; +} EFI_REDFISH_PORT_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_7/EfiPortV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_7/EfiPortV1_0_7.h new file mode 100644 index 00000000000..0f88f3913a6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_7/EfiPortV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Port v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PORT_V1_0_7_H__ +#define EFI_REDFISH_INTERP_PORT_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Port/v1_0_7/Redfish_Port_v1_0_7_CS.h" +// +// EFI structure of Redfish Port v1_0_7 +// +typedef struct _EFI_REDFISH_PORT_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PORT_V1_0_7_CS *Port; +} EFI_REDFISH_PORT_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_8/EfiPortV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_8/EfiPortV1_0_8.h new file mode 100644 index 00000000000..3620ad6888c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_0_8/EfiPortV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Port v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PORT_V1_0_8_H__ +#define EFI_REDFISH_INTERP_PORT_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Port/v1_0_8/Redfish_Port_v1_0_8_CS.h" +// +// EFI structure of Redfish Port v1_0_8 +// +typedef struct _EFI_REDFISH_PORT_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PORT_V1_0_8_CS *Port; +} EFI_REDFISH_PORT_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_1_0/EfiPortV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_1_0/EfiPortV1_1_0.h new file mode 100644 index 00000000000..595667a8068 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_1_0/EfiPortV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Port v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PORT_V1_1_0_H__ +#define EFI_REDFISH_INTERP_PORT_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Port/v1_1_0/Redfish_Port_v1_1_0_CS.h" +// +// EFI structure of Redfish Port v1_1_0 +// +typedef struct _EFI_REDFISH_PORT_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PORT_V1_1_0_CS *Port; +} EFI_REDFISH_PORT_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_1_1/EfiPortV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_1_1/EfiPortV1_1_1.h new file mode 100644 index 00000000000..4a49613fd7f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_1_1/EfiPortV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Port v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PORT_V1_1_1_H__ +#define EFI_REDFISH_INTERP_PORT_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Port/v1_1_1/Redfish_Port_v1_1_1_CS.h" +// +// EFI structure of Redfish Port v1_1_1 +// +typedef struct _EFI_REDFISH_PORT_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PORT_V1_1_1_CS *Port; +} EFI_REDFISH_PORT_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_1_2/EfiPortV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_1_2/EfiPortV1_1_2.h new file mode 100644 index 00000000000..b9bb72602dc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_1_2/EfiPortV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Port v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PORT_V1_1_2_H__ +#define EFI_REDFISH_INTERP_PORT_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Port/v1_1_2/Redfish_Port_v1_1_2_CS.h" +// +// EFI structure of Redfish Port v1_1_2 +// +typedef struct _EFI_REDFISH_PORT_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PORT_V1_1_2_CS *Port; +} EFI_REDFISH_PORT_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_1_3/EfiPortV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_1_3/EfiPortV1_1_3.h new file mode 100644 index 00000000000..ef73cb5c5b1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_1_3/EfiPortV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Port v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PORT_V1_1_3_H__ +#define EFI_REDFISH_INTERP_PORT_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Port/v1_1_3/Redfish_Port_v1_1_3_CS.h" +// +// EFI structure of Redfish Port v1_1_3 +// +typedef struct _EFI_REDFISH_PORT_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PORT_V1_1_3_CS *Port; +} EFI_REDFISH_PORT_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_1_4/EfiPortV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_1_4/EfiPortV1_1_4.h new file mode 100644 index 00000000000..963a80e79e0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_1_4/EfiPortV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Port v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PORT_V1_1_4_H__ +#define EFI_REDFISH_INTERP_PORT_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Port/v1_1_4/Redfish_Port_v1_1_4_CS.h" +// +// EFI structure of Redfish Port v1_1_4 +// +typedef struct _EFI_REDFISH_PORT_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PORT_V1_1_4_CS *Port; +} EFI_REDFISH_PORT_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_1_5/EfiPortV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_1_5/EfiPortV1_1_5.h new file mode 100644 index 00000000000..c1d1f501d83 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_1_5/EfiPortV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Port v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PORT_V1_1_5_H__ +#define EFI_REDFISH_INTERP_PORT_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Port/v1_1_5/Redfish_Port_v1_1_5_CS.h" +// +// EFI structure of Redfish Port v1_1_5 +// +typedef struct _EFI_REDFISH_PORT_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PORT_V1_1_5_CS *Port; +} EFI_REDFISH_PORT_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_2_0/EfiPortV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_2_0/EfiPortV1_2_0.h new file mode 100644 index 00000000000..e28d22bc4ca --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_2_0/EfiPortV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Port v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PORT_V1_2_0_H__ +#define EFI_REDFISH_INTERP_PORT_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Port/v1_2_0/Redfish_Port_v1_2_0_CS.h" +// +// EFI structure of Redfish Port v1_2_0 +// +typedef struct _EFI_REDFISH_PORT_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PORT_V1_2_0_CS *Port; +} EFI_REDFISH_PORT_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_2_1/EfiPortV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_2_1/EfiPortV1_2_1.h new file mode 100644 index 00000000000..ad5e12724fc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_2_1/EfiPortV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Port v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PORT_V1_2_1_H__ +#define EFI_REDFISH_INTERP_PORT_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Port/v1_2_1/Redfish_Port_v1_2_1_CS.h" +// +// EFI structure of Redfish Port v1_2_1 +// +typedef struct _EFI_REDFISH_PORT_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PORT_V1_2_1_CS *Port; +} EFI_REDFISH_PORT_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_2_2/EfiPortV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_2_2/EfiPortV1_2_2.h new file mode 100644 index 00000000000..52e0a7fa5f0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_2_2/EfiPortV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Port v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PORT_V1_2_2_H__ +#define EFI_REDFISH_INTERP_PORT_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Port/v1_2_2/Redfish_Port_v1_2_2_CS.h" +// +// EFI structure of Redfish Port v1_2_2 +// +typedef struct _EFI_REDFISH_PORT_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PORT_V1_2_2_CS *Port; +} EFI_REDFISH_PORT_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_2_3/EfiPortV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_2_3/EfiPortV1_2_3.h new file mode 100644 index 00000000000..c1522501547 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_2_3/EfiPortV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Port v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PORT_V1_2_3_H__ +#define EFI_REDFISH_INTERP_PORT_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Port/v1_2_3/Redfish_Port_v1_2_3_CS.h" +// +// EFI structure of Redfish Port v1_2_3 +// +typedef struct _EFI_REDFISH_PORT_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PORT_V1_2_3_CS *Port; +} EFI_REDFISH_PORT_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_3_0/EfiPortV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_3_0/EfiPortV1_3_0.h new file mode 100644 index 00000000000..413a6fff7f9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_3_0/EfiPortV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Port v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PORT_V1_3_0_H__ +#define EFI_REDFISH_INTERP_PORT_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Port/v1_3_0/Redfish_Port_v1_3_0_CS.h" +// +// EFI structure of Redfish Port v1_3_0 +// +typedef struct _EFI_REDFISH_PORT_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PORT_V1_3_0_CS *Port; +} EFI_REDFISH_PORT_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_3_1/EfiPortV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_3_1/EfiPortV1_3_1.h new file mode 100644 index 00000000000..5c361732189 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Port/v1_3_1/EfiPortV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Port v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PORT_V1_3_1_H__ +#define EFI_REDFISH_INTERP_PORT_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Port/v1_3_1/Redfish_Port_v1_3_1_CS.h" +// +// EFI structure of Redfish Port v1_3_1 +// +typedef struct _EFI_REDFISH_PORT_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PORT_V1_3_1_CS *Port; +} EFI_REDFISH_PORT_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PortCollection/EfiPortCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/PortCollection/EfiPortCollection.h new file mode 100644 index 00000000000..0097d93d1b1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PortCollection/EfiPortCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PortCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PORTCOLLECTION_H__ +#define EFI_REDFISH_INTERP_PORTCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/PortCollection/Redfish_PortCollection_CS.h" +// +// EFI structure of Redfish PortCollection +// +typedef struct _EFI_REDFISH_PORTCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PORTCOLLECTION_CS *PortCollection; +} EFI_REDFISH_PORTCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PortMetrics/v1_0_0/EfiPortMetricsV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/PortMetrics/v1_0_0/EfiPortMetricsV1_0_0.h new file mode 100644 index 00000000000..5b351f8e662 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PortMetrics/v1_0_0/EfiPortMetricsV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PortMetrics v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PORTMETRICS_V1_0_0_H__ +#define EFI_REDFISH_INTERP_PORTMETRICS_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/PortMetrics/v1_0_0/Redfish_PortMetrics_v1_0_0_CS.h" +// +// EFI structure of Redfish PortMetrics v1_0_0 +// +typedef struct _EFI_REDFISH_PORTMETRICS_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PORTMETRICS_V1_0_0_CS *PortMetrics; +} EFI_REDFISH_PORTMETRICS_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PortMetrics/v1_0_1/EfiPortMetricsV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/PortMetrics/v1_0_1/EfiPortMetricsV1_0_1.h new file mode 100644 index 00000000000..3afec94600a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PortMetrics/v1_0_1/EfiPortMetricsV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PortMetrics v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PORTMETRICS_V1_0_1_H__ +#define EFI_REDFISH_INTERP_PORTMETRICS_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/PortMetrics/v1_0_1/Redfish_PortMetrics_v1_0_1_CS.h" +// +// EFI structure of Redfish PortMetrics v1_0_1 +// +typedef struct _EFI_REDFISH_PORTMETRICS_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PORTMETRICS_V1_0_1_CS *PortMetrics; +} EFI_REDFISH_PORTMETRICS_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_0/EfiPowerV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_0/EfiPowerV1_0_0.h new file mode 100644 index 00000000000..c82d5433802 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_0/EfiPowerV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_0_0_H__ +#define EFI_REDFISH_INTERP_POWER_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_0_0/Redfish_Power_v1_0_0_CS.h" +// +// EFI structure of Redfish Power v1_0_0 +// +typedef struct _EFI_REDFISH_POWER_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_0_0_CS *Power; +} EFI_REDFISH_POWER_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_1/EfiPowerV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_1/EfiPowerV1_0_1.h new file mode 100644 index 00000000000..97cb27f7620 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_1/EfiPowerV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_0_1_H__ +#define EFI_REDFISH_INTERP_POWER_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_0_1/Redfish_Power_v1_0_1_CS.h" +// +// EFI structure of Redfish Power v1_0_1 +// +typedef struct _EFI_REDFISH_POWER_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_0_1_CS *Power; +} EFI_REDFISH_POWER_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_10/EfiPowerV1_0_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_10/EfiPowerV1_0_10.h new file mode 100644 index 00000000000..7d4b077e425 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_10/EfiPowerV1_0_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_0_10_H__ +#define EFI_REDFISH_INTERP_POWER_V1_0_10_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_0_10/Redfish_Power_v1_0_10_CS.h" +// +// EFI structure of Redfish Power v1_0_10 +// +typedef struct _EFI_REDFISH_POWER_V1_0_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_0_10_CS *Power; +} EFI_REDFISH_POWER_V1_0_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_11/EfiPowerV1_0_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_11/EfiPowerV1_0_11.h new file mode 100644 index 00000000000..e6827da5cbb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_11/EfiPowerV1_0_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_0_11_H__ +#define EFI_REDFISH_INTERP_POWER_V1_0_11_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_0_11/Redfish_Power_v1_0_11_CS.h" +// +// EFI structure of Redfish Power v1_0_11 +// +typedef struct _EFI_REDFISH_POWER_V1_0_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_0_11_CS *Power; +} EFI_REDFISH_POWER_V1_0_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_12/EfiPowerV1_0_12.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_12/EfiPowerV1_0_12.h new file mode 100644 index 00000000000..0bdb69d0f0d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_12/EfiPowerV1_0_12.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_0_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_0_12_H__ +#define EFI_REDFISH_INTERP_POWER_V1_0_12_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_0_12/Redfish_Power_v1_0_12_CS.h" +// +// EFI structure of Redfish Power v1_0_12 +// +typedef struct _EFI_REDFISH_POWER_V1_0_12 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_0_12_CS *Power; +} EFI_REDFISH_POWER_V1_0_12; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_2/EfiPowerV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_2/EfiPowerV1_0_2.h new file mode 100644 index 00000000000..f0c8a495aab --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_2/EfiPowerV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_0_2_H__ +#define EFI_REDFISH_INTERP_POWER_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_0_2/Redfish_Power_v1_0_2_CS.h" +// +// EFI structure of Redfish Power v1_0_2 +// +typedef struct _EFI_REDFISH_POWER_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_0_2_CS *Power; +} EFI_REDFISH_POWER_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_3/EfiPowerV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_3/EfiPowerV1_0_3.h new file mode 100644 index 00000000000..1b582fefbf0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_3/EfiPowerV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_0_3_H__ +#define EFI_REDFISH_INTERP_POWER_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_0_3/Redfish_Power_v1_0_3_CS.h" +// +// EFI structure of Redfish Power v1_0_3 +// +typedef struct _EFI_REDFISH_POWER_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_0_3_CS *Power; +} EFI_REDFISH_POWER_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_4/EfiPowerV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_4/EfiPowerV1_0_4.h new file mode 100644 index 00000000000..f2340a4fa70 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_4/EfiPowerV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_0_4_H__ +#define EFI_REDFISH_INTERP_POWER_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_0_4/Redfish_Power_v1_0_4_CS.h" +// +// EFI structure of Redfish Power v1_0_4 +// +typedef struct _EFI_REDFISH_POWER_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_0_4_CS *Power; +} EFI_REDFISH_POWER_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_5/EfiPowerV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_5/EfiPowerV1_0_5.h new file mode 100644 index 00000000000..6b0dc753d66 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_5/EfiPowerV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_0_5_H__ +#define EFI_REDFISH_INTERP_POWER_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_0_5/Redfish_Power_v1_0_5_CS.h" +// +// EFI structure of Redfish Power v1_0_5 +// +typedef struct _EFI_REDFISH_POWER_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_0_5_CS *Power; +} EFI_REDFISH_POWER_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_6/EfiPowerV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_6/EfiPowerV1_0_6.h new file mode 100644 index 00000000000..7ae7c272442 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_6/EfiPowerV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_0_6_H__ +#define EFI_REDFISH_INTERP_POWER_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_0_6/Redfish_Power_v1_0_6_CS.h" +// +// EFI structure of Redfish Power v1_0_6 +// +typedef struct _EFI_REDFISH_POWER_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_0_6_CS *Power; +} EFI_REDFISH_POWER_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_7/EfiPowerV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_7/EfiPowerV1_0_7.h new file mode 100644 index 00000000000..0c848f4700e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_7/EfiPowerV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_0_7_H__ +#define EFI_REDFISH_INTERP_POWER_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_0_7/Redfish_Power_v1_0_7_CS.h" +// +// EFI structure of Redfish Power v1_0_7 +// +typedef struct _EFI_REDFISH_POWER_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_0_7_CS *Power; +} EFI_REDFISH_POWER_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_8/EfiPowerV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_8/EfiPowerV1_0_8.h new file mode 100644 index 00000000000..e8d5ed884e9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_8/EfiPowerV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_0_8_H__ +#define EFI_REDFISH_INTERP_POWER_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_0_8/Redfish_Power_v1_0_8_CS.h" +// +// EFI structure of Redfish Power v1_0_8 +// +typedef struct _EFI_REDFISH_POWER_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_0_8_CS *Power; +} EFI_REDFISH_POWER_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_9/EfiPowerV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_9/EfiPowerV1_0_9.h new file mode 100644 index 00000000000..cbe6b30d507 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_0_9/EfiPowerV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_0_9_H__ +#define EFI_REDFISH_INTERP_POWER_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_0_9/Redfish_Power_v1_0_9_CS.h" +// +// EFI structure of Redfish Power v1_0_9 +// +typedef struct _EFI_REDFISH_POWER_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_0_9_CS *Power; +} EFI_REDFISH_POWER_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_0/EfiPowerV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_0/EfiPowerV1_1_0.h new file mode 100644 index 00000000000..ba806cbb333 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_0/EfiPowerV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_1_0_H__ +#define EFI_REDFISH_INTERP_POWER_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_1_0/Redfish_Power_v1_1_0_CS.h" +// +// EFI structure of Redfish Power v1_1_0 +// +typedef struct _EFI_REDFISH_POWER_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_1_0_CS *Power; +} EFI_REDFISH_POWER_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_1/EfiPowerV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_1/EfiPowerV1_1_1.h new file mode 100644 index 00000000000..a06134ee8f4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_1/EfiPowerV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_1_1_H__ +#define EFI_REDFISH_INTERP_POWER_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_1_1/Redfish_Power_v1_1_1_CS.h" +// +// EFI structure of Redfish Power v1_1_1 +// +typedef struct _EFI_REDFISH_POWER_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_1_1_CS *Power; +} EFI_REDFISH_POWER_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_10/EfiPowerV1_1_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_10/EfiPowerV1_1_10.h new file mode 100644 index 00000000000..daa2992a56d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_10/EfiPowerV1_1_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_1_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_1_10_H__ +#define EFI_REDFISH_INTERP_POWER_V1_1_10_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_1_10/Redfish_Power_v1_1_10_CS.h" +// +// EFI structure of Redfish Power v1_1_10 +// +typedef struct _EFI_REDFISH_POWER_V1_1_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_1_10_CS *Power; +} EFI_REDFISH_POWER_V1_1_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_2/EfiPowerV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_2/EfiPowerV1_1_2.h new file mode 100644 index 00000000000..ad9226a78c9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_2/EfiPowerV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_1_2_H__ +#define EFI_REDFISH_INTERP_POWER_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_1_2/Redfish_Power_v1_1_2_CS.h" +// +// EFI structure of Redfish Power v1_1_2 +// +typedef struct _EFI_REDFISH_POWER_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_1_2_CS *Power; +} EFI_REDFISH_POWER_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_3/EfiPowerV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_3/EfiPowerV1_1_3.h new file mode 100644 index 00000000000..0336481edad --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_3/EfiPowerV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_1_3_H__ +#define EFI_REDFISH_INTERP_POWER_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_1_3/Redfish_Power_v1_1_3_CS.h" +// +// EFI structure of Redfish Power v1_1_3 +// +typedef struct _EFI_REDFISH_POWER_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_1_3_CS *Power; +} EFI_REDFISH_POWER_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_4/EfiPowerV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_4/EfiPowerV1_1_4.h new file mode 100644 index 00000000000..622fa9bb450 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_4/EfiPowerV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_1_4_H__ +#define EFI_REDFISH_INTERP_POWER_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_1_4/Redfish_Power_v1_1_4_CS.h" +// +// EFI structure of Redfish Power v1_1_4 +// +typedef struct _EFI_REDFISH_POWER_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_1_4_CS *Power; +} EFI_REDFISH_POWER_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_5/EfiPowerV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_5/EfiPowerV1_1_5.h new file mode 100644 index 00000000000..92f67eaeed1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_5/EfiPowerV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_1_5_H__ +#define EFI_REDFISH_INTERP_POWER_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_1_5/Redfish_Power_v1_1_5_CS.h" +// +// EFI structure of Redfish Power v1_1_5 +// +typedef struct _EFI_REDFISH_POWER_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_1_5_CS *Power; +} EFI_REDFISH_POWER_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_6/EfiPowerV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_6/EfiPowerV1_1_6.h new file mode 100644 index 00000000000..1a3b417711b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_6/EfiPowerV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_1_6_H__ +#define EFI_REDFISH_INTERP_POWER_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_1_6/Redfish_Power_v1_1_6_CS.h" +// +// EFI structure of Redfish Power v1_1_6 +// +typedef struct _EFI_REDFISH_POWER_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_1_6_CS *Power; +} EFI_REDFISH_POWER_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_7/EfiPowerV1_1_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_7/EfiPowerV1_1_7.h new file mode 100644 index 00000000000..73a12ef62f0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_7/EfiPowerV1_1_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_1_7_H__ +#define EFI_REDFISH_INTERP_POWER_V1_1_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_1_7/Redfish_Power_v1_1_7_CS.h" +// +// EFI structure of Redfish Power v1_1_7 +// +typedef struct _EFI_REDFISH_POWER_V1_1_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_1_7_CS *Power; +} EFI_REDFISH_POWER_V1_1_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_8/EfiPowerV1_1_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_8/EfiPowerV1_1_8.h new file mode 100644 index 00000000000..fa69fc0eebd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_8/EfiPowerV1_1_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_1_8_H__ +#define EFI_REDFISH_INTERP_POWER_V1_1_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_1_8/Redfish_Power_v1_1_8_CS.h" +// +// EFI structure of Redfish Power v1_1_8 +// +typedef struct _EFI_REDFISH_POWER_V1_1_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_1_8_CS *Power; +} EFI_REDFISH_POWER_V1_1_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_9/EfiPowerV1_1_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_9/EfiPowerV1_1_9.h new file mode 100644 index 00000000000..b19b45f06e2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_1_9/EfiPowerV1_1_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_1_9_H__ +#define EFI_REDFISH_INTERP_POWER_V1_1_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_1_9/Redfish_Power_v1_1_9_CS.h" +// +// EFI structure of Redfish Power v1_1_9 +// +typedef struct _EFI_REDFISH_POWER_V1_1_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_1_9_CS *Power; +} EFI_REDFISH_POWER_V1_1_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_0/EfiPowerV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_0/EfiPowerV1_2_0.h new file mode 100644 index 00000000000..5a7bc96ce46 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_0/EfiPowerV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_2_0_H__ +#define EFI_REDFISH_INTERP_POWER_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_2_0/Redfish_Power_v1_2_0_CS.h" +// +// EFI structure of Redfish Power v1_2_0 +// +typedef struct _EFI_REDFISH_POWER_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_2_0_CS *Power; +} EFI_REDFISH_POWER_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_1/EfiPowerV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_1/EfiPowerV1_2_1.h new file mode 100644 index 00000000000..eddcb3f0355 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_1/EfiPowerV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_2_1_H__ +#define EFI_REDFISH_INTERP_POWER_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_2_1/Redfish_Power_v1_2_1_CS.h" +// +// EFI structure of Redfish Power v1_2_1 +// +typedef struct _EFI_REDFISH_POWER_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_2_1_CS *Power; +} EFI_REDFISH_POWER_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_10/EfiPowerV1_2_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_10/EfiPowerV1_2_10.h new file mode 100644 index 00000000000..b01aea54c1f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_10/EfiPowerV1_2_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_2_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_2_10_H__ +#define EFI_REDFISH_INTERP_POWER_V1_2_10_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_2_10/Redfish_Power_v1_2_10_CS.h" +// +// EFI structure of Redfish Power v1_2_10 +// +typedef struct _EFI_REDFISH_POWER_V1_2_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_2_10_CS *Power; +} EFI_REDFISH_POWER_V1_2_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_2/EfiPowerV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_2/EfiPowerV1_2_2.h new file mode 100644 index 00000000000..80b56fcaa34 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_2/EfiPowerV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_2_2_H__ +#define EFI_REDFISH_INTERP_POWER_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_2_2/Redfish_Power_v1_2_2_CS.h" +// +// EFI structure of Redfish Power v1_2_2 +// +typedef struct _EFI_REDFISH_POWER_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_2_2_CS *Power; +} EFI_REDFISH_POWER_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_3/EfiPowerV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_3/EfiPowerV1_2_3.h new file mode 100644 index 00000000000..3df5b8b22ed --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_3/EfiPowerV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_2_3_H__ +#define EFI_REDFISH_INTERP_POWER_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_2_3/Redfish_Power_v1_2_3_CS.h" +// +// EFI structure of Redfish Power v1_2_3 +// +typedef struct _EFI_REDFISH_POWER_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_2_3_CS *Power; +} EFI_REDFISH_POWER_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_4/EfiPowerV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_4/EfiPowerV1_2_4.h new file mode 100644 index 00000000000..bc0c4d39d72 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_4/EfiPowerV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_2_4_H__ +#define EFI_REDFISH_INTERP_POWER_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_2_4/Redfish_Power_v1_2_4_CS.h" +// +// EFI structure of Redfish Power v1_2_4 +// +typedef struct _EFI_REDFISH_POWER_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_2_4_CS *Power; +} EFI_REDFISH_POWER_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_5/EfiPowerV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_5/EfiPowerV1_2_5.h new file mode 100644 index 00000000000..7a3c8e35044 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_5/EfiPowerV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_2_5_H__ +#define EFI_REDFISH_INTERP_POWER_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_2_5/Redfish_Power_v1_2_5_CS.h" +// +// EFI structure of Redfish Power v1_2_5 +// +typedef struct _EFI_REDFISH_POWER_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_2_5_CS *Power; +} EFI_REDFISH_POWER_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_6/EfiPowerV1_2_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_6/EfiPowerV1_2_6.h new file mode 100644 index 00000000000..5d153a98ae0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_6/EfiPowerV1_2_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_2_6_H__ +#define EFI_REDFISH_INTERP_POWER_V1_2_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_2_6/Redfish_Power_v1_2_6_CS.h" +// +// EFI structure of Redfish Power v1_2_6 +// +typedef struct _EFI_REDFISH_POWER_V1_2_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_2_6_CS *Power; +} EFI_REDFISH_POWER_V1_2_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_7/EfiPowerV1_2_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_7/EfiPowerV1_2_7.h new file mode 100644 index 00000000000..4c047f11437 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_7/EfiPowerV1_2_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_2_7_H__ +#define EFI_REDFISH_INTERP_POWER_V1_2_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_2_7/Redfish_Power_v1_2_7_CS.h" +// +// EFI structure of Redfish Power v1_2_7 +// +typedef struct _EFI_REDFISH_POWER_V1_2_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_2_7_CS *Power; +} EFI_REDFISH_POWER_V1_2_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_8/EfiPowerV1_2_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_8/EfiPowerV1_2_8.h new file mode 100644 index 00000000000..2a3ca07d651 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_8/EfiPowerV1_2_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_2_8_H__ +#define EFI_REDFISH_INTERP_POWER_V1_2_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_2_8/Redfish_Power_v1_2_8_CS.h" +// +// EFI structure of Redfish Power v1_2_8 +// +typedef struct _EFI_REDFISH_POWER_V1_2_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_2_8_CS *Power; +} EFI_REDFISH_POWER_V1_2_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_9/EfiPowerV1_2_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_9/EfiPowerV1_2_9.h new file mode 100644 index 00000000000..2c3f55d47ad --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_2_9/EfiPowerV1_2_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_2_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_2_9_H__ +#define EFI_REDFISH_INTERP_POWER_V1_2_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_2_9/Redfish_Power_v1_2_9_CS.h" +// +// EFI structure of Redfish Power v1_2_9 +// +typedef struct _EFI_REDFISH_POWER_V1_2_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_2_9_CS *Power; +} EFI_REDFISH_POWER_V1_2_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_0/EfiPowerV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_0/EfiPowerV1_3_0.h new file mode 100644 index 00000000000..45c31ca4096 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_0/EfiPowerV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_3_0_H__ +#define EFI_REDFISH_INTERP_POWER_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_3_0/Redfish_Power_v1_3_0_CS.h" +// +// EFI structure of Redfish Power v1_3_0 +// +typedef struct _EFI_REDFISH_POWER_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_3_0_CS *Power; +} EFI_REDFISH_POWER_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_1/EfiPowerV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_1/EfiPowerV1_3_1.h new file mode 100644 index 00000000000..95cc93e55ef --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_1/EfiPowerV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_3_1_H__ +#define EFI_REDFISH_INTERP_POWER_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_3_1/Redfish_Power_v1_3_1_CS.h" +// +// EFI structure of Redfish Power v1_3_1 +// +typedef struct _EFI_REDFISH_POWER_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_3_1_CS *Power; +} EFI_REDFISH_POWER_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_2/EfiPowerV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_2/EfiPowerV1_3_2.h new file mode 100644 index 00000000000..54255a1bd85 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_2/EfiPowerV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_3_2_H__ +#define EFI_REDFISH_INTERP_POWER_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_3_2/Redfish_Power_v1_3_2_CS.h" +// +// EFI structure of Redfish Power v1_3_2 +// +typedef struct _EFI_REDFISH_POWER_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_3_2_CS *Power; +} EFI_REDFISH_POWER_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_3/EfiPowerV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_3/EfiPowerV1_3_3.h new file mode 100644 index 00000000000..85e43dfb182 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_3/EfiPowerV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_3_3_H__ +#define EFI_REDFISH_INTERP_POWER_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_3_3/Redfish_Power_v1_3_3_CS.h" +// +// EFI structure of Redfish Power v1_3_3 +// +typedef struct _EFI_REDFISH_POWER_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_3_3_CS *Power; +} EFI_REDFISH_POWER_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_4/EfiPowerV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_4/EfiPowerV1_3_4.h new file mode 100644 index 00000000000..60425e1a199 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_4/EfiPowerV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_3_4_H__ +#define EFI_REDFISH_INTERP_POWER_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_3_4/Redfish_Power_v1_3_4_CS.h" +// +// EFI structure of Redfish Power v1_3_4 +// +typedef struct _EFI_REDFISH_POWER_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_3_4_CS *Power; +} EFI_REDFISH_POWER_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_5/EfiPowerV1_3_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_5/EfiPowerV1_3_5.h new file mode 100644 index 00000000000..abf3263250c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_5/EfiPowerV1_3_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_3_5_H__ +#define EFI_REDFISH_INTERP_POWER_V1_3_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_3_5/Redfish_Power_v1_3_5_CS.h" +// +// EFI structure of Redfish Power v1_3_5 +// +typedef struct _EFI_REDFISH_POWER_V1_3_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_3_5_CS *Power; +} EFI_REDFISH_POWER_V1_3_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_6/EfiPowerV1_3_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_6/EfiPowerV1_3_6.h new file mode 100644 index 00000000000..2512b0e0847 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_6/EfiPowerV1_3_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_3_6_H__ +#define EFI_REDFISH_INTERP_POWER_V1_3_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_3_6/Redfish_Power_v1_3_6_CS.h" +// +// EFI structure of Redfish Power v1_3_6 +// +typedef struct _EFI_REDFISH_POWER_V1_3_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_3_6_CS *Power; +} EFI_REDFISH_POWER_V1_3_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_7/EfiPowerV1_3_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_7/EfiPowerV1_3_7.h new file mode 100644 index 00000000000..b97d1ae1db0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_7/EfiPowerV1_3_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_3_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_3_7_H__ +#define EFI_REDFISH_INTERP_POWER_V1_3_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_3_7/Redfish_Power_v1_3_7_CS.h" +// +// EFI structure of Redfish Power v1_3_7 +// +typedef struct _EFI_REDFISH_POWER_V1_3_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_3_7_CS *Power; +} EFI_REDFISH_POWER_V1_3_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_8/EfiPowerV1_3_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_8/EfiPowerV1_3_8.h new file mode 100644 index 00000000000..b471caa3eef --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_3_8/EfiPowerV1_3_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_3_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_3_8_H__ +#define EFI_REDFISH_INTERP_POWER_V1_3_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_3_8/Redfish_Power_v1_3_8_CS.h" +// +// EFI structure of Redfish Power v1_3_8 +// +typedef struct _EFI_REDFISH_POWER_V1_3_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_3_8_CS *Power; +} EFI_REDFISH_POWER_V1_3_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_0/EfiPowerV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_0/EfiPowerV1_4_0.h new file mode 100644 index 00000000000..a118838d0a9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_0/EfiPowerV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_4_0_H__ +#define EFI_REDFISH_INTERP_POWER_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_4_0/Redfish_Power_v1_4_0_CS.h" +// +// EFI structure of Redfish Power v1_4_0 +// +typedef struct _EFI_REDFISH_POWER_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_4_0_CS *Power; +} EFI_REDFISH_POWER_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_1/EfiPowerV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_1/EfiPowerV1_4_1.h new file mode 100644 index 00000000000..38260b70a68 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_1/EfiPowerV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_4_1_H__ +#define EFI_REDFISH_INTERP_POWER_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_4_1/Redfish_Power_v1_4_1_CS.h" +// +// EFI structure of Redfish Power v1_4_1 +// +typedef struct _EFI_REDFISH_POWER_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_4_1_CS *Power; +} EFI_REDFISH_POWER_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_2/EfiPowerV1_4_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_2/EfiPowerV1_4_2.h new file mode 100644 index 00000000000..bb4c1da1ed4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_2/EfiPowerV1_4_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_4_2_H__ +#define EFI_REDFISH_INTERP_POWER_V1_4_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_4_2/Redfish_Power_v1_4_2_CS.h" +// +// EFI structure of Redfish Power v1_4_2 +// +typedef struct _EFI_REDFISH_POWER_V1_4_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_4_2_CS *Power; +} EFI_REDFISH_POWER_V1_4_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_3/EfiPowerV1_4_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_3/EfiPowerV1_4_3.h new file mode 100644 index 00000000000..96a25545a24 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_3/EfiPowerV1_4_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_4_3_H__ +#define EFI_REDFISH_INTERP_POWER_V1_4_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_4_3/Redfish_Power_v1_4_3_CS.h" +// +// EFI structure of Redfish Power v1_4_3 +// +typedef struct _EFI_REDFISH_POWER_V1_4_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_4_3_CS *Power; +} EFI_REDFISH_POWER_V1_4_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_4/EfiPowerV1_4_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_4/EfiPowerV1_4_4.h new file mode 100644 index 00000000000..1810491662c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_4/EfiPowerV1_4_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_4_4_H__ +#define EFI_REDFISH_INTERP_POWER_V1_4_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_4_4/Redfish_Power_v1_4_4_CS.h" +// +// EFI structure of Redfish Power v1_4_4 +// +typedef struct _EFI_REDFISH_POWER_V1_4_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_4_4_CS *Power; +} EFI_REDFISH_POWER_V1_4_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_5/EfiPowerV1_4_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_5/EfiPowerV1_4_5.h new file mode 100644 index 00000000000..622ef1783ab --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_5/EfiPowerV1_4_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_4_5_H__ +#define EFI_REDFISH_INTERP_POWER_V1_4_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_4_5/Redfish_Power_v1_4_5_CS.h" +// +// EFI structure of Redfish Power v1_4_5 +// +typedef struct _EFI_REDFISH_POWER_V1_4_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_4_5_CS *Power; +} EFI_REDFISH_POWER_V1_4_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_6/EfiPowerV1_4_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_6/EfiPowerV1_4_6.h new file mode 100644 index 00000000000..990ab6ed8cb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_6/EfiPowerV1_4_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_4_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_4_6_H__ +#define EFI_REDFISH_INTERP_POWER_V1_4_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_4_6/Redfish_Power_v1_4_6_CS.h" +// +// EFI structure of Redfish Power v1_4_6 +// +typedef struct _EFI_REDFISH_POWER_V1_4_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_4_6_CS *Power; +} EFI_REDFISH_POWER_V1_4_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_7/EfiPowerV1_4_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_7/EfiPowerV1_4_7.h new file mode 100644 index 00000000000..fe874a4344b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_4_7/EfiPowerV1_4_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_4_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_4_7_H__ +#define EFI_REDFISH_INTERP_POWER_V1_4_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_4_7/Redfish_Power_v1_4_7_CS.h" +// +// EFI structure of Redfish Power v1_4_7 +// +typedef struct _EFI_REDFISH_POWER_V1_4_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_4_7_CS *Power; +} EFI_REDFISH_POWER_V1_4_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_0/EfiPowerV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_0/EfiPowerV1_5_0.h new file mode 100644 index 00000000000..9695cc966b3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_0/EfiPowerV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_5_0_H__ +#define EFI_REDFISH_INTERP_POWER_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_5_0/Redfish_Power_v1_5_0_CS.h" +// +// EFI structure of Redfish Power v1_5_0 +// +typedef struct _EFI_REDFISH_POWER_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_5_0_CS *Power; +} EFI_REDFISH_POWER_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_1/EfiPowerV1_5_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_1/EfiPowerV1_5_1.h new file mode 100644 index 00000000000..aa5d8e3fd7e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_1/EfiPowerV1_5_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_5_1_H__ +#define EFI_REDFISH_INTERP_POWER_V1_5_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_5_1/Redfish_Power_v1_5_1_CS.h" +// +// EFI structure of Redfish Power v1_5_1 +// +typedef struct _EFI_REDFISH_POWER_V1_5_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_5_1_CS *Power; +} EFI_REDFISH_POWER_V1_5_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_2/EfiPowerV1_5_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_2/EfiPowerV1_5_2.h new file mode 100644 index 00000000000..55be990d2bb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_2/EfiPowerV1_5_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_5_2_H__ +#define EFI_REDFISH_INTERP_POWER_V1_5_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_5_2/Redfish_Power_v1_5_2_CS.h" +// +// EFI structure of Redfish Power v1_5_2 +// +typedef struct _EFI_REDFISH_POWER_V1_5_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_5_2_CS *Power; +} EFI_REDFISH_POWER_V1_5_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_3/EfiPowerV1_5_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_3/EfiPowerV1_5_3.h new file mode 100644 index 00000000000..7749288ddd7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_3/EfiPowerV1_5_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_5_3_H__ +#define EFI_REDFISH_INTERP_POWER_V1_5_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_5_3/Redfish_Power_v1_5_3_CS.h" +// +// EFI structure of Redfish Power v1_5_3 +// +typedef struct _EFI_REDFISH_POWER_V1_5_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_5_3_CS *Power; +} EFI_REDFISH_POWER_V1_5_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_4/EfiPowerV1_5_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_4/EfiPowerV1_5_4.h new file mode 100644 index 00000000000..50cea73c168 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_4/EfiPowerV1_5_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_5_4_H__ +#define EFI_REDFISH_INTERP_POWER_V1_5_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_5_4/Redfish_Power_v1_5_4_CS.h" +// +// EFI structure of Redfish Power v1_5_4 +// +typedef struct _EFI_REDFISH_POWER_V1_5_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_5_4_CS *Power; +} EFI_REDFISH_POWER_V1_5_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_5/EfiPowerV1_5_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_5/EfiPowerV1_5_5.h new file mode 100644 index 00000000000..e0ddb5f50f8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_5/EfiPowerV1_5_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_5_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_5_5_H__ +#define EFI_REDFISH_INTERP_POWER_V1_5_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_5_5/Redfish_Power_v1_5_5_CS.h" +// +// EFI structure of Redfish Power v1_5_5 +// +typedef struct _EFI_REDFISH_POWER_V1_5_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_5_5_CS *Power; +} EFI_REDFISH_POWER_V1_5_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_6/EfiPowerV1_5_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_6/EfiPowerV1_5_6.h new file mode 100644 index 00000000000..fa63ae39100 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_5_6/EfiPowerV1_5_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_5_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_5_6_H__ +#define EFI_REDFISH_INTERP_POWER_V1_5_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_5_6/Redfish_Power_v1_5_6_CS.h" +// +// EFI structure of Redfish Power v1_5_6 +// +typedef struct _EFI_REDFISH_POWER_V1_5_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_5_6_CS *Power; +} EFI_REDFISH_POWER_V1_5_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_6_0/EfiPowerV1_6_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_6_0/EfiPowerV1_6_0.h new file mode 100644 index 00000000000..3dd1ebb31a8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_6_0/EfiPowerV1_6_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_6_0_H__ +#define EFI_REDFISH_INTERP_POWER_V1_6_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_6_0/Redfish_Power_v1_6_0_CS.h" +// +// EFI structure of Redfish Power v1_6_0 +// +typedef struct _EFI_REDFISH_POWER_V1_6_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_6_0_CS *Power; +} EFI_REDFISH_POWER_V1_6_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_6_1/EfiPowerV1_6_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_6_1/EfiPowerV1_6_1.h new file mode 100644 index 00000000000..6e4f99f3160 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_6_1/EfiPowerV1_6_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_6_1_H__ +#define EFI_REDFISH_INTERP_POWER_V1_6_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_6_1/Redfish_Power_v1_6_1_CS.h" +// +// EFI structure of Redfish Power v1_6_1 +// +typedef struct _EFI_REDFISH_POWER_V1_6_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_6_1_CS *Power; +} EFI_REDFISH_POWER_V1_6_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_6_2/EfiPowerV1_6_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_6_2/EfiPowerV1_6_2.h new file mode 100644 index 00000000000..a4c91260b32 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_6_2/EfiPowerV1_6_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_6_2_H__ +#define EFI_REDFISH_INTERP_POWER_V1_6_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_6_2/Redfish_Power_v1_6_2_CS.h" +// +// EFI structure of Redfish Power v1_6_2 +// +typedef struct _EFI_REDFISH_POWER_V1_6_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_6_2_CS *Power; +} EFI_REDFISH_POWER_V1_6_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_7_0/EfiPowerV1_7_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_7_0/EfiPowerV1_7_0.h new file mode 100644 index 00000000000..69f6476ff4f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Power/v1_7_0/EfiPowerV1_7_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Power v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWER_V1_7_0_H__ +#define EFI_REDFISH_INTERP_POWER_V1_7_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Power/v1_7_0/Redfish_Power_v1_7_0_CS.h" +// +// EFI structure of Redfish Power v1_7_0 +// +typedef struct _EFI_REDFISH_POWER_V1_7_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWER_V1_7_0_CS *Power; +} EFI_REDFISH_POWER_V1_7_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PowerDistribution/v1_0_0/EfiPowerDistributionV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/PowerDistribution/v1_0_0/EfiPowerDistributionV1_0_0.h new file mode 100644 index 00000000000..3ec021cf4b6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PowerDistribution/v1_0_0/EfiPowerDistributionV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PowerDistribution v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWERDISTRIBUTION_V1_0_0_H__ +#define EFI_REDFISH_INTERP_POWERDISTRIBUTION_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/PowerDistribution/v1_0_0/Redfish_PowerDistribution_v1_0_0_CS.h" +// +// EFI structure of Redfish PowerDistribution v1_0_0 +// +typedef struct _EFI_REDFISH_POWERDISTRIBUTION_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWERDISTRIBUTION_V1_0_0_CS *PowerDistribution; +} EFI_REDFISH_POWERDISTRIBUTION_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PowerDistribution/v1_0_1/EfiPowerDistributionV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/PowerDistribution/v1_0_1/EfiPowerDistributionV1_0_1.h new file mode 100644 index 00000000000..4acfe689338 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PowerDistribution/v1_0_1/EfiPowerDistributionV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PowerDistribution v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWERDISTRIBUTION_V1_0_1_H__ +#define EFI_REDFISH_INTERP_POWERDISTRIBUTION_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/PowerDistribution/v1_0_1/Redfish_PowerDistribution_v1_0_1_CS.h" +// +// EFI structure of Redfish PowerDistribution v1_0_1 +// +typedef struct _EFI_REDFISH_POWERDISTRIBUTION_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWERDISTRIBUTION_V1_0_1_CS *PowerDistribution; +} EFI_REDFISH_POWERDISTRIBUTION_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PowerDistribution/v1_0_2/EfiPowerDistributionV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/PowerDistribution/v1_0_2/EfiPowerDistributionV1_0_2.h new file mode 100644 index 00000000000..ccaca34b462 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PowerDistribution/v1_0_2/EfiPowerDistributionV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PowerDistribution v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWERDISTRIBUTION_V1_0_2_H__ +#define EFI_REDFISH_INTERP_POWERDISTRIBUTION_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/PowerDistribution/v1_0_2/Redfish_PowerDistribution_v1_0_2_CS.h" +// +// EFI structure of Redfish PowerDistribution v1_0_2 +// +typedef struct _EFI_REDFISH_POWERDISTRIBUTION_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWERDISTRIBUTION_V1_0_2_CS *PowerDistribution; +} EFI_REDFISH_POWERDISTRIBUTION_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PowerDistributionCollection/EfiPowerDistributionCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/PowerDistributionCollection/EfiPowerDistributionCollection.h new file mode 100644 index 00000000000..651e1b48871 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PowerDistributionCollection/EfiPowerDistributionCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PowerDistributionCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWERDISTRIBUTIONCOLLECTION_H__ +#define EFI_REDFISH_INTERP_POWERDISTRIBUTIONCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/PowerDistributionCollection/Redfish_PowerDistributionCollection_CS.h" +// +// EFI structure of Redfish PowerDistributionCollection +// +typedef struct _EFI_REDFISH_POWERDISTRIBUTIONCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWERDISTRIBUTIONCOLLECTION_CS *PowerDistributionCollection; +} EFI_REDFISH_POWERDISTRIBUTIONCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PowerDistributionMetrics/v1_0_0/EfiPowerDistributionMetricsV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/PowerDistributionMetrics/v1_0_0/EfiPowerDistributionMetricsV1_0_0.h new file mode 100644 index 00000000000..bcd109f7bd1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PowerDistributionMetrics/v1_0_0/EfiPowerDistributionMetricsV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PowerDistributionMetrics v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWERDISTRIBUTIONMETRICS_V1_0_0_H__ +#define EFI_REDFISH_INTERP_POWERDISTRIBUTIONMETRICS_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/PowerDistributionMetrics/v1_0_0/Redfish_PowerDistributionMetrics_v1_0_0_CS.h" +// +// EFI structure of Redfish PowerDistributionMetrics v1_0_0 +// +typedef struct _EFI_REDFISH_POWERDISTRIBUTIONMETRICS_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWERDISTRIBUTIONMETRICS_V1_0_0_CS *PowerDistributionMetrics; +} EFI_REDFISH_POWERDISTRIBUTIONMETRICS_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PowerDomain/v1_0_0/EfiPowerDomainV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/PowerDomain/v1_0_0/EfiPowerDomainV1_0_0.h new file mode 100644 index 00000000000..052a2e33ec7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PowerDomain/v1_0_0/EfiPowerDomainV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PowerDomain v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWERDOMAIN_V1_0_0_H__ +#define EFI_REDFISH_INTERP_POWERDOMAIN_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/PowerDomain/v1_0_0/Redfish_PowerDomain_v1_0_0_CS.h" +// +// EFI structure of Redfish PowerDomain v1_0_0 +// +typedef struct _EFI_REDFISH_POWERDOMAIN_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWERDOMAIN_V1_0_0_CS *PowerDomain; +} EFI_REDFISH_POWERDOMAIN_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PowerDomain/v1_0_1/EfiPowerDomainV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/PowerDomain/v1_0_1/EfiPowerDomainV1_0_1.h new file mode 100644 index 00000000000..4ab3b93b8ea --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PowerDomain/v1_0_1/EfiPowerDomainV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PowerDomain v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWERDOMAIN_V1_0_1_H__ +#define EFI_REDFISH_INTERP_POWERDOMAIN_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/PowerDomain/v1_0_1/Redfish_PowerDomain_v1_0_1_CS.h" +// +// EFI structure of Redfish PowerDomain v1_0_1 +// +typedef struct _EFI_REDFISH_POWERDOMAIN_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWERDOMAIN_V1_0_1_CS *PowerDomain; +} EFI_REDFISH_POWERDOMAIN_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PowerDomainCollection/EfiPowerDomainCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/PowerDomainCollection/EfiPowerDomainCollection.h new file mode 100644 index 00000000000..642aec7bda5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PowerDomainCollection/EfiPowerDomainCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PowerDomainCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWERDOMAINCOLLECTION_H__ +#define EFI_REDFISH_INTERP_POWERDOMAINCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/PowerDomainCollection/Redfish_PowerDomainCollection_CS.h" +// +// EFI structure of Redfish PowerDomainCollection +// +typedef struct _EFI_REDFISH_POWERDOMAINCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWERDOMAINCOLLECTION_CS *PowerDomainCollection; +} EFI_REDFISH_POWERDOMAINCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PowerEquipment/v1_0_0/EfiPowerEquipmentV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/PowerEquipment/v1_0_0/EfiPowerEquipmentV1_0_0.h new file mode 100644 index 00000000000..2b4d0a93a08 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PowerEquipment/v1_0_0/EfiPowerEquipmentV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PowerEquipment v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWEREQUIPMENT_V1_0_0_H__ +#define EFI_REDFISH_INTERP_POWEREQUIPMENT_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/PowerEquipment/v1_0_0/Redfish_PowerEquipment_v1_0_0_CS.h" +// +// EFI structure of Redfish PowerEquipment v1_0_0 +// +typedef struct _EFI_REDFISH_POWEREQUIPMENT_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWEREQUIPMENT_V1_0_0_CS *PowerEquipment; +} EFI_REDFISH_POWEREQUIPMENT_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PowerSubsystem/v1_0_0/EfiPowerSubsystemV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/PowerSubsystem/v1_0_0/EfiPowerSubsystemV1_0_0.h new file mode 100644 index 00000000000..1bf973b6408 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PowerSubsystem/v1_0_0/EfiPowerSubsystemV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PowerSubsystem v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWERSUBSYSTEM_V1_0_0_H__ +#define EFI_REDFISH_INTERP_POWERSUBSYSTEM_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/PowerSubsystem/v1_0_0/Redfish_PowerSubsystem_v1_0_0_CS.h" +// +// EFI structure of Redfish PowerSubsystem v1_0_0 +// +typedef struct _EFI_REDFISH_POWERSUBSYSTEM_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWERSUBSYSTEM_V1_0_0_CS *PowerSubsystem; +} EFI_REDFISH_POWERSUBSYSTEM_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PowerSupply/v1_0_0/EfiPowerSupplyV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/PowerSupply/v1_0_0/EfiPowerSupplyV1_0_0.h new file mode 100644 index 00000000000..93da5f0b73d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PowerSupply/v1_0_0/EfiPowerSupplyV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PowerSupply v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWERSUPPLY_V1_0_0_H__ +#define EFI_REDFISH_INTERP_POWERSUPPLY_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/PowerSupply/v1_0_0/Redfish_PowerSupply_v1_0_0_CS.h" +// +// EFI structure of Redfish PowerSupply v1_0_0 +// +typedef struct _EFI_REDFISH_POWERSUPPLY_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWERSUPPLY_V1_0_0_CS *PowerSupply; +} EFI_REDFISH_POWERSUPPLY_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PowerSupplyCollection/EfiPowerSupplyCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/PowerSupplyCollection/EfiPowerSupplyCollection.h new file mode 100644 index 00000000000..8dc6b0e7917 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PowerSupplyCollection/EfiPowerSupplyCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PowerSupplyCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWERSUPPLYCOLLECTION_H__ +#define EFI_REDFISH_INTERP_POWERSUPPLYCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/PowerSupplyCollection/Redfish_PowerSupplyCollection_CS.h" +// +// EFI structure of Redfish PowerSupplyCollection +// +typedef struct _EFI_REDFISH_POWERSUPPLYCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWERSUPPLYCOLLECTION_CS *PowerSupplyCollection; +} EFI_REDFISH_POWERSUPPLYCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PowerSupplyMetrics/v1_0_0/EfiPowerSupplyMetricsV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/PowerSupplyMetrics/v1_0_0/EfiPowerSupplyMetricsV1_0_0.h new file mode 100644 index 00000000000..8e50b798e0f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PowerSupplyMetrics/v1_0_0/EfiPowerSupplyMetricsV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PowerSupplyMetrics v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_POWERSUPPLYMETRICS_V1_0_0_H__ +#define EFI_REDFISH_INTERP_POWERSUPPLYMETRICS_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/PowerSupplyMetrics/v1_0_0/Redfish_PowerSupplyMetrics_v1_0_0_CS.h" +// +// EFI structure of Redfish PowerSupplyMetrics v1_0_0 +// +typedef struct _EFI_REDFISH_POWERSUPPLYMETRICS_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_POWERSUPPLYMETRICS_V1_0_0_CS *PowerSupplyMetrics; +} EFI_REDFISH_POWERSUPPLYMETRICS_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_0_0/EfiPrivilegeRegistryV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_0_0/EfiPrivilegeRegistryV1_0_0.h new file mode 100644 index 00000000000..ddce7ddf3f1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_0_0/EfiPrivilegeRegistryV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PrivilegeRegistry v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PRIVILEGEREGISTRY_V1_0_0_H__ +#define EFI_REDFISH_INTERP_PRIVILEGEREGISTRY_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/PrivilegeRegistry/v1_0_0/Redfish_PrivilegeRegistry_v1_0_0_CS.h" +// +// EFI structure of Redfish PrivilegeRegistry v1_0_0 +// +typedef struct _EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_0_CS *PrivilegeRegistry; +} EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_0_1/EfiPrivilegeRegistryV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_0_1/EfiPrivilegeRegistryV1_0_1.h new file mode 100644 index 00000000000..e1927a86e64 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_0_1/EfiPrivilegeRegistryV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PrivilegeRegistry v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PRIVILEGEREGISTRY_V1_0_1_H__ +#define EFI_REDFISH_INTERP_PRIVILEGEREGISTRY_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/PrivilegeRegistry/v1_0_1/Redfish_PrivilegeRegistry_v1_0_1_CS.h" +// +// EFI structure of Redfish PrivilegeRegistry v1_0_1 +// +typedef struct _EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_1_CS *PrivilegeRegistry; +} EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_0_2/EfiPrivilegeRegistryV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_0_2/EfiPrivilegeRegistryV1_0_2.h new file mode 100644 index 00000000000..2a79442f727 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_0_2/EfiPrivilegeRegistryV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PrivilegeRegistry v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PRIVILEGEREGISTRY_V1_0_2_H__ +#define EFI_REDFISH_INTERP_PRIVILEGEREGISTRY_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/PrivilegeRegistry/v1_0_2/Redfish_PrivilegeRegistry_v1_0_2_CS.h" +// +// EFI structure of Redfish PrivilegeRegistry v1_0_2 +// +typedef struct _EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_2_CS *PrivilegeRegistry; +} EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_0_3/EfiPrivilegeRegistryV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_0_3/EfiPrivilegeRegistryV1_0_3.h new file mode 100644 index 00000000000..1501ec0d44c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_0_3/EfiPrivilegeRegistryV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PrivilegeRegistry v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PRIVILEGEREGISTRY_V1_0_3_H__ +#define EFI_REDFISH_INTERP_PRIVILEGEREGISTRY_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/PrivilegeRegistry/v1_0_3/Redfish_PrivilegeRegistry_v1_0_3_CS.h" +// +// EFI structure of Redfish PrivilegeRegistry v1_0_3 +// +typedef struct _EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_3_CS *PrivilegeRegistry; +} EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_0_4/EfiPrivilegeRegistryV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_0_4/EfiPrivilegeRegistryV1_0_4.h new file mode 100644 index 00000000000..d5a909cd5e8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_0_4/EfiPrivilegeRegistryV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PrivilegeRegistry v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PRIVILEGEREGISTRY_V1_0_4_H__ +#define EFI_REDFISH_INTERP_PRIVILEGEREGISTRY_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/PrivilegeRegistry/v1_0_4/Redfish_PrivilegeRegistry_v1_0_4_CS.h" +// +// EFI structure of Redfish PrivilegeRegistry v1_0_4 +// +typedef struct _EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_4_CS *PrivilegeRegistry; +} EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_0_5/EfiPrivilegeRegistryV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_0_5/EfiPrivilegeRegistryV1_0_5.h new file mode 100644 index 00000000000..9bbe331ca86 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_0_5/EfiPrivilegeRegistryV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PrivilegeRegistry v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PRIVILEGEREGISTRY_V1_0_5_H__ +#define EFI_REDFISH_INTERP_PRIVILEGEREGISTRY_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/PrivilegeRegistry/v1_0_5/Redfish_PrivilegeRegistry_v1_0_5_CS.h" +// +// EFI structure of Redfish PrivilegeRegistry v1_0_5 +// +typedef struct _EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_5_CS *PrivilegeRegistry; +} EFI_REDFISH_PRIVILEGEREGISTRY_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_1_0/EfiPrivilegeRegistryV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_1_0/EfiPrivilegeRegistryV1_1_0.h new file mode 100644 index 00000000000..cd244f45f21 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_1_0/EfiPrivilegeRegistryV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PrivilegeRegistry v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PRIVILEGEREGISTRY_V1_1_0_H__ +#define EFI_REDFISH_INTERP_PRIVILEGEREGISTRY_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/PrivilegeRegistry/v1_1_0/Redfish_PrivilegeRegistry_v1_1_0_CS.h" +// +// EFI structure of Redfish PrivilegeRegistry v1_1_0 +// +typedef struct _EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_0_CS *PrivilegeRegistry; +} EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_1_1/EfiPrivilegeRegistryV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_1_1/EfiPrivilegeRegistryV1_1_1.h new file mode 100644 index 00000000000..a65ca77b8c6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_1_1/EfiPrivilegeRegistryV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PrivilegeRegistry v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PRIVILEGEREGISTRY_V1_1_1_H__ +#define EFI_REDFISH_INTERP_PRIVILEGEREGISTRY_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/PrivilegeRegistry/v1_1_1/Redfish_PrivilegeRegistry_v1_1_1_CS.h" +// +// EFI structure of Redfish PrivilegeRegistry v1_1_1 +// +typedef struct _EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_1_CS *PrivilegeRegistry; +} EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_1_2/EfiPrivilegeRegistryV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_1_2/EfiPrivilegeRegistryV1_1_2.h new file mode 100644 index 00000000000..b16fc65d21e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_1_2/EfiPrivilegeRegistryV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PrivilegeRegistry v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PRIVILEGEREGISTRY_V1_1_2_H__ +#define EFI_REDFISH_INTERP_PRIVILEGEREGISTRY_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/PrivilegeRegistry/v1_1_2/Redfish_PrivilegeRegistry_v1_1_2_CS.h" +// +// EFI structure of Redfish PrivilegeRegistry v1_1_2 +// +typedef struct _EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_2_CS *PrivilegeRegistry; +} EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_1_3/EfiPrivilegeRegistryV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_1_3/EfiPrivilegeRegistryV1_1_3.h new file mode 100644 index 00000000000..cc3c8d62661 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_1_3/EfiPrivilegeRegistryV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PrivilegeRegistry v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PRIVILEGEREGISTRY_V1_1_3_H__ +#define EFI_REDFISH_INTERP_PRIVILEGEREGISTRY_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/PrivilegeRegistry/v1_1_3/Redfish_PrivilegeRegistry_v1_1_3_CS.h" +// +// EFI structure of Redfish PrivilegeRegistry v1_1_3 +// +typedef struct _EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_3_CS *PrivilegeRegistry; +} EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_1_4/EfiPrivilegeRegistryV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_1_4/EfiPrivilegeRegistryV1_1_4.h new file mode 100644 index 00000000000..2c2334138db --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/PrivilegeRegistry/v1_1_4/EfiPrivilegeRegistryV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for PrivilegeRegistry v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PRIVILEGEREGISTRY_V1_1_4_H__ +#define EFI_REDFISH_INTERP_PRIVILEGEREGISTRY_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/PrivilegeRegistry/v1_1_4/Redfish_PrivilegeRegistry_v1_1_4_CS.h" +// +// EFI structure of Redfish PrivilegeRegistry v1_1_4 +// +typedef struct _EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_4_CS *PrivilegeRegistry; +} EFI_REDFISH_PRIVILEGEREGISTRY_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_0/EfiProcessorV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_0/EfiProcessorV1_0_0.h new file mode 100644 index 00000000000..45c1857479d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_0/EfiProcessorV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_0_0_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_0_0/Redfish_Processor_v1_0_0_CS.h" +// +// EFI structure of Redfish Processor v1_0_0 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_0_0_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_10/EfiProcessorV1_0_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_10/EfiProcessorV1_0_10.h new file mode 100644 index 00000000000..ddb6404e4a9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_10/EfiProcessorV1_0_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_0_10_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_0_10_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_0_10/Redfish_Processor_v1_0_10_CS.h" +// +// EFI structure of Redfish Processor v1_0_10 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_0_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_0_10_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_0_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_11/EfiProcessorV1_0_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_11/EfiProcessorV1_0_11.h new file mode 100644 index 00000000000..31270ae4005 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_11/EfiProcessorV1_0_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_0_11_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_0_11_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_0_11/Redfish_Processor_v1_0_11_CS.h" +// +// EFI structure of Redfish Processor v1_0_11 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_0_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_0_11_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_0_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_12/EfiProcessorV1_0_12.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_12/EfiProcessorV1_0_12.h new file mode 100644 index 00000000000..8f0a494c5ad --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_12/EfiProcessorV1_0_12.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_0_12 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_0_12_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_0_12_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_0_12/Redfish_Processor_v1_0_12_CS.h" +// +// EFI structure of Redfish Processor v1_0_12 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_0_12 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_0_12_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_0_12; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_2/EfiProcessorV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_2/EfiProcessorV1_0_2.h new file mode 100644 index 00000000000..2d298fa3b5d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_2/EfiProcessorV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_0_2_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_0_2/Redfish_Processor_v1_0_2_CS.h" +// +// EFI structure of Redfish Processor v1_0_2 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_0_2_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_3/EfiProcessorV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_3/EfiProcessorV1_0_3.h new file mode 100644 index 00000000000..f7a5c398a3d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_3/EfiProcessorV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_0_3_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_0_3/Redfish_Processor_v1_0_3_CS.h" +// +// EFI structure of Redfish Processor v1_0_3 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_0_3_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_4/EfiProcessorV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_4/EfiProcessorV1_0_4.h new file mode 100644 index 00000000000..56bde5ec9f7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_4/EfiProcessorV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_0_4_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_0_4/Redfish_Processor_v1_0_4_CS.h" +// +// EFI structure of Redfish Processor v1_0_4 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_0_4_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_5/EfiProcessorV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_5/EfiProcessorV1_0_5.h new file mode 100644 index 00000000000..43cd8ff539c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_5/EfiProcessorV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_0_5_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_0_5/Redfish_Processor_v1_0_5_CS.h" +// +// EFI structure of Redfish Processor v1_0_5 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_0_5_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_6/EfiProcessorV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_6/EfiProcessorV1_0_6.h new file mode 100644 index 00000000000..d5355401b07 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_6/EfiProcessorV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_0_6_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_0_6/Redfish_Processor_v1_0_6_CS.h" +// +// EFI structure of Redfish Processor v1_0_6 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_0_6_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_7/EfiProcessorV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_7/EfiProcessorV1_0_7.h new file mode 100644 index 00000000000..493364f6204 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_7/EfiProcessorV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_0_7_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_0_7/Redfish_Processor_v1_0_7_CS.h" +// +// EFI structure of Redfish Processor v1_0_7 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_0_7_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_8/EfiProcessorV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_8/EfiProcessorV1_0_8.h new file mode 100644 index 00000000000..509246e1d04 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_8/EfiProcessorV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_0_8_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_0_8/Redfish_Processor_v1_0_8_CS.h" +// +// EFI structure of Redfish Processor v1_0_8 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_0_8_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_9/EfiProcessorV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_9/EfiProcessorV1_0_9.h new file mode 100644 index 00000000000..5e61e065b62 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_0_9/EfiProcessorV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_0_9_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_0_9/Redfish_Processor_v1_0_9_CS.h" +// +// EFI structure of Redfish Processor v1_0_9 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_0_9_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_10_0/EfiProcessorV1_10_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_10_0/EfiProcessorV1_10_0.h new file mode 100644 index 00000000000..333b9797175 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_10_0/EfiProcessorV1_10_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_10_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_10_0_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_10_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_10_0/Redfish_Processor_v1_10_0_CS.h" +// +// EFI structure of Redfish Processor v1_10_0 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_10_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_10_0_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_10_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_10_1/EfiProcessorV1_10_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_10_1/EfiProcessorV1_10_1.h new file mode 100644 index 00000000000..759f5bc624f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_10_1/EfiProcessorV1_10_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_10_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_10_1_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_10_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_10_1/Redfish_Processor_v1_10_1_CS.h" +// +// EFI structure of Redfish Processor v1_10_1 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_10_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_10_1_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_10_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_11_0/EfiProcessorV1_11_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_11_0/EfiProcessorV1_11_0.h new file mode 100644 index 00000000000..900da8a6189 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_11_0/EfiProcessorV1_11_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_11_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_11_0_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_11_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_11_0/Redfish_Processor_v1_11_0_CS.h" +// +// EFI structure of Redfish Processor v1_11_0 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_11_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_11_0_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_11_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_0/EfiProcessorV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_0/EfiProcessorV1_1_0.h new file mode 100644 index 00000000000..580cd1a5878 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_0/EfiProcessorV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_1_0_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_1_0/Redfish_Processor_v1_1_0_CS.h" +// +// EFI structure of Redfish Processor v1_1_0 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_1_0_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_1/EfiProcessorV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_1/EfiProcessorV1_1_1.h new file mode 100644 index 00000000000..ce033602c9e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_1/EfiProcessorV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_1_1_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_1_1/Redfish_Processor_v1_1_1_CS.h" +// +// EFI structure of Redfish Processor v1_1_1 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_1_1_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_2/EfiProcessorV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_2/EfiProcessorV1_1_2.h new file mode 100644 index 00000000000..38304307ff9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_2/EfiProcessorV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_1_2_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_1_2/Redfish_Processor_v1_1_2_CS.h" +// +// EFI structure of Redfish Processor v1_1_2 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_1_2_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_3/EfiProcessorV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_3/EfiProcessorV1_1_3.h new file mode 100644 index 00000000000..31a89b9d55f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_3/EfiProcessorV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_1_3_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_1_3/Redfish_Processor_v1_1_3_CS.h" +// +// EFI structure of Redfish Processor v1_1_3 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_1_3_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_4/EfiProcessorV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_4/EfiProcessorV1_1_4.h new file mode 100644 index 00000000000..9d9093498c5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_4/EfiProcessorV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_1_4_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_1_4/Redfish_Processor_v1_1_4_CS.h" +// +// EFI structure of Redfish Processor v1_1_4 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_1_4_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_5/EfiProcessorV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_5/EfiProcessorV1_1_5.h new file mode 100644 index 00000000000..c148100b8d1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_5/EfiProcessorV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_1_5_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_1_5/Redfish_Processor_v1_1_5_CS.h" +// +// EFI structure of Redfish Processor v1_1_5 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_1_5_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_6/EfiProcessorV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_6/EfiProcessorV1_1_6.h new file mode 100644 index 00000000000..9009eba346d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_6/EfiProcessorV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_1_6_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_1_6/Redfish_Processor_v1_1_6_CS.h" +// +// EFI structure of Redfish Processor v1_1_6 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_1_6_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_7/EfiProcessorV1_1_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_7/EfiProcessorV1_1_7.h new file mode 100644 index 00000000000..526720dfe3d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_7/EfiProcessorV1_1_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_1_7_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_1_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_1_7/Redfish_Processor_v1_1_7_CS.h" +// +// EFI structure of Redfish Processor v1_1_7 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_1_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_1_7_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_1_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_8/EfiProcessorV1_1_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_8/EfiProcessorV1_1_8.h new file mode 100644 index 00000000000..e3bc7958478 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_1_8/EfiProcessorV1_1_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_1_8_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_1_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_1_8/Redfish_Processor_v1_1_8_CS.h" +// +// EFI structure of Redfish Processor v1_1_8 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_1_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_1_8_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_1_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_0/EfiProcessorV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_0/EfiProcessorV1_2_0.h new file mode 100644 index 00000000000..e322056b484 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_0/EfiProcessorV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_2_0_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_2_0/Redfish_Processor_v1_2_0_CS.h" +// +// EFI structure of Redfish Processor v1_2_0 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_2_0_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_1/EfiProcessorV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_1/EfiProcessorV1_2_1.h new file mode 100644 index 00000000000..b57ff7ed555 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_1/EfiProcessorV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_2_1_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_2_1/Redfish_Processor_v1_2_1_CS.h" +// +// EFI structure of Redfish Processor v1_2_1 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_2_1_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_2/EfiProcessorV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_2/EfiProcessorV1_2_2.h new file mode 100644 index 00000000000..6e7c19aa2b9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_2/EfiProcessorV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_2_2_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_2_2/Redfish_Processor_v1_2_2_CS.h" +// +// EFI structure of Redfish Processor v1_2_2 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_2_2_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_3/EfiProcessorV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_3/EfiProcessorV1_2_3.h new file mode 100644 index 00000000000..a5b5a4362cc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_3/EfiProcessorV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_2_3_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_2_3/Redfish_Processor_v1_2_3_CS.h" +// +// EFI structure of Redfish Processor v1_2_3 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_2_3_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_4/EfiProcessorV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_4/EfiProcessorV1_2_4.h new file mode 100644 index 00000000000..e37cff2a61c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_4/EfiProcessorV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_2_4_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_2_4/Redfish_Processor_v1_2_4_CS.h" +// +// EFI structure of Redfish Processor v1_2_4 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_2_4_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_5/EfiProcessorV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_5/EfiProcessorV1_2_5.h new file mode 100644 index 00000000000..06713d8826c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_5/EfiProcessorV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_2_5_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_2_5/Redfish_Processor_v1_2_5_CS.h" +// +// EFI structure of Redfish Processor v1_2_5 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_2_5_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_6/EfiProcessorV1_2_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_6/EfiProcessorV1_2_6.h new file mode 100644 index 00000000000..92986b2ef93 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_6/EfiProcessorV1_2_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_2_6_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_2_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_2_6/Redfish_Processor_v1_2_6_CS.h" +// +// EFI structure of Redfish Processor v1_2_6 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_2_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_2_6_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_2_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_7/EfiProcessorV1_2_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_7/EfiProcessorV1_2_7.h new file mode 100644 index 00000000000..6cc4994f357 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_7/EfiProcessorV1_2_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_2_7_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_2_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_2_7/Redfish_Processor_v1_2_7_CS.h" +// +// EFI structure of Redfish Processor v1_2_7 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_2_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_2_7_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_2_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_8/EfiProcessorV1_2_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_8/EfiProcessorV1_2_8.h new file mode 100644 index 00000000000..c24dc5bf1f7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_2_8/EfiProcessorV1_2_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_2_8_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_2_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_2_8/Redfish_Processor_v1_2_8_CS.h" +// +// EFI structure of Redfish Processor v1_2_8 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_2_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_2_8_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_2_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_0/EfiProcessorV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_0/EfiProcessorV1_3_0.h new file mode 100644 index 00000000000..4a66bbabcfe --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_0/EfiProcessorV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_3_0_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_3_0/Redfish_Processor_v1_3_0_CS.h" +// +// EFI structure of Redfish Processor v1_3_0 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_3_0_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_1/EfiProcessorV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_1/EfiProcessorV1_3_1.h new file mode 100644 index 00000000000..6375bd26e67 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_1/EfiProcessorV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_3_1_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_3_1/Redfish_Processor_v1_3_1_CS.h" +// +// EFI structure of Redfish Processor v1_3_1 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_3_1_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_2/EfiProcessorV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_2/EfiProcessorV1_3_2.h new file mode 100644 index 00000000000..1b26c03eb61 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_2/EfiProcessorV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_3_2_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_3_2/Redfish_Processor_v1_3_2_CS.h" +// +// EFI structure of Redfish Processor v1_3_2 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_3_2_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_3/EfiProcessorV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_3/EfiProcessorV1_3_3.h new file mode 100644 index 00000000000..2efa639e5dd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_3/EfiProcessorV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_3_3_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_3_3/Redfish_Processor_v1_3_3_CS.h" +// +// EFI structure of Redfish Processor v1_3_3 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_3_3_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_4/EfiProcessorV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_4/EfiProcessorV1_3_4.h new file mode 100644 index 00000000000..fb6dafbb02d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_4/EfiProcessorV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_3_4_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_3_4/Redfish_Processor_v1_3_4_CS.h" +// +// EFI structure of Redfish Processor v1_3_4 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_3_4_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_5/EfiProcessorV1_3_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_5/EfiProcessorV1_3_5.h new file mode 100644 index 00000000000..b914cbae94d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_5/EfiProcessorV1_3_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_3_5_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_3_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_3_5/Redfish_Processor_v1_3_5_CS.h" +// +// EFI structure of Redfish Processor v1_3_5 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_3_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_3_5_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_3_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_6/EfiProcessorV1_3_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_6/EfiProcessorV1_3_6.h new file mode 100644 index 00000000000..3b131c24845 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_6/EfiProcessorV1_3_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_3_6_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_3_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_3_6/Redfish_Processor_v1_3_6_CS.h" +// +// EFI structure of Redfish Processor v1_3_6 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_3_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_3_6_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_3_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_7/EfiProcessorV1_3_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_7/EfiProcessorV1_3_7.h new file mode 100644 index 00000000000..7f9bd506b6e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_7/EfiProcessorV1_3_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_3_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_3_7_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_3_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_3_7/Redfish_Processor_v1_3_7_CS.h" +// +// EFI structure of Redfish Processor v1_3_7 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_3_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_3_7_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_3_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_8/EfiProcessorV1_3_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_8/EfiProcessorV1_3_8.h new file mode 100644 index 00000000000..4f39ccc56c4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_3_8/EfiProcessorV1_3_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_3_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_3_8_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_3_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_3_8/Redfish_Processor_v1_3_8_CS.h" +// +// EFI structure of Redfish Processor v1_3_8 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_3_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_3_8_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_3_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_0/EfiProcessorV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_0/EfiProcessorV1_4_0.h new file mode 100644 index 00000000000..60106047fcf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_0/EfiProcessorV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_4_0_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_4_0/Redfish_Processor_v1_4_0_CS.h" +// +// EFI structure of Redfish Processor v1_4_0 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_4_0_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_1/EfiProcessorV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_1/EfiProcessorV1_4_1.h new file mode 100644 index 00000000000..f301dc49c4f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_1/EfiProcessorV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_4_1_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_4_1/Redfish_Processor_v1_4_1_CS.h" +// +// EFI structure of Redfish Processor v1_4_1 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_4_1_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_2/EfiProcessorV1_4_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_2/EfiProcessorV1_4_2.h new file mode 100644 index 00000000000..f46e4951153 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_2/EfiProcessorV1_4_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_4_2_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_4_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_4_2/Redfish_Processor_v1_4_2_CS.h" +// +// EFI structure of Redfish Processor v1_4_2 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_4_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_4_2_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_4_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_3/EfiProcessorV1_4_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_3/EfiProcessorV1_4_3.h new file mode 100644 index 00000000000..f2a926b8deb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_3/EfiProcessorV1_4_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_4_3_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_4_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_4_3/Redfish_Processor_v1_4_3_CS.h" +// +// EFI structure of Redfish Processor v1_4_3 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_4_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_4_3_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_4_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_4/EfiProcessorV1_4_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_4/EfiProcessorV1_4_4.h new file mode 100644 index 00000000000..67c3902c404 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_4/EfiProcessorV1_4_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_4_4_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_4_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_4_4/Redfish_Processor_v1_4_4_CS.h" +// +// EFI structure of Redfish Processor v1_4_4 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_4_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_4_4_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_4_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_5/EfiProcessorV1_4_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_5/EfiProcessorV1_4_5.h new file mode 100644 index 00000000000..f6e18c6cacf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_5/EfiProcessorV1_4_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_4_5_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_4_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_4_5/Redfish_Processor_v1_4_5_CS.h" +// +// EFI structure of Redfish Processor v1_4_5 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_4_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_4_5_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_4_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_6/EfiProcessorV1_4_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_6/EfiProcessorV1_4_6.h new file mode 100644 index 00000000000..646ec224f6d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_6/EfiProcessorV1_4_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_4_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_4_6_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_4_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_4_6/Redfish_Processor_v1_4_6_CS.h" +// +// EFI structure of Redfish Processor v1_4_6 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_4_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_4_6_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_4_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_7/EfiProcessorV1_4_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_7/EfiProcessorV1_4_7.h new file mode 100644 index 00000000000..a0e45ea8ea5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_4_7/EfiProcessorV1_4_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_4_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_4_7_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_4_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_4_7/Redfish_Processor_v1_4_7_CS.h" +// +// EFI structure of Redfish Processor v1_4_7 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_4_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_4_7_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_4_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_0/EfiProcessorV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_0/EfiProcessorV1_5_0.h new file mode 100644 index 00000000000..a4b7fc089d3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_0/EfiProcessorV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_5_0_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_5_0/Redfish_Processor_v1_5_0_CS.h" +// +// EFI structure of Redfish Processor v1_5_0 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_5_0_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_1/EfiProcessorV1_5_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_1/EfiProcessorV1_5_1.h new file mode 100644 index 00000000000..33abaa36d4f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_1/EfiProcessorV1_5_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_5_1_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_5_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_5_1/Redfish_Processor_v1_5_1_CS.h" +// +// EFI structure of Redfish Processor v1_5_1 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_5_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_5_1_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_5_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_2/EfiProcessorV1_5_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_2/EfiProcessorV1_5_2.h new file mode 100644 index 00000000000..ae9f0e1f746 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_2/EfiProcessorV1_5_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_5_2_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_5_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_5_2/Redfish_Processor_v1_5_2_CS.h" +// +// EFI structure of Redfish Processor v1_5_2 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_5_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_5_2_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_5_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_3/EfiProcessorV1_5_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_3/EfiProcessorV1_5_3.h new file mode 100644 index 00000000000..c1c68cd0e0f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_3/EfiProcessorV1_5_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_5_3_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_5_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_5_3/Redfish_Processor_v1_5_3_CS.h" +// +// EFI structure of Redfish Processor v1_5_3 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_5_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_5_3_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_5_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_4/EfiProcessorV1_5_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_4/EfiProcessorV1_5_4.h new file mode 100644 index 00000000000..a8a2d0a4b60 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_4/EfiProcessorV1_5_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_5_4_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_5_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_5_4/Redfish_Processor_v1_5_4_CS.h" +// +// EFI structure of Redfish Processor v1_5_4 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_5_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_5_4_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_5_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_5/EfiProcessorV1_5_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_5/EfiProcessorV1_5_5.h new file mode 100644 index 00000000000..0019c2c9c55 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_5/EfiProcessorV1_5_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_5_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_5_5_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_5_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_5_5/Redfish_Processor_v1_5_5_CS.h" +// +// EFI structure of Redfish Processor v1_5_5 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_5_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_5_5_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_5_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_6/EfiProcessorV1_5_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_6/EfiProcessorV1_5_6.h new file mode 100644 index 00000000000..9b1e2c6a410 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_5_6/EfiProcessorV1_5_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_5_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_5_6_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_5_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_5_6/Redfish_Processor_v1_5_6_CS.h" +// +// EFI structure of Redfish Processor v1_5_6 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_5_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_5_6_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_5_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_6_0/EfiProcessorV1_6_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_6_0/EfiProcessorV1_6_0.h new file mode 100644 index 00000000000..7394ba1dd66 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_6_0/EfiProcessorV1_6_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_6_0_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_6_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_6_0/Redfish_Processor_v1_6_0_CS.h" +// +// EFI structure of Redfish Processor v1_6_0 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_6_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_6_0_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_6_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_6_1/EfiProcessorV1_6_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_6_1/EfiProcessorV1_6_1.h new file mode 100644 index 00000000000..9a32c27aaf3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_6_1/EfiProcessorV1_6_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_6_1_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_6_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_6_1/Redfish_Processor_v1_6_1_CS.h" +// +// EFI structure of Redfish Processor v1_6_1 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_6_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_6_1_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_6_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_6_2/EfiProcessorV1_6_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_6_2/EfiProcessorV1_6_2.h new file mode 100644 index 00000000000..9b1cf7305ea --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_6_2/EfiProcessorV1_6_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_6_2_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_6_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_6_2/Redfish_Processor_v1_6_2_CS.h" +// +// EFI structure of Redfish Processor v1_6_2 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_6_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_6_2_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_6_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_6_3/EfiProcessorV1_6_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_6_3/EfiProcessorV1_6_3.h new file mode 100644 index 00000000000..e2ae0cc83b3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_6_3/EfiProcessorV1_6_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_6_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_6_3_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_6_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_6_3/Redfish_Processor_v1_6_3_CS.h" +// +// EFI structure of Redfish Processor v1_6_3 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_6_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_6_3_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_6_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_6_4/EfiProcessorV1_6_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_6_4/EfiProcessorV1_6_4.h new file mode 100644 index 00000000000..a965a6dd634 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_6_4/EfiProcessorV1_6_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_6_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_6_4_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_6_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_6_4/Redfish_Processor_v1_6_4_CS.h" +// +// EFI structure of Redfish Processor v1_6_4 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_6_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_6_4_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_6_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_7_0/EfiProcessorV1_7_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_7_0/EfiProcessorV1_7_0.h new file mode 100644 index 00000000000..bd44bf59a16 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_7_0/EfiProcessorV1_7_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_7_0_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_7_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_7_0/Redfish_Processor_v1_7_0_CS.h" +// +// EFI structure of Redfish Processor v1_7_0 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_7_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_7_0_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_7_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_7_1/EfiProcessorV1_7_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_7_1/EfiProcessorV1_7_1.h new file mode 100644 index 00000000000..fd75db13584 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_7_1/EfiProcessorV1_7_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_7_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_7_1_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_7_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_7_1/Redfish_Processor_v1_7_1_CS.h" +// +// EFI structure of Redfish Processor v1_7_1 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_7_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_7_1_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_7_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_7_2/EfiProcessorV1_7_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_7_2/EfiProcessorV1_7_2.h new file mode 100644 index 00000000000..9cb802768cb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_7_2/EfiProcessorV1_7_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_7_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_7_2_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_7_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_7_2/Redfish_Processor_v1_7_2_CS.h" +// +// EFI structure of Redfish Processor v1_7_2 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_7_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_7_2_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_7_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_7_3/EfiProcessorV1_7_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_7_3/EfiProcessorV1_7_3.h new file mode 100644 index 00000000000..1a83cbec39d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_7_3/EfiProcessorV1_7_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_7_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_7_3_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_7_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_7_3/Redfish_Processor_v1_7_3_CS.h" +// +// EFI structure of Redfish Processor v1_7_3 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_7_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_7_3_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_7_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_8_0/EfiProcessorV1_8_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_8_0/EfiProcessorV1_8_0.h new file mode 100644 index 00000000000..a811914bdb4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_8_0/EfiProcessorV1_8_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_8_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_8_0_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_8_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_8_0/Redfish_Processor_v1_8_0_CS.h" +// +// EFI structure of Redfish Processor v1_8_0 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_8_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_8_0_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_8_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_8_1/EfiProcessorV1_8_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_8_1/EfiProcessorV1_8_1.h new file mode 100644 index 00000000000..9a81d643c2b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_8_1/EfiProcessorV1_8_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_8_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_8_1_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_8_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_8_1/Redfish_Processor_v1_8_1_CS.h" +// +// EFI structure of Redfish Processor v1_8_1 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_8_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_8_1_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_8_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_8_2/EfiProcessorV1_8_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_8_2/EfiProcessorV1_8_2.h new file mode 100644 index 00000000000..b837f6c0b74 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_8_2/EfiProcessorV1_8_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_8_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_8_2_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_8_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_8_2/Redfish_Processor_v1_8_2_CS.h" +// +// EFI structure of Redfish Processor v1_8_2 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_8_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_8_2_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_8_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_9_0/EfiProcessorV1_9_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_9_0/EfiProcessorV1_9_0.h new file mode 100644 index 00000000000..0dfc25a2cc0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_9_0/EfiProcessorV1_9_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_9_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_9_0_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_9_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_9_0/Redfish_Processor_v1_9_0_CS.h" +// +// EFI structure of Redfish Processor v1_9_0 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_9_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_9_0_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_9_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_9_1/EfiProcessorV1_9_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_9_1/EfiProcessorV1_9_1.h new file mode 100644 index 00000000000..adbddb74cf4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Processor/v1_9_1/EfiProcessorV1_9_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Processor v1_9_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSOR_V1_9_1_H__ +#define EFI_REDFISH_INTERP_PROCESSOR_V1_9_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Processor/v1_9_1/Redfish_Processor_v1_9_1_CS.h" +// +// EFI structure of Redfish Processor v1_9_1 +// +typedef struct _EFI_REDFISH_PROCESSOR_V1_9_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSOR_V1_9_1_CS *Processor; +} EFI_REDFISH_PROCESSOR_V1_9_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorCollection/EfiProcessorCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorCollection/EfiProcessorCollection.h new file mode 100644 index 00000000000..a26c5e4a1c4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorCollection/EfiProcessorCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ProcessorCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSORCOLLECTION_H__ +#define EFI_REDFISH_INTERP_PROCESSORCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/ProcessorCollection/Redfish_ProcessorCollection_CS.h" +// +// EFI structure of Redfish ProcessorCollection +// +typedef struct _EFI_REDFISH_PROCESSORCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSORCOLLECTION_CS *ProcessorCollection; +} EFI_REDFISH_PROCESSORCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_0_0/EfiProcessorMetricsV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_0_0/EfiProcessorMetricsV1_0_0.h new file mode 100644 index 00000000000..73b5a799e08 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_0_0/EfiProcessorMetricsV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ProcessorMetrics v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSORMETRICS_V1_0_0_H__ +#define EFI_REDFISH_INTERP_PROCESSORMETRICS_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ProcessorMetrics/v1_0_0/Redfish_ProcessorMetrics_v1_0_0_CS.h" +// +// EFI structure of Redfish ProcessorMetrics v1_0_0 +// +typedef struct _EFI_REDFISH_PROCESSORMETRICS_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSORMETRICS_V1_0_0_CS *ProcessorMetrics; +} EFI_REDFISH_PROCESSORMETRICS_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_0_1/EfiProcessorMetricsV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_0_1/EfiProcessorMetricsV1_0_1.h new file mode 100644 index 00000000000..e30ac4d503b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_0_1/EfiProcessorMetricsV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ProcessorMetrics v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSORMETRICS_V1_0_1_H__ +#define EFI_REDFISH_INTERP_PROCESSORMETRICS_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ProcessorMetrics/v1_0_1/Redfish_ProcessorMetrics_v1_0_1_CS.h" +// +// EFI structure of Redfish ProcessorMetrics v1_0_1 +// +typedef struct _EFI_REDFISH_PROCESSORMETRICS_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSORMETRICS_V1_0_1_CS *ProcessorMetrics; +} EFI_REDFISH_PROCESSORMETRICS_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_0_2/EfiProcessorMetricsV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_0_2/EfiProcessorMetricsV1_0_2.h new file mode 100644 index 00000000000..e2f589e2803 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_0_2/EfiProcessorMetricsV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ProcessorMetrics v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSORMETRICS_V1_0_2_H__ +#define EFI_REDFISH_INTERP_PROCESSORMETRICS_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ProcessorMetrics/v1_0_2/Redfish_ProcessorMetrics_v1_0_2_CS.h" +// +// EFI structure of Redfish ProcessorMetrics v1_0_2 +// +typedef struct _EFI_REDFISH_PROCESSORMETRICS_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSORMETRICS_V1_0_2_CS *ProcessorMetrics; +} EFI_REDFISH_PROCESSORMETRICS_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_0_3/EfiProcessorMetricsV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_0_3/EfiProcessorMetricsV1_0_3.h new file mode 100644 index 00000000000..08985c1ba66 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_0_3/EfiProcessorMetricsV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ProcessorMetrics v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSORMETRICS_V1_0_3_H__ +#define EFI_REDFISH_INTERP_PROCESSORMETRICS_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ProcessorMetrics/v1_0_3/Redfish_ProcessorMetrics_v1_0_3_CS.h" +// +// EFI structure of Redfish ProcessorMetrics v1_0_3 +// +typedef struct _EFI_REDFISH_PROCESSORMETRICS_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSORMETRICS_V1_0_3_CS *ProcessorMetrics; +} EFI_REDFISH_PROCESSORMETRICS_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_0_4/EfiProcessorMetricsV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_0_4/EfiProcessorMetricsV1_0_4.h new file mode 100644 index 00000000000..113a1a33f8c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_0_4/EfiProcessorMetricsV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ProcessorMetrics v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSORMETRICS_V1_0_4_H__ +#define EFI_REDFISH_INTERP_PROCESSORMETRICS_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ProcessorMetrics/v1_0_4/Redfish_ProcessorMetrics_v1_0_4_CS.h" +// +// EFI structure of Redfish ProcessorMetrics v1_0_4 +// +typedef struct _EFI_REDFISH_PROCESSORMETRICS_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSORMETRICS_V1_0_4_CS *ProcessorMetrics; +} EFI_REDFISH_PROCESSORMETRICS_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_1_0/EfiProcessorMetricsV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_1_0/EfiProcessorMetricsV1_1_0.h new file mode 100644 index 00000000000..b630ff23260 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_1_0/EfiProcessorMetricsV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ProcessorMetrics v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSORMETRICS_V1_1_0_H__ +#define EFI_REDFISH_INTERP_PROCESSORMETRICS_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ProcessorMetrics/v1_1_0/Redfish_ProcessorMetrics_v1_1_0_CS.h" +// +// EFI structure of Redfish ProcessorMetrics v1_1_0 +// +typedef struct _EFI_REDFISH_PROCESSORMETRICS_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSORMETRICS_V1_1_0_CS *ProcessorMetrics; +} EFI_REDFISH_PROCESSORMETRICS_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_1_1/EfiProcessorMetricsV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_1_1/EfiProcessorMetricsV1_1_1.h new file mode 100644 index 00000000000..906208984ce --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_1_1/EfiProcessorMetricsV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ProcessorMetrics v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSORMETRICS_V1_1_1_H__ +#define EFI_REDFISH_INTERP_PROCESSORMETRICS_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ProcessorMetrics/v1_1_1/Redfish_ProcessorMetrics_v1_1_1_CS.h" +// +// EFI structure of Redfish ProcessorMetrics v1_1_1 +// +typedef struct _EFI_REDFISH_PROCESSORMETRICS_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSORMETRICS_V1_1_1_CS *ProcessorMetrics; +} EFI_REDFISH_PROCESSORMETRICS_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_1_2/EfiProcessorMetricsV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_1_2/EfiProcessorMetricsV1_1_2.h new file mode 100644 index 00000000000..25f97284f6e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_1_2/EfiProcessorMetricsV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ProcessorMetrics v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSORMETRICS_V1_1_2_H__ +#define EFI_REDFISH_INTERP_PROCESSORMETRICS_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ProcessorMetrics/v1_1_2/Redfish_ProcessorMetrics_v1_1_2_CS.h" +// +// EFI structure of Redfish ProcessorMetrics v1_1_2 +// +typedef struct _EFI_REDFISH_PROCESSORMETRICS_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSORMETRICS_V1_1_2_CS *ProcessorMetrics; +} EFI_REDFISH_PROCESSORMETRICS_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_2_0/EfiProcessorMetricsV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_2_0/EfiProcessorMetricsV1_2_0.h new file mode 100644 index 00000000000..1ececdac383 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ProcessorMetrics/v1_2_0/EfiProcessorMetricsV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ProcessorMetrics v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_PROCESSORMETRICS_V1_2_0_H__ +#define EFI_REDFISH_INTERP_PROCESSORMETRICS_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ProcessorMetrics/v1_2_0/Redfish_ProcessorMetrics_v1_2_0_CS.h" +// +// EFI structure of Redfish ProcessorMetrics v1_2_0 +// +typedef struct _EFI_REDFISH_PROCESSORMETRICS_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_PROCESSORMETRICS_V1_2_0_CS *ProcessorMetrics; +} EFI_REDFISH_PROCESSORMETRICS_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_0/EfiResourceBlockV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_0/EfiResourceBlockV1_0_0.h new file mode 100644 index 00000000000..a53c24d6981 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_0/EfiResourceBlockV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlock v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_0_0_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlock/v1_0_0/Redfish_ResourceBlock_v1_0_0_CS.h" +// +// EFI structure of Redfish ResourceBlock v1_0_0 +// +typedef struct _EFI_REDFISH_RESOURCEBLOCK_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCK_V1_0_0_CS *ResourceBlock; +} EFI_REDFISH_RESOURCEBLOCK_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_1/EfiResourceBlockV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_1/EfiResourceBlockV1_0_1.h new file mode 100644 index 00000000000..54ee97490ad --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_1/EfiResourceBlockV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlock v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_0_1_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlock/v1_0_1/Redfish_ResourceBlock_v1_0_1_CS.h" +// +// EFI structure of Redfish ResourceBlock v1_0_1 +// +typedef struct _EFI_REDFISH_RESOURCEBLOCK_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCK_V1_0_1_CS *ResourceBlock; +} EFI_REDFISH_RESOURCEBLOCK_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_2/EfiResourceBlockV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_2/EfiResourceBlockV1_0_2.h new file mode 100644 index 00000000000..614dd491aaa --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_2/EfiResourceBlockV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlock v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_0_2_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlock/v1_0_2/Redfish_ResourceBlock_v1_0_2_CS.h" +// +// EFI structure of Redfish ResourceBlock v1_0_2 +// +typedef struct _EFI_REDFISH_RESOURCEBLOCK_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCK_V1_0_2_CS *ResourceBlock; +} EFI_REDFISH_RESOURCEBLOCK_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_3/EfiResourceBlockV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_3/EfiResourceBlockV1_0_3.h new file mode 100644 index 00000000000..7ba2da030a7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_3/EfiResourceBlockV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlock v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_0_3_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlock/v1_0_3/Redfish_ResourceBlock_v1_0_3_CS.h" +// +// EFI structure of Redfish ResourceBlock v1_0_3 +// +typedef struct _EFI_REDFISH_RESOURCEBLOCK_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCK_V1_0_3_CS *ResourceBlock; +} EFI_REDFISH_RESOURCEBLOCK_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_4/EfiResourceBlockV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_4/EfiResourceBlockV1_0_4.h new file mode 100644 index 00000000000..fb60276dd77 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_4/EfiResourceBlockV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlock v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_0_4_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlock/v1_0_4/Redfish_ResourceBlock_v1_0_4_CS.h" +// +// EFI structure of Redfish ResourceBlock v1_0_4 +// +typedef struct _EFI_REDFISH_RESOURCEBLOCK_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCK_V1_0_4_CS *ResourceBlock; +} EFI_REDFISH_RESOURCEBLOCK_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_5/EfiResourceBlockV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_5/EfiResourceBlockV1_0_5.h new file mode 100644 index 00000000000..bc4fed34bf0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_5/EfiResourceBlockV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlock v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_0_5_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlock/v1_0_5/Redfish_ResourceBlock_v1_0_5_CS.h" +// +// EFI structure of Redfish ResourceBlock v1_0_5 +// +typedef struct _EFI_REDFISH_RESOURCEBLOCK_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCK_V1_0_5_CS *ResourceBlock; +} EFI_REDFISH_RESOURCEBLOCK_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_6/EfiResourceBlockV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_6/EfiResourceBlockV1_0_6.h new file mode 100644 index 00000000000..29c571f3b2e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_0_6/EfiResourceBlockV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlock v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_0_6_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlock/v1_0_6/Redfish_ResourceBlock_v1_0_6_CS.h" +// +// EFI structure of Redfish ResourceBlock v1_0_6 +// +typedef struct _EFI_REDFISH_RESOURCEBLOCK_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCK_V1_0_6_CS *ResourceBlock; +} EFI_REDFISH_RESOURCEBLOCK_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_0/EfiResourceBlockV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_0/EfiResourceBlockV1_1_0.h new file mode 100644 index 00000000000..11728678233 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_0/EfiResourceBlockV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlock v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_1_0_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlock/v1_1_0/Redfish_ResourceBlock_v1_1_0_CS.h" +// +// EFI structure of Redfish ResourceBlock v1_1_0 +// +typedef struct _EFI_REDFISH_RESOURCEBLOCK_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCK_V1_1_0_CS *ResourceBlock; +} EFI_REDFISH_RESOURCEBLOCK_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_1/EfiResourceBlockV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_1/EfiResourceBlockV1_1_1.h new file mode 100644 index 00000000000..4181e04ba37 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_1/EfiResourceBlockV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlock v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_1_1_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlock/v1_1_1/Redfish_ResourceBlock_v1_1_1_CS.h" +// +// EFI structure of Redfish ResourceBlock v1_1_1 +// +typedef struct _EFI_REDFISH_RESOURCEBLOCK_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCK_V1_1_1_CS *ResourceBlock; +} EFI_REDFISH_RESOURCEBLOCK_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_2/EfiResourceBlockV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_2/EfiResourceBlockV1_1_2.h new file mode 100644 index 00000000000..3faead82ea3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_2/EfiResourceBlockV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlock v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_1_2_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlock/v1_1_2/Redfish_ResourceBlock_v1_1_2_CS.h" +// +// EFI structure of Redfish ResourceBlock v1_1_2 +// +typedef struct _EFI_REDFISH_RESOURCEBLOCK_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCK_V1_1_2_CS *ResourceBlock; +} EFI_REDFISH_RESOURCEBLOCK_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_3/EfiResourceBlockV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_3/EfiResourceBlockV1_1_3.h new file mode 100644 index 00000000000..fecd752a70c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_3/EfiResourceBlockV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlock v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_1_3_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlock/v1_1_3/Redfish_ResourceBlock_v1_1_3_CS.h" +// +// EFI structure of Redfish ResourceBlock v1_1_3 +// +typedef struct _EFI_REDFISH_RESOURCEBLOCK_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCK_V1_1_3_CS *ResourceBlock; +} EFI_REDFISH_RESOURCEBLOCK_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_4/EfiResourceBlockV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_4/EfiResourceBlockV1_1_4.h new file mode 100644 index 00000000000..48518a0f055 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_4/EfiResourceBlockV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlock v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_1_4_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlock/v1_1_4/Redfish_ResourceBlock_v1_1_4_CS.h" +// +// EFI structure of Redfish ResourceBlock v1_1_4 +// +typedef struct _EFI_REDFISH_RESOURCEBLOCK_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCK_V1_1_4_CS *ResourceBlock; +} EFI_REDFISH_RESOURCEBLOCK_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_5/EfiResourceBlockV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_5/EfiResourceBlockV1_1_5.h new file mode 100644 index 00000000000..327d9f7e1b7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_5/EfiResourceBlockV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlock v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_1_5_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlock/v1_1_5/Redfish_ResourceBlock_v1_1_5_CS.h" +// +// EFI structure of Redfish ResourceBlock v1_1_5 +// +typedef struct _EFI_REDFISH_RESOURCEBLOCK_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCK_V1_1_5_CS *ResourceBlock; +} EFI_REDFISH_RESOURCEBLOCK_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_6/EfiResourceBlockV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_6/EfiResourceBlockV1_1_6.h new file mode 100644 index 00000000000..eb25b505bc5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_1_6/EfiResourceBlockV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlock v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_1_6_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlock/v1_1_6/Redfish_ResourceBlock_v1_1_6_CS.h" +// +// EFI structure of Redfish ResourceBlock v1_1_6 +// +typedef struct _EFI_REDFISH_RESOURCEBLOCK_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCK_V1_1_6_CS *ResourceBlock; +} EFI_REDFISH_RESOURCEBLOCK_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_2_0/EfiResourceBlockV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_2_0/EfiResourceBlockV1_2_0.h new file mode 100644 index 00000000000..4e787196e1e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_2_0/EfiResourceBlockV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlock v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_2_0_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlock/v1_2_0/Redfish_ResourceBlock_v1_2_0_CS.h" +// +// EFI structure of Redfish ResourceBlock v1_2_0 +// +typedef struct _EFI_REDFISH_RESOURCEBLOCK_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCK_V1_2_0_CS *ResourceBlock; +} EFI_REDFISH_RESOURCEBLOCK_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_2_1/EfiResourceBlockV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_2_1/EfiResourceBlockV1_2_1.h new file mode 100644 index 00000000000..040f365dc5c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_2_1/EfiResourceBlockV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlock v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_2_1_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlock/v1_2_1/Redfish_ResourceBlock_v1_2_1_CS.h" +// +// EFI structure of Redfish ResourceBlock v1_2_1 +// +typedef struct _EFI_REDFISH_RESOURCEBLOCK_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCK_V1_2_1_CS *ResourceBlock; +} EFI_REDFISH_RESOURCEBLOCK_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_2_2/EfiResourceBlockV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_2_2/EfiResourceBlockV1_2_2.h new file mode 100644 index 00000000000..e946e0c5b99 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_2_2/EfiResourceBlockV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlock v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_2_2_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlock/v1_2_2/Redfish_ResourceBlock_v1_2_2_CS.h" +// +// EFI structure of Redfish ResourceBlock v1_2_2 +// +typedef struct _EFI_REDFISH_RESOURCEBLOCK_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCK_V1_2_2_CS *ResourceBlock; +} EFI_REDFISH_RESOURCEBLOCK_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_2_3/EfiResourceBlockV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_2_3/EfiResourceBlockV1_2_3.h new file mode 100644 index 00000000000..85becc4fbff --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_2_3/EfiResourceBlockV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlock v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_2_3_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlock/v1_2_3/Redfish_ResourceBlock_v1_2_3_CS.h" +// +// EFI structure of Redfish ResourceBlock v1_2_3 +// +typedef struct _EFI_REDFISH_RESOURCEBLOCK_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCK_V1_2_3_CS *ResourceBlock; +} EFI_REDFISH_RESOURCEBLOCK_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_2_4/EfiResourceBlockV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_2_4/EfiResourceBlockV1_2_4.h new file mode 100644 index 00000000000..860506bee9f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_2_4/EfiResourceBlockV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlock v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_2_4_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlock/v1_2_4/Redfish_ResourceBlock_v1_2_4_CS.h" +// +// EFI structure of Redfish ResourceBlock v1_2_4 +// +typedef struct _EFI_REDFISH_RESOURCEBLOCK_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCK_V1_2_4_CS *ResourceBlock; +} EFI_REDFISH_RESOURCEBLOCK_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_2_5/EfiResourceBlockV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_2_5/EfiResourceBlockV1_2_5.h new file mode 100644 index 00000000000..2830b78eb83 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_2_5/EfiResourceBlockV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlock v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_2_5_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlock/v1_2_5/Redfish_ResourceBlock_v1_2_5_CS.h" +// +// EFI structure of Redfish ResourceBlock v1_2_5 +// +typedef struct _EFI_REDFISH_RESOURCEBLOCK_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCK_V1_2_5_CS *ResourceBlock; +} EFI_REDFISH_RESOURCEBLOCK_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_3_0/EfiResourceBlockV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_3_0/EfiResourceBlockV1_3_0.h new file mode 100644 index 00000000000..3dcad6fa3b1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_3_0/EfiResourceBlockV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlock v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_3_0_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlock/v1_3_0/Redfish_ResourceBlock_v1_3_0_CS.h" +// +// EFI structure of Redfish ResourceBlock v1_3_0 +// +typedef struct _EFI_REDFISH_RESOURCEBLOCK_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCK_V1_3_0_CS *ResourceBlock; +} EFI_REDFISH_RESOURCEBLOCK_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_3_1/EfiResourceBlockV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_3_1/EfiResourceBlockV1_3_1.h new file mode 100644 index 00000000000..8e5d4547c6a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_3_1/EfiResourceBlockV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlock v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_3_1_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlock/v1_3_1/Redfish_ResourceBlock_v1_3_1_CS.h" +// +// EFI structure of Redfish ResourceBlock v1_3_1 +// +typedef struct _EFI_REDFISH_RESOURCEBLOCK_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCK_V1_3_1_CS *ResourceBlock; +} EFI_REDFISH_RESOURCEBLOCK_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_3_2/EfiResourceBlockV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_3_2/EfiResourceBlockV1_3_2.h new file mode 100644 index 00000000000..0a3ec01446d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_3_2/EfiResourceBlockV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlock v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_3_2_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlock/v1_3_2/Redfish_ResourceBlock_v1_3_2_CS.h" +// +// EFI structure of Redfish ResourceBlock v1_3_2 +// +typedef struct _EFI_REDFISH_RESOURCEBLOCK_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCK_V1_3_2_CS *ResourceBlock; +} EFI_REDFISH_RESOURCEBLOCK_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_3_3/EfiResourceBlockV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_3_3/EfiResourceBlockV1_3_3.h new file mode 100644 index 00000000000..dd4a34b408e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_3_3/EfiResourceBlockV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlock v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_3_3_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlock/v1_3_3/Redfish_ResourceBlock_v1_3_3_CS.h" +// +// EFI structure of Redfish ResourceBlock v1_3_3 +// +typedef struct _EFI_REDFISH_RESOURCEBLOCK_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCK_V1_3_3_CS *ResourceBlock; +} EFI_REDFISH_RESOURCEBLOCK_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_3_4/EfiResourceBlockV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_3_4/EfiResourceBlockV1_3_4.h new file mode 100644 index 00000000000..64bb768eb0b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlock/v1_3_4/EfiResourceBlockV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlock v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_3_4_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCK_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlock/v1_3_4/Redfish_ResourceBlock_v1_3_4_CS.h" +// +// EFI structure of Redfish ResourceBlock v1_3_4 +// +typedef struct _EFI_REDFISH_RESOURCEBLOCK_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCK_V1_3_4_CS *ResourceBlock; +} EFI_REDFISH_RESOURCEBLOCK_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlockCollection/EfiResourceBlockCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlockCollection/EfiResourceBlockCollection.h new file mode 100644 index 00000000000..691b8542b54 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ResourceBlockCollection/EfiResourceBlockCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ResourceBlockCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_RESOURCEBLOCKCOLLECTION_H__ +#define EFI_REDFISH_INTERP_RESOURCEBLOCKCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/ResourceBlockCollection/Redfish_ResourceBlockCollection_CS.h" +// +// EFI structure of Redfish ResourceBlockCollection +// +typedef struct _EFI_REDFISH_RESOURCEBLOCKCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_RESOURCEBLOCKCOLLECTION_CS *ResourceBlockCollection; +} EFI_REDFISH_RESOURCEBLOCKCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_0/EfiRoleV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_0/EfiRoleV1_0_0.h new file mode 100644 index 00000000000..9e08d342c70 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_0/EfiRoleV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Role v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROLE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_ROLE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Role/v1_0_0/Redfish_Role_v1_0_0_CS.h" +// +// EFI structure of Redfish Role v1_0_0 +// +typedef struct _EFI_REDFISH_ROLE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROLE_V1_0_0_CS *Role; +} EFI_REDFISH_ROLE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_2/EfiRoleV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_2/EfiRoleV1_0_2.h new file mode 100644 index 00000000000..e15217f8c13 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_2/EfiRoleV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Role v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROLE_V1_0_2_H__ +#define EFI_REDFISH_INTERP_ROLE_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Role/v1_0_2/Redfish_Role_v1_0_2_CS.h" +// +// EFI structure of Redfish Role v1_0_2 +// +typedef struct _EFI_REDFISH_ROLE_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROLE_V1_0_2_CS *Role; +} EFI_REDFISH_ROLE_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_3/EfiRoleV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_3/EfiRoleV1_0_3.h new file mode 100644 index 00000000000..b1c62d77fe2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_3/EfiRoleV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Role v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROLE_V1_0_3_H__ +#define EFI_REDFISH_INTERP_ROLE_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Role/v1_0_3/Redfish_Role_v1_0_3_CS.h" +// +// EFI structure of Redfish Role v1_0_3 +// +typedef struct _EFI_REDFISH_ROLE_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROLE_V1_0_3_CS *Role; +} EFI_REDFISH_ROLE_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_4/EfiRoleV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_4/EfiRoleV1_0_4.h new file mode 100644 index 00000000000..f8d833d3379 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_4/EfiRoleV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Role v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROLE_V1_0_4_H__ +#define EFI_REDFISH_INTERP_ROLE_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Role/v1_0_4/Redfish_Role_v1_0_4_CS.h" +// +// EFI structure of Redfish Role v1_0_4 +// +typedef struct _EFI_REDFISH_ROLE_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROLE_V1_0_4_CS *Role; +} EFI_REDFISH_ROLE_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_5/EfiRoleV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_5/EfiRoleV1_0_5.h new file mode 100644 index 00000000000..4fe1054cd1a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_5/EfiRoleV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Role v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROLE_V1_0_5_H__ +#define EFI_REDFISH_INTERP_ROLE_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Role/v1_0_5/Redfish_Role_v1_0_5_CS.h" +// +// EFI structure of Redfish Role v1_0_5 +// +typedef struct _EFI_REDFISH_ROLE_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROLE_V1_0_5_CS *Role; +} EFI_REDFISH_ROLE_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_6/EfiRoleV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_6/EfiRoleV1_0_6.h new file mode 100644 index 00000000000..c35b29d96f0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_6/EfiRoleV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Role v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROLE_V1_0_6_H__ +#define EFI_REDFISH_INTERP_ROLE_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Role/v1_0_6/Redfish_Role_v1_0_6_CS.h" +// +// EFI structure of Redfish Role v1_0_6 +// +typedef struct _EFI_REDFISH_ROLE_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROLE_V1_0_6_CS *Role; +} EFI_REDFISH_ROLE_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_7/EfiRoleV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_7/EfiRoleV1_0_7.h new file mode 100644 index 00000000000..5101419d765 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_0_7/EfiRoleV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Role v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROLE_V1_0_7_H__ +#define EFI_REDFISH_INTERP_ROLE_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Role/v1_0_7/Redfish_Role_v1_0_7_CS.h" +// +// EFI structure of Redfish Role v1_0_7 +// +typedef struct _EFI_REDFISH_ROLE_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROLE_V1_0_7_CS *Role; +} EFI_REDFISH_ROLE_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_1_0/EfiRoleV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_1_0/EfiRoleV1_1_0.h new file mode 100644 index 00000000000..345834dd932 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_1_0/EfiRoleV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Role v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROLE_V1_1_0_H__ +#define EFI_REDFISH_INTERP_ROLE_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Role/v1_1_0/Redfish_Role_v1_1_0_CS.h" +// +// EFI structure of Redfish Role v1_1_0 +// +typedef struct _EFI_REDFISH_ROLE_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROLE_V1_1_0_CS *Role; +} EFI_REDFISH_ROLE_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_1_1/EfiRoleV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_1_1/EfiRoleV1_1_1.h new file mode 100644 index 00000000000..1c937c47cdc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_1_1/EfiRoleV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Role v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROLE_V1_1_1_H__ +#define EFI_REDFISH_INTERP_ROLE_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Role/v1_1_1/Redfish_Role_v1_1_1_CS.h" +// +// EFI structure of Redfish Role v1_1_1 +// +typedef struct _EFI_REDFISH_ROLE_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROLE_V1_1_1_CS *Role; +} EFI_REDFISH_ROLE_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_1_2/EfiRoleV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_1_2/EfiRoleV1_1_2.h new file mode 100644 index 00000000000..58ef6e3109b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_1_2/EfiRoleV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Role v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROLE_V1_1_2_H__ +#define EFI_REDFISH_INTERP_ROLE_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Role/v1_1_2/Redfish_Role_v1_1_2_CS.h" +// +// EFI structure of Redfish Role v1_1_2 +// +typedef struct _EFI_REDFISH_ROLE_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROLE_V1_1_2_CS *Role; +} EFI_REDFISH_ROLE_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_1_3/EfiRoleV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_1_3/EfiRoleV1_1_3.h new file mode 100644 index 00000000000..cc6ec1d7efe --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_1_3/EfiRoleV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Role v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROLE_V1_1_3_H__ +#define EFI_REDFISH_INTERP_ROLE_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Role/v1_1_3/Redfish_Role_v1_1_3_CS.h" +// +// EFI structure of Redfish Role v1_1_3 +// +typedef struct _EFI_REDFISH_ROLE_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROLE_V1_1_3_CS *Role; +} EFI_REDFISH_ROLE_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_1_4/EfiRoleV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_1_4/EfiRoleV1_1_4.h new file mode 100644 index 00000000000..235644c91a1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_1_4/EfiRoleV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Role v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROLE_V1_1_4_H__ +#define EFI_REDFISH_INTERP_ROLE_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Role/v1_1_4/Redfish_Role_v1_1_4_CS.h" +// +// EFI structure of Redfish Role v1_1_4 +// +typedef struct _EFI_REDFISH_ROLE_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROLE_V1_1_4_CS *Role; +} EFI_REDFISH_ROLE_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_1_5/EfiRoleV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_1_5/EfiRoleV1_1_5.h new file mode 100644 index 00000000000..ebdc681d938 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_1_5/EfiRoleV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Role v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROLE_V1_1_5_H__ +#define EFI_REDFISH_INTERP_ROLE_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Role/v1_1_5/Redfish_Role_v1_1_5_CS.h" +// +// EFI structure of Redfish Role v1_1_5 +// +typedef struct _EFI_REDFISH_ROLE_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROLE_V1_1_5_CS *Role; +} EFI_REDFISH_ROLE_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_2_0/EfiRoleV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_2_0/EfiRoleV1_2_0.h new file mode 100644 index 00000000000..adcfeafb961 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_2_0/EfiRoleV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Role v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROLE_V1_2_0_H__ +#define EFI_REDFISH_INTERP_ROLE_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Role/v1_2_0/Redfish_Role_v1_2_0_CS.h" +// +// EFI structure of Redfish Role v1_2_0 +// +typedef struct _EFI_REDFISH_ROLE_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROLE_V1_2_0_CS *Role; +} EFI_REDFISH_ROLE_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_2_1/EfiRoleV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_2_1/EfiRoleV1_2_1.h new file mode 100644 index 00000000000..4a0ab304f10 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_2_1/EfiRoleV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Role v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROLE_V1_2_1_H__ +#define EFI_REDFISH_INTERP_ROLE_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Role/v1_2_1/Redfish_Role_v1_2_1_CS.h" +// +// EFI structure of Redfish Role v1_2_1 +// +typedef struct _EFI_REDFISH_ROLE_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROLE_V1_2_1_CS *Role; +} EFI_REDFISH_ROLE_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_2_2/EfiRoleV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_2_2/EfiRoleV1_2_2.h new file mode 100644 index 00000000000..205ccf6e7b2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_2_2/EfiRoleV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Role v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROLE_V1_2_2_H__ +#define EFI_REDFISH_INTERP_ROLE_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Role/v1_2_2/Redfish_Role_v1_2_2_CS.h" +// +// EFI structure of Redfish Role v1_2_2 +// +typedef struct _EFI_REDFISH_ROLE_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROLE_V1_2_2_CS *Role; +} EFI_REDFISH_ROLE_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_2_3/EfiRoleV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_2_3/EfiRoleV1_2_3.h new file mode 100644 index 00000000000..a15e37d9ca5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_2_3/EfiRoleV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Role v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROLE_V1_2_3_H__ +#define EFI_REDFISH_INTERP_ROLE_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Role/v1_2_3/Redfish_Role_v1_2_3_CS.h" +// +// EFI structure of Redfish Role v1_2_3 +// +typedef struct _EFI_REDFISH_ROLE_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROLE_V1_2_3_CS *Role; +} EFI_REDFISH_ROLE_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_2_4/EfiRoleV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_2_4/EfiRoleV1_2_4.h new file mode 100644 index 00000000000..9494ec42468 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_2_4/EfiRoleV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Role v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROLE_V1_2_4_H__ +#define EFI_REDFISH_INTERP_ROLE_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Role/v1_2_4/Redfish_Role_v1_2_4_CS.h" +// +// EFI structure of Redfish Role v1_2_4 +// +typedef struct _EFI_REDFISH_ROLE_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROLE_V1_2_4_CS *Role; +} EFI_REDFISH_ROLE_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_2_5/EfiRoleV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_2_5/EfiRoleV1_2_5.h new file mode 100644 index 00000000000..4687c29ca2f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_2_5/EfiRoleV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Role v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROLE_V1_2_5_H__ +#define EFI_REDFISH_INTERP_ROLE_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Role/v1_2_5/Redfish_Role_v1_2_5_CS.h" +// +// EFI structure of Redfish Role v1_2_5 +// +typedef struct _EFI_REDFISH_ROLE_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROLE_V1_2_5_CS *Role; +} EFI_REDFISH_ROLE_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_3_0/EfiRoleV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_3_0/EfiRoleV1_3_0.h new file mode 100644 index 00000000000..87f8113bbf2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Role/v1_3_0/EfiRoleV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Role v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROLE_V1_3_0_H__ +#define EFI_REDFISH_INTERP_ROLE_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Role/v1_3_0/Redfish_Role_v1_3_0_CS.h" +// +// EFI structure of Redfish Role v1_3_0 +// +typedef struct _EFI_REDFISH_ROLE_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROLE_V1_3_0_CS *Role; +} EFI_REDFISH_ROLE_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/RoleCollection/EfiRoleCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/RoleCollection/EfiRoleCollection.h new file mode 100644 index 00000000000..30fa2d9696c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/RoleCollection/EfiRoleCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for RoleCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROLECOLLECTION_H__ +#define EFI_REDFISH_INTERP_ROLECOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/RoleCollection/Redfish_RoleCollection_CS.h" +// +// EFI structure of Redfish RoleCollection +// +typedef struct _EFI_REDFISH_ROLECOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROLECOLLECTION_CS *RoleCollection; +} EFI_REDFISH_ROLECOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/RouteEntry/v1_0_0/EfiRouteEntryV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/RouteEntry/v1_0_0/EfiRouteEntryV1_0_0.h new file mode 100644 index 00000000000..cd28f495a33 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/RouteEntry/v1_0_0/EfiRouteEntryV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for RouteEntry v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROUTEENTRY_V1_0_0_H__ +#define EFI_REDFISH_INTERP_ROUTEENTRY_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/RouteEntry/v1_0_0/Redfish_RouteEntry_v1_0_0_CS.h" +// +// EFI structure of Redfish RouteEntry v1_0_0 +// +typedef struct _EFI_REDFISH_ROUTEENTRY_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROUTEENTRY_V1_0_0_CS *RouteEntry; +} EFI_REDFISH_ROUTEENTRY_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/RouteEntry/v1_0_1/EfiRouteEntryV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/RouteEntry/v1_0_1/EfiRouteEntryV1_0_1.h new file mode 100644 index 00000000000..df2605d6099 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/RouteEntry/v1_0_1/EfiRouteEntryV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for RouteEntry v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROUTEENTRY_V1_0_1_H__ +#define EFI_REDFISH_INTERP_ROUTEENTRY_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/RouteEntry/v1_0_1/Redfish_RouteEntry_v1_0_1_CS.h" +// +// EFI structure of Redfish RouteEntry v1_0_1 +// +typedef struct _EFI_REDFISH_ROUTEENTRY_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROUTEENTRY_V1_0_1_CS *RouteEntry; +} EFI_REDFISH_ROUTEENTRY_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/RouteEntryCollection/EfiRouteEntryCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/RouteEntryCollection/EfiRouteEntryCollection.h new file mode 100644 index 00000000000..6988a0fdab5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/RouteEntryCollection/EfiRouteEntryCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for RouteEntryCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROUTEENTRYCOLLECTION_H__ +#define EFI_REDFISH_INTERP_ROUTEENTRYCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/RouteEntryCollection/Redfish_RouteEntryCollection_CS.h" +// +// EFI structure of Redfish RouteEntryCollection +// +typedef struct _EFI_REDFISH_ROUTEENTRYCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROUTEENTRYCOLLECTION_CS *RouteEntryCollection; +} EFI_REDFISH_ROUTEENTRYCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/RouteSetEntry/v1_0_0/EfiRouteSetEntryV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/RouteSetEntry/v1_0_0/EfiRouteSetEntryV1_0_0.h new file mode 100644 index 00000000000..c50359bd4f1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/RouteSetEntry/v1_0_0/EfiRouteSetEntryV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for RouteSetEntry v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROUTESETENTRY_V1_0_0_H__ +#define EFI_REDFISH_INTERP_ROUTESETENTRY_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/RouteSetEntry/v1_0_0/Redfish_RouteSetEntry_v1_0_0_CS.h" +// +// EFI structure of Redfish RouteSetEntry v1_0_0 +// +typedef struct _EFI_REDFISH_ROUTESETENTRY_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROUTESETENTRY_V1_0_0_CS *RouteSetEntry; +} EFI_REDFISH_ROUTESETENTRY_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/RouteSetEntry/v1_0_1/EfiRouteSetEntryV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/RouteSetEntry/v1_0_1/EfiRouteSetEntryV1_0_1.h new file mode 100644 index 00000000000..d5c60717c07 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/RouteSetEntry/v1_0_1/EfiRouteSetEntryV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for RouteSetEntry v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROUTESETENTRY_V1_0_1_H__ +#define EFI_REDFISH_INTERP_ROUTESETENTRY_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/RouteSetEntry/v1_0_1/Redfish_RouteSetEntry_v1_0_1_CS.h" +// +// EFI structure of Redfish RouteSetEntry v1_0_1 +// +typedef struct _EFI_REDFISH_ROUTESETENTRY_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROUTESETENTRY_V1_0_1_CS *RouteSetEntry; +} EFI_REDFISH_ROUTESETENTRY_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/RouteSetEntryCollection/EfiRouteSetEntryCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/RouteSetEntryCollection/EfiRouteSetEntryCollection.h new file mode 100644 index 00000000000..7ab57ea6ec9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/RouteSetEntryCollection/EfiRouteSetEntryCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for RouteSetEntryCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ROUTESETENTRYCOLLECTION_H__ +#define EFI_REDFISH_INTERP_ROUTESETENTRYCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/RouteSetEntryCollection/Redfish_RouteSetEntryCollection_CS.h" +// +// EFI structure of Redfish RouteSetEntryCollection +// +typedef struct _EFI_REDFISH_ROUTESETENTRYCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ROUTESETENTRYCOLLECTION_CS *RouteSetEntryCollection; +} EFI_REDFISH_ROUTESETENTRYCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_0/EfiSecureBootV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_0/EfiSecureBootV1_0_0.h new file mode 100644 index 00000000000..cc214c1cdff --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_0/EfiSecureBootV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SecureBoot v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SECUREBOOT_V1_0_0_H__ +#define EFI_REDFISH_INTERP_SECUREBOOT_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/SecureBoot/v1_0_0/Redfish_SecureBoot_v1_0_0_CS.h" +// +// EFI structure of Redfish SecureBoot v1_0_0 +// +typedef struct _EFI_REDFISH_SECUREBOOT_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SECUREBOOT_V1_0_0_CS *SecureBoot; +} EFI_REDFISH_SECUREBOOT_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_1/EfiSecureBootV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_1/EfiSecureBootV1_0_1.h new file mode 100644 index 00000000000..eda4aedc862 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_1/EfiSecureBootV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SecureBoot v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SECUREBOOT_V1_0_1_H__ +#define EFI_REDFISH_INTERP_SECUREBOOT_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/SecureBoot/v1_0_1/Redfish_SecureBoot_v1_0_1_CS.h" +// +// EFI structure of Redfish SecureBoot v1_0_1 +// +typedef struct _EFI_REDFISH_SECUREBOOT_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SECUREBOOT_V1_0_1_CS *SecureBoot; +} EFI_REDFISH_SECUREBOOT_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_2/EfiSecureBootV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_2/EfiSecureBootV1_0_2.h new file mode 100644 index 00000000000..b817cfca60e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_2/EfiSecureBootV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SecureBoot v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SECUREBOOT_V1_0_2_H__ +#define EFI_REDFISH_INTERP_SECUREBOOT_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/SecureBoot/v1_0_2/Redfish_SecureBoot_v1_0_2_CS.h" +// +// EFI structure of Redfish SecureBoot v1_0_2 +// +typedef struct _EFI_REDFISH_SECUREBOOT_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SECUREBOOT_V1_0_2_CS *SecureBoot; +} EFI_REDFISH_SECUREBOOT_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_3/EfiSecureBootV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_3/EfiSecureBootV1_0_3.h new file mode 100644 index 00000000000..603d2f8c56a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_3/EfiSecureBootV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SecureBoot v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SECUREBOOT_V1_0_3_H__ +#define EFI_REDFISH_INTERP_SECUREBOOT_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/SecureBoot/v1_0_3/Redfish_SecureBoot_v1_0_3_CS.h" +// +// EFI structure of Redfish SecureBoot v1_0_3 +// +typedef struct _EFI_REDFISH_SECUREBOOT_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SECUREBOOT_V1_0_3_CS *SecureBoot; +} EFI_REDFISH_SECUREBOOT_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_4/EfiSecureBootV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_4/EfiSecureBootV1_0_4.h new file mode 100644 index 00000000000..fc04a087767 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_4/EfiSecureBootV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SecureBoot v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SECUREBOOT_V1_0_4_H__ +#define EFI_REDFISH_INTERP_SECUREBOOT_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/SecureBoot/v1_0_4/Redfish_SecureBoot_v1_0_4_CS.h" +// +// EFI structure of Redfish SecureBoot v1_0_4 +// +typedef struct _EFI_REDFISH_SECUREBOOT_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SECUREBOOT_V1_0_4_CS *SecureBoot; +} EFI_REDFISH_SECUREBOOT_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_5/EfiSecureBootV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_5/EfiSecureBootV1_0_5.h new file mode 100644 index 00000000000..95a0ae39efe --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_5/EfiSecureBootV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SecureBoot v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SECUREBOOT_V1_0_5_H__ +#define EFI_REDFISH_INTERP_SECUREBOOT_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/SecureBoot/v1_0_5/Redfish_SecureBoot_v1_0_5_CS.h" +// +// EFI structure of Redfish SecureBoot v1_0_5 +// +typedef struct _EFI_REDFISH_SECUREBOOT_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SECUREBOOT_V1_0_5_CS *SecureBoot; +} EFI_REDFISH_SECUREBOOT_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_6/EfiSecureBootV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_6/EfiSecureBootV1_0_6.h new file mode 100644 index 00000000000..0c21e606101 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_6/EfiSecureBootV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SecureBoot v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SECUREBOOT_V1_0_6_H__ +#define EFI_REDFISH_INTERP_SECUREBOOT_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/SecureBoot/v1_0_6/Redfish_SecureBoot_v1_0_6_CS.h" +// +// EFI structure of Redfish SecureBoot v1_0_6 +// +typedef struct _EFI_REDFISH_SECUREBOOT_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SECUREBOOT_V1_0_6_CS *SecureBoot; +} EFI_REDFISH_SECUREBOOT_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_7/EfiSecureBootV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_7/EfiSecureBootV1_0_7.h new file mode 100644 index 00000000000..5f02262c52a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_0_7/EfiSecureBootV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SecureBoot v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SECUREBOOT_V1_0_7_H__ +#define EFI_REDFISH_INTERP_SECUREBOOT_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/SecureBoot/v1_0_7/Redfish_SecureBoot_v1_0_7_CS.h" +// +// EFI structure of Redfish SecureBoot v1_0_7 +// +typedef struct _EFI_REDFISH_SECUREBOOT_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SECUREBOOT_V1_0_7_CS *SecureBoot; +} EFI_REDFISH_SECUREBOOT_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_1_0/EfiSecureBootV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_1_0/EfiSecureBootV1_1_0.h new file mode 100644 index 00000000000..555f15eec25 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SecureBoot/v1_1_0/EfiSecureBootV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SecureBoot v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SECUREBOOT_V1_1_0_H__ +#define EFI_REDFISH_INTERP_SECUREBOOT_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/SecureBoot/v1_1_0/Redfish_SecureBoot_v1_1_0_CS.h" +// +// EFI structure of Redfish SecureBoot v1_1_0 +// +typedef struct _EFI_REDFISH_SECUREBOOT_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SECUREBOOT_V1_1_0_CS *SecureBoot; +} EFI_REDFISH_SECUREBOOT_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SecureBootDatabase/v1_0_0/EfiSecureBootDatabaseV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/SecureBootDatabase/v1_0_0/EfiSecureBootDatabaseV1_0_0.h new file mode 100644 index 00000000000..3e4d1ba013a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SecureBootDatabase/v1_0_0/EfiSecureBootDatabaseV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SecureBootDatabase v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SECUREBOOTDATABASE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_SECUREBOOTDATABASE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/SecureBootDatabase/v1_0_0/Redfish_SecureBootDatabase_v1_0_0_CS.h" +// +// EFI structure of Redfish SecureBootDatabase v1_0_0 +// +typedef struct _EFI_REDFISH_SECUREBOOTDATABASE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SECUREBOOTDATABASE_V1_0_0_CS *SecureBootDatabase; +} EFI_REDFISH_SECUREBOOTDATABASE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SecureBootDatabaseCollection/EfiSecureBootDatabaseCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/SecureBootDatabaseCollection/EfiSecureBootDatabaseCollection.h new file mode 100644 index 00000000000..69ab0b5012f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SecureBootDatabaseCollection/EfiSecureBootDatabaseCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SecureBootDatabaseCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SECUREBOOTDATABASECOLLECTION_H__ +#define EFI_REDFISH_INTERP_SECUREBOOTDATABASECOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/SecureBootDatabaseCollection/Redfish_SecureBootDatabaseCollection_CS.h" +// +// EFI structure of Redfish SecureBootDatabaseCollection +// +typedef struct _EFI_REDFISH_SECUREBOOTDATABASECOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SECUREBOOTDATABASECOLLECTION_CS *SecureBootDatabaseCollection; +} EFI_REDFISH_SECUREBOOTDATABASECOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_0/EfiSensorV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_0/EfiSensorV1_0_0.h new file mode 100644 index 00000000000..f015c9866ba --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_0/EfiSensorV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Sensor v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SENSOR_V1_0_0_H__ +#define EFI_REDFISH_INTERP_SENSOR_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Sensor/v1_0_0/Redfish_Sensor_v1_0_0_CS.h" +// +// EFI structure of Redfish Sensor v1_0_0 +// +typedef struct _EFI_REDFISH_SENSOR_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SENSOR_V1_0_0_CS *Sensor; +} EFI_REDFISH_SENSOR_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_1/EfiSensorV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_1/EfiSensorV1_0_1.h new file mode 100644 index 00000000000..c437a709f02 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_1/EfiSensorV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Sensor v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SENSOR_V1_0_1_H__ +#define EFI_REDFISH_INTERP_SENSOR_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Sensor/v1_0_1/Redfish_Sensor_v1_0_1_CS.h" +// +// EFI structure of Redfish Sensor v1_0_1 +// +typedef struct _EFI_REDFISH_SENSOR_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SENSOR_V1_0_1_CS *Sensor; +} EFI_REDFISH_SENSOR_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_2/EfiSensorV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_2/EfiSensorV1_0_2.h new file mode 100644 index 00000000000..1d56a846248 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_2/EfiSensorV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Sensor v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SENSOR_V1_0_2_H__ +#define EFI_REDFISH_INTERP_SENSOR_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Sensor/v1_0_2/Redfish_Sensor_v1_0_2_CS.h" +// +// EFI structure of Redfish Sensor v1_0_2 +// +typedef struct _EFI_REDFISH_SENSOR_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SENSOR_V1_0_2_CS *Sensor; +} EFI_REDFISH_SENSOR_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_3/EfiSensorV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_3/EfiSensorV1_0_3.h new file mode 100644 index 00000000000..cbe242bdfc0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_3/EfiSensorV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Sensor v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SENSOR_V1_0_3_H__ +#define EFI_REDFISH_INTERP_SENSOR_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Sensor/v1_0_3/Redfish_Sensor_v1_0_3_CS.h" +// +// EFI structure of Redfish Sensor v1_0_3 +// +typedef struct _EFI_REDFISH_SENSOR_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SENSOR_V1_0_3_CS *Sensor; +} EFI_REDFISH_SENSOR_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_4/EfiSensorV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_4/EfiSensorV1_0_4.h new file mode 100644 index 00000000000..f143eb96a9e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_4/EfiSensorV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Sensor v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SENSOR_V1_0_4_H__ +#define EFI_REDFISH_INTERP_SENSOR_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Sensor/v1_0_4/Redfish_Sensor_v1_0_4_CS.h" +// +// EFI structure of Redfish Sensor v1_0_4 +// +typedef struct _EFI_REDFISH_SENSOR_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SENSOR_V1_0_4_CS *Sensor; +} EFI_REDFISH_SENSOR_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_5/EfiSensorV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_5/EfiSensorV1_0_5.h new file mode 100644 index 00000000000..6b3eaed961a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_5/EfiSensorV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Sensor v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SENSOR_V1_0_5_H__ +#define EFI_REDFISH_INTERP_SENSOR_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Sensor/v1_0_5/Redfish_Sensor_v1_0_5_CS.h" +// +// EFI structure of Redfish Sensor v1_0_5 +// +typedef struct _EFI_REDFISH_SENSOR_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SENSOR_V1_0_5_CS *Sensor; +} EFI_REDFISH_SENSOR_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_6/EfiSensorV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_6/EfiSensorV1_0_6.h new file mode 100644 index 00000000000..fa59d7be849 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_0_6/EfiSensorV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Sensor v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SENSOR_V1_0_6_H__ +#define EFI_REDFISH_INTERP_SENSOR_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Sensor/v1_0_6/Redfish_Sensor_v1_0_6_CS.h" +// +// EFI structure of Redfish Sensor v1_0_6 +// +typedef struct _EFI_REDFISH_SENSOR_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SENSOR_V1_0_6_CS *Sensor; +} EFI_REDFISH_SENSOR_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_1_0/EfiSensorV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_1_0/EfiSensorV1_1_0.h new file mode 100644 index 00000000000..7e19c9e001b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_1_0/EfiSensorV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Sensor v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SENSOR_V1_1_0_H__ +#define EFI_REDFISH_INTERP_SENSOR_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Sensor/v1_1_0/Redfish_Sensor_v1_1_0_CS.h" +// +// EFI structure of Redfish Sensor v1_1_0 +// +typedef struct _EFI_REDFISH_SENSOR_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SENSOR_V1_1_0_CS *Sensor; +} EFI_REDFISH_SENSOR_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_1_1/EfiSensorV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_1_1/EfiSensorV1_1_1.h new file mode 100644 index 00000000000..55a9aec68a6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_1_1/EfiSensorV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Sensor v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SENSOR_V1_1_1_H__ +#define EFI_REDFISH_INTERP_SENSOR_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Sensor/v1_1_1/Redfish_Sensor_v1_1_1_CS.h" +// +// EFI structure of Redfish Sensor v1_1_1 +// +typedef struct _EFI_REDFISH_SENSOR_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SENSOR_V1_1_1_CS *Sensor; +} EFI_REDFISH_SENSOR_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_1_2/EfiSensorV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_1_2/EfiSensorV1_1_2.h new file mode 100644 index 00000000000..de3b38e64b0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_1_2/EfiSensorV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Sensor v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SENSOR_V1_1_2_H__ +#define EFI_REDFISH_INTERP_SENSOR_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Sensor/v1_1_2/Redfish_Sensor_v1_1_2_CS.h" +// +// EFI structure of Redfish Sensor v1_1_2 +// +typedef struct _EFI_REDFISH_SENSOR_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SENSOR_V1_1_2_CS *Sensor; +} EFI_REDFISH_SENSOR_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_2_0/EfiSensorV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_2_0/EfiSensorV1_2_0.h new file mode 100644 index 00000000000..effc78a24d7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Sensor/v1_2_0/EfiSensorV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Sensor v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SENSOR_V1_2_0_H__ +#define EFI_REDFISH_INTERP_SENSOR_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Sensor/v1_2_0/Redfish_Sensor_v1_2_0_CS.h" +// +// EFI structure of Redfish Sensor v1_2_0 +// +typedef struct _EFI_REDFISH_SENSOR_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SENSOR_V1_2_0_CS *Sensor; +} EFI_REDFISH_SENSOR_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SensorCollection/EfiSensorCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/SensorCollection/EfiSensorCollection.h new file mode 100644 index 00000000000..4a7174a5795 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SensorCollection/EfiSensorCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SensorCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SENSORCOLLECTION_H__ +#define EFI_REDFISH_INTERP_SENSORCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/SensorCollection/Redfish_SensorCollection_CS.h" +// +// EFI structure of Redfish SensorCollection +// +typedef struct _EFI_REDFISH_SENSORCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SENSORCOLLECTION_CS *SensorCollection; +} EFI_REDFISH_SENSORCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_0/EfiSerialInterfaceV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_0/EfiSerialInterfaceV1_0_0.h new file mode 100644 index 00000000000..59a530afa3d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_0/EfiSerialInterfaceV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SerialInterface v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERIALINTERFACE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_SERIALINTERFACE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/SerialInterface/v1_0_0/Redfish_SerialInterface_v1_0_0_CS.h" +// +// EFI structure of Redfish SerialInterface v1_0_0 +// +typedef struct _EFI_REDFISH_SERIALINTERFACE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERIALINTERFACE_V1_0_0_CS *SerialInterface; +} EFI_REDFISH_SERIALINTERFACE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_10/EfiSerialInterfaceV1_0_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_10/EfiSerialInterfaceV1_0_10.h new file mode 100644 index 00000000000..be139ec6f98 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_10/EfiSerialInterfaceV1_0_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SerialInterface v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERIALINTERFACE_V1_0_10_H__ +#define EFI_REDFISH_INTERP_SERIALINTERFACE_V1_0_10_H__ + +#include +#include +#include "ConverterLib/edk2library/SerialInterface/v1_0_10/Redfish_SerialInterface_v1_0_10_CS.h" +// +// EFI structure of Redfish SerialInterface v1_0_10 +// +typedef struct _EFI_REDFISH_SERIALINTERFACE_V1_0_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERIALINTERFACE_V1_0_10_CS *SerialInterface; +} EFI_REDFISH_SERIALINTERFACE_V1_0_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_2/EfiSerialInterfaceV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_2/EfiSerialInterfaceV1_0_2.h new file mode 100644 index 00000000000..b51b0c2eac1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_2/EfiSerialInterfaceV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SerialInterface v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERIALINTERFACE_V1_0_2_H__ +#define EFI_REDFISH_INTERP_SERIALINTERFACE_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/SerialInterface/v1_0_2/Redfish_SerialInterface_v1_0_2_CS.h" +// +// EFI structure of Redfish SerialInterface v1_0_2 +// +typedef struct _EFI_REDFISH_SERIALINTERFACE_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERIALINTERFACE_V1_0_2_CS *SerialInterface; +} EFI_REDFISH_SERIALINTERFACE_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_3/EfiSerialInterfaceV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_3/EfiSerialInterfaceV1_0_3.h new file mode 100644 index 00000000000..abec219e7ad --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_3/EfiSerialInterfaceV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SerialInterface v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERIALINTERFACE_V1_0_3_H__ +#define EFI_REDFISH_INTERP_SERIALINTERFACE_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/SerialInterface/v1_0_3/Redfish_SerialInterface_v1_0_3_CS.h" +// +// EFI structure of Redfish SerialInterface v1_0_3 +// +typedef struct _EFI_REDFISH_SERIALINTERFACE_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERIALINTERFACE_V1_0_3_CS *SerialInterface; +} EFI_REDFISH_SERIALINTERFACE_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_4/EfiSerialInterfaceV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_4/EfiSerialInterfaceV1_0_4.h new file mode 100644 index 00000000000..b4b8b9ee07f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_4/EfiSerialInterfaceV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SerialInterface v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERIALINTERFACE_V1_0_4_H__ +#define EFI_REDFISH_INTERP_SERIALINTERFACE_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/SerialInterface/v1_0_4/Redfish_SerialInterface_v1_0_4_CS.h" +// +// EFI structure of Redfish SerialInterface v1_0_4 +// +typedef struct _EFI_REDFISH_SERIALINTERFACE_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERIALINTERFACE_V1_0_4_CS *SerialInterface; +} EFI_REDFISH_SERIALINTERFACE_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_5/EfiSerialInterfaceV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_5/EfiSerialInterfaceV1_0_5.h new file mode 100644 index 00000000000..3c4b16324a2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_5/EfiSerialInterfaceV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SerialInterface v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERIALINTERFACE_V1_0_5_H__ +#define EFI_REDFISH_INTERP_SERIALINTERFACE_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/SerialInterface/v1_0_5/Redfish_SerialInterface_v1_0_5_CS.h" +// +// EFI structure of Redfish SerialInterface v1_0_5 +// +typedef struct _EFI_REDFISH_SERIALINTERFACE_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERIALINTERFACE_V1_0_5_CS *SerialInterface; +} EFI_REDFISH_SERIALINTERFACE_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_6/EfiSerialInterfaceV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_6/EfiSerialInterfaceV1_0_6.h new file mode 100644 index 00000000000..b3a93c7b083 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_6/EfiSerialInterfaceV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SerialInterface v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERIALINTERFACE_V1_0_6_H__ +#define EFI_REDFISH_INTERP_SERIALINTERFACE_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/SerialInterface/v1_0_6/Redfish_SerialInterface_v1_0_6_CS.h" +// +// EFI structure of Redfish SerialInterface v1_0_6 +// +typedef struct _EFI_REDFISH_SERIALINTERFACE_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERIALINTERFACE_V1_0_6_CS *SerialInterface; +} EFI_REDFISH_SERIALINTERFACE_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_7/EfiSerialInterfaceV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_7/EfiSerialInterfaceV1_0_7.h new file mode 100644 index 00000000000..73ad811ad9b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_7/EfiSerialInterfaceV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SerialInterface v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERIALINTERFACE_V1_0_7_H__ +#define EFI_REDFISH_INTERP_SERIALINTERFACE_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/SerialInterface/v1_0_7/Redfish_SerialInterface_v1_0_7_CS.h" +// +// EFI structure of Redfish SerialInterface v1_0_7 +// +typedef struct _EFI_REDFISH_SERIALINTERFACE_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERIALINTERFACE_V1_0_7_CS *SerialInterface; +} EFI_REDFISH_SERIALINTERFACE_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_8/EfiSerialInterfaceV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_8/EfiSerialInterfaceV1_0_8.h new file mode 100644 index 00000000000..129515a5860 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_8/EfiSerialInterfaceV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SerialInterface v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERIALINTERFACE_V1_0_8_H__ +#define EFI_REDFISH_INTERP_SERIALINTERFACE_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/SerialInterface/v1_0_8/Redfish_SerialInterface_v1_0_8_CS.h" +// +// EFI structure of Redfish SerialInterface v1_0_8 +// +typedef struct _EFI_REDFISH_SERIALINTERFACE_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERIALINTERFACE_V1_0_8_CS *SerialInterface; +} EFI_REDFISH_SERIALINTERFACE_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_9/EfiSerialInterfaceV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_9/EfiSerialInterfaceV1_0_9.h new file mode 100644 index 00000000000..2091feeeb80 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_0_9/EfiSerialInterfaceV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SerialInterface v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERIALINTERFACE_V1_0_9_H__ +#define EFI_REDFISH_INTERP_SERIALINTERFACE_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/SerialInterface/v1_0_9/Redfish_SerialInterface_v1_0_9_CS.h" +// +// EFI structure of Redfish SerialInterface v1_0_9 +// +typedef struct _EFI_REDFISH_SERIALINTERFACE_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERIALINTERFACE_V1_0_9_CS *SerialInterface; +} EFI_REDFISH_SERIALINTERFACE_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_0/EfiSerialInterfaceV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_0/EfiSerialInterfaceV1_1_0.h new file mode 100644 index 00000000000..b69ea5a37c9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_0/EfiSerialInterfaceV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SerialInterface v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERIALINTERFACE_V1_1_0_H__ +#define EFI_REDFISH_INTERP_SERIALINTERFACE_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/SerialInterface/v1_1_0/Redfish_SerialInterface_v1_1_0_CS.h" +// +// EFI structure of Redfish SerialInterface v1_1_0 +// +typedef struct _EFI_REDFISH_SERIALINTERFACE_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERIALINTERFACE_V1_1_0_CS *SerialInterface; +} EFI_REDFISH_SERIALINTERFACE_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_1/EfiSerialInterfaceV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_1/EfiSerialInterfaceV1_1_1.h new file mode 100644 index 00000000000..8b0a0b899bf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_1/EfiSerialInterfaceV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SerialInterface v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERIALINTERFACE_V1_1_1_H__ +#define EFI_REDFISH_INTERP_SERIALINTERFACE_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/SerialInterface/v1_1_1/Redfish_SerialInterface_v1_1_1_CS.h" +// +// EFI structure of Redfish SerialInterface v1_1_1 +// +typedef struct _EFI_REDFISH_SERIALINTERFACE_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERIALINTERFACE_V1_1_1_CS *SerialInterface; +} EFI_REDFISH_SERIALINTERFACE_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_2/EfiSerialInterfaceV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_2/EfiSerialInterfaceV1_1_2.h new file mode 100644 index 00000000000..26e3e00eef5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_2/EfiSerialInterfaceV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SerialInterface v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERIALINTERFACE_V1_1_2_H__ +#define EFI_REDFISH_INTERP_SERIALINTERFACE_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/SerialInterface/v1_1_2/Redfish_SerialInterface_v1_1_2_CS.h" +// +// EFI structure of Redfish SerialInterface v1_1_2 +// +typedef struct _EFI_REDFISH_SERIALINTERFACE_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERIALINTERFACE_V1_1_2_CS *SerialInterface; +} EFI_REDFISH_SERIALINTERFACE_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_3/EfiSerialInterfaceV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_3/EfiSerialInterfaceV1_1_3.h new file mode 100644 index 00000000000..acf7d7a11bc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_3/EfiSerialInterfaceV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SerialInterface v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERIALINTERFACE_V1_1_3_H__ +#define EFI_REDFISH_INTERP_SERIALINTERFACE_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/SerialInterface/v1_1_3/Redfish_SerialInterface_v1_1_3_CS.h" +// +// EFI structure of Redfish SerialInterface v1_1_3 +// +typedef struct _EFI_REDFISH_SERIALINTERFACE_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERIALINTERFACE_V1_1_3_CS *SerialInterface; +} EFI_REDFISH_SERIALINTERFACE_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_4/EfiSerialInterfaceV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_4/EfiSerialInterfaceV1_1_4.h new file mode 100644 index 00000000000..f290d1bbf83 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_4/EfiSerialInterfaceV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SerialInterface v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERIALINTERFACE_V1_1_4_H__ +#define EFI_REDFISH_INTERP_SERIALINTERFACE_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/SerialInterface/v1_1_4/Redfish_SerialInterface_v1_1_4_CS.h" +// +// EFI structure of Redfish SerialInterface v1_1_4 +// +typedef struct _EFI_REDFISH_SERIALINTERFACE_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERIALINTERFACE_V1_1_4_CS *SerialInterface; +} EFI_REDFISH_SERIALINTERFACE_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_5/EfiSerialInterfaceV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_5/EfiSerialInterfaceV1_1_5.h new file mode 100644 index 00000000000..5c0f234d50d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_5/EfiSerialInterfaceV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SerialInterface v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERIALINTERFACE_V1_1_5_H__ +#define EFI_REDFISH_INTERP_SERIALINTERFACE_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/SerialInterface/v1_1_5/Redfish_SerialInterface_v1_1_5_CS.h" +// +// EFI structure of Redfish SerialInterface v1_1_5 +// +typedef struct _EFI_REDFISH_SERIALINTERFACE_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERIALINTERFACE_V1_1_5_CS *SerialInterface; +} EFI_REDFISH_SERIALINTERFACE_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_6/EfiSerialInterfaceV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_6/EfiSerialInterfaceV1_1_6.h new file mode 100644 index 00000000000..ed71eb137d3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_6/EfiSerialInterfaceV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SerialInterface v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERIALINTERFACE_V1_1_6_H__ +#define EFI_REDFISH_INTERP_SERIALINTERFACE_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/SerialInterface/v1_1_6/Redfish_SerialInterface_v1_1_6_CS.h" +// +// EFI structure of Redfish SerialInterface v1_1_6 +// +typedef struct _EFI_REDFISH_SERIALINTERFACE_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERIALINTERFACE_V1_1_6_CS *SerialInterface; +} EFI_REDFISH_SERIALINTERFACE_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_7/EfiSerialInterfaceV1_1_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_7/EfiSerialInterfaceV1_1_7.h new file mode 100644 index 00000000000..b418006e782 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterface/v1_1_7/EfiSerialInterfaceV1_1_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SerialInterface v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERIALINTERFACE_V1_1_7_H__ +#define EFI_REDFISH_INTERP_SERIALINTERFACE_V1_1_7_H__ + +#include +#include +#include "ConverterLib/edk2library/SerialInterface/v1_1_7/Redfish_SerialInterface_v1_1_7_CS.h" +// +// EFI structure of Redfish SerialInterface v1_1_7 +// +typedef struct _EFI_REDFISH_SERIALINTERFACE_V1_1_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERIALINTERFACE_V1_1_7_CS *SerialInterface; +} EFI_REDFISH_SERIALINTERFACE_V1_1_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterfaceCollection/EfiSerialInterfaceCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterfaceCollection/EfiSerialInterfaceCollection.h new file mode 100644 index 00000000000..46400eb3381 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SerialInterfaceCollection/EfiSerialInterfaceCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SerialInterfaceCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERIALINTERFACECOLLECTION_H__ +#define EFI_REDFISH_INTERP_SERIALINTERFACECOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/SerialInterfaceCollection/Redfish_SerialInterfaceCollection_CS.h" +// +// EFI structure of Redfish SerialInterfaceCollection +// +typedef struct _EFI_REDFISH_SERIALINTERFACECOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERIALINTERFACECOLLECTION_CS *SerialInterfaceCollection; +} EFI_REDFISH_SERIALINTERFACECOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_0/EfiServiceRootV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_0/EfiServiceRootV1_0_0.h new file mode 100644 index 00000000000..311673ab4df --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_0/EfiServiceRootV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_0_0_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_0_0/Redfish_ServiceRoot_v1_0_0_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_0_0 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_0_0_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_2/EfiServiceRootV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_2/EfiServiceRootV1_0_2.h new file mode 100644 index 00000000000..a7b3d3d8a57 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_2/EfiServiceRootV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_0_2_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_0_2/Redfish_ServiceRoot_v1_0_2_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_0_2 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_0_2_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_3/EfiServiceRootV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_3/EfiServiceRootV1_0_3.h new file mode 100644 index 00000000000..aa340631058 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_3/EfiServiceRootV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_0_3_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_0_3/Redfish_ServiceRoot_v1_0_3_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_0_3 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_0_3_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_4/EfiServiceRootV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_4/EfiServiceRootV1_0_4.h new file mode 100644 index 00000000000..a0d00d72e28 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_4/EfiServiceRootV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_0_4_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_0_4/Redfish_ServiceRoot_v1_0_4_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_0_4 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_0_4_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_5/EfiServiceRootV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_5/EfiServiceRootV1_0_5.h new file mode 100644 index 00000000000..15c2a0d5381 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_5/EfiServiceRootV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_0_5_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_0_5/Redfish_ServiceRoot_v1_0_5_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_0_5 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_0_5_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_6/EfiServiceRootV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_6/EfiServiceRootV1_0_6.h new file mode 100644 index 00000000000..8275bce816f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_6/EfiServiceRootV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_0_6_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_0_6/Redfish_ServiceRoot_v1_0_6_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_0_6 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_0_6_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_7/EfiServiceRootV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_7/EfiServiceRootV1_0_7.h new file mode 100644 index 00000000000..00ce1ce9952 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_7/EfiServiceRootV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_0_7_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_0_7/Redfish_ServiceRoot_v1_0_7_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_0_7 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_0_7_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_8/EfiServiceRootV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_8/EfiServiceRootV1_0_8.h new file mode 100644 index 00000000000..dc308ca5f2f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_8/EfiServiceRootV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_0_8_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_0_8/Redfish_ServiceRoot_v1_0_8_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_0_8 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_0_8_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_9/EfiServiceRootV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_9/EfiServiceRootV1_0_9.h new file mode 100644 index 00000000000..59b163c2fa5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_0_9/EfiServiceRootV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_0_9_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_0_9/Redfish_ServiceRoot_v1_0_9_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_0_9 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_0_9_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_0/EfiServiceRootV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_0/EfiServiceRootV1_1_0.h new file mode 100644 index 00000000000..22435c67bc6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_0/EfiServiceRootV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_1_0_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_1_0/Redfish_ServiceRoot_v1_1_0_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_1_0 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_1_0_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_1/EfiServiceRootV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_1/EfiServiceRootV1_1_1.h new file mode 100644 index 00000000000..646e6d762f3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_1/EfiServiceRootV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_1_1_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_1_1/Redfish_ServiceRoot_v1_1_1_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_1_1 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_1_1_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_2/EfiServiceRootV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_2/EfiServiceRootV1_1_2.h new file mode 100644 index 00000000000..34532690c23 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_2/EfiServiceRootV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_1_2_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_1_2/Redfish_ServiceRoot_v1_1_2_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_1_2 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_1_2_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_3/EfiServiceRootV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_3/EfiServiceRootV1_1_3.h new file mode 100644 index 00000000000..6b2a347ab18 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_3/EfiServiceRootV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_1_3_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_1_3/Redfish_ServiceRoot_v1_1_3_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_1_3 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_1_3_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_4/EfiServiceRootV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_4/EfiServiceRootV1_1_4.h new file mode 100644 index 00000000000..0d9155ebf07 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_4/EfiServiceRootV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_1_4_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_1_4/Redfish_ServiceRoot_v1_1_4_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_1_4 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_1_4_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_5/EfiServiceRootV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_5/EfiServiceRootV1_1_5.h new file mode 100644 index 00000000000..707e7880e1d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_5/EfiServiceRootV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_1_5_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_1_5/Redfish_ServiceRoot_v1_1_5_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_1_5 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_1_5_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_6/EfiServiceRootV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_6/EfiServiceRootV1_1_6.h new file mode 100644 index 00000000000..1b6b35d9397 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_1_6/EfiServiceRootV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_1_6_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_1_6/Redfish_ServiceRoot_v1_1_6_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_1_6 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_1_6_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_2_0/EfiServiceRootV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_2_0/EfiServiceRootV1_2_0.h new file mode 100644 index 00000000000..98159e76c9f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_2_0/EfiServiceRootV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_2_0_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_2_0/Redfish_ServiceRoot_v1_2_0_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_2_0 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_2_0_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_2_1/EfiServiceRootV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_2_1/EfiServiceRootV1_2_1.h new file mode 100644 index 00000000000..e183628685d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_2_1/EfiServiceRootV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_2_1_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_2_1/Redfish_ServiceRoot_v1_2_1_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_2_1 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_2_1_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_2_2/EfiServiceRootV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_2_2/EfiServiceRootV1_2_2.h new file mode 100644 index 00000000000..27b73d8a9b7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_2_2/EfiServiceRootV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_2_2_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_2_2/Redfish_ServiceRoot_v1_2_2_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_2_2 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_2_2_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_2_3/EfiServiceRootV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_2_3/EfiServiceRootV1_2_3.h new file mode 100644 index 00000000000..9fb531c4918 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_2_3/EfiServiceRootV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_2_3_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_2_3/Redfish_ServiceRoot_v1_2_3_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_2_3 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_2_3_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_2_4/EfiServiceRootV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_2_4/EfiServiceRootV1_2_4.h new file mode 100644 index 00000000000..4617d763cad --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_2_4/EfiServiceRootV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_2_4_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_2_4/Redfish_ServiceRoot_v1_2_4_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_2_4 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_2_4_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_3_0/EfiServiceRootV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_3_0/EfiServiceRootV1_3_0.h new file mode 100644 index 00000000000..8f85ef9de82 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_3_0/EfiServiceRootV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_3_0_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_3_0/Redfish_ServiceRoot_v1_3_0_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_3_0 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_3_0_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_3_1/EfiServiceRootV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_3_1/EfiServiceRootV1_3_1.h new file mode 100644 index 00000000000..f7f7cac096c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_3_1/EfiServiceRootV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_3_1_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_3_1/Redfish_ServiceRoot_v1_3_1_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_3_1 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_3_1_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_3_2/EfiServiceRootV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_3_2/EfiServiceRootV1_3_2.h new file mode 100644 index 00000000000..a2acce05f8d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_3_2/EfiServiceRootV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_3_2_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_3_2/Redfish_ServiceRoot_v1_3_2_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_3_2 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_3_2_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_3_3/EfiServiceRootV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_3_3/EfiServiceRootV1_3_3.h new file mode 100644 index 00000000000..e22b2da3c72 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_3_3/EfiServiceRootV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_3_3_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_3_3/Redfish_ServiceRoot_v1_3_3_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_3_3 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_3_3_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_3_4/EfiServiceRootV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_3_4/EfiServiceRootV1_3_4.h new file mode 100644 index 00000000000..0441f23289f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_3_4/EfiServiceRootV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_3_4_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_3_4/Redfish_ServiceRoot_v1_3_4_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_3_4 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_3_4_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_3_5/EfiServiceRootV1_3_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_3_5/EfiServiceRootV1_3_5.h new file mode 100644 index 00000000000..62fedd8d325 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_3_5/EfiServiceRootV1_3_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_3_5_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_3_5_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_3_5/Redfish_ServiceRoot_v1_3_5_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_3_5 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_3_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_3_5_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_3_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_4_0/EfiServiceRootV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_4_0/EfiServiceRootV1_4_0.h new file mode 100644 index 00000000000..1b86104b563 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_4_0/EfiServiceRootV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_4_0_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_4_0/Redfish_ServiceRoot_v1_4_0_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_4_0 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_4_0_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_4_1/EfiServiceRootV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_4_1/EfiServiceRootV1_4_1.h new file mode 100644 index 00000000000..49fe8ab5bf2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_4_1/EfiServiceRootV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_4_1_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_4_1/Redfish_ServiceRoot_v1_4_1_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_4_1 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_4_1_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_4_2/EfiServiceRootV1_4_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_4_2/EfiServiceRootV1_4_2.h new file mode 100644 index 00000000000..6e03cbf9ee0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_4_2/EfiServiceRootV1_4_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_4_2_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_4_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_4_2/Redfish_ServiceRoot_v1_4_2_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_4_2 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_4_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_4_2_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_4_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_4_3/EfiServiceRootV1_4_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_4_3/EfiServiceRootV1_4_3.h new file mode 100644 index 00000000000..297cdff9366 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_4_3/EfiServiceRootV1_4_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_4_3_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_4_3_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_4_3/Redfish_ServiceRoot_v1_4_3_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_4_3 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_4_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_4_3_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_4_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_5_0/EfiServiceRootV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_5_0/EfiServiceRootV1_5_0.h new file mode 100644 index 00000000000..baadaaaeede --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_5_0/EfiServiceRootV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_5_0_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_5_0/Redfish_ServiceRoot_v1_5_0_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_5_0 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_5_0_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_5_1/EfiServiceRootV1_5_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_5_1/EfiServiceRootV1_5_1.h new file mode 100644 index 00000000000..f6bb0fd9c23 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_5_1/EfiServiceRootV1_5_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_5_1_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_5_1_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_5_1/Redfish_ServiceRoot_v1_5_1_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_5_1 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_5_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_5_1_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_5_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_5_2/EfiServiceRootV1_5_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_5_2/EfiServiceRootV1_5_2.h new file mode 100644 index 00000000000..0d63d2bdaf2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_5_2/EfiServiceRootV1_5_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_5_2_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_5_2_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_5_2/Redfish_ServiceRoot_v1_5_2_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_5_2 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_5_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_5_2_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_5_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_6_0/EfiServiceRootV1_6_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_6_0/EfiServiceRootV1_6_0.h new file mode 100644 index 00000000000..12e22ff7891 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_6_0/EfiServiceRootV1_6_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_6_0_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_6_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_6_0/Redfish_ServiceRoot_v1_6_0_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_6_0 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_6_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_6_0_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_6_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_7_0/EfiServiceRootV1_7_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_7_0/EfiServiceRootV1_7_0.h new file mode 100644 index 00000000000..1ac8a5f45d9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_7_0/EfiServiceRootV1_7_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_7_0_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_7_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_7_0/Redfish_ServiceRoot_v1_7_0_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_7_0 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_7_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_7_0_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_7_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_8_0/EfiServiceRootV1_8_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_8_0/EfiServiceRootV1_8_0.h new file mode 100644 index 00000000000..53f14330c8b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_8_0/EfiServiceRootV1_8_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_8_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_8_0_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_8_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_8_0/Redfish_ServiceRoot_v1_8_0_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_8_0 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_8_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_8_0_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_8_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_9_0/EfiServiceRootV1_9_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_9_0/EfiServiceRootV1_9_0.h new file mode 100644 index 00000000000..7d54376740d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ServiceRoot/v1_9_0/EfiServiceRootV1_9_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ServiceRoot v1_9_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SERVICEROOT_V1_9_0_H__ +#define EFI_REDFISH_INTERP_SERVICEROOT_V1_9_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ServiceRoot/v1_9_0/Redfish_ServiceRoot_v1_9_0_CS.h" +// +// EFI structure of Redfish ServiceRoot v1_9_0 +// +typedef struct _EFI_REDFISH_SERVICEROOT_V1_9_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SERVICEROOT_V1_9_0_CS *ServiceRoot; +} EFI_REDFISH_SERVICEROOT_V1_9_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_0_0/EfiSessionV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_0_0/EfiSessionV1_0_0.h new file mode 100644 index 00000000000..d5316a00a1d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_0_0/EfiSessionV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Session v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSION_V1_0_0_H__ +#define EFI_REDFISH_INTERP_SESSION_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Session/v1_0_0/Redfish_Session_v1_0_0_CS.h" +// +// EFI structure of Redfish Session v1_0_0 +// +typedef struct _EFI_REDFISH_SESSION_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSION_V1_0_0_CS *Session; +} EFI_REDFISH_SESSION_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_0_2/EfiSessionV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_0_2/EfiSessionV1_0_2.h new file mode 100644 index 00000000000..6d3baf6835e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_0_2/EfiSessionV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Session v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSION_V1_0_2_H__ +#define EFI_REDFISH_INTERP_SESSION_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Session/v1_0_2/Redfish_Session_v1_0_2_CS.h" +// +// EFI structure of Redfish Session v1_0_2 +// +typedef struct _EFI_REDFISH_SESSION_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSION_V1_0_2_CS *Session; +} EFI_REDFISH_SESSION_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_0_3/EfiSessionV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_0_3/EfiSessionV1_0_3.h new file mode 100644 index 00000000000..b9b368d77a1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_0_3/EfiSessionV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Session v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSION_V1_0_3_H__ +#define EFI_REDFISH_INTERP_SESSION_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Session/v1_0_3/Redfish_Session_v1_0_3_CS.h" +// +// EFI structure of Redfish Session v1_0_3 +// +typedef struct _EFI_REDFISH_SESSION_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSION_V1_0_3_CS *Session; +} EFI_REDFISH_SESSION_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_0_4/EfiSessionV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_0_4/EfiSessionV1_0_4.h new file mode 100644 index 00000000000..55fd03bc3f8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_0_4/EfiSessionV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Session v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSION_V1_0_4_H__ +#define EFI_REDFISH_INTERP_SESSION_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Session/v1_0_4/Redfish_Session_v1_0_4_CS.h" +// +// EFI structure of Redfish Session v1_0_4 +// +typedef struct _EFI_REDFISH_SESSION_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSION_V1_0_4_CS *Session; +} EFI_REDFISH_SESSION_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_0_5/EfiSessionV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_0_5/EfiSessionV1_0_5.h new file mode 100644 index 00000000000..2c6f4c799d9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_0_5/EfiSessionV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Session v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSION_V1_0_5_H__ +#define EFI_REDFISH_INTERP_SESSION_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Session/v1_0_5/Redfish_Session_v1_0_5_CS.h" +// +// EFI structure of Redfish Session v1_0_5 +// +typedef struct _EFI_REDFISH_SESSION_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSION_V1_0_5_CS *Session; +} EFI_REDFISH_SESSION_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_0_6/EfiSessionV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_0_6/EfiSessionV1_0_6.h new file mode 100644 index 00000000000..b5a34e607c7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_0_6/EfiSessionV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Session v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSION_V1_0_6_H__ +#define EFI_REDFISH_INTERP_SESSION_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Session/v1_0_6/Redfish_Session_v1_0_6_CS.h" +// +// EFI structure of Redfish Session v1_0_6 +// +typedef struct _EFI_REDFISH_SESSION_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSION_V1_0_6_CS *Session; +} EFI_REDFISH_SESSION_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_1_0/EfiSessionV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_1_0/EfiSessionV1_1_0.h new file mode 100644 index 00000000000..8a956a958e4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_1_0/EfiSessionV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Session v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSION_V1_1_0_H__ +#define EFI_REDFISH_INTERP_SESSION_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Session/v1_1_0/Redfish_Session_v1_1_0_CS.h" +// +// EFI structure of Redfish Session v1_1_0 +// +typedef struct _EFI_REDFISH_SESSION_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSION_V1_1_0_CS *Session; +} EFI_REDFISH_SESSION_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_1_1/EfiSessionV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_1_1/EfiSessionV1_1_1.h new file mode 100644 index 00000000000..c26a83179ba --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_1_1/EfiSessionV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Session v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSION_V1_1_1_H__ +#define EFI_REDFISH_INTERP_SESSION_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Session/v1_1_1/Redfish_Session_v1_1_1_CS.h" +// +// EFI structure of Redfish Session v1_1_1 +// +typedef struct _EFI_REDFISH_SESSION_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSION_V1_1_1_CS *Session; +} EFI_REDFISH_SESSION_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_1_2/EfiSessionV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_1_2/EfiSessionV1_1_2.h new file mode 100644 index 00000000000..85ad6f4c281 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_1_2/EfiSessionV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Session v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSION_V1_1_2_H__ +#define EFI_REDFISH_INTERP_SESSION_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Session/v1_1_2/Redfish_Session_v1_1_2_CS.h" +// +// EFI structure of Redfish Session v1_1_2 +// +typedef struct _EFI_REDFISH_SESSION_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSION_V1_1_2_CS *Session; +} EFI_REDFISH_SESSION_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_1_3/EfiSessionV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_1_3/EfiSessionV1_1_3.h new file mode 100644 index 00000000000..d1c4d3a2279 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_1_3/EfiSessionV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Session v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSION_V1_1_3_H__ +#define EFI_REDFISH_INTERP_SESSION_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Session/v1_1_3/Redfish_Session_v1_1_3_CS.h" +// +// EFI structure of Redfish Session v1_1_3 +// +typedef struct _EFI_REDFISH_SESSION_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSION_V1_1_3_CS *Session; +} EFI_REDFISH_SESSION_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_2_0/EfiSessionV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_2_0/EfiSessionV1_2_0.h new file mode 100644 index 00000000000..c9fb4dacd01 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_2_0/EfiSessionV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Session v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSION_V1_2_0_H__ +#define EFI_REDFISH_INTERP_SESSION_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Session/v1_2_0/Redfish_Session_v1_2_0_CS.h" +// +// EFI structure of Redfish Session v1_2_0 +// +typedef struct _EFI_REDFISH_SESSION_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSION_V1_2_0_CS *Session; +} EFI_REDFISH_SESSION_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_2_1/EfiSessionV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_2_1/EfiSessionV1_2_1.h new file mode 100644 index 00000000000..f4586433bd6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_2_1/EfiSessionV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Session v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSION_V1_2_1_H__ +#define EFI_REDFISH_INTERP_SESSION_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Session/v1_2_1/Redfish_Session_v1_2_1_CS.h" +// +// EFI structure of Redfish Session v1_2_1 +// +typedef struct _EFI_REDFISH_SESSION_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSION_V1_2_1_CS *Session; +} EFI_REDFISH_SESSION_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_3_0/EfiSessionV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_3_0/EfiSessionV1_3_0.h new file mode 100644 index 00000000000..1cb57a0066b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Session/v1_3_0/EfiSessionV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Session v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSION_V1_3_0_H__ +#define EFI_REDFISH_INTERP_SESSION_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Session/v1_3_0/Redfish_Session_v1_3_0_CS.h" +// +// EFI structure of Redfish Session v1_3_0 +// +typedef struct _EFI_REDFISH_SESSION_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSION_V1_3_0_CS *Session; +} EFI_REDFISH_SESSION_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SessionCollection/EfiSessionCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/SessionCollection/EfiSessionCollection.h new file mode 100644 index 00000000000..b24495a5f16 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SessionCollection/EfiSessionCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SessionCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSIONCOLLECTION_H__ +#define EFI_REDFISH_INTERP_SESSIONCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/SessionCollection/Redfish_SessionCollection_CS.h" +// +// EFI structure of Redfish SessionCollection +// +typedef struct _EFI_REDFISH_SESSIONCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSIONCOLLECTION_CS *SessionCollection; +} EFI_REDFISH_SESSIONCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_0/EfiSessionServiceV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_0/EfiSessionServiceV1_0_0.h new file mode 100644 index 00000000000..b569ed57bcf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_0/EfiSessionServiceV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SessionService v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSIONSERVICE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_SESSIONSERVICE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/SessionService/v1_0_0/Redfish_SessionService_v1_0_0_CS.h" +// +// EFI structure of Redfish SessionService v1_0_0 +// +typedef struct _EFI_REDFISH_SESSIONSERVICE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSIONSERVICE_V1_0_0_CS *SessionService; +} EFI_REDFISH_SESSIONSERVICE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_2/EfiSessionServiceV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_2/EfiSessionServiceV1_0_2.h new file mode 100644 index 00000000000..2d9bdf74623 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_2/EfiSessionServiceV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SessionService v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSIONSERVICE_V1_0_2_H__ +#define EFI_REDFISH_INTERP_SESSIONSERVICE_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/SessionService/v1_0_2/Redfish_SessionService_v1_0_2_CS.h" +// +// EFI structure of Redfish SessionService v1_0_2 +// +typedef struct _EFI_REDFISH_SESSIONSERVICE_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSIONSERVICE_V1_0_2_CS *SessionService; +} EFI_REDFISH_SESSIONSERVICE_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_3/EfiSessionServiceV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_3/EfiSessionServiceV1_0_3.h new file mode 100644 index 00000000000..532ada34889 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_3/EfiSessionServiceV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SessionService v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSIONSERVICE_V1_0_3_H__ +#define EFI_REDFISH_INTERP_SESSIONSERVICE_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/SessionService/v1_0_3/Redfish_SessionService_v1_0_3_CS.h" +// +// EFI structure of Redfish SessionService v1_0_3 +// +typedef struct _EFI_REDFISH_SESSIONSERVICE_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSIONSERVICE_V1_0_3_CS *SessionService; +} EFI_REDFISH_SESSIONSERVICE_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_4/EfiSessionServiceV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_4/EfiSessionServiceV1_0_4.h new file mode 100644 index 00000000000..3d98a4327f8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_4/EfiSessionServiceV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SessionService v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSIONSERVICE_V1_0_4_H__ +#define EFI_REDFISH_INTERP_SESSIONSERVICE_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/SessionService/v1_0_4/Redfish_SessionService_v1_0_4_CS.h" +// +// EFI structure of Redfish SessionService v1_0_4 +// +typedef struct _EFI_REDFISH_SESSIONSERVICE_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSIONSERVICE_V1_0_4_CS *SessionService; +} EFI_REDFISH_SESSIONSERVICE_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_5/EfiSessionServiceV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_5/EfiSessionServiceV1_0_5.h new file mode 100644 index 00000000000..9129445bf4f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_5/EfiSessionServiceV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SessionService v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSIONSERVICE_V1_0_5_H__ +#define EFI_REDFISH_INTERP_SESSIONSERVICE_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/SessionService/v1_0_5/Redfish_SessionService_v1_0_5_CS.h" +// +// EFI structure of Redfish SessionService v1_0_5 +// +typedef struct _EFI_REDFISH_SESSIONSERVICE_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSIONSERVICE_V1_0_5_CS *SessionService; +} EFI_REDFISH_SESSIONSERVICE_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_6/EfiSessionServiceV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_6/EfiSessionServiceV1_0_6.h new file mode 100644 index 00000000000..e97a7ee0e86 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_6/EfiSessionServiceV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SessionService v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSIONSERVICE_V1_0_6_H__ +#define EFI_REDFISH_INTERP_SESSIONSERVICE_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/SessionService/v1_0_6/Redfish_SessionService_v1_0_6_CS.h" +// +// EFI structure of Redfish SessionService v1_0_6 +// +typedef struct _EFI_REDFISH_SESSIONSERVICE_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSIONSERVICE_V1_0_6_CS *SessionService; +} EFI_REDFISH_SESSIONSERVICE_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_7/EfiSessionServiceV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_7/EfiSessionServiceV1_0_7.h new file mode 100644 index 00000000000..a3161a4fcb1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_7/EfiSessionServiceV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SessionService v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSIONSERVICE_V1_0_7_H__ +#define EFI_REDFISH_INTERP_SESSIONSERVICE_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/SessionService/v1_0_7/Redfish_SessionService_v1_0_7_CS.h" +// +// EFI structure of Redfish SessionService v1_0_7 +// +typedef struct _EFI_REDFISH_SESSIONSERVICE_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSIONSERVICE_V1_0_7_CS *SessionService; +} EFI_REDFISH_SESSIONSERVICE_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_8/EfiSessionServiceV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_8/EfiSessionServiceV1_0_8.h new file mode 100644 index 00000000000..d6622d7cb3b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_8/EfiSessionServiceV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SessionService v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSIONSERVICE_V1_0_8_H__ +#define EFI_REDFISH_INTERP_SESSIONSERVICE_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/SessionService/v1_0_8/Redfish_SessionService_v1_0_8_CS.h" +// +// EFI structure of Redfish SessionService v1_0_8 +// +typedef struct _EFI_REDFISH_SESSIONSERVICE_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSIONSERVICE_V1_0_8_CS *SessionService; +} EFI_REDFISH_SESSIONSERVICE_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_9/EfiSessionServiceV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_9/EfiSessionServiceV1_0_9.h new file mode 100644 index 00000000000..72f307f1b9b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_0_9/EfiSessionServiceV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SessionService v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSIONSERVICE_V1_0_9_H__ +#define EFI_REDFISH_INTERP_SESSIONSERVICE_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/SessionService/v1_0_9/Redfish_SessionService_v1_0_9_CS.h" +// +// EFI structure of Redfish SessionService v1_0_9 +// +typedef struct _EFI_REDFISH_SESSIONSERVICE_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSIONSERVICE_V1_0_9_CS *SessionService; +} EFI_REDFISH_SESSIONSERVICE_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_0/EfiSessionServiceV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_0/EfiSessionServiceV1_1_0.h new file mode 100644 index 00000000000..4617cc8e5e7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_0/EfiSessionServiceV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SessionService v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSIONSERVICE_V1_1_0_H__ +#define EFI_REDFISH_INTERP_SESSIONSERVICE_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/SessionService/v1_1_0/Redfish_SessionService_v1_1_0_CS.h" +// +// EFI structure of Redfish SessionService v1_1_0 +// +typedef struct _EFI_REDFISH_SESSIONSERVICE_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSIONSERVICE_V1_1_0_CS *SessionService; +} EFI_REDFISH_SESSIONSERVICE_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_1/EfiSessionServiceV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_1/EfiSessionServiceV1_1_1.h new file mode 100644 index 00000000000..27e8bd4211c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_1/EfiSessionServiceV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SessionService v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSIONSERVICE_V1_1_1_H__ +#define EFI_REDFISH_INTERP_SESSIONSERVICE_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/SessionService/v1_1_1/Redfish_SessionService_v1_1_1_CS.h" +// +// EFI structure of Redfish SessionService v1_1_1 +// +typedef struct _EFI_REDFISH_SESSIONSERVICE_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSIONSERVICE_V1_1_1_CS *SessionService; +} EFI_REDFISH_SESSIONSERVICE_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_2/EfiSessionServiceV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_2/EfiSessionServiceV1_1_2.h new file mode 100644 index 00000000000..1ab492280dc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_2/EfiSessionServiceV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SessionService v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSIONSERVICE_V1_1_2_H__ +#define EFI_REDFISH_INTERP_SESSIONSERVICE_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/SessionService/v1_1_2/Redfish_SessionService_v1_1_2_CS.h" +// +// EFI structure of Redfish SessionService v1_1_2 +// +typedef struct _EFI_REDFISH_SESSIONSERVICE_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSIONSERVICE_V1_1_2_CS *SessionService; +} EFI_REDFISH_SESSIONSERVICE_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_3/EfiSessionServiceV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_3/EfiSessionServiceV1_1_3.h new file mode 100644 index 00000000000..2e9ff258c21 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_3/EfiSessionServiceV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SessionService v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSIONSERVICE_V1_1_3_H__ +#define EFI_REDFISH_INTERP_SESSIONSERVICE_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/SessionService/v1_1_3/Redfish_SessionService_v1_1_3_CS.h" +// +// EFI structure of Redfish SessionService v1_1_3 +// +typedef struct _EFI_REDFISH_SESSIONSERVICE_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSIONSERVICE_V1_1_3_CS *SessionService; +} EFI_REDFISH_SESSIONSERVICE_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_4/EfiSessionServiceV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_4/EfiSessionServiceV1_1_4.h new file mode 100644 index 00000000000..85fa1686480 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_4/EfiSessionServiceV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SessionService v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSIONSERVICE_V1_1_4_H__ +#define EFI_REDFISH_INTERP_SESSIONSERVICE_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/SessionService/v1_1_4/Redfish_SessionService_v1_1_4_CS.h" +// +// EFI structure of Redfish SessionService v1_1_4 +// +typedef struct _EFI_REDFISH_SESSIONSERVICE_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSIONSERVICE_V1_1_4_CS *SessionService; +} EFI_REDFISH_SESSIONSERVICE_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_5/EfiSessionServiceV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_5/EfiSessionServiceV1_1_5.h new file mode 100644 index 00000000000..2eb04f0aa0a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_5/EfiSessionServiceV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SessionService v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSIONSERVICE_V1_1_5_H__ +#define EFI_REDFISH_INTERP_SESSIONSERVICE_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/SessionService/v1_1_5/Redfish_SessionService_v1_1_5_CS.h" +// +// EFI structure of Redfish SessionService v1_1_5 +// +typedef struct _EFI_REDFISH_SESSIONSERVICE_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSIONSERVICE_V1_1_5_CS *SessionService; +} EFI_REDFISH_SESSIONSERVICE_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_6/EfiSessionServiceV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_6/EfiSessionServiceV1_1_6.h new file mode 100644 index 00000000000..3816870000f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_6/EfiSessionServiceV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SessionService v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSIONSERVICE_V1_1_6_H__ +#define EFI_REDFISH_INTERP_SESSIONSERVICE_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/SessionService/v1_1_6/Redfish_SessionService_v1_1_6_CS.h" +// +// EFI structure of Redfish SessionService v1_1_6 +// +typedef struct _EFI_REDFISH_SESSIONSERVICE_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSIONSERVICE_V1_1_6_CS *SessionService; +} EFI_REDFISH_SESSIONSERVICE_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_7/EfiSessionServiceV1_1_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_7/EfiSessionServiceV1_1_7.h new file mode 100644 index 00000000000..bfd6b643b51 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_7/EfiSessionServiceV1_1_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SessionService v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSIONSERVICE_V1_1_7_H__ +#define EFI_REDFISH_INTERP_SESSIONSERVICE_V1_1_7_H__ + +#include +#include +#include "ConverterLib/edk2library/SessionService/v1_1_7/Redfish_SessionService_v1_1_7_CS.h" +// +// EFI structure of Redfish SessionService v1_1_7 +// +typedef struct _EFI_REDFISH_SESSIONSERVICE_V1_1_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSIONSERVICE_V1_1_7_CS *SessionService; +} EFI_REDFISH_SESSIONSERVICE_V1_1_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_8/EfiSessionServiceV1_1_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_8/EfiSessionServiceV1_1_8.h new file mode 100644 index 00000000000..9c52a8921c4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SessionService/v1_1_8/EfiSessionServiceV1_1_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SessionService v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SESSIONSERVICE_V1_1_8_H__ +#define EFI_REDFISH_INTERP_SESSIONSERVICE_V1_1_8_H__ + +#include +#include +#include "ConverterLib/edk2library/SessionService/v1_1_8/Redfish_SessionService_v1_1_8_CS.h" +// +// EFI structure of Redfish SessionService v1_1_8 +// +typedef struct _EFI_REDFISH_SESSIONSERVICE_V1_1_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SESSIONSERVICE_V1_1_8_CS *SessionService; +} EFI_REDFISH_SESSIONSERVICE_V1_1_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Signature/v1_0_0/EfiSignatureV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Signature/v1_0_0/EfiSignatureV1_0_0.h new file mode 100644 index 00000000000..5db5ce7d1c0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Signature/v1_0_0/EfiSignatureV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Signature v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIGNATURE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_SIGNATURE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Signature/v1_0_0/Redfish_Signature_v1_0_0_CS.h" +// +// EFI structure of Redfish Signature v1_0_0 +// +typedef struct _EFI_REDFISH_SIGNATURE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIGNATURE_V1_0_0_CS *Signature; +} EFI_REDFISH_SIGNATURE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Signature/v1_0_1/EfiSignatureV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Signature/v1_0_1/EfiSignatureV1_0_1.h new file mode 100644 index 00000000000..e997a175841 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Signature/v1_0_1/EfiSignatureV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Signature v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIGNATURE_V1_0_1_H__ +#define EFI_REDFISH_INTERP_SIGNATURE_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Signature/v1_0_1/Redfish_Signature_v1_0_1_CS.h" +// +// EFI structure of Redfish Signature v1_0_1 +// +typedef struct _EFI_REDFISH_SIGNATURE_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIGNATURE_V1_0_1_CS *Signature; +} EFI_REDFISH_SIGNATURE_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Signature/v1_0_2/EfiSignatureV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Signature/v1_0_2/EfiSignatureV1_0_2.h new file mode 100644 index 00000000000..12d299ba49f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Signature/v1_0_2/EfiSignatureV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Signature v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIGNATURE_V1_0_2_H__ +#define EFI_REDFISH_INTERP_SIGNATURE_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Signature/v1_0_2/Redfish_Signature_v1_0_2_CS.h" +// +// EFI structure of Redfish Signature v1_0_2 +// +typedef struct _EFI_REDFISH_SIGNATURE_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIGNATURE_V1_0_2_CS *Signature; +} EFI_REDFISH_SIGNATURE_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SignatureCollection/EfiSignatureCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/SignatureCollection/EfiSignatureCollection.h new file mode 100644 index 00000000000..c317cf729a5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SignatureCollection/EfiSignatureCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SignatureCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIGNATURECOLLECTION_H__ +#define EFI_REDFISH_INTERP_SIGNATURECOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/SignatureCollection/Redfish_SignatureCollection_CS.h" +// +// EFI structure of Redfish SignatureCollection +// +typedef struct _EFI_REDFISH_SIGNATURECOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIGNATURECOLLECTION_CS *SignatureCollection; +} EFI_REDFISH_SIGNATURECOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_0/EfiSimpleStorageV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_0/EfiSimpleStorageV1_0_0.h new file mode 100644 index 00000000000..645faa70bf5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_0/EfiSimpleStorageV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SimpleStorage v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/SimpleStorage/v1_0_0/Redfish_SimpleStorage_v1_0_0_CS.h" +// +// EFI structure of Redfish SimpleStorage v1_0_0 +// +typedef struct _EFI_REDFISH_SIMPLESTORAGE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIMPLESTORAGE_V1_0_0_CS *SimpleStorage; +} EFI_REDFISH_SIMPLESTORAGE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_2/EfiSimpleStorageV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_2/EfiSimpleStorageV1_0_2.h new file mode 100644 index 00000000000..bc444eb81fa --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_2/EfiSimpleStorageV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SimpleStorage v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_0_2_H__ +#define EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/SimpleStorage/v1_0_2/Redfish_SimpleStorage_v1_0_2_CS.h" +// +// EFI structure of Redfish SimpleStorage v1_0_2 +// +typedef struct _EFI_REDFISH_SIMPLESTORAGE_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIMPLESTORAGE_V1_0_2_CS *SimpleStorage; +} EFI_REDFISH_SIMPLESTORAGE_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_3/EfiSimpleStorageV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_3/EfiSimpleStorageV1_0_3.h new file mode 100644 index 00000000000..7f7900f1da4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_3/EfiSimpleStorageV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SimpleStorage v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_0_3_H__ +#define EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/SimpleStorage/v1_0_3/Redfish_SimpleStorage_v1_0_3_CS.h" +// +// EFI structure of Redfish SimpleStorage v1_0_3 +// +typedef struct _EFI_REDFISH_SIMPLESTORAGE_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIMPLESTORAGE_V1_0_3_CS *SimpleStorage; +} EFI_REDFISH_SIMPLESTORAGE_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_4/EfiSimpleStorageV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_4/EfiSimpleStorageV1_0_4.h new file mode 100644 index 00000000000..495bf2f94c1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_4/EfiSimpleStorageV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SimpleStorage v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_0_4_H__ +#define EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/SimpleStorage/v1_0_4/Redfish_SimpleStorage_v1_0_4_CS.h" +// +// EFI structure of Redfish SimpleStorage v1_0_4 +// +typedef struct _EFI_REDFISH_SIMPLESTORAGE_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIMPLESTORAGE_V1_0_4_CS *SimpleStorage; +} EFI_REDFISH_SIMPLESTORAGE_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_5/EfiSimpleStorageV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_5/EfiSimpleStorageV1_0_5.h new file mode 100644 index 00000000000..14b81b76302 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_5/EfiSimpleStorageV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SimpleStorage v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_0_5_H__ +#define EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/SimpleStorage/v1_0_5/Redfish_SimpleStorage_v1_0_5_CS.h" +// +// EFI structure of Redfish SimpleStorage v1_0_5 +// +typedef struct _EFI_REDFISH_SIMPLESTORAGE_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIMPLESTORAGE_V1_0_5_CS *SimpleStorage; +} EFI_REDFISH_SIMPLESTORAGE_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_6/EfiSimpleStorageV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_6/EfiSimpleStorageV1_0_6.h new file mode 100644 index 00000000000..b12d4337b85 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_6/EfiSimpleStorageV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SimpleStorage v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_0_6_H__ +#define EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/SimpleStorage/v1_0_6/Redfish_SimpleStorage_v1_0_6_CS.h" +// +// EFI structure of Redfish SimpleStorage v1_0_6 +// +typedef struct _EFI_REDFISH_SIMPLESTORAGE_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIMPLESTORAGE_V1_0_6_CS *SimpleStorage; +} EFI_REDFISH_SIMPLESTORAGE_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_7/EfiSimpleStorageV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_7/EfiSimpleStorageV1_0_7.h new file mode 100644 index 00000000000..7803933b9e9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_7/EfiSimpleStorageV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SimpleStorage v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_0_7_H__ +#define EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/SimpleStorage/v1_0_7/Redfish_SimpleStorage_v1_0_7_CS.h" +// +// EFI structure of Redfish SimpleStorage v1_0_7 +// +typedef struct _EFI_REDFISH_SIMPLESTORAGE_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIMPLESTORAGE_V1_0_7_CS *SimpleStorage; +} EFI_REDFISH_SIMPLESTORAGE_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_8/EfiSimpleStorageV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_8/EfiSimpleStorageV1_0_8.h new file mode 100644 index 00000000000..9f376c6a6f9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_0_8/EfiSimpleStorageV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SimpleStorage v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_0_8_H__ +#define EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/SimpleStorage/v1_0_8/Redfish_SimpleStorage_v1_0_8_CS.h" +// +// EFI structure of Redfish SimpleStorage v1_0_8 +// +typedef struct _EFI_REDFISH_SIMPLESTORAGE_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIMPLESTORAGE_V1_0_8_CS *SimpleStorage; +} EFI_REDFISH_SIMPLESTORAGE_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_0/EfiSimpleStorageV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_0/EfiSimpleStorageV1_1_0.h new file mode 100644 index 00000000000..e5651ac0e81 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_0/EfiSimpleStorageV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SimpleStorage v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_1_0_H__ +#define EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/SimpleStorage/v1_1_0/Redfish_SimpleStorage_v1_1_0_CS.h" +// +// EFI structure of Redfish SimpleStorage v1_1_0 +// +typedef struct _EFI_REDFISH_SIMPLESTORAGE_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIMPLESTORAGE_V1_1_0_CS *SimpleStorage; +} EFI_REDFISH_SIMPLESTORAGE_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_1/EfiSimpleStorageV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_1/EfiSimpleStorageV1_1_1.h new file mode 100644 index 00000000000..97a6c95e21b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_1/EfiSimpleStorageV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SimpleStorage v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_1_1_H__ +#define EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/SimpleStorage/v1_1_1/Redfish_SimpleStorage_v1_1_1_CS.h" +// +// EFI structure of Redfish SimpleStorage v1_1_1 +// +typedef struct _EFI_REDFISH_SIMPLESTORAGE_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIMPLESTORAGE_V1_1_1_CS *SimpleStorage; +} EFI_REDFISH_SIMPLESTORAGE_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_2/EfiSimpleStorageV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_2/EfiSimpleStorageV1_1_2.h new file mode 100644 index 00000000000..3053b1cfe5d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_2/EfiSimpleStorageV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SimpleStorage v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_1_2_H__ +#define EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/SimpleStorage/v1_1_2/Redfish_SimpleStorage_v1_1_2_CS.h" +// +// EFI structure of Redfish SimpleStorage v1_1_2 +// +typedef struct _EFI_REDFISH_SIMPLESTORAGE_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIMPLESTORAGE_V1_1_2_CS *SimpleStorage; +} EFI_REDFISH_SIMPLESTORAGE_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_3/EfiSimpleStorageV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_3/EfiSimpleStorageV1_1_3.h new file mode 100644 index 00000000000..120d4fe6bc0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_3/EfiSimpleStorageV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SimpleStorage v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_1_3_H__ +#define EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/SimpleStorage/v1_1_3/Redfish_SimpleStorage_v1_1_3_CS.h" +// +// EFI structure of Redfish SimpleStorage v1_1_3 +// +typedef struct _EFI_REDFISH_SIMPLESTORAGE_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIMPLESTORAGE_V1_1_3_CS *SimpleStorage; +} EFI_REDFISH_SIMPLESTORAGE_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_4/EfiSimpleStorageV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_4/EfiSimpleStorageV1_1_4.h new file mode 100644 index 00000000000..172424318d0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_4/EfiSimpleStorageV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SimpleStorage v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_1_4_H__ +#define EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/SimpleStorage/v1_1_4/Redfish_SimpleStorage_v1_1_4_CS.h" +// +// EFI structure of Redfish SimpleStorage v1_1_4 +// +typedef struct _EFI_REDFISH_SIMPLESTORAGE_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIMPLESTORAGE_V1_1_4_CS *SimpleStorage; +} EFI_REDFISH_SIMPLESTORAGE_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_5/EfiSimpleStorageV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_5/EfiSimpleStorageV1_1_5.h new file mode 100644 index 00000000000..c7d4ff73a75 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_5/EfiSimpleStorageV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SimpleStorage v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_1_5_H__ +#define EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/SimpleStorage/v1_1_5/Redfish_SimpleStorage_v1_1_5_CS.h" +// +// EFI structure of Redfish SimpleStorage v1_1_5 +// +typedef struct _EFI_REDFISH_SIMPLESTORAGE_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIMPLESTORAGE_V1_1_5_CS *SimpleStorage; +} EFI_REDFISH_SIMPLESTORAGE_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_6/EfiSimpleStorageV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_6/EfiSimpleStorageV1_1_6.h new file mode 100644 index 00000000000..25f6d2c1e01 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_1_6/EfiSimpleStorageV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SimpleStorage v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_1_6_H__ +#define EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/SimpleStorage/v1_1_6/Redfish_SimpleStorage_v1_1_6_CS.h" +// +// EFI structure of Redfish SimpleStorage v1_1_6 +// +typedef struct _EFI_REDFISH_SIMPLESTORAGE_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIMPLESTORAGE_V1_1_6_CS *SimpleStorage; +} EFI_REDFISH_SIMPLESTORAGE_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_2_0/EfiSimpleStorageV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_2_0/EfiSimpleStorageV1_2_0.h new file mode 100644 index 00000000000..fa59d29c7c5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_2_0/EfiSimpleStorageV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SimpleStorage v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_2_0_H__ +#define EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/SimpleStorage/v1_2_0/Redfish_SimpleStorage_v1_2_0_CS.h" +// +// EFI structure of Redfish SimpleStorage v1_2_0 +// +typedef struct _EFI_REDFISH_SIMPLESTORAGE_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIMPLESTORAGE_V1_2_0_CS *SimpleStorage; +} EFI_REDFISH_SIMPLESTORAGE_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_2_1/EfiSimpleStorageV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_2_1/EfiSimpleStorageV1_2_1.h new file mode 100644 index 00000000000..ca3d971cf07 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_2_1/EfiSimpleStorageV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SimpleStorage v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_2_1_H__ +#define EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/SimpleStorage/v1_2_1/Redfish_SimpleStorage_v1_2_1_CS.h" +// +// EFI structure of Redfish SimpleStorage v1_2_1 +// +typedef struct _EFI_REDFISH_SIMPLESTORAGE_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIMPLESTORAGE_V1_2_1_CS *SimpleStorage; +} EFI_REDFISH_SIMPLESTORAGE_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_2_2/EfiSimpleStorageV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_2_2/EfiSimpleStorageV1_2_2.h new file mode 100644 index 00000000000..5fc9d85f941 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_2_2/EfiSimpleStorageV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SimpleStorage v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_2_2_H__ +#define EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/SimpleStorage/v1_2_2/Redfish_SimpleStorage_v1_2_2_CS.h" +// +// EFI structure of Redfish SimpleStorage v1_2_2 +// +typedef struct _EFI_REDFISH_SIMPLESTORAGE_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIMPLESTORAGE_V1_2_2_CS *SimpleStorage; +} EFI_REDFISH_SIMPLESTORAGE_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_2_3/EfiSimpleStorageV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_2_3/EfiSimpleStorageV1_2_3.h new file mode 100644 index 00000000000..7d6922ef19a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_2_3/EfiSimpleStorageV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SimpleStorage v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_2_3_H__ +#define EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/SimpleStorage/v1_2_3/Redfish_SimpleStorage_v1_2_3_CS.h" +// +// EFI structure of Redfish SimpleStorage v1_2_3 +// +typedef struct _EFI_REDFISH_SIMPLESTORAGE_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIMPLESTORAGE_V1_2_3_CS *SimpleStorage; +} EFI_REDFISH_SIMPLESTORAGE_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_2_4/EfiSimpleStorageV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_2_4/EfiSimpleStorageV1_2_4.h new file mode 100644 index 00000000000..e2f48bf836c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_2_4/EfiSimpleStorageV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SimpleStorage v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_2_4_H__ +#define EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/SimpleStorage/v1_2_4/Redfish_SimpleStorage_v1_2_4_CS.h" +// +// EFI structure of Redfish SimpleStorage v1_2_4 +// +typedef struct _EFI_REDFISH_SIMPLESTORAGE_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIMPLESTORAGE_V1_2_4_CS *SimpleStorage; +} EFI_REDFISH_SIMPLESTORAGE_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_3_0/EfiSimpleStorageV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_3_0/EfiSimpleStorageV1_3_0.h new file mode 100644 index 00000000000..b32bc76d095 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_3_0/EfiSimpleStorageV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SimpleStorage v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_3_0_H__ +#define EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/SimpleStorage/v1_3_0/Redfish_SimpleStorage_v1_3_0_CS.h" +// +// EFI structure of Redfish SimpleStorage v1_3_0 +// +typedef struct _EFI_REDFISH_SIMPLESTORAGE_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIMPLESTORAGE_V1_3_0_CS *SimpleStorage; +} EFI_REDFISH_SIMPLESTORAGE_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_3_1/EfiSimpleStorageV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_3_1/EfiSimpleStorageV1_3_1.h new file mode 100644 index 00000000000..cfdb93448c0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorage/v1_3_1/EfiSimpleStorageV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SimpleStorage v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_3_1_H__ +#define EFI_REDFISH_INTERP_SIMPLESTORAGE_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/SimpleStorage/v1_3_1/Redfish_SimpleStorage_v1_3_1_CS.h" +// +// EFI structure of Redfish SimpleStorage v1_3_1 +// +typedef struct _EFI_REDFISH_SIMPLESTORAGE_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIMPLESTORAGE_V1_3_1_CS *SimpleStorage; +} EFI_REDFISH_SIMPLESTORAGE_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorageCollection/EfiSimpleStorageCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorageCollection/EfiSimpleStorageCollection.h new file mode 100644 index 00000000000..48f23e2b8f6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SimpleStorageCollection/EfiSimpleStorageCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SimpleStorageCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SIMPLESTORAGECOLLECTION_H__ +#define EFI_REDFISH_INTERP_SIMPLESTORAGECOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/SimpleStorageCollection/Redfish_SimpleStorageCollection_CS.h" +// +// EFI structure of Redfish SimpleStorageCollection +// +typedef struct _EFI_REDFISH_SIMPLESTORAGECOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SIMPLESTORAGECOLLECTION_CS *SimpleStorageCollection; +} EFI_REDFISH_SIMPLESTORAGECOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_0_0/EfiSoftwareInventoryV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_0_0/EfiSoftwareInventoryV1_0_0.h new file mode 100644 index 00000000000..9b4f444a51e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_0_0/EfiSoftwareInventoryV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SoftwareInventory v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_0_0_H__ +#define EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/SoftwareInventory/v1_0_0/Redfish_SoftwareInventory_v1_0_0_CS.h" +// +// EFI structure of Redfish SoftwareInventory v1_0_0 +// +typedef struct _EFI_REDFISH_SOFTWAREINVENTORY_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SOFTWAREINVENTORY_V1_0_0_CS *SoftwareInventory; +} EFI_REDFISH_SOFTWAREINVENTORY_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_0_1/EfiSoftwareInventoryV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_0_1/EfiSoftwareInventoryV1_0_1.h new file mode 100644 index 00000000000..e48da13d25c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_0_1/EfiSoftwareInventoryV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SoftwareInventory v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_0_1_H__ +#define EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/SoftwareInventory/v1_0_1/Redfish_SoftwareInventory_v1_0_1_CS.h" +// +// EFI structure of Redfish SoftwareInventory v1_0_1 +// +typedef struct _EFI_REDFISH_SOFTWAREINVENTORY_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SOFTWAREINVENTORY_V1_0_1_CS *SoftwareInventory; +} EFI_REDFISH_SOFTWAREINVENTORY_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_0_2/EfiSoftwareInventoryV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_0_2/EfiSoftwareInventoryV1_0_2.h new file mode 100644 index 00000000000..329a6f12e8b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_0_2/EfiSoftwareInventoryV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SoftwareInventory v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_0_2_H__ +#define EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/SoftwareInventory/v1_0_2/Redfish_SoftwareInventory_v1_0_2_CS.h" +// +// EFI structure of Redfish SoftwareInventory v1_0_2 +// +typedef struct _EFI_REDFISH_SOFTWAREINVENTORY_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SOFTWAREINVENTORY_V1_0_2_CS *SoftwareInventory; +} EFI_REDFISH_SOFTWAREINVENTORY_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_0_3/EfiSoftwareInventoryV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_0_3/EfiSoftwareInventoryV1_0_3.h new file mode 100644 index 00000000000..ffeb727381b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_0_3/EfiSoftwareInventoryV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SoftwareInventory v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_0_3_H__ +#define EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/SoftwareInventory/v1_0_3/Redfish_SoftwareInventory_v1_0_3_CS.h" +// +// EFI structure of Redfish SoftwareInventory v1_0_3 +// +typedef struct _EFI_REDFISH_SOFTWAREINVENTORY_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SOFTWAREINVENTORY_V1_0_3_CS *SoftwareInventory; +} EFI_REDFISH_SOFTWAREINVENTORY_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_0_4/EfiSoftwareInventoryV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_0_4/EfiSoftwareInventoryV1_0_4.h new file mode 100644 index 00000000000..5931741fd80 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_0_4/EfiSoftwareInventoryV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SoftwareInventory v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_0_4_H__ +#define EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/SoftwareInventory/v1_0_4/Redfish_SoftwareInventory_v1_0_4_CS.h" +// +// EFI structure of Redfish SoftwareInventory v1_0_4 +// +typedef struct _EFI_REDFISH_SOFTWAREINVENTORY_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SOFTWAREINVENTORY_V1_0_4_CS *SoftwareInventory; +} EFI_REDFISH_SOFTWAREINVENTORY_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_0_5/EfiSoftwareInventoryV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_0_5/EfiSoftwareInventoryV1_0_5.h new file mode 100644 index 00000000000..0a04a98391a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_0_5/EfiSoftwareInventoryV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SoftwareInventory v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_0_5_H__ +#define EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/SoftwareInventory/v1_0_5/Redfish_SoftwareInventory_v1_0_5_CS.h" +// +// EFI structure of Redfish SoftwareInventory v1_0_5 +// +typedef struct _EFI_REDFISH_SOFTWAREINVENTORY_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SOFTWAREINVENTORY_V1_0_5_CS *SoftwareInventory; +} EFI_REDFISH_SOFTWAREINVENTORY_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_1_0/EfiSoftwareInventoryV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_1_0/EfiSoftwareInventoryV1_1_0.h new file mode 100644 index 00000000000..b7adee641a0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_1_0/EfiSoftwareInventoryV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SoftwareInventory v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_1_0_H__ +#define EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/SoftwareInventory/v1_1_0/Redfish_SoftwareInventory_v1_1_0_CS.h" +// +// EFI structure of Redfish SoftwareInventory v1_1_0 +// +typedef struct _EFI_REDFISH_SOFTWAREINVENTORY_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SOFTWAREINVENTORY_V1_1_0_CS *SoftwareInventory; +} EFI_REDFISH_SOFTWAREINVENTORY_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_1_1/EfiSoftwareInventoryV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_1_1/EfiSoftwareInventoryV1_1_1.h new file mode 100644 index 00000000000..8292f3e513d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_1_1/EfiSoftwareInventoryV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SoftwareInventory v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_1_1_H__ +#define EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/SoftwareInventory/v1_1_1/Redfish_SoftwareInventory_v1_1_1_CS.h" +// +// EFI structure of Redfish SoftwareInventory v1_1_1 +// +typedef struct _EFI_REDFISH_SOFTWAREINVENTORY_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SOFTWAREINVENTORY_V1_1_1_CS *SoftwareInventory; +} EFI_REDFISH_SOFTWAREINVENTORY_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_1_2/EfiSoftwareInventoryV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_1_2/EfiSoftwareInventoryV1_1_2.h new file mode 100644 index 00000000000..5bd0fa4f4aa --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_1_2/EfiSoftwareInventoryV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SoftwareInventory v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_1_2_H__ +#define EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/SoftwareInventory/v1_1_2/Redfish_SoftwareInventory_v1_1_2_CS.h" +// +// EFI structure of Redfish SoftwareInventory v1_1_2 +// +typedef struct _EFI_REDFISH_SOFTWAREINVENTORY_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SOFTWAREINVENTORY_V1_1_2_CS *SoftwareInventory; +} EFI_REDFISH_SOFTWAREINVENTORY_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_1_3/EfiSoftwareInventoryV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_1_3/EfiSoftwareInventoryV1_1_3.h new file mode 100644 index 00000000000..73f9f5d98c0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_1_3/EfiSoftwareInventoryV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SoftwareInventory v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_1_3_H__ +#define EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/SoftwareInventory/v1_1_3/Redfish_SoftwareInventory_v1_1_3_CS.h" +// +// EFI structure of Redfish SoftwareInventory v1_1_3 +// +typedef struct _EFI_REDFISH_SOFTWAREINVENTORY_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SOFTWAREINVENTORY_V1_1_3_CS *SoftwareInventory; +} EFI_REDFISH_SOFTWAREINVENTORY_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_1_4/EfiSoftwareInventoryV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_1_4/EfiSoftwareInventoryV1_1_4.h new file mode 100644 index 00000000000..a66338c47c0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_1_4/EfiSoftwareInventoryV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SoftwareInventory v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_1_4_H__ +#define EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/SoftwareInventory/v1_1_4/Redfish_SoftwareInventory_v1_1_4_CS.h" +// +// EFI structure of Redfish SoftwareInventory v1_1_4 +// +typedef struct _EFI_REDFISH_SOFTWAREINVENTORY_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SOFTWAREINVENTORY_V1_1_4_CS *SoftwareInventory; +} EFI_REDFISH_SOFTWAREINVENTORY_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_2_0/EfiSoftwareInventoryV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_2_0/EfiSoftwareInventoryV1_2_0.h new file mode 100644 index 00000000000..4c17de6ccf4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_2_0/EfiSoftwareInventoryV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SoftwareInventory v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_2_0_H__ +#define EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/SoftwareInventory/v1_2_0/Redfish_SoftwareInventory_v1_2_0_CS.h" +// +// EFI structure of Redfish SoftwareInventory v1_2_0 +// +typedef struct _EFI_REDFISH_SOFTWAREINVENTORY_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SOFTWAREINVENTORY_V1_2_0_CS *SoftwareInventory; +} EFI_REDFISH_SOFTWAREINVENTORY_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_2_1/EfiSoftwareInventoryV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_2_1/EfiSoftwareInventoryV1_2_1.h new file mode 100644 index 00000000000..855cf43b76b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_2_1/EfiSoftwareInventoryV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SoftwareInventory v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_2_1_H__ +#define EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/SoftwareInventory/v1_2_1/Redfish_SoftwareInventory_v1_2_1_CS.h" +// +// EFI structure of Redfish SoftwareInventory v1_2_1 +// +typedef struct _EFI_REDFISH_SOFTWAREINVENTORY_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SOFTWAREINVENTORY_V1_2_1_CS *SoftwareInventory; +} EFI_REDFISH_SOFTWAREINVENTORY_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_2_2/EfiSoftwareInventoryV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_2_2/EfiSoftwareInventoryV1_2_2.h new file mode 100644 index 00000000000..b9d9ff5a51d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_2_2/EfiSoftwareInventoryV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SoftwareInventory v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_2_2_H__ +#define EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/SoftwareInventory/v1_2_2/Redfish_SoftwareInventory_v1_2_2_CS.h" +// +// EFI structure of Redfish SoftwareInventory v1_2_2 +// +typedef struct _EFI_REDFISH_SOFTWAREINVENTORY_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SOFTWAREINVENTORY_V1_2_2_CS *SoftwareInventory; +} EFI_REDFISH_SOFTWAREINVENTORY_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_2_3/EfiSoftwareInventoryV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_2_3/EfiSoftwareInventoryV1_2_3.h new file mode 100644 index 00000000000..683942bbcf1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_2_3/EfiSoftwareInventoryV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SoftwareInventory v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_2_3_H__ +#define EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/SoftwareInventory/v1_2_3/Redfish_SoftwareInventory_v1_2_3_CS.h" +// +// EFI structure of Redfish SoftwareInventory v1_2_3 +// +typedef struct _EFI_REDFISH_SOFTWAREINVENTORY_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SOFTWAREINVENTORY_V1_2_3_CS *SoftwareInventory; +} EFI_REDFISH_SOFTWAREINVENTORY_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_3_0/EfiSoftwareInventoryV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_3_0/EfiSoftwareInventoryV1_3_0.h new file mode 100644 index 00000000000..8ae82281f26 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_3_0/EfiSoftwareInventoryV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SoftwareInventory v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_3_0_H__ +#define EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/SoftwareInventory/v1_3_0/Redfish_SoftwareInventory_v1_3_0_CS.h" +// +// EFI structure of Redfish SoftwareInventory v1_3_0 +// +typedef struct _EFI_REDFISH_SOFTWAREINVENTORY_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SOFTWAREINVENTORY_V1_3_0_CS *SoftwareInventory; +} EFI_REDFISH_SOFTWAREINVENTORY_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_4_0/EfiSoftwareInventoryV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_4_0/EfiSoftwareInventoryV1_4_0.h new file mode 100644 index 00000000000..30dbc4b86d7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventory/v1_4_0/EfiSoftwareInventoryV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SoftwareInventory v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_4_0_H__ +#define EFI_REDFISH_INTERP_SOFTWAREINVENTORY_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/SoftwareInventory/v1_4_0/Redfish_SoftwareInventory_v1_4_0_CS.h" +// +// EFI structure of Redfish SoftwareInventory v1_4_0 +// +typedef struct _EFI_REDFISH_SOFTWAREINVENTORY_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SOFTWAREINVENTORY_V1_4_0_CS *SoftwareInventory; +} EFI_REDFISH_SOFTWAREINVENTORY_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventoryCollection/EfiSoftwareInventoryCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventoryCollection/EfiSoftwareInventoryCollection.h new file mode 100644 index 00000000000..a8cca355a01 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SoftwareInventoryCollection/EfiSoftwareInventoryCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SoftwareInventoryCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SOFTWAREINVENTORYCOLLECTION_H__ +#define EFI_REDFISH_INTERP_SOFTWAREINVENTORYCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/SoftwareInventoryCollection/Redfish_SoftwareInventoryCollection_CS.h" +// +// EFI structure of Redfish SoftwareInventoryCollection +// +typedef struct _EFI_REDFISH_SOFTWAREINVENTORYCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SOFTWAREINVENTORYCOLLECTION_CS *SoftwareInventoryCollection; +} EFI_REDFISH_SOFTWAREINVENTORYCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_1/EfiStorageV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_1/EfiStorageV1_0_1.h new file mode 100644 index 00000000000..6e83e047c2e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_1/EfiStorageV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_0_1_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_0_1/Redfish_Storage_v1_0_1_CS.h" +// +// EFI structure of Redfish Storage v1_0_1 +// +typedef struct _EFI_REDFISH_STORAGE_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_0_1_CS *Storage; +} EFI_REDFISH_STORAGE_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_10/EfiStorageV1_0_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_10/EfiStorageV1_0_10.h new file mode 100644 index 00000000000..b2a97caf8d5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_10/EfiStorageV1_0_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_0_10_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_0_10_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_0_10/Redfish_Storage_v1_0_10_CS.h" +// +// EFI structure of Redfish Storage v1_0_10 +// +typedef struct _EFI_REDFISH_STORAGE_V1_0_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_0_10_CS *Storage; +} EFI_REDFISH_STORAGE_V1_0_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_2/EfiStorageV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_2/EfiStorageV1_0_2.h new file mode 100644 index 00000000000..86a569d1055 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_2/EfiStorageV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_0_2_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_0_2/Redfish_Storage_v1_0_2_CS.h" +// +// EFI structure of Redfish Storage v1_0_2 +// +typedef struct _EFI_REDFISH_STORAGE_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_0_2_CS *Storage; +} EFI_REDFISH_STORAGE_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_3/EfiStorageV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_3/EfiStorageV1_0_3.h new file mode 100644 index 00000000000..fb1b76f5100 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_3/EfiStorageV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_0_3_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_0_3/Redfish_Storage_v1_0_3_CS.h" +// +// EFI structure of Redfish Storage v1_0_3 +// +typedef struct _EFI_REDFISH_STORAGE_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_0_3_CS *Storage; +} EFI_REDFISH_STORAGE_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_4/EfiStorageV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_4/EfiStorageV1_0_4.h new file mode 100644 index 00000000000..6d3bd9b0f82 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_4/EfiStorageV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_0_4_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_0_4/Redfish_Storage_v1_0_4_CS.h" +// +// EFI structure of Redfish Storage v1_0_4 +// +typedef struct _EFI_REDFISH_STORAGE_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_0_4_CS *Storage; +} EFI_REDFISH_STORAGE_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_5/EfiStorageV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_5/EfiStorageV1_0_5.h new file mode 100644 index 00000000000..941e7efdf38 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_5/EfiStorageV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_0_5_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_0_5/Redfish_Storage_v1_0_5_CS.h" +// +// EFI structure of Redfish Storage v1_0_5 +// +typedef struct _EFI_REDFISH_STORAGE_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_0_5_CS *Storage; +} EFI_REDFISH_STORAGE_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_6/EfiStorageV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_6/EfiStorageV1_0_6.h new file mode 100644 index 00000000000..f1f7f341539 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_6/EfiStorageV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_0_6_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_0_6/Redfish_Storage_v1_0_6_CS.h" +// +// EFI structure of Redfish Storage v1_0_6 +// +typedef struct _EFI_REDFISH_STORAGE_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_0_6_CS *Storage; +} EFI_REDFISH_STORAGE_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_7/EfiStorageV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_7/EfiStorageV1_0_7.h new file mode 100644 index 00000000000..f460d56d207 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_7/EfiStorageV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_0_7_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_0_7/Redfish_Storage_v1_0_7_CS.h" +// +// EFI structure of Redfish Storage v1_0_7 +// +typedef struct _EFI_REDFISH_STORAGE_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_0_7_CS *Storage; +} EFI_REDFISH_STORAGE_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_8/EfiStorageV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_8/EfiStorageV1_0_8.h new file mode 100644 index 00000000000..9c5965daf48 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_8/EfiStorageV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_0_8_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_0_8/Redfish_Storage_v1_0_8_CS.h" +// +// EFI structure of Redfish Storage v1_0_8 +// +typedef struct _EFI_REDFISH_STORAGE_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_0_8_CS *Storage; +} EFI_REDFISH_STORAGE_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_9/EfiStorageV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_9/EfiStorageV1_0_9.h new file mode 100644 index 00000000000..5949938486e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_0_9/EfiStorageV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_0_9_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_0_9/Redfish_Storage_v1_0_9_CS.h" +// +// EFI structure of Redfish Storage v1_0_9 +// +typedef struct _EFI_REDFISH_STORAGE_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_0_9_CS *Storage; +} EFI_REDFISH_STORAGE_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_10_0/EfiStorageV1_10_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_10_0/EfiStorageV1_10_0.h new file mode 100644 index 00000000000..b24a9c3cd5a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_10_0/EfiStorageV1_10_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_10_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_10_0_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_10_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_10_0/Redfish_Storage_v1_10_0_CS.h" +// +// EFI structure of Redfish Storage v1_10_0 +// +typedef struct _EFI_REDFISH_STORAGE_V1_10_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_10_0_CS *Storage; +} EFI_REDFISH_STORAGE_V1_10_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_1/EfiStorageV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_1/EfiStorageV1_1_1.h new file mode 100644 index 00000000000..d218c294c27 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_1/EfiStorageV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_1_1_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_1_1/Redfish_Storage_v1_1_1_CS.h" +// +// EFI structure of Redfish Storage v1_1_1 +// +typedef struct _EFI_REDFISH_STORAGE_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_1_1_CS *Storage; +} EFI_REDFISH_STORAGE_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_2/EfiStorageV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_2/EfiStorageV1_1_2.h new file mode 100644 index 00000000000..a9473ba0ce1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_2/EfiStorageV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_1_2_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_1_2/Redfish_Storage_v1_1_2_CS.h" +// +// EFI structure of Redfish Storage v1_1_2 +// +typedef struct _EFI_REDFISH_STORAGE_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_1_2_CS *Storage; +} EFI_REDFISH_STORAGE_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_3/EfiStorageV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_3/EfiStorageV1_1_3.h new file mode 100644 index 00000000000..2e216965dbc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_3/EfiStorageV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_1_3_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_1_3/Redfish_Storage_v1_1_3_CS.h" +// +// EFI structure of Redfish Storage v1_1_3 +// +typedef struct _EFI_REDFISH_STORAGE_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_1_3_CS *Storage; +} EFI_REDFISH_STORAGE_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_4/EfiStorageV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_4/EfiStorageV1_1_4.h new file mode 100644 index 00000000000..6c33663e7a2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_4/EfiStorageV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_1_4_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_1_4/Redfish_Storage_v1_1_4_CS.h" +// +// EFI structure of Redfish Storage v1_1_4 +// +typedef struct _EFI_REDFISH_STORAGE_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_1_4_CS *Storage; +} EFI_REDFISH_STORAGE_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_5/EfiStorageV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_5/EfiStorageV1_1_5.h new file mode 100644 index 00000000000..9be92a17916 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_5/EfiStorageV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_1_5_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_1_5/Redfish_Storage_v1_1_5_CS.h" +// +// EFI structure of Redfish Storage v1_1_5 +// +typedef struct _EFI_REDFISH_STORAGE_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_1_5_CS *Storage; +} EFI_REDFISH_STORAGE_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_6/EfiStorageV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_6/EfiStorageV1_1_6.h new file mode 100644 index 00000000000..63451a3cf08 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_6/EfiStorageV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_1_6_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_1_6/Redfish_Storage_v1_1_6_CS.h" +// +// EFI structure of Redfish Storage v1_1_6 +// +typedef struct _EFI_REDFISH_STORAGE_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_1_6_CS *Storage; +} EFI_REDFISH_STORAGE_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_7/EfiStorageV1_1_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_7/EfiStorageV1_1_7.h new file mode 100644 index 00000000000..6ce2fae6b7c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_7/EfiStorageV1_1_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_1_7_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_1_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_1_7/Redfish_Storage_v1_1_7_CS.h" +// +// EFI structure of Redfish Storage v1_1_7 +// +typedef struct _EFI_REDFISH_STORAGE_V1_1_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_1_7_CS *Storage; +} EFI_REDFISH_STORAGE_V1_1_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_8/EfiStorageV1_1_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_8/EfiStorageV1_1_8.h new file mode 100644 index 00000000000..f9bde3dd96f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_8/EfiStorageV1_1_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_1_8_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_1_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_1_8/Redfish_Storage_v1_1_8_CS.h" +// +// EFI structure of Redfish Storage v1_1_8 +// +typedef struct _EFI_REDFISH_STORAGE_V1_1_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_1_8_CS *Storage; +} EFI_REDFISH_STORAGE_V1_1_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_9/EfiStorageV1_1_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_9/EfiStorageV1_1_9.h new file mode 100644 index 00000000000..595c1fb4b69 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_1_9/EfiStorageV1_1_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_1_9_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_1_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_1_9/Redfish_Storage_v1_1_9_CS.h" +// +// EFI structure of Redfish Storage v1_1_9 +// +typedef struct _EFI_REDFISH_STORAGE_V1_1_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_1_9_CS *Storage; +} EFI_REDFISH_STORAGE_V1_1_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_0/EfiStorageV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_0/EfiStorageV1_2_0.h new file mode 100644 index 00000000000..de144e92c12 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_0/EfiStorageV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_2_0_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_2_0/Redfish_Storage_v1_2_0_CS.h" +// +// EFI structure of Redfish Storage v1_2_0 +// +typedef struct _EFI_REDFISH_STORAGE_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_2_0_CS *Storage; +} EFI_REDFISH_STORAGE_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_1/EfiStorageV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_1/EfiStorageV1_2_1.h new file mode 100644 index 00000000000..5b5fa82f958 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_1/EfiStorageV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_2_1_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_2_1/Redfish_Storage_v1_2_1_CS.h" +// +// EFI structure of Redfish Storage v1_2_1 +// +typedef struct _EFI_REDFISH_STORAGE_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_2_1_CS *Storage; +} EFI_REDFISH_STORAGE_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_2/EfiStorageV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_2/EfiStorageV1_2_2.h new file mode 100644 index 00000000000..2aa25c27a23 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_2/EfiStorageV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_2_2_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_2_2/Redfish_Storage_v1_2_2_CS.h" +// +// EFI structure of Redfish Storage v1_2_2 +// +typedef struct _EFI_REDFISH_STORAGE_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_2_2_CS *Storage; +} EFI_REDFISH_STORAGE_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_3/EfiStorageV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_3/EfiStorageV1_2_3.h new file mode 100644 index 00000000000..1aa0c03016f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_3/EfiStorageV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_2_3_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_2_3/Redfish_Storage_v1_2_3_CS.h" +// +// EFI structure of Redfish Storage v1_2_3 +// +typedef struct _EFI_REDFISH_STORAGE_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_2_3_CS *Storage; +} EFI_REDFISH_STORAGE_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_4/EfiStorageV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_4/EfiStorageV1_2_4.h new file mode 100644 index 00000000000..ce26d9decb5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_4/EfiStorageV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_2_4_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_2_4/Redfish_Storage_v1_2_4_CS.h" +// +// EFI structure of Redfish Storage v1_2_4 +// +typedef struct _EFI_REDFISH_STORAGE_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_2_4_CS *Storage; +} EFI_REDFISH_STORAGE_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_5/EfiStorageV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_5/EfiStorageV1_2_5.h new file mode 100644 index 00000000000..b9af28d19dd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_5/EfiStorageV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_2_5_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_2_5/Redfish_Storage_v1_2_5_CS.h" +// +// EFI structure of Redfish Storage v1_2_5 +// +typedef struct _EFI_REDFISH_STORAGE_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_2_5_CS *Storage; +} EFI_REDFISH_STORAGE_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_6/EfiStorageV1_2_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_6/EfiStorageV1_2_6.h new file mode 100644 index 00000000000..18a23f312a6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_6/EfiStorageV1_2_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_2_6_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_2_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_2_6/Redfish_Storage_v1_2_6_CS.h" +// +// EFI structure of Redfish Storage v1_2_6 +// +typedef struct _EFI_REDFISH_STORAGE_V1_2_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_2_6_CS *Storage; +} EFI_REDFISH_STORAGE_V1_2_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_7/EfiStorageV1_2_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_7/EfiStorageV1_2_7.h new file mode 100644 index 00000000000..e751ddb2e56 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_2_7/EfiStorageV1_2_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_2_7_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_2_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_2_7/Redfish_Storage_v1_2_7_CS.h" +// +// EFI structure of Redfish Storage v1_2_7 +// +typedef struct _EFI_REDFISH_STORAGE_V1_2_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_2_7_CS *Storage; +} EFI_REDFISH_STORAGE_V1_2_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_0/EfiStorageV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_0/EfiStorageV1_3_0.h new file mode 100644 index 00000000000..d4bb2dcc67f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_0/EfiStorageV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_3_0_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_3_0/Redfish_Storage_v1_3_0_CS.h" +// +// EFI structure of Redfish Storage v1_3_0 +// +typedef struct _EFI_REDFISH_STORAGE_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_3_0_CS *Storage; +} EFI_REDFISH_STORAGE_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_1/EfiStorageV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_1/EfiStorageV1_3_1.h new file mode 100644 index 00000000000..b402888aa0b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_1/EfiStorageV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_3_1_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_3_1/Redfish_Storage_v1_3_1_CS.h" +// +// EFI structure of Redfish Storage v1_3_1 +// +typedef struct _EFI_REDFISH_STORAGE_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_3_1_CS *Storage; +} EFI_REDFISH_STORAGE_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_2/EfiStorageV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_2/EfiStorageV1_3_2.h new file mode 100644 index 00000000000..438202116b5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_2/EfiStorageV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_3_2_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_3_2/Redfish_Storage_v1_3_2_CS.h" +// +// EFI structure of Redfish Storage v1_3_2 +// +typedef struct _EFI_REDFISH_STORAGE_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_3_2_CS *Storage; +} EFI_REDFISH_STORAGE_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_3/EfiStorageV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_3/EfiStorageV1_3_3.h new file mode 100644 index 00000000000..722d30721b2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_3/EfiStorageV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_3_3_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_3_3/Redfish_Storage_v1_3_3_CS.h" +// +// EFI structure of Redfish Storage v1_3_3 +// +typedef struct _EFI_REDFISH_STORAGE_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_3_3_CS *Storage; +} EFI_REDFISH_STORAGE_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_4/EfiStorageV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_4/EfiStorageV1_3_4.h new file mode 100644 index 00000000000..ebb2dfc3c4e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_4/EfiStorageV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_3_4_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_3_4/Redfish_Storage_v1_3_4_CS.h" +// +// EFI structure of Redfish Storage v1_3_4 +// +typedef struct _EFI_REDFISH_STORAGE_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_3_4_CS *Storage; +} EFI_REDFISH_STORAGE_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_5/EfiStorageV1_3_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_5/EfiStorageV1_3_5.h new file mode 100644 index 00000000000..b8a403b679e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_5/EfiStorageV1_3_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_3_5_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_3_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_3_5/Redfish_Storage_v1_3_5_CS.h" +// +// EFI structure of Redfish Storage v1_3_5 +// +typedef struct _EFI_REDFISH_STORAGE_V1_3_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_3_5_CS *Storage; +} EFI_REDFISH_STORAGE_V1_3_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_6/EfiStorageV1_3_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_6/EfiStorageV1_3_6.h new file mode 100644 index 00000000000..a49cdd133eb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_6/EfiStorageV1_3_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_3_6_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_3_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_3_6/Redfish_Storage_v1_3_6_CS.h" +// +// EFI structure of Redfish Storage v1_3_6 +// +typedef struct _EFI_REDFISH_STORAGE_V1_3_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_3_6_CS *Storage; +} EFI_REDFISH_STORAGE_V1_3_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_7/EfiStorageV1_3_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_7/EfiStorageV1_3_7.h new file mode 100644 index 00000000000..17a9abe295b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_3_7/EfiStorageV1_3_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_3_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_3_7_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_3_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_3_7/Redfish_Storage_v1_3_7_CS.h" +// +// EFI structure of Redfish Storage v1_3_7 +// +typedef struct _EFI_REDFISH_STORAGE_V1_3_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_3_7_CS *Storage; +} EFI_REDFISH_STORAGE_V1_3_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_0/EfiStorageV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_0/EfiStorageV1_4_0.h new file mode 100644 index 00000000000..82bee5f509d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_0/EfiStorageV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_4_0_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_4_0/Redfish_Storage_v1_4_0_CS.h" +// +// EFI structure of Redfish Storage v1_4_0 +// +typedef struct _EFI_REDFISH_STORAGE_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_4_0_CS *Storage; +} EFI_REDFISH_STORAGE_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_1/EfiStorageV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_1/EfiStorageV1_4_1.h new file mode 100644 index 00000000000..5300d34ac6e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_1/EfiStorageV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_4_1_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_4_1/Redfish_Storage_v1_4_1_CS.h" +// +// EFI structure of Redfish Storage v1_4_1 +// +typedef struct _EFI_REDFISH_STORAGE_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_4_1_CS *Storage; +} EFI_REDFISH_STORAGE_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_2/EfiStorageV1_4_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_2/EfiStorageV1_4_2.h new file mode 100644 index 00000000000..ef77af4130d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_2/EfiStorageV1_4_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_4_2_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_4_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_4_2/Redfish_Storage_v1_4_2_CS.h" +// +// EFI structure of Redfish Storage v1_4_2 +// +typedef struct _EFI_REDFISH_STORAGE_V1_4_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_4_2_CS *Storage; +} EFI_REDFISH_STORAGE_V1_4_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_3/EfiStorageV1_4_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_3/EfiStorageV1_4_3.h new file mode 100644 index 00000000000..56abc695c72 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_3/EfiStorageV1_4_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_4_3_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_4_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_4_3/Redfish_Storage_v1_4_3_CS.h" +// +// EFI structure of Redfish Storage v1_4_3 +// +typedef struct _EFI_REDFISH_STORAGE_V1_4_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_4_3_CS *Storage; +} EFI_REDFISH_STORAGE_V1_4_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_4/EfiStorageV1_4_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_4/EfiStorageV1_4_4.h new file mode 100644 index 00000000000..295e10dd89d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_4/EfiStorageV1_4_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_4_4_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_4_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_4_4/Redfish_Storage_v1_4_4_CS.h" +// +// EFI structure of Redfish Storage v1_4_4 +// +typedef struct _EFI_REDFISH_STORAGE_V1_4_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_4_4_CS *Storage; +} EFI_REDFISH_STORAGE_V1_4_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_5/EfiStorageV1_4_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_5/EfiStorageV1_4_5.h new file mode 100644 index 00000000000..f6d66a016fb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_5/EfiStorageV1_4_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_4_5_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_4_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_4_5/Redfish_Storage_v1_4_5_CS.h" +// +// EFI structure of Redfish Storage v1_4_5 +// +typedef struct _EFI_REDFISH_STORAGE_V1_4_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_4_5_CS *Storage; +} EFI_REDFISH_STORAGE_V1_4_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_6/EfiStorageV1_4_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_6/EfiStorageV1_4_6.h new file mode 100644 index 00000000000..4737cd57fc2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_4_6/EfiStorageV1_4_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_4_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_4_6_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_4_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_4_6/Redfish_Storage_v1_4_6_CS.h" +// +// EFI structure of Redfish Storage v1_4_6 +// +typedef struct _EFI_REDFISH_STORAGE_V1_4_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_4_6_CS *Storage; +} EFI_REDFISH_STORAGE_V1_4_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_5_0/EfiStorageV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_5_0/EfiStorageV1_5_0.h new file mode 100644 index 00000000000..359e1ccfdb4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_5_0/EfiStorageV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_5_0_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_5_0/Redfish_Storage_v1_5_0_CS.h" +// +// EFI structure of Redfish Storage v1_5_0 +// +typedef struct _EFI_REDFISH_STORAGE_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_5_0_CS *Storage; +} EFI_REDFISH_STORAGE_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_5_1/EfiStorageV1_5_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_5_1/EfiStorageV1_5_1.h new file mode 100644 index 00000000000..972f41c8b5f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_5_1/EfiStorageV1_5_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_5_1_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_5_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_5_1/Redfish_Storage_v1_5_1_CS.h" +// +// EFI structure of Redfish Storage v1_5_1 +// +typedef struct _EFI_REDFISH_STORAGE_V1_5_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_5_1_CS *Storage; +} EFI_REDFISH_STORAGE_V1_5_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_5_2/EfiStorageV1_5_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_5_2/EfiStorageV1_5_2.h new file mode 100644 index 00000000000..becbeeb42df --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_5_2/EfiStorageV1_5_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_5_2_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_5_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_5_2/Redfish_Storage_v1_5_2_CS.h" +// +// EFI structure of Redfish Storage v1_5_2 +// +typedef struct _EFI_REDFISH_STORAGE_V1_5_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_5_2_CS *Storage; +} EFI_REDFISH_STORAGE_V1_5_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_5_3/EfiStorageV1_5_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_5_3/EfiStorageV1_5_3.h new file mode 100644 index 00000000000..a209593cff4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_5_3/EfiStorageV1_5_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_5_3_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_5_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_5_3/Redfish_Storage_v1_5_3_CS.h" +// +// EFI structure of Redfish Storage v1_5_3 +// +typedef struct _EFI_REDFISH_STORAGE_V1_5_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_5_3_CS *Storage; +} EFI_REDFISH_STORAGE_V1_5_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_5_4/EfiStorageV1_5_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_5_4/EfiStorageV1_5_4.h new file mode 100644 index 00000000000..60b026f5e01 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_5_4/EfiStorageV1_5_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_5_4_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_5_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_5_4/Redfish_Storage_v1_5_4_CS.h" +// +// EFI structure of Redfish Storage v1_5_4 +// +typedef struct _EFI_REDFISH_STORAGE_V1_5_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_5_4_CS *Storage; +} EFI_REDFISH_STORAGE_V1_5_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_5_5/EfiStorageV1_5_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_5_5/EfiStorageV1_5_5.h new file mode 100644 index 00000000000..af2bcd62c8e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_5_5/EfiStorageV1_5_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_5_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_5_5_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_5_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_5_5/Redfish_Storage_v1_5_5_CS.h" +// +// EFI structure of Redfish Storage v1_5_5 +// +typedef struct _EFI_REDFISH_STORAGE_V1_5_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_5_5_CS *Storage; +} EFI_REDFISH_STORAGE_V1_5_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_6_0/EfiStorageV1_6_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_6_0/EfiStorageV1_6_0.h new file mode 100644 index 00000000000..e79cfc6b9a2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_6_0/EfiStorageV1_6_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_6_0_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_6_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_6_0/Redfish_Storage_v1_6_0_CS.h" +// +// EFI structure of Redfish Storage v1_6_0 +// +typedef struct _EFI_REDFISH_STORAGE_V1_6_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_6_0_CS *Storage; +} EFI_REDFISH_STORAGE_V1_6_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_6_1/EfiStorageV1_6_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_6_1/EfiStorageV1_6_1.h new file mode 100644 index 00000000000..35961260c85 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_6_1/EfiStorageV1_6_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_6_1_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_6_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_6_1/Redfish_Storage_v1_6_1_CS.h" +// +// EFI structure of Redfish Storage v1_6_1 +// +typedef struct _EFI_REDFISH_STORAGE_V1_6_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_6_1_CS *Storage; +} EFI_REDFISH_STORAGE_V1_6_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_6_2/EfiStorageV1_6_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_6_2/EfiStorageV1_6_2.h new file mode 100644 index 00000000000..4e56dc3cda0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_6_2/EfiStorageV1_6_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_6_2_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_6_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_6_2/Redfish_Storage_v1_6_2_CS.h" +// +// EFI structure of Redfish Storage v1_6_2 +// +typedef struct _EFI_REDFISH_STORAGE_V1_6_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_6_2_CS *Storage; +} EFI_REDFISH_STORAGE_V1_6_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_6_3/EfiStorageV1_6_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_6_3/EfiStorageV1_6_3.h new file mode 100644 index 00000000000..391e5bbc59a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_6_3/EfiStorageV1_6_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_6_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_6_3_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_6_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_6_3/Redfish_Storage_v1_6_3_CS.h" +// +// EFI structure of Redfish Storage v1_6_3 +// +typedef struct _EFI_REDFISH_STORAGE_V1_6_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_6_3_CS *Storage; +} EFI_REDFISH_STORAGE_V1_6_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_6_4/EfiStorageV1_6_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_6_4/EfiStorageV1_6_4.h new file mode 100644 index 00000000000..11cf9c87583 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_6_4/EfiStorageV1_6_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_6_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_6_4_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_6_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_6_4/Redfish_Storage_v1_6_4_CS.h" +// +// EFI structure of Redfish Storage v1_6_4 +// +typedef struct _EFI_REDFISH_STORAGE_V1_6_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_6_4_CS *Storage; +} EFI_REDFISH_STORAGE_V1_6_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_7_0/EfiStorageV1_7_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_7_0/EfiStorageV1_7_0.h new file mode 100644 index 00000000000..f55939853a2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_7_0/EfiStorageV1_7_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_7_0_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_7_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_7_0/Redfish_Storage_v1_7_0_CS.h" +// +// EFI structure of Redfish Storage v1_7_0 +// +typedef struct _EFI_REDFISH_STORAGE_V1_7_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_7_0_CS *Storage; +} EFI_REDFISH_STORAGE_V1_7_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_7_1/EfiStorageV1_7_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_7_1/EfiStorageV1_7_1.h new file mode 100644 index 00000000000..b467331b444 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_7_1/EfiStorageV1_7_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_7_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_7_1_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_7_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_7_1/Redfish_Storage_v1_7_1_CS.h" +// +// EFI structure of Redfish Storage v1_7_1 +// +typedef struct _EFI_REDFISH_STORAGE_V1_7_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_7_1_CS *Storage; +} EFI_REDFISH_STORAGE_V1_7_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_7_2/EfiStorageV1_7_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_7_2/EfiStorageV1_7_2.h new file mode 100644 index 00000000000..6294e07888b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_7_2/EfiStorageV1_7_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_7_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_7_2_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_7_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_7_2/Redfish_Storage_v1_7_2_CS.h" +// +// EFI structure of Redfish Storage v1_7_2 +// +typedef struct _EFI_REDFISH_STORAGE_V1_7_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_7_2_CS *Storage; +} EFI_REDFISH_STORAGE_V1_7_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_7_3/EfiStorageV1_7_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_7_3/EfiStorageV1_7_3.h new file mode 100644 index 00000000000..ba4acbcab15 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_7_3/EfiStorageV1_7_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_7_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_7_3_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_7_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_7_3/Redfish_Storage_v1_7_3_CS.h" +// +// EFI structure of Redfish Storage v1_7_3 +// +typedef struct _EFI_REDFISH_STORAGE_V1_7_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_7_3_CS *Storage; +} EFI_REDFISH_STORAGE_V1_7_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_8_0/EfiStorageV1_8_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_8_0/EfiStorageV1_8_0.h new file mode 100644 index 00000000000..79617c5aa6a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_8_0/EfiStorageV1_8_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_8_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_8_0_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_8_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_8_0/Redfish_Storage_v1_8_0_CS.h" +// +// EFI structure of Redfish Storage v1_8_0 +// +typedef struct _EFI_REDFISH_STORAGE_V1_8_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_8_0_CS *Storage; +} EFI_REDFISH_STORAGE_V1_8_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_8_1/EfiStorageV1_8_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_8_1/EfiStorageV1_8_1.h new file mode 100644 index 00000000000..065e0185860 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_8_1/EfiStorageV1_8_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_8_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_8_1_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_8_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_8_1/Redfish_Storage_v1_8_1_CS.h" +// +// EFI structure of Redfish Storage v1_8_1 +// +typedef struct _EFI_REDFISH_STORAGE_V1_8_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_8_1_CS *Storage; +} EFI_REDFISH_STORAGE_V1_8_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_8_2/EfiStorageV1_8_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_8_2/EfiStorageV1_8_2.h new file mode 100644 index 00000000000..edeecf30fb6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_8_2/EfiStorageV1_8_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_8_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_8_2_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_8_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_8_2/Redfish_Storage_v1_8_2_CS.h" +// +// EFI structure of Redfish Storage v1_8_2 +// +typedef struct _EFI_REDFISH_STORAGE_V1_8_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_8_2_CS *Storage; +} EFI_REDFISH_STORAGE_V1_8_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_9_0/EfiStorageV1_9_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_9_0/EfiStorageV1_9_0.h new file mode 100644 index 00000000000..e8623266127 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_9_0/EfiStorageV1_9_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_9_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_9_0_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_9_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_9_0/Redfish_Storage_v1_9_0_CS.h" +// +// EFI structure of Redfish Storage v1_9_0 +// +typedef struct _EFI_REDFISH_STORAGE_V1_9_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_9_0_CS *Storage; +} EFI_REDFISH_STORAGE_V1_9_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_9_1/EfiStorageV1_9_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_9_1/EfiStorageV1_9_1.h new file mode 100644 index 00000000000..a15ee0403b6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Storage/v1_9_1/EfiStorageV1_9_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Storage v1_9_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGE_V1_9_1_H__ +#define EFI_REDFISH_INTERP_STORAGE_V1_9_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Storage/v1_9_1/Redfish_Storage_v1_9_1_CS.h" +// +// EFI structure of Redfish Storage v1_9_1 +// +typedef struct _EFI_REDFISH_STORAGE_V1_9_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGE_V1_9_1_CS *Storage; +} EFI_REDFISH_STORAGE_V1_9_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/StorageCollection/EfiStorageCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/StorageCollection/EfiStorageCollection.h new file mode 100644 index 00000000000..3117832e6d0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/StorageCollection/EfiStorageCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for StorageCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGECOLLECTION_H__ +#define EFI_REDFISH_INTERP_STORAGECOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/StorageCollection/Redfish_StorageCollection_CS.h" +// +// EFI structure of Redfish StorageCollection +// +typedef struct _EFI_REDFISH_STORAGECOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGECOLLECTION_CS *StorageCollection; +} EFI_REDFISH_STORAGECOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/StorageController/v1_0_0/EfiStorageControllerV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/StorageController/v1_0_0/EfiStorageControllerV1_0_0.h new file mode 100644 index 00000000000..20755b9dec5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/StorageController/v1_0_0/EfiStorageControllerV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for StorageController v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGECONTROLLER_V1_0_0_H__ +#define EFI_REDFISH_INTERP_STORAGECONTROLLER_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/StorageController/v1_0_0/Redfish_StorageController_v1_0_0_CS.h" +// +// EFI structure of Redfish StorageController v1_0_0 +// +typedef struct _EFI_REDFISH_STORAGECONTROLLER_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGECONTROLLER_V1_0_0_CS *StorageController; +} EFI_REDFISH_STORAGECONTROLLER_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/StorageController/v1_0_1/EfiStorageControllerV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/StorageController/v1_0_1/EfiStorageControllerV1_0_1.h new file mode 100644 index 00000000000..39107a16bd7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/StorageController/v1_0_1/EfiStorageControllerV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for StorageController v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGECONTROLLER_V1_0_1_H__ +#define EFI_REDFISH_INTERP_STORAGECONTROLLER_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/StorageController/v1_0_1/Redfish_StorageController_v1_0_1_CS.h" +// +// EFI structure of Redfish StorageController v1_0_1 +// +typedef struct _EFI_REDFISH_STORAGECONTROLLER_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGECONTROLLER_V1_0_1_CS *StorageController; +} EFI_REDFISH_STORAGECONTROLLER_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/StorageController/v1_1_0/EfiStorageControllerV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/StorageController/v1_1_0/EfiStorageControllerV1_1_0.h new file mode 100644 index 00000000000..3028f9007e9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/StorageController/v1_1_0/EfiStorageControllerV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for StorageController v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGECONTROLLER_V1_1_0_H__ +#define EFI_REDFISH_INTERP_STORAGECONTROLLER_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/StorageController/v1_1_0/Redfish_StorageController_v1_1_0_CS.h" +// +// EFI structure of Redfish StorageController v1_1_0 +// +typedef struct _EFI_REDFISH_STORAGECONTROLLER_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGECONTROLLER_V1_1_0_CS *StorageController; +} EFI_REDFISH_STORAGECONTROLLER_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/StorageControllerCollection/EfiStorageControllerCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/StorageControllerCollection/EfiStorageControllerCollection.h new file mode 100644 index 00000000000..04a69e5adfd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/StorageControllerCollection/EfiStorageControllerCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for StorageControllerCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_STORAGECONTROLLERCOLLECTION_H__ +#define EFI_REDFISH_INTERP_STORAGECONTROLLERCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/StorageControllerCollection/Redfish_StorageControllerCollection_CS.h" +// +// EFI structure of Redfish StorageControllerCollection +// +typedef struct _EFI_REDFISH_STORAGECONTROLLERCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_STORAGECONTROLLERCOLLECTION_CS *StorageControllerCollection; +} EFI_REDFISH_STORAGECONTROLLERCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_0/EfiSwitchV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_0/EfiSwitchV1_0_0.h new file mode 100644 index 00000000000..8af634b0ff1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_0/EfiSwitchV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Switch v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SWITCH_V1_0_0_H__ +#define EFI_REDFISH_INTERP_SWITCH_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Switch/v1_0_0/Redfish_Switch_v1_0_0_CS.h" +// +// EFI structure of Redfish Switch v1_0_0 +// +typedef struct _EFI_REDFISH_SWITCH_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SWITCH_V1_0_0_CS *Switch; +} EFI_REDFISH_SWITCH_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_1/EfiSwitchV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_1/EfiSwitchV1_0_1.h new file mode 100644 index 00000000000..04a6f150a35 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_1/EfiSwitchV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Switch v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SWITCH_V1_0_1_H__ +#define EFI_REDFISH_INTERP_SWITCH_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Switch/v1_0_1/Redfish_Switch_v1_0_1_CS.h" +// +// EFI structure of Redfish Switch v1_0_1 +// +typedef struct _EFI_REDFISH_SWITCH_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SWITCH_V1_0_1_CS *Switch; +} EFI_REDFISH_SWITCH_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_2/EfiSwitchV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_2/EfiSwitchV1_0_2.h new file mode 100644 index 00000000000..cdd6e719bc6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_2/EfiSwitchV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Switch v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SWITCH_V1_0_2_H__ +#define EFI_REDFISH_INTERP_SWITCH_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Switch/v1_0_2/Redfish_Switch_v1_0_2_CS.h" +// +// EFI structure of Redfish Switch v1_0_2 +// +typedef struct _EFI_REDFISH_SWITCH_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SWITCH_V1_0_2_CS *Switch; +} EFI_REDFISH_SWITCH_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_3/EfiSwitchV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_3/EfiSwitchV1_0_3.h new file mode 100644 index 00000000000..998e44fa421 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_3/EfiSwitchV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Switch v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SWITCH_V1_0_3_H__ +#define EFI_REDFISH_INTERP_SWITCH_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Switch/v1_0_3/Redfish_Switch_v1_0_3_CS.h" +// +// EFI structure of Redfish Switch v1_0_3 +// +typedef struct _EFI_REDFISH_SWITCH_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SWITCH_V1_0_3_CS *Switch; +} EFI_REDFISH_SWITCH_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_4/EfiSwitchV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_4/EfiSwitchV1_0_4.h new file mode 100644 index 00000000000..2f2af3fcacc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_4/EfiSwitchV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Switch v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SWITCH_V1_0_4_H__ +#define EFI_REDFISH_INTERP_SWITCH_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Switch/v1_0_4/Redfish_Switch_v1_0_4_CS.h" +// +// EFI structure of Redfish Switch v1_0_4 +// +typedef struct _EFI_REDFISH_SWITCH_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SWITCH_V1_0_4_CS *Switch; +} EFI_REDFISH_SWITCH_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_5/EfiSwitchV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_5/EfiSwitchV1_0_5.h new file mode 100644 index 00000000000..b48bc4fd458 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_5/EfiSwitchV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Switch v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SWITCH_V1_0_5_H__ +#define EFI_REDFISH_INTERP_SWITCH_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Switch/v1_0_5/Redfish_Switch_v1_0_5_CS.h" +// +// EFI structure of Redfish Switch v1_0_5 +// +typedef struct _EFI_REDFISH_SWITCH_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SWITCH_V1_0_5_CS *Switch; +} EFI_REDFISH_SWITCH_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_6/EfiSwitchV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_6/EfiSwitchV1_0_6.h new file mode 100644 index 00000000000..7b11ac54fea --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_6/EfiSwitchV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Switch v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SWITCH_V1_0_6_H__ +#define EFI_REDFISH_INTERP_SWITCH_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Switch/v1_0_6/Redfish_Switch_v1_0_6_CS.h" +// +// EFI structure of Redfish Switch v1_0_6 +// +typedef struct _EFI_REDFISH_SWITCH_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SWITCH_V1_0_6_CS *Switch; +} EFI_REDFISH_SWITCH_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_7/EfiSwitchV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_7/EfiSwitchV1_0_7.h new file mode 100644 index 00000000000..bd0a894c31c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_7/EfiSwitchV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Switch v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SWITCH_V1_0_7_H__ +#define EFI_REDFISH_INTERP_SWITCH_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Switch/v1_0_7/Redfish_Switch_v1_0_7_CS.h" +// +// EFI structure of Redfish Switch v1_0_7 +// +typedef struct _EFI_REDFISH_SWITCH_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SWITCH_V1_0_7_CS *Switch; +} EFI_REDFISH_SWITCH_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_8/EfiSwitchV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_8/EfiSwitchV1_0_8.h new file mode 100644 index 00000000000..942d54a0877 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_0_8/EfiSwitchV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Switch v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SWITCH_V1_0_8_H__ +#define EFI_REDFISH_INTERP_SWITCH_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Switch/v1_0_8/Redfish_Switch_v1_0_8_CS.h" +// +// EFI structure of Redfish Switch v1_0_8 +// +typedef struct _EFI_REDFISH_SWITCH_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SWITCH_V1_0_8_CS *Switch; +} EFI_REDFISH_SWITCH_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_1_0/EfiSwitchV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_1_0/EfiSwitchV1_1_0.h new file mode 100644 index 00000000000..360bfa8fe31 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_1_0/EfiSwitchV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Switch v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SWITCH_V1_1_0_H__ +#define EFI_REDFISH_INTERP_SWITCH_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Switch/v1_1_0/Redfish_Switch_v1_1_0_CS.h" +// +// EFI structure of Redfish Switch v1_1_0 +// +typedef struct _EFI_REDFISH_SWITCH_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SWITCH_V1_1_0_CS *Switch; +} EFI_REDFISH_SWITCH_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_1_1/EfiSwitchV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_1_1/EfiSwitchV1_1_1.h new file mode 100644 index 00000000000..0978a0f13f7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_1_1/EfiSwitchV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Switch v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SWITCH_V1_1_1_H__ +#define EFI_REDFISH_INTERP_SWITCH_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Switch/v1_1_1/Redfish_Switch_v1_1_1_CS.h" +// +// EFI structure of Redfish Switch v1_1_1 +// +typedef struct _EFI_REDFISH_SWITCH_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SWITCH_V1_1_1_CS *Switch; +} EFI_REDFISH_SWITCH_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_1_2/EfiSwitchV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_1_2/EfiSwitchV1_1_2.h new file mode 100644 index 00000000000..cd277a5e747 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_1_2/EfiSwitchV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Switch v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SWITCH_V1_1_2_H__ +#define EFI_REDFISH_INTERP_SWITCH_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Switch/v1_1_2/Redfish_Switch_v1_1_2_CS.h" +// +// EFI structure of Redfish Switch v1_1_2 +// +typedef struct _EFI_REDFISH_SWITCH_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SWITCH_V1_1_2_CS *Switch; +} EFI_REDFISH_SWITCH_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_1_3/EfiSwitchV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_1_3/EfiSwitchV1_1_3.h new file mode 100644 index 00000000000..d7b98da3b88 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_1_3/EfiSwitchV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Switch v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SWITCH_V1_1_3_H__ +#define EFI_REDFISH_INTERP_SWITCH_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Switch/v1_1_3/Redfish_Switch_v1_1_3_CS.h" +// +// EFI structure of Redfish Switch v1_1_3 +// +typedef struct _EFI_REDFISH_SWITCH_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SWITCH_V1_1_3_CS *Switch; +} EFI_REDFISH_SWITCH_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_1_4/EfiSwitchV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_1_4/EfiSwitchV1_1_4.h new file mode 100644 index 00000000000..4cd11f3f5cc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_1_4/EfiSwitchV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Switch v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SWITCH_V1_1_4_H__ +#define EFI_REDFISH_INTERP_SWITCH_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Switch/v1_1_4/Redfish_Switch_v1_1_4_CS.h" +// +// EFI structure of Redfish Switch v1_1_4 +// +typedef struct _EFI_REDFISH_SWITCH_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SWITCH_V1_1_4_CS *Switch; +} EFI_REDFISH_SWITCH_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_1_5/EfiSwitchV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_1_5/EfiSwitchV1_1_5.h new file mode 100644 index 00000000000..68c4661dd51 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_1_5/EfiSwitchV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Switch v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SWITCH_V1_1_5_H__ +#define EFI_REDFISH_INTERP_SWITCH_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Switch/v1_1_5/Redfish_Switch_v1_1_5_CS.h" +// +// EFI structure of Redfish Switch v1_1_5 +// +typedef struct _EFI_REDFISH_SWITCH_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SWITCH_V1_1_5_CS *Switch; +} EFI_REDFISH_SWITCH_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_2_0/EfiSwitchV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_2_0/EfiSwitchV1_2_0.h new file mode 100644 index 00000000000..f53a06b7172 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_2_0/EfiSwitchV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Switch v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SWITCH_V1_2_0_H__ +#define EFI_REDFISH_INTERP_SWITCH_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Switch/v1_2_0/Redfish_Switch_v1_2_0_CS.h" +// +// EFI structure of Redfish Switch v1_2_0 +// +typedef struct _EFI_REDFISH_SWITCH_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SWITCH_V1_2_0_CS *Switch; +} EFI_REDFISH_SWITCH_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_2_1/EfiSwitchV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_2_1/EfiSwitchV1_2_1.h new file mode 100644 index 00000000000..6ec82d371bb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_2_1/EfiSwitchV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Switch v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SWITCH_V1_2_1_H__ +#define EFI_REDFISH_INTERP_SWITCH_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Switch/v1_2_1/Redfish_Switch_v1_2_1_CS.h" +// +// EFI structure of Redfish Switch v1_2_1 +// +typedef struct _EFI_REDFISH_SWITCH_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SWITCH_V1_2_1_CS *Switch; +} EFI_REDFISH_SWITCH_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_2_2/EfiSwitchV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_2_2/EfiSwitchV1_2_2.h new file mode 100644 index 00000000000..fc6c6cbf692 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_2_2/EfiSwitchV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Switch v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SWITCH_V1_2_2_H__ +#define EFI_REDFISH_INTERP_SWITCH_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Switch/v1_2_2/Redfish_Switch_v1_2_2_CS.h" +// +// EFI structure of Redfish Switch v1_2_2 +// +typedef struct _EFI_REDFISH_SWITCH_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SWITCH_V1_2_2_CS *Switch; +} EFI_REDFISH_SWITCH_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_3_0/EfiSwitchV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_3_0/EfiSwitchV1_3_0.h new file mode 100644 index 00000000000..438e700976b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_3_0/EfiSwitchV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Switch v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SWITCH_V1_3_0_H__ +#define EFI_REDFISH_INTERP_SWITCH_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Switch/v1_3_0/Redfish_Switch_v1_3_0_CS.h" +// +// EFI structure of Redfish Switch v1_3_0 +// +typedef struct _EFI_REDFISH_SWITCH_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SWITCH_V1_3_0_CS *Switch; +} EFI_REDFISH_SWITCH_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_3_1/EfiSwitchV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_3_1/EfiSwitchV1_3_1.h new file mode 100644 index 00000000000..bdcbaf08a5a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_3_1/EfiSwitchV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Switch v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SWITCH_V1_3_1_H__ +#define EFI_REDFISH_INTERP_SWITCH_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Switch/v1_3_1/Redfish_Switch_v1_3_1_CS.h" +// +// EFI structure of Redfish Switch v1_3_1 +// +typedef struct _EFI_REDFISH_SWITCH_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SWITCH_V1_3_1_CS *Switch; +} EFI_REDFISH_SWITCH_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_3_2/EfiSwitchV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_3_2/EfiSwitchV1_3_2.h new file mode 100644 index 00000000000..9c3913f2a4e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_3_2/EfiSwitchV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Switch v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SWITCH_V1_3_2_H__ +#define EFI_REDFISH_INTERP_SWITCH_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Switch/v1_3_2/Redfish_Switch_v1_3_2_CS.h" +// +// EFI structure of Redfish Switch v1_3_2 +// +typedef struct _EFI_REDFISH_SWITCH_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SWITCH_V1_3_2_CS *Switch; +} EFI_REDFISH_SWITCH_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_4_0/EfiSwitchV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_4_0/EfiSwitchV1_4_0.h new file mode 100644 index 00000000000..fd3b7319edf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_4_0/EfiSwitchV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Switch v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SWITCH_V1_4_0_H__ +#define EFI_REDFISH_INTERP_SWITCH_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Switch/v1_4_0/Redfish_Switch_v1_4_0_CS.h" +// +// EFI structure of Redfish Switch v1_4_0 +// +typedef struct _EFI_REDFISH_SWITCH_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SWITCH_V1_4_0_CS *Switch; +} EFI_REDFISH_SWITCH_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_4_1/EfiSwitchV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_4_1/EfiSwitchV1_4_1.h new file mode 100644 index 00000000000..97db2582374 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_4_1/EfiSwitchV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Switch v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SWITCH_V1_4_1_H__ +#define EFI_REDFISH_INTERP_SWITCH_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Switch/v1_4_1/Redfish_Switch_v1_4_1_CS.h" +// +// EFI structure of Redfish Switch v1_4_1 +// +typedef struct _EFI_REDFISH_SWITCH_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SWITCH_V1_4_1_CS *Switch; +} EFI_REDFISH_SWITCH_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_5_0/EfiSwitchV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_5_0/EfiSwitchV1_5_0.h new file mode 100644 index 00000000000..e753b267e7d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Switch/v1_5_0/EfiSwitchV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Switch v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SWITCH_V1_5_0_H__ +#define EFI_REDFISH_INTERP_SWITCH_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Switch/v1_5_0/Redfish_Switch_v1_5_0_CS.h" +// +// EFI structure of Redfish Switch v1_5_0 +// +typedef struct _EFI_REDFISH_SWITCH_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SWITCH_V1_5_0_CS *Switch; +} EFI_REDFISH_SWITCH_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/SwitchCollection/EfiSwitchCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/SwitchCollection/EfiSwitchCollection.h new file mode 100644 index 00000000000..16d174b0f9b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/SwitchCollection/EfiSwitchCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for SwitchCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_SWITCHCOLLECTION_H__ +#define EFI_REDFISH_INTERP_SWITCHCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/SwitchCollection/Redfish_SwitchCollection_CS.h" +// +// EFI structure of Redfish SwitchCollection +// +typedef struct _EFI_REDFISH_SWITCHCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_SWITCHCOLLECTION_CS *SwitchCollection; +} EFI_REDFISH_SWITCHCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_0/EfiTaskV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_0/EfiTaskV1_0_0.h new file mode 100644 index 00000000000..4305827f488 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_0/EfiTaskV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_0_0_H__ +#define EFI_REDFISH_INTERP_TASK_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_0_0/Redfish_Task_v1_0_0_CS.h" +// +// EFI structure of Redfish Task v1_0_0 +// +typedef struct _EFI_REDFISH_TASK_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_0_0_CS *Task; +} EFI_REDFISH_TASK_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_2/EfiTaskV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_2/EfiTaskV1_0_2.h new file mode 100644 index 00000000000..cc0a2d22f45 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_2/EfiTaskV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_0_2_H__ +#define EFI_REDFISH_INTERP_TASK_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_0_2/Redfish_Task_v1_0_2_CS.h" +// +// EFI structure of Redfish Task v1_0_2 +// +typedef struct _EFI_REDFISH_TASK_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_0_2_CS *Task; +} EFI_REDFISH_TASK_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_3/EfiTaskV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_3/EfiTaskV1_0_3.h new file mode 100644 index 00000000000..50b38a1327c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_3/EfiTaskV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_0_3_H__ +#define EFI_REDFISH_INTERP_TASK_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_0_3/Redfish_Task_v1_0_3_CS.h" +// +// EFI structure of Redfish Task v1_0_3 +// +typedef struct _EFI_REDFISH_TASK_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_0_3_CS *Task; +} EFI_REDFISH_TASK_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_4/EfiTaskV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_4/EfiTaskV1_0_4.h new file mode 100644 index 00000000000..c71ca2abddb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_4/EfiTaskV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_0_4_H__ +#define EFI_REDFISH_INTERP_TASK_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_0_4/Redfish_Task_v1_0_4_CS.h" +// +// EFI structure of Redfish Task v1_0_4 +// +typedef struct _EFI_REDFISH_TASK_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_0_4_CS *Task; +} EFI_REDFISH_TASK_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_5/EfiTaskV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_5/EfiTaskV1_0_5.h new file mode 100644 index 00000000000..b163c92572b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_5/EfiTaskV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_0_5_H__ +#define EFI_REDFISH_INTERP_TASK_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_0_5/Redfish_Task_v1_0_5_CS.h" +// +// EFI structure of Redfish Task v1_0_5 +// +typedef struct _EFI_REDFISH_TASK_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_0_5_CS *Task; +} EFI_REDFISH_TASK_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_6/EfiTaskV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_6/EfiTaskV1_0_6.h new file mode 100644 index 00000000000..987cac953b4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_6/EfiTaskV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_0_6_H__ +#define EFI_REDFISH_INTERP_TASK_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_0_6/Redfish_Task_v1_0_6_CS.h" +// +// EFI structure of Redfish Task v1_0_6 +// +typedef struct _EFI_REDFISH_TASK_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_0_6_CS *Task; +} EFI_REDFISH_TASK_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_7/EfiTaskV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_7/EfiTaskV1_0_7.h new file mode 100644 index 00000000000..3f3a75128ff --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_7/EfiTaskV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_0_7_H__ +#define EFI_REDFISH_INTERP_TASK_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_0_7/Redfish_Task_v1_0_7_CS.h" +// +// EFI structure of Redfish Task v1_0_7 +// +typedef struct _EFI_REDFISH_TASK_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_0_7_CS *Task; +} EFI_REDFISH_TASK_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_8/EfiTaskV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_8/EfiTaskV1_0_8.h new file mode 100644 index 00000000000..c79b115205a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_8/EfiTaskV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_0_8_H__ +#define EFI_REDFISH_INTERP_TASK_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_0_8/Redfish_Task_v1_0_8_CS.h" +// +// EFI structure of Redfish Task v1_0_8 +// +typedef struct _EFI_REDFISH_TASK_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_0_8_CS *Task; +} EFI_REDFISH_TASK_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_9/EfiTaskV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_9/EfiTaskV1_0_9.h new file mode 100644 index 00000000000..48543bb2e51 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_0_9/EfiTaskV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_0_9_H__ +#define EFI_REDFISH_INTERP_TASK_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_0_9/Redfish_Task_v1_0_9_CS.h" +// +// EFI structure of Redfish Task v1_0_9 +// +typedef struct _EFI_REDFISH_TASK_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_0_9_CS *Task; +} EFI_REDFISH_TASK_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_0/EfiTaskV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_0/EfiTaskV1_1_0.h new file mode 100644 index 00000000000..98d46bfe191 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_0/EfiTaskV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_1_0_H__ +#define EFI_REDFISH_INTERP_TASK_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_1_0/Redfish_Task_v1_1_0_CS.h" +// +// EFI structure of Redfish Task v1_1_0 +// +typedef struct _EFI_REDFISH_TASK_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_1_0_CS *Task; +} EFI_REDFISH_TASK_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_1/EfiTaskV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_1/EfiTaskV1_1_1.h new file mode 100644 index 00000000000..14f9f266798 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_1/EfiTaskV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_1_1_H__ +#define EFI_REDFISH_INTERP_TASK_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_1_1/Redfish_Task_v1_1_1_CS.h" +// +// EFI structure of Redfish Task v1_1_1 +// +typedef struct _EFI_REDFISH_TASK_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_1_1_CS *Task; +} EFI_REDFISH_TASK_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_2/EfiTaskV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_2/EfiTaskV1_1_2.h new file mode 100644 index 00000000000..c7f36701478 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_2/EfiTaskV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_1_2_H__ +#define EFI_REDFISH_INTERP_TASK_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_1_2/Redfish_Task_v1_1_2_CS.h" +// +// EFI structure of Redfish Task v1_1_2 +// +typedef struct _EFI_REDFISH_TASK_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_1_2_CS *Task; +} EFI_REDFISH_TASK_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_3/EfiTaskV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_3/EfiTaskV1_1_3.h new file mode 100644 index 00000000000..d059a6a0a7d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_3/EfiTaskV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_1_3_H__ +#define EFI_REDFISH_INTERP_TASK_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_1_3/Redfish_Task_v1_1_3_CS.h" +// +// EFI structure of Redfish Task v1_1_3 +// +typedef struct _EFI_REDFISH_TASK_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_1_3_CS *Task; +} EFI_REDFISH_TASK_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_4/EfiTaskV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_4/EfiTaskV1_1_4.h new file mode 100644 index 00000000000..b56a1332a4f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_4/EfiTaskV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_1_4_H__ +#define EFI_REDFISH_INTERP_TASK_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_1_4/Redfish_Task_v1_1_4_CS.h" +// +// EFI structure of Redfish Task v1_1_4 +// +typedef struct _EFI_REDFISH_TASK_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_1_4_CS *Task; +} EFI_REDFISH_TASK_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_5/EfiTaskV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_5/EfiTaskV1_1_5.h new file mode 100644 index 00000000000..0988f24979b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_5/EfiTaskV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_1_5_H__ +#define EFI_REDFISH_INTERP_TASK_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_1_5/Redfish_Task_v1_1_5_CS.h" +// +// EFI structure of Redfish Task v1_1_5 +// +typedef struct _EFI_REDFISH_TASK_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_1_5_CS *Task; +} EFI_REDFISH_TASK_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_6/EfiTaskV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_6/EfiTaskV1_1_6.h new file mode 100644 index 00000000000..045100e33b8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_1_6/EfiTaskV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_1_6_H__ +#define EFI_REDFISH_INTERP_TASK_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_1_6/Redfish_Task_v1_1_6_CS.h" +// +// EFI structure of Redfish Task v1_1_6 +// +typedef struct _EFI_REDFISH_TASK_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_1_6_CS *Task; +} EFI_REDFISH_TASK_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_2_0/EfiTaskV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_2_0/EfiTaskV1_2_0.h new file mode 100644 index 00000000000..18f5a712f68 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_2_0/EfiTaskV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_2_0_H__ +#define EFI_REDFISH_INTERP_TASK_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_2_0/Redfish_Task_v1_2_0_CS.h" +// +// EFI structure of Redfish Task v1_2_0 +// +typedef struct _EFI_REDFISH_TASK_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_2_0_CS *Task; +} EFI_REDFISH_TASK_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_2_1/EfiTaskV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_2_1/EfiTaskV1_2_1.h new file mode 100644 index 00000000000..8ca10700ca1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_2_1/EfiTaskV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_2_1_H__ +#define EFI_REDFISH_INTERP_TASK_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_2_1/Redfish_Task_v1_2_1_CS.h" +// +// EFI structure of Redfish Task v1_2_1 +// +typedef struct _EFI_REDFISH_TASK_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_2_1_CS *Task; +} EFI_REDFISH_TASK_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_2_2/EfiTaskV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_2_2/EfiTaskV1_2_2.h new file mode 100644 index 00000000000..8f409662ecf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_2_2/EfiTaskV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_2_2_H__ +#define EFI_REDFISH_INTERP_TASK_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_2_2/Redfish_Task_v1_2_2_CS.h" +// +// EFI structure of Redfish Task v1_2_2 +// +typedef struct _EFI_REDFISH_TASK_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_2_2_CS *Task; +} EFI_REDFISH_TASK_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_2_3/EfiTaskV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_2_3/EfiTaskV1_2_3.h new file mode 100644 index 00000000000..7c5d4dea3c8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_2_3/EfiTaskV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_2_3_H__ +#define EFI_REDFISH_INTERP_TASK_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_2_3/Redfish_Task_v1_2_3_CS.h" +// +// EFI structure of Redfish Task v1_2_3 +// +typedef struct _EFI_REDFISH_TASK_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_2_3_CS *Task; +} EFI_REDFISH_TASK_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_2_4/EfiTaskV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_2_4/EfiTaskV1_2_4.h new file mode 100644 index 00000000000..3b84469e4f3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_2_4/EfiTaskV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_2_4_H__ +#define EFI_REDFISH_INTERP_TASK_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_2_4/Redfish_Task_v1_2_4_CS.h" +// +// EFI structure of Redfish Task v1_2_4 +// +typedef struct _EFI_REDFISH_TASK_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_2_4_CS *Task; +} EFI_REDFISH_TASK_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_2_5/EfiTaskV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_2_5/EfiTaskV1_2_5.h new file mode 100644 index 00000000000..ad60ab25e2f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_2_5/EfiTaskV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_2_5_H__ +#define EFI_REDFISH_INTERP_TASK_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_2_5/Redfish_Task_v1_2_5_CS.h" +// +// EFI structure of Redfish Task v1_2_5 +// +typedef struct _EFI_REDFISH_TASK_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_2_5_CS *Task; +} EFI_REDFISH_TASK_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_3_0/EfiTaskV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_3_0/EfiTaskV1_3_0.h new file mode 100644 index 00000000000..dac50505f00 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_3_0/EfiTaskV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_3_0_H__ +#define EFI_REDFISH_INTERP_TASK_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_3_0/Redfish_Task_v1_3_0_CS.h" +// +// EFI structure of Redfish Task v1_3_0 +// +typedef struct _EFI_REDFISH_TASK_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_3_0_CS *Task; +} EFI_REDFISH_TASK_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_3_1/EfiTaskV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_3_1/EfiTaskV1_3_1.h new file mode 100644 index 00000000000..e5f14f44142 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_3_1/EfiTaskV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_3_1_H__ +#define EFI_REDFISH_INTERP_TASK_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_3_1/Redfish_Task_v1_3_1_CS.h" +// +// EFI structure of Redfish Task v1_3_1 +// +typedef struct _EFI_REDFISH_TASK_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_3_1_CS *Task; +} EFI_REDFISH_TASK_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_3_2/EfiTaskV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_3_2/EfiTaskV1_3_2.h new file mode 100644 index 00000000000..88262ad80b7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_3_2/EfiTaskV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_3_2_H__ +#define EFI_REDFISH_INTERP_TASK_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_3_2/Redfish_Task_v1_3_2_CS.h" +// +// EFI structure of Redfish Task v1_3_2 +// +typedef struct _EFI_REDFISH_TASK_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_3_2_CS *Task; +} EFI_REDFISH_TASK_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_3_3/EfiTaskV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_3_3/EfiTaskV1_3_3.h new file mode 100644 index 00000000000..e912796799a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_3_3/EfiTaskV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_3_3_H__ +#define EFI_REDFISH_INTERP_TASK_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_3_3/Redfish_Task_v1_3_3_CS.h" +// +// EFI structure of Redfish Task v1_3_3 +// +typedef struct _EFI_REDFISH_TASK_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_3_3_CS *Task; +} EFI_REDFISH_TASK_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_3_4/EfiTaskV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_3_4/EfiTaskV1_3_4.h new file mode 100644 index 00000000000..69e28c4d1af --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_3_4/EfiTaskV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_3_4_H__ +#define EFI_REDFISH_INTERP_TASK_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_3_4/Redfish_Task_v1_3_4_CS.h" +// +// EFI structure of Redfish Task v1_3_4 +// +typedef struct _EFI_REDFISH_TASK_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_3_4_CS *Task; +} EFI_REDFISH_TASK_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_3_5/EfiTaskV1_3_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_3_5/EfiTaskV1_3_5.h new file mode 100644 index 00000000000..201e358f2bd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_3_5/EfiTaskV1_3_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_3_5_H__ +#define EFI_REDFISH_INTERP_TASK_V1_3_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_3_5/Redfish_Task_v1_3_5_CS.h" +// +// EFI structure of Redfish Task v1_3_5 +// +typedef struct _EFI_REDFISH_TASK_V1_3_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_3_5_CS *Task; +} EFI_REDFISH_TASK_V1_3_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_4_0/EfiTaskV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_4_0/EfiTaskV1_4_0.h new file mode 100644 index 00000000000..d8c22dd17ca --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_4_0/EfiTaskV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_4_0_H__ +#define EFI_REDFISH_INTERP_TASK_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_4_0/Redfish_Task_v1_4_0_CS.h" +// +// EFI structure of Redfish Task v1_4_0 +// +typedef struct _EFI_REDFISH_TASK_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_4_0_CS *Task; +} EFI_REDFISH_TASK_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_4_1/EfiTaskV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_4_1/EfiTaskV1_4_1.h new file mode 100644 index 00000000000..bf2e639bbad --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_4_1/EfiTaskV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_4_1_H__ +#define EFI_REDFISH_INTERP_TASK_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_4_1/Redfish_Task_v1_4_1_CS.h" +// +// EFI structure of Redfish Task v1_4_1 +// +typedef struct _EFI_REDFISH_TASK_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_4_1_CS *Task; +} EFI_REDFISH_TASK_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_4_2/EfiTaskV1_4_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_4_2/EfiTaskV1_4_2.h new file mode 100644 index 00000000000..c4eaf90f4bc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_4_2/EfiTaskV1_4_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_4_2_H__ +#define EFI_REDFISH_INTERP_TASK_V1_4_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_4_2/Redfish_Task_v1_4_2_CS.h" +// +// EFI structure of Redfish Task v1_4_2 +// +typedef struct _EFI_REDFISH_TASK_V1_4_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_4_2_CS *Task; +} EFI_REDFISH_TASK_V1_4_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_4_3/EfiTaskV1_4_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_4_3/EfiTaskV1_4_3.h new file mode 100644 index 00000000000..1fc609851f1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_4_3/EfiTaskV1_4_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_4_3_H__ +#define EFI_REDFISH_INTERP_TASK_V1_4_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_4_3/Redfish_Task_v1_4_3_CS.h" +// +// EFI structure of Redfish Task v1_4_3 +// +typedef struct _EFI_REDFISH_TASK_V1_4_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_4_3_CS *Task; +} EFI_REDFISH_TASK_V1_4_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_4_4/EfiTaskV1_4_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_4_4/EfiTaskV1_4_4.h new file mode 100644 index 00000000000..d65026ec128 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_4_4/EfiTaskV1_4_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_4_4_H__ +#define EFI_REDFISH_INTERP_TASK_V1_4_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_4_4/Redfish_Task_v1_4_4_CS.h" +// +// EFI structure of Redfish Task v1_4_4 +// +typedef struct _EFI_REDFISH_TASK_V1_4_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_4_4_CS *Task; +} EFI_REDFISH_TASK_V1_4_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_5_0/EfiTaskV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_5_0/EfiTaskV1_5_0.h new file mode 100644 index 00000000000..0dff619deaa --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_5_0/EfiTaskV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_5_0_H__ +#define EFI_REDFISH_INTERP_TASK_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_5_0/Redfish_Task_v1_5_0_CS.h" +// +// EFI structure of Redfish Task v1_5_0 +// +typedef struct _EFI_REDFISH_TASK_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_5_0_CS *Task; +} EFI_REDFISH_TASK_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_5_1/EfiTaskV1_5_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_5_1/EfiTaskV1_5_1.h new file mode 100644 index 00000000000..89094ff97a2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Task/v1_5_1/EfiTaskV1_5_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Task v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASK_V1_5_1_H__ +#define EFI_REDFISH_INTERP_TASK_V1_5_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Task/v1_5_1/Redfish_Task_v1_5_1_CS.h" +// +// EFI structure of Redfish Task v1_5_1 +// +typedef struct _EFI_REDFISH_TASK_V1_5_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASK_V1_5_1_CS *Task; +} EFI_REDFISH_TASK_V1_5_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TaskCollection/EfiTaskCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/TaskCollection/EfiTaskCollection.h new file mode 100644 index 00000000000..9e35e7a4528 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TaskCollection/EfiTaskCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TaskCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASKCOLLECTION_H__ +#define EFI_REDFISH_INTERP_TASKCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/TaskCollection/Redfish_TaskCollection_CS.h" +// +// EFI structure of Redfish TaskCollection +// +typedef struct _EFI_REDFISH_TASKCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASKCOLLECTION_CS *TaskCollection; +} EFI_REDFISH_TASKCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_0/EfiTaskServiceV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_0/EfiTaskServiceV1_0_0.h new file mode 100644 index 00000000000..6abeda63ecf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_0/EfiTaskServiceV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TaskService v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASKSERVICE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_TASKSERVICE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/TaskService/v1_0_0/Redfish_TaskService_v1_0_0_CS.h" +// +// EFI structure of Redfish TaskService v1_0_0 +// +typedef struct _EFI_REDFISH_TASKSERVICE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASKSERVICE_V1_0_0_CS *TaskService; +} EFI_REDFISH_TASKSERVICE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_2/EfiTaskServiceV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_2/EfiTaskServiceV1_0_2.h new file mode 100644 index 00000000000..d2803a96408 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_2/EfiTaskServiceV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TaskService v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASKSERVICE_V1_0_2_H__ +#define EFI_REDFISH_INTERP_TASKSERVICE_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/TaskService/v1_0_2/Redfish_TaskService_v1_0_2_CS.h" +// +// EFI structure of Redfish TaskService v1_0_2 +// +typedef struct _EFI_REDFISH_TASKSERVICE_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASKSERVICE_V1_0_2_CS *TaskService; +} EFI_REDFISH_TASKSERVICE_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_3/EfiTaskServiceV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_3/EfiTaskServiceV1_0_3.h new file mode 100644 index 00000000000..481c8d8fe71 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_3/EfiTaskServiceV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TaskService v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASKSERVICE_V1_0_3_H__ +#define EFI_REDFISH_INTERP_TASKSERVICE_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/TaskService/v1_0_3/Redfish_TaskService_v1_0_3_CS.h" +// +// EFI structure of Redfish TaskService v1_0_3 +// +typedef struct _EFI_REDFISH_TASKSERVICE_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASKSERVICE_V1_0_3_CS *TaskService; +} EFI_REDFISH_TASKSERVICE_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_4/EfiTaskServiceV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_4/EfiTaskServiceV1_0_4.h new file mode 100644 index 00000000000..66360ca7019 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_4/EfiTaskServiceV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TaskService v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASKSERVICE_V1_0_4_H__ +#define EFI_REDFISH_INTERP_TASKSERVICE_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/TaskService/v1_0_4/Redfish_TaskService_v1_0_4_CS.h" +// +// EFI structure of Redfish TaskService v1_0_4 +// +typedef struct _EFI_REDFISH_TASKSERVICE_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASKSERVICE_V1_0_4_CS *TaskService; +} EFI_REDFISH_TASKSERVICE_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_5/EfiTaskServiceV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_5/EfiTaskServiceV1_0_5.h new file mode 100644 index 00000000000..6bbb5148d0c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_5/EfiTaskServiceV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TaskService v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASKSERVICE_V1_0_5_H__ +#define EFI_REDFISH_INTERP_TASKSERVICE_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/TaskService/v1_0_5/Redfish_TaskService_v1_0_5_CS.h" +// +// EFI structure of Redfish TaskService v1_0_5 +// +typedef struct _EFI_REDFISH_TASKSERVICE_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASKSERVICE_V1_0_5_CS *TaskService; +} EFI_REDFISH_TASKSERVICE_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_6/EfiTaskServiceV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_6/EfiTaskServiceV1_0_6.h new file mode 100644 index 00000000000..713fa09f527 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_6/EfiTaskServiceV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TaskService v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASKSERVICE_V1_0_6_H__ +#define EFI_REDFISH_INTERP_TASKSERVICE_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/TaskService/v1_0_6/Redfish_TaskService_v1_0_6_CS.h" +// +// EFI structure of Redfish TaskService v1_0_6 +// +typedef struct _EFI_REDFISH_TASKSERVICE_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASKSERVICE_V1_0_6_CS *TaskService; +} EFI_REDFISH_TASKSERVICE_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_7/EfiTaskServiceV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_7/EfiTaskServiceV1_0_7.h new file mode 100644 index 00000000000..25746f8bea9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_7/EfiTaskServiceV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TaskService v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASKSERVICE_V1_0_7_H__ +#define EFI_REDFISH_INTERP_TASKSERVICE_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/TaskService/v1_0_7/Redfish_TaskService_v1_0_7_CS.h" +// +// EFI structure of Redfish TaskService v1_0_7 +// +typedef struct _EFI_REDFISH_TASKSERVICE_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASKSERVICE_V1_0_7_CS *TaskService; +} EFI_REDFISH_TASKSERVICE_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_8/EfiTaskServiceV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_8/EfiTaskServiceV1_0_8.h new file mode 100644 index 00000000000..31a0bf87296 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_8/EfiTaskServiceV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TaskService v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASKSERVICE_V1_0_8_H__ +#define EFI_REDFISH_INTERP_TASKSERVICE_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/TaskService/v1_0_8/Redfish_TaskService_v1_0_8_CS.h" +// +// EFI structure of Redfish TaskService v1_0_8 +// +typedef struct _EFI_REDFISH_TASKSERVICE_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASKSERVICE_V1_0_8_CS *TaskService; +} EFI_REDFISH_TASKSERVICE_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_9/EfiTaskServiceV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_9/EfiTaskServiceV1_0_9.h new file mode 100644 index 00000000000..1bd5ba17ba6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_0_9/EfiTaskServiceV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TaskService v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASKSERVICE_V1_0_9_H__ +#define EFI_REDFISH_INTERP_TASKSERVICE_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/TaskService/v1_0_9/Redfish_TaskService_v1_0_9_CS.h" +// +// EFI structure of Redfish TaskService v1_0_9 +// +typedef struct _EFI_REDFISH_TASKSERVICE_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASKSERVICE_V1_0_9_CS *TaskService; +} EFI_REDFISH_TASKSERVICE_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_0/EfiTaskServiceV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_0/EfiTaskServiceV1_1_0.h new file mode 100644 index 00000000000..382122d2115 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_0/EfiTaskServiceV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TaskService v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASKSERVICE_V1_1_0_H__ +#define EFI_REDFISH_INTERP_TASKSERVICE_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/TaskService/v1_1_0/Redfish_TaskService_v1_1_0_CS.h" +// +// EFI structure of Redfish TaskService v1_1_0 +// +typedef struct _EFI_REDFISH_TASKSERVICE_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASKSERVICE_V1_1_0_CS *TaskService; +} EFI_REDFISH_TASKSERVICE_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_1/EfiTaskServiceV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_1/EfiTaskServiceV1_1_1.h new file mode 100644 index 00000000000..6009cc61930 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_1/EfiTaskServiceV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TaskService v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASKSERVICE_V1_1_1_H__ +#define EFI_REDFISH_INTERP_TASKSERVICE_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/TaskService/v1_1_1/Redfish_TaskService_v1_1_1_CS.h" +// +// EFI structure of Redfish TaskService v1_1_1 +// +typedef struct _EFI_REDFISH_TASKSERVICE_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASKSERVICE_V1_1_1_CS *TaskService; +} EFI_REDFISH_TASKSERVICE_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_2/EfiTaskServiceV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_2/EfiTaskServiceV1_1_2.h new file mode 100644 index 00000000000..4234c6980e8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_2/EfiTaskServiceV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TaskService v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASKSERVICE_V1_1_2_H__ +#define EFI_REDFISH_INTERP_TASKSERVICE_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/TaskService/v1_1_2/Redfish_TaskService_v1_1_2_CS.h" +// +// EFI structure of Redfish TaskService v1_1_2 +// +typedef struct _EFI_REDFISH_TASKSERVICE_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASKSERVICE_V1_1_2_CS *TaskService; +} EFI_REDFISH_TASKSERVICE_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_3/EfiTaskServiceV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_3/EfiTaskServiceV1_1_3.h new file mode 100644 index 00000000000..8e52e44dde9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_3/EfiTaskServiceV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TaskService v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASKSERVICE_V1_1_3_H__ +#define EFI_REDFISH_INTERP_TASKSERVICE_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/TaskService/v1_1_3/Redfish_TaskService_v1_1_3_CS.h" +// +// EFI structure of Redfish TaskService v1_1_3 +// +typedef struct _EFI_REDFISH_TASKSERVICE_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASKSERVICE_V1_1_3_CS *TaskService; +} EFI_REDFISH_TASKSERVICE_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_4/EfiTaskServiceV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_4/EfiTaskServiceV1_1_4.h new file mode 100644 index 00000000000..5090cc7b1b4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_4/EfiTaskServiceV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TaskService v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASKSERVICE_V1_1_4_H__ +#define EFI_REDFISH_INTERP_TASKSERVICE_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/TaskService/v1_1_4/Redfish_TaskService_v1_1_4_CS.h" +// +// EFI structure of Redfish TaskService v1_1_4 +// +typedef struct _EFI_REDFISH_TASKSERVICE_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASKSERVICE_V1_1_4_CS *TaskService; +} EFI_REDFISH_TASKSERVICE_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_5/EfiTaskServiceV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_5/EfiTaskServiceV1_1_5.h new file mode 100644 index 00000000000..8d293b9d2df --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_5/EfiTaskServiceV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TaskService v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASKSERVICE_V1_1_5_H__ +#define EFI_REDFISH_INTERP_TASKSERVICE_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/TaskService/v1_1_5/Redfish_TaskService_v1_1_5_CS.h" +// +// EFI structure of Redfish TaskService v1_1_5 +// +typedef struct _EFI_REDFISH_TASKSERVICE_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASKSERVICE_V1_1_5_CS *TaskService; +} EFI_REDFISH_TASKSERVICE_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_6/EfiTaskServiceV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_6/EfiTaskServiceV1_1_6.h new file mode 100644 index 00000000000..330ddc497ed --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TaskService/v1_1_6/EfiTaskServiceV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TaskService v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TASKSERVICE_V1_1_6_H__ +#define EFI_REDFISH_INTERP_TASKSERVICE_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/TaskService/v1_1_6/Redfish_TaskService_v1_1_6_CS.h" +// +// EFI structure of Redfish TaskService v1_1_6 +// +typedef struct _EFI_REDFISH_TASKSERVICE_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TASKSERVICE_V1_1_6_CS *TaskService; +} EFI_REDFISH_TASKSERVICE_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_0_0/EfiTelemetryServiceV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_0_0/EfiTelemetryServiceV1_0_0.h new file mode 100644 index 00000000000..a60355d0da1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_0_0/EfiTelemetryServiceV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TelemetryService v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/TelemetryService/v1_0_0/Redfish_TelemetryService_v1_0_0_CS.h" +// +// EFI structure of Redfish TelemetryService v1_0_0 +// +typedef struct _EFI_REDFISH_TELEMETRYSERVICE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TELEMETRYSERVICE_V1_0_0_CS *TelemetryService; +} EFI_REDFISH_TELEMETRYSERVICE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_0_1/EfiTelemetryServiceV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_0_1/EfiTelemetryServiceV1_0_1.h new file mode 100644 index 00000000000..6fc63f3f35a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_0_1/EfiTelemetryServiceV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TelemetryService v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_0_1_H__ +#define EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/TelemetryService/v1_0_1/Redfish_TelemetryService_v1_0_1_CS.h" +// +// EFI structure of Redfish TelemetryService v1_0_1 +// +typedef struct _EFI_REDFISH_TELEMETRYSERVICE_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TELEMETRYSERVICE_V1_0_1_CS *TelemetryService; +} EFI_REDFISH_TELEMETRYSERVICE_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_0_2/EfiTelemetryServiceV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_0_2/EfiTelemetryServiceV1_0_2.h new file mode 100644 index 00000000000..3cc56416af0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_0_2/EfiTelemetryServiceV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TelemetryService v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_0_2_H__ +#define EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/TelemetryService/v1_0_2/Redfish_TelemetryService_v1_0_2_CS.h" +// +// EFI structure of Redfish TelemetryService v1_0_2 +// +typedef struct _EFI_REDFISH_TELEMETRYSERVICE_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TELEMETRYSERVICE_V1_0_2_CS *TelemetryService; +} EFI_REDFISH_TELEMETRYSERVICE_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_0_3/EfiTelemetryServiceV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_0_3/EfiTelemetryServiceV1_0_3.h new file mode 100644 index 00000000000..9556659d308 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_0_3/EfiTelemetryServiceV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TelemetryService v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_0_3_H__ +#define EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/TelemetryService/v1_0_3/Redfish_TelemetryService_v1_0_3_CS.h" +// +// EFI structure of Redfish TelemetryService v1_0_3 +// +typedef struct _EFI_REDFISH_TELEMETRYSERVICE_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TELEMETRYSERVICE_V1_0_3_CS *TelemetryService; +} EFI_REDFISH_TELEMETRYSERVICE_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_0_4/EfiTelemetryServiceV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_0_4/EfiTelemetryServiceV1_0_4.h new file mode 100644 index 00000000000..1b95f70b26d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_0_4/EfiTelemetryServiceV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TelemetryService v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_0_4_H__ +#define EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/TelemetryService/v1_0_4/Redfish_TelemetryService_v1_0_4_CS.h" +// +// EFI structure of Redfish TelemetryService v1_0_4 +// +typedef struct _EFI_REDFISH_TELEMETRYSERVICE_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TELEMETRYSERVICE_V1_0_4_CS *TelemetryService; +} EFI_REDFISH_TELEMETRYSERVICE_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_1_0/EfiTelemetryServiceV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_1_0/EfiTelemetryServiceV1_1_0.h new file mode 100644 index 00000000000..25b11d1f59a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_1_0/EfiTelemetryServiceV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TelemetryService v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_1_0_H__ +#define EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/TelemetryService/v1_1_0/Redfish_TelemetryService_v1_1_0_CS.h" +// +// EFI structure of Redfish TelemetryService v1_1_0 +// +typedef struct _EFI_REDFISH_TELEMETRYSERVICE_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TELEMETRYSERVICE_V1_1_0_CS *TelemetryService; +} EFI_REDFISH_TELEMETRYSERVICE_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_1_1/EfiTelemetryServiceV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_1_1/EfiTelemetryServiceV1_1_1.h new file mode 100644 index 00000000000..949f7a232eb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_1_1/EfiTelemetryServiceV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TelemetryService v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_1_1_H__ +#define EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/TelemetryService/v1_1_1/Redfish_TelemetryService_v1_1_1_CS.h" +// +// EFI structure of Redfish TelemetryService v1_1_1 +// +typedef struct _EFI_REDFISH_TELEMETRYSERVICE_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TELEMETRYSERVICE_V1_1_1_CS *TelemetryService; +} EFI_REDFISH_TELEMETRYSERVICE_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_1_2/EfiTelemetryServiceV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_1_2/EfiTelemetryServiceV1_1_2.h new file mode 100644 index 00000000000..8bad77f8654 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_1_2/EfiTelemetryServiceV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TelemetryService v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_1_2_H__ +#define EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/TelemetryService/v1_1_2/Redfish_TelemetryService_v1_1_2_CS.h" +// +// EFI structure of Redfish TelemetryService v1_1_2 +// +typedef struct _EFI_REDFISH_TELEMETRYSERVICE_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TELEMETRYSERVICE_V1_1_2_CS *TelemetryService; +} EFI_REDFISH_TELEMETRYSERVICE_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_1_3/EfiTelemetryServiceV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_1_3/EfiTelemetryServiceV1_1_3.h new file mode 100644 index 00000000000..68d8929ed2b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_1_3/EfiTelemetryServiceV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TelemetryService v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_1_3_H__ +#define EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/TelemetryService/v1_1_3/Redfish_TelemetryService_v1_1_3_CS.h" +// +// EFI structure of Redfish TelemetryService v1_1_3 +// +typedef struct _EFI_REDFISH_TELEMETRYSERVICE_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TELEMETRYSERVICE_V1_1_3_CS *TelemetryService; +} EFI_REDFISH_TELEMETRYSERVICE_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_1_4/EfiTelemetryServiceV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_1_4/EfiTelemetryServiceV1_1_4.h new file mode 100644 index 00000000000..f468773e23d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_1_4/EfiTelemetryServiceV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TelemetryService v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_1_4_H__ +#define EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/TelemetryService/v1_1_4/Redfish_TelemetryService_v1_1_4_CS.h" +// +// EFI structure of Redfish TelemetryService v1_1_4 +// +typedef struct _EFI_REDFISH_TELEMETRYSERVICE_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TELEMETRYSERVICE_V1_1_4_CS *TelemetryService; +} EFI_REDFISH_TELEMETRYSERVICE_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_2_0/EfiTelemetryServiceV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_2_0/EfiTelemetryServiceV1_2_0.h new file mode 100644 index 00000000000..8bb41a8752b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_2_0/EfiTelemetryServiceV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TelemetryService v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_2_0_H__ +#define EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/TelemetryService/v1_2_0/Redfish_TelemetryService_v1_2_0_CS.h" +// +// EFI structure of Redfish TelemetryService v1_2_0 +// +typedef struct _EFI_REDFISH_TELEMETRYSERVICE_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TELEMETRYSERVICE_V1_2_0_CS *TelemetryService; +} EFI_REDFISH_TELEMETRYSERVICE_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_2_1/EfiTelemetryServiceV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_2_1/EfiTelemetryServiceV1_2_1.h new file mode 100644 index 00000000000..8d057da4334 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_2_1/EfiTelemetryServiceV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TelemetryService v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_2_1_H__ +#define EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/TelemetryService/v1_2_1/Redfish_TelemetryService_v1_2_1_CS.h" +// +// EFI structure of Redfish TelemetryService v1_2_1 +// +typedef struct _EFI_REDFISH_TELEMETRYSERVICE_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TELEMETRYSERVICE_V1_2_1_CS *TelemetryService; +} EFI_REDFISH_TELEMETRYSERVICE_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_2_2/EfiTelemetryServiceV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_2_2/EfiTelemetryServiceV1_2_2.h new file mode 100644 index 00000000000..62817b68a53 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_2_2/EfiTelemetryServiceV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TelemetryService v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_2_2_H__ +#define EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/TelemetryService/v1_2_2/Redfish_TelemetryService_v1_2_2_CS.h" +// +// EFI structure of Redfish TelemetryService v1_2_2 +// +typedef struct _EFI_REDFISH_TELEMETRYSERVICE_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TELEMETRYSERVICE_V1_2_2_CS *TelemetryService; +} EFI_REDFISH_TELEMETRYSERVICE_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_3_0/EfiTelemetryServiceV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_3_0/EfiTelemetryServiceV1_3_0.h new file mode 100644 index 00000000000..ecc07396cdf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TelemetryService/v1_3_0/EfiTelemetryServiceV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TelemetryService v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_3_0_H__ +#define EFI_REDFISH_INTERP_TELEMETRYSERVICE_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/TelemetryService/v1_3_0/Redfish_TelemetryService_v1_3_0_CS.h" +// +// EFI structure of Redfish TelemetryService v1_3_0 +// +typedef struct _EFI_REDFISH_TELEMETRYSERVICE_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TELEMETRYSERVICE_V1_3_0_CS *TelemetryService; +} EFI_REDFISH_TELEMETRYSERVICE_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_0/EfiThermalV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_0/EfiThermalV1_0_0.h new file mode 100644 index 00000000000..f105be5f5d5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_0/EfiThermalV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_0_0_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_0_0/Redfish_Thermal_v1_0_0_CS.h" +// +// EFI structure of Redfish Thermal v1_0_0 +// +typedef struct _EFI_REDFISH_THERMAL_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_0_0_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_1/EfiThermalV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_1/EfiThermalV1_0_1.h new file mode 100644 index 00000000000..19c9d8d4e0a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_1/EfiThermalV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_0_1_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_0_1/Redfish_Thermal_v1_0_1_CS.h" +// +// EFI structure of Redfish Thermal v1_0_1 +// +typedef struct _EFI_REDFISH_THERMAL_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_0_1_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_10/EfiThermalV1_0_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_10/EfiThermalV1_0_10.h new file mode 100644 index 00000000000..6c2432d6a30 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_10/EfiThermalV1_0_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_0_10_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_0_10_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_0_10/Redfish_Thermal_v1_0_10_CS.h" +// +// EFI structure of Redfish Thermal v1_0_10 +// +typedef struct _EFI_REDFISH_THERMAL_V1_0_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_0_10_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_0_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_11/EfiThermalV1_0_11.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_11/EfiThermalV1_0_11.h new file mode 100644 index 00000000000..86bf025270e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_11/EfiThermalV1_0_11.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_0_11 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_0_11_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_0_11_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_0_11/Redfish_Thermal_v1_0_11_CS.h" +// +// EFI structure of Redfish Thermal v1_0_11 +// +typedef struct _EFI_REDFISH_THERMAL_V1_0_11 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_0_11_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_0_11; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_2/EfiThermalV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_2/EfiThermalV1_0_2.h new file mode 100644 index 00000000000..011687eced4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_2/EfiThermalV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_0_2_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_0_2/Redfish_Thermal_v1_0_2_CS.h" +// +// EFI structure of Redfish Thermal v1_0_2 +// +typedef struct _EFI_REDFISH_THERMAL_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_0_2_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_3/EfiThermalV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_3/EfiThermalV1_0_3.h new file mode 100644 index 00000000000..2bd0d4f497f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_3/EfiThermalV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_0_3_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_0_3/Redfish_Thermal_v1_0_3_CS.h" +// +// EFI structure of Redfish Thermal v1_0_3 +// +typedef struct _EFI_REDFISH_THERMAL_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_0_3_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_4/EfiThermalV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_4/EfiThermalV1_0_4.h new file mode 100644 index 00000000000..cfa8054ea02 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_4/EfiThermalV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_0_4_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_0_4/Redfish_Thermal_v1_0_4_CS.h" +// +// EFI structure of Redfish Thermal v1_0_4 +// +typedef struct _EFI_REDFISH_THERMAL_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_0_4_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_5/EfiThermalV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_5/EfiThermalV1_0_5.h new file mode 100644 index 00000000000..64b39d22880 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_5/EfiThermalV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_0_5_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_0_5/Redfish_Thermal_v1_0_5_CS.h" +// +// EFI structure of Redfish Thermal v1_0_5 +// +typedef struct _EFI_REDFISH_THERMAL_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_0_5_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_6/EfiThermalV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_6/EfiThermalV1_0_6.h new file mode 100644 index 00000000000..75fd0417d12 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_6/EfiThermalV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_0_6_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_0_6/Redfish_Thermal_v1_0_6_CS.h" +// +// EFI structure of Redfish Thermal v1_0_6 +// +typedef struct _EFI_REDFISH_THERMAL_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_0_6_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_7/EfiThermalV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_7/EfiThermalV1_0_7.h new file mode 100644 index 00000000000..ba6279beb37 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_7/EfiThermalV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_0_7_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_0_7/Redfish_Thermal_v1_0_7_CS.h" +// +// EFI structure of Redfish Thermal v1_0_7 +// +typedef struct _EFI_REDFISH_THERMAL_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_0_7_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_8/EfiThermalV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_8/EfiThermalV1_0_8.h new file mode 100644 index 00000000000..09abdadf428 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_8/EfiThermalV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_0_8_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_0_8/Redfish_Thermal_v1_0_8_CS.h" +// +// EFI structure of Redfish Thermal v1_0_8 +// +typedef struct _EFI_REDFISH_THERMAL_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_0_8_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_9/EfiThermalV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_9/EfiThermalV1_0_9.h new file mode 100644 index 00000000000..855f0dc3b73 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_0_9/EfiThermalV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_0_9_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_0_9/Redfish_Thermal_v1_0_9_CS.h" +// +// EFI structure of Redfish Thermal v1_0_9 +// +typedef struct _EFI_REDFISH_THERMAL_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_0_9_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_0/EfiThermalV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_0/EfiThermalV1_1_0.h new file mode 100644 index 00000000000..175554d5aea --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_0/EfiThermalV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_1_0_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_1_0/Redfish_Thermal_v1_1_0_CS.h" +// +// EFI structure of Redfish Thermal v1_1_0 +// +typedef struct _EFI_REDFISH_THERMAL_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_1_0_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_1/EfiThermalV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_1/EfiThermalV1_1_1.h new file mode 100644 index 00000000000..7113da4ee6b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_1/EfiThermalV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_1_1_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_1_1/Redfish_Thermal_v1_1_1_CS.h" +// +// EFI structure of Redfish Thermal v1_1_1 +// +typedef struct _EFI_REDFISH_THERMAL_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_1_1_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_2/EfiThermalV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_2/EfiThermalV1_1_2.h new file mode 100644 index 00000000000..a84f0be332b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_2/EfiThermalV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_1_2_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_1_2/Redfish_Thermal_v1_1_2_CS.h" +// +// EFI structure of Redfish Thermal v1_1_2 +// +typedef struct _EFI_REDFISH_THERMAL_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_1_2_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_3/EfiThermalV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_3/EfiThermalV1_1_3.h new file mode 100644 index 00000000000..191b1a09533 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_3/EfiThermalV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_1_3_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_1_3/Redfish_Thermal_v1_1_3_CS.h" +// +// EFI structure of Redfish Thermal v1_1_3 +// +typedef struct _EFI_REDFISH_THERMAL_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_1_3_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_4/EfiThermalV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_4/EfiThermalV1_1_4.h new file mode 100644 index 00000000000..81d7112dd91 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_4/EfiThermalV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_1_4_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_1_4/Redfish_Thermal_v1_1_4_CS.h" +// +// EFI structure of Redfish Thermal v1_1_4 +// +typedef struct _EFI_REDFISH_THERMAL_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_1_4_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_5/EfiThermalV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_5/EfiThermalV1_1_5.h new file mode 100644 index 00000000000..53599546bb4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_5/EfiThermalV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_1_5_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_1_5/Redfish_Thermal_v1_1_5_CS.h" +// +// EFI structure of Redfish Thermal v1_1_5 +// +typedef struct _EFI_REDFISH_THERMAL_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_1_5_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_6/EfiThermalV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_6/EfiThermalV1_1_6.h new file mode 100644 index 00000000000..64a5ea1cad9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_6/EfiThermalV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_1_6_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_1_6/Redfish_Thermal_v1_1_6_CS.h" +// +// EFI structure of Redfish Thermal v1_1_6 +// +typedef struct _EFI_REDFISH_THERMAL_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_1_6_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_7/EfiThermalV1_1_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_7/EfiThermalV1_1_7.h new file mode 100644 index 00000000000..69feb35d78b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_7/EfiThermalV1_1_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_1_7_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_1_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_1_7/Redfish_Thermal_v1_1_7_CS.h" +// +// EFI structure of Redfish Thermal v1_1_7 +// +typedef struct _EFI_REDFISH_THERMAL_V1_1_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_1_7_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_1_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_8/EfiThermalV1_1_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_8/EfiThermalV1_1_8.h new file mode 100644 index 00000000000..f58ec6acd77 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_8/EfiThermalV1_1_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_1_8_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_1_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_1_8/Redfish_Thermal_v1_1_8_CS.h" +// +// EFI structure of Redfish Thermal v1_1_8 +// +typedef struct _EFI_REDFISH_THERMAL_V1_1_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_1_8_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_1_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_9/EfiThermalV1_1_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_9/EfiThermalV1_1_9.h new file mode 100644 index 00000000000..743e6a34087 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_1_9/EfiThermalV1_1_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_1_9_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_1_9_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_1_9/Redfish_Thermal_v1_1_9_CS.h" +// +// EFI structure of Redfish Thermal v1_1_9 +// +typedef struct _EFI_REDFISH_THERMAL_V1_1_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_1_9_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_1_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_0/EfiThermalV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_0/EfiThermalV1_2_0.h new file mode 100644 index 00000000000..cf5ef3f8639 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_0/EfiThermalV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_2_0_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_2_0/Redfish_Thermal_v1_2_0_CS.h" +// +// EFI structure of Redfish Thermal v1_2_0 +// +typedef struct _EFI_REDFISH_THERMAL_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_2_0_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_1/EfiThermalV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_1/EfiThermalV1_2_1.h new file mode 100644 index 00000000000..9ca7dc5d906 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_1/EfiThermalV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_2_1_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_2_1/Redfish_Thermal_v1_2_1_CS.h" +// +// EFI structure of Redfish Thermal v1_2_1 +// +typedef struct _EFI_REDFISH_THERMAL_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_2_1_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_2/EfiThermalV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_2/EfiThermalV1_2_2.h new file mode 100644 index 00000000000..bd50c0574be --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_2/EfiThermalV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_2_2_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_2_2/Redfish_Thermal_v1_2_2_CS.h" +// +// EFI structure of Redfish Thermal v1_2_2 +// +typedef struct _EFI_REDFISH_THERMAL_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_2_2_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_3/EfiThermalV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_3/EfiThermalV1_2_3.h new file mode 100644 index 00000000000..b60617939f3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_3/EfiThermalV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_2_3_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_2_3/Redfish_Thermal_v1_2_3_CS.h" +// +// EFI structure of Redfish Thermal v1_2_3 +// +typedef struct _EFI_REDFISH_THERMAL_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_2_3_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_4/EfiThermalV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_4/EfiThermalV1_2_4.h new file mode 100644 index 00000000000..971805acff3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_4/EfiThermalV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_2_4_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_2_4/Redfish_Thermal_v1_2_4_CS.h" +// +// EFI structure of Redfish Thermal v1_2_4 +// +typedef struct _EFI_REDFISH_THERMAL_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_2_4_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_5/EfiThermalV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_5/EfiThermalV1_2_5.h new file mode 100644 index 00000000000..db8ac6318a0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_5/EfiThermalV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_2_5_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_2_5/Redfish_Thermal_v1_2_5_CS.h" +// +// EFI structure of Redfish Thermal v1_2_5 +// +typedef struct _EFI_REDFISH_THERMAL_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_2_5_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_6/EfiThermalV1_2_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_6/EfiThermalV1_2_6.h new file mode 100644 index 00000000000..d537843f396 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_6/EfiThermalV1_2_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_2_6_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_2_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_2_6/Redfish_Thermal_v1_2_6_CS.h" +// +// EFI structure of Redfish Thermal v1_2_6 +// +typedef struct _EFI_REDFISH_THERMAL_V1_2_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_2_6_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_2_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_7/EfiThermalV1_2_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_7/EfiThermalV1_2_7.h new file mode 100644 index 00000000000..0392f45af64 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_7/EfiThermalV1_2_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_2_7_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_2_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_2_7/Redfish_Thermal_v1_2_7_CS.h" +// +// EFI structure of Redfish Thermal v1_2_7 +// +typedef struct _EFI_REDFISH_THERMAL_V1_2_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_2_7_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_2_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_8/EfiThermalV1_2_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_8/EfiThermalV1_2_8.h new file mode 100644 index 00000000000..4abcd592dd3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_2_8/EfiThermalV1_2_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_2_8_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_2_8_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_2_8/Redfish_Thermal_v1_2_8_CS.h" +// +// EFI structure of Redfish Thermal v1_2_8 +// +typedef struct _EFI_REDFISH_THERMAL_V1_2_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_2_8_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_2_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_0/EfiThermalV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_0/EfiThermalV1_3_0.h new file mode 100644 index 00000000000..6ed7b3b2479 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_0/EfiThermalV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_3_0_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_3_0/Redfish_Thermal_v1_3_0_CS.h" +// +// EFI structure of Redfish Thermal v1_3_0 +// +typedef struct _EFI_REDFISH_THERMAL_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_3_0_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_1/EfiThermalV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_1/EfiThermalV1_3_1.h new file mode 100644 index 00000000000..dadf3c4d955 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_1/EfiThermalV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_3_1_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_3_1/Redfish_Thermal_v1_3_1_CS.h" +// +// EFI structure of Redfish Thermal v1_3_1 +// +typedef struct _EFI_REDFISH_THERMAL_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_3_1_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_2/EfiThermalV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_2/EfiThermalV1_3_2.h new file mode 100644 index 00000000000..7cfe325c984 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_2/EfiThermalV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_3_2_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_3_2/Redfish_Thermal_v1_3_2_CS.h" +// +// EFI structure of Redfish Thermal v1_3_2 +// +typedef struct _EFI_REDFISH_THERMAL_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_3_2_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_3/EfiThermalV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_3/EfiThermalV1_3_3.h new file mode 100644 index 00000000000..0d4ed98a88c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_3/EfiThermalV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_3_3_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_3_3/Redfish_Thermal_v1_3_3_CS.h" +// +// EFI structure of Redfish Thermal v1_3_3 +// +typedef struct _EFI_REDFISH_THERMAL_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_3_3_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_4/EfiThermalV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_4/EfiThermalV1_3_4.h new file mode 100644 index 00000000000..796f35aa014 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_4/EfiThermalV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_3_4_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_3_4/Redfish_Thermal_v1_3_4_CS.h" +// +// EFI structure of Redfish Thermal v1_3_4 +// +typedef struct _EFI_REDFISH_THERMAL_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_3_4_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_5/EfiThermalV1_3_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_5/EfiThermalV1_3_5.h new file mode 100644 index 00000000000..0b85018c211 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_5/EfiThermalV1_3_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_3_5_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_3_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_3_5/Redfish_Thermal_v1_3_5_CS.h" +// +// EFI structure of Redfish Thermal v1_3_5 +// +typedef struct _EFI_REDFISH_THERMAL_V1_3_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_3_5_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_3_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_6/EfiThermalV1_3_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_6/EfiThermalV1_3_6.h new file mode 100644 index 00000000000..4d0d3420f82 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_6/EfiThermalV1_3_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_3_6_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_3_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_3_6/Redfish_Thermal_v1_3_6_CS.h" +// +// EFI structure of Redfish Thermal v1_3_6 +// +typedef struct _EFI_REDFISH_THERMAL_V1_3_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_3_6_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_3_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_7/EfiThermalV1_3_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_7/EfiThermalV1_3_7.h new file mode 100644 index 00000000000..4662703216c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_3_7/EfiThermalV1_3_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_3_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_3_7_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_3_7_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_3_7/Redfish_Thermal_v1_3_7_CS.h" +// +// EFI structure of Redfish Thermal v1_3_7 +// +typedef struct _EFI_REDFISH_THERMAL_V1_3_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_3_7_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_3_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_0/EfiThermalV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_0/EfiThermalV1_4_0.h new file mode 100644 index 00000000000..e98674f9266 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_0/EfiThermalV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_4_0_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_4_0/Redfish_Thermal_v1_4_0_CS.h" +// +// EFI structure of Redfish Thermal v1_4_0 +// +typedef struct _EFI_REDFISH_THERMAL_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_4_0_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_1/EfiThermalV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_1/EfiThermalV1_4_1.h new file mode 100644 index 00000000000..10218469e26 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_1/EfiThermalV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_4_1_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_4_1/Redfish_Thermal_v1_4_1_CS.h" +// +// EFI structure of Redfish Thermal v1_4_1 +// +typedef struct _EFI_REDFISH_THERMAL_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_4_1_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_2/EfiThermalV1_4_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_2/EfiThermalV1_4_2.h new file mode 100644 index 00000000000..0a0259cf4a6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_2/EfiThermalV1_4_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_4_2_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_4_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_4_2/Redfish_Thermal_v1_4_2_CS.h" +// +// EFI structure of Redfish Thermal v1_4_2 +// +typedef struct _EFI_REDFISH_THERMAL_V1_4_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_4_2_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_4_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_3/EfiThermalV1_4_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_3/EfiThermalV1_4_3.h new file mode 100644 index 00000000000..1616e066078 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_3/EfiThermalV1_4_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_4_3_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_4_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_4_3/Redfish_Thermal_v1_4_3_CS.h" +// +// EFI structure of Redfish Thermal v1_4_3 +// +typedef struct _EFI_REDFISH_THERMAL_V1_4_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_4_3_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_4_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_4/EfiThermalV1_4_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_4/EfiThermalV1_4_4.h new file mode 100644 index 00000000000..6e82656b2b9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_4/EfiThermalV1_4_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_4_4_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_4_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_4_4/Redfish_Thermal_v1_4_4_CS.h" +// +// EFI structure of Redfish Thermal v1_4_4 +// +typedef struct _EFI_REDFISH_THERMAL_V1_4_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_4_4_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_4_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_5/EfiThermalV1_4_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_5/EfiThermalV1_4_5.h new file mode 100644 index 00000000000..69e588a2271 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_5/EfiThermalV1_4_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_4_5_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_4_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_4_5/Redfish_Thermal_v1_4_5_CS.h" +// +// EFI structure of Redfish Thermal v1_4_5 +// +typedef struct _EFI_REDFISH_THERMAL_V1_4_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_4_5_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_4_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_6/EfiThermalV1_4_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_6/EfiThermalV1_4_6.h new file mode 100644 index 00000000000..7e91be0be40 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_4_6/EfiThermalV1_4_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_4_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_4_6_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_4_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_4_6/Redfish_Thermal_v1_4_6_CS.h" +// +// EFI structure of Redfish Thermal v1_4_6 +// +typedef struct _EFI_REDFISH_THERMAL_V1_4_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_4_6_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_4_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_5_0/EfiThermalV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_5_0/EfiThermalV1_5_0.h new file mode 100644 index 00000000000..22fa06d4143 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_5_0/EfiThermalV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_5_0_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_5_0/Redfish_Thermal_v1_5_0_CS.h" +// +// EFI structure of Redfish Thermal v1_5_0 +// +typedef struct _EFI_REDFISH_THERMAL_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_5_0_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_5_1/EfiThermalV1_5_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_5_1/EfiThermalV1_5_1.h new file mode 100644 index 00000000000..a9db81d2e44 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_5_1/EfiThermalV1_5_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_5_1_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_5_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_5_1/Redfish_Thermal_v1_5_1_CS.h" +// +// EFI structure of Redfish Thermal v1_5_1 +// +typedef struct _EFI_REDFISH_THERMAL_V1_5_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_5_1_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_5_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_5_2/EfiThermalV1_5_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_5_2/EfiThermalV1_5_2.h new file mode 100644 index 00000000000..2f13c09b918 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_5_2/EfiThermalV1_5_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_5_2_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_5_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_5_2/Redfish_Thermal_v1_5_2_CS.h" +// +// EFI structure of Redfish Thermal v1_5_2 +// +typedef struct _EFI_REDFISH_THERMAL_V1_5_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_5_2_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_5_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_5_3/EfiThermalV1_5_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_5_3/EfiThermalV1_5_3.h new file mode 100644 index 00000000000..4a9426414f3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_5_3/EfiThermalV1_5_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_5_3_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_5_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_5_3/Redfish_Thermal_v1_5_3_CS.h" +// +// EFI structure of Redfish Thermal v1_5_3 +// +typedef struct _EFI_REDFISH_THERMAL_V1_5_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_5_3_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_5_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_5_4/EfiThermalV1_5_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_5_4/EfiThermalV1_5_4.h new file mode 100644 index 00000000000..70ab4ec8399 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_5_4/EfiThermalV1_5_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_5_4_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_5_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_5_4/Redfish_Thermal_v1_5_4_CS.h" +// +// EFI structure of Redfish Thermal v1_5_4 +// +typedef struct _EFI_REDFISH_THERMAL_V1_5_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_5_4_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_5_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_5_5/EfiThermalV1_5_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_5_5/EfiThermalV1_5_5.h new file mode 100644 index 00000000000..ce86438c9ed --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_5_5/EfiThermalV1_5_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_5_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_5_5_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_5_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_5_5/Redfish_Thermal_v1_5_5_CS.h" +// +// EFI structure of Redfish Thermal v1_5_5 +// +typedef struct _EFI_REDFISH_THERMAL_V1_5_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_5_5_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_5_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_6_0/EfiThermalV1_6_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_6_0/EfiThermalV1_6_0.h new file mode 100644 index 00000000000..3196ccf6d28 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_6_0/EfiThermalV1_6_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_6_0_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_6_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_6_0/Redfish_Thermal_v1_6_0_CS.h" +// +// EFI structure of Redfish Thermal v1_6_0 +// +typedef struct _EFI_REDFISH_THERMAL_V1_6_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_6_0_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_6_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_6_1/EfiThermalV1_6_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_6_1/EfiThermalV1_6_1.h new file mode 100644 index 00000000000..30ac0439830 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_6_1/EfiThermalV1_6_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_6_1_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_6_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_6_1/Redfish_Thermal_v1_6_1_CS.h" +// +// EFI structure of Redfish Thermal v1_6_1 +// +typedef struct _EFI_REDFISH_THERMAL_V1_6_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_6_1_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_6_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_6_2/EfiThermalV1_6_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_6_2/EfiThermalV1_6_2.h new file mode 100644 index 00000000000..a16ae62885f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_6_2/EfiThermalV1_6_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_6_2_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_6_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_6_2/Redfish_Thermal_v1_6_2_CS.h" +// +// EFI structure of Redfish Thermal v1_6_2 +// +typedef struct _EFI_REDFISH_THERMAL_V1_6_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_6_2_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_6_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_7_0/EfiThermalV1_7_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_7_0/EfiThermalV1_7_0.h new file mode 100644 index 00000000000..7db31dd371a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Thermal/v1_7_0/EfiThermalV1_7_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Thermal v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMAL_V1_7_0_H__ +#define EFI_REDFISH_INTERP_THERMAL_V1_7_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Thermal/v1_7_0/Redfish_Thermal_v1_7_0_CS.h" +// +// EFI structure of Redfish Thermal v1_7_0 +// +typedef struct _EFI_REDFISH_THERMAL_V1_7_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMAL_V1_7_0_CS *Thermal; +} EFI_REDFISH_THERMAL_V1_7_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ThermalMetrics/v1_0_0/EfiThermalMetricsV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ThermalMetrics/v1_0_0/EfiThermalMetricsV1_0_0.h new file mode 100644 index 00000000000..30f44226b44 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ThermalMetrics/v1_0_0/EfiThermalMetricsV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ThermalMetrics v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMALMETRICS_V1_0_0_H__ +#define EFI_REDFISH_INTERP_THERMALMETRICS_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ThermalMetrics/v1_0_0/Redfish_ThermalMetrics_v1_0_0_CS.h" +// +// EFI structure of Redfish ThermalMetrics v1_0_0 +// +typedef struct _EFI_REDFISH_THERMALMETRICS_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMALMETRICS_V1_0_0_CS *ThermalMetrics; +} EFI_REDFISH_THERMALMETRICS_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ThermalSubsystem/v1_0_0/EfiThermalSubsystemV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/ThermalSubsystem/v1_0_0/EfiThermalSubsystemV1_0_0.h new file mode 100644 index 00000000000..43f7577e9d0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ThermalSubsystem/v1_0_0/EfiThermalSubsystemV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ThermalSubsystem v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_THERMALSUBSYSTEM_V1_0_0_H__ +#define EFI_REDFISH_INTERP_THERMALSUBSYSTEM_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/ThermalSubsystem/v1_0_0/Redfish_ThermalSubsystem_v1_0_0_CS.h" +// +// EFI structure of Redfish ThermalSubsystem v1_0_0 +// +typedef struct _EFI_REDFISH_THERMALSUBSYSTEM_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_THERMALSUBSYSTEM_V1_0_0_CS *ThermalSubsystem; +} EFI_REDFISH_THERMALSUBSYSTEM_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_0_0/EfiTriggersV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_0_0/EfiTriggersV1_0_0.h new file mode 100644 index 00000000000..25e679d5c2e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_0_0/EfiTriggersV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Triggers v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TRIGGERS_V1_0_0_H__ +#define EFI_REDFISH_INTERP_TRIGGERS_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Triggers/v1_0_0/Redfish_Triggers_v1_0_0_CS.h" +// +// EFI structure of Redfish Triggers v1_0_0 +// +typedef struct _EFI_REDFISH_TRIGGERS_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TRIGGERS_V1_0_0_CS *Triggers; +} EFI_REDFISH_TRIGGERS_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_0_1/EfiTriggersV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_0_1/EfiTriggersV1_0_1.h new file mode 100644 index 00000000000..549bccf92e3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_0_1/EfiTriggersV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Triggers v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TRIGGERS_V1_0_1_H__ +#define EFI_REDFISH_INTERP_TRIGGERS_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Triggers/v1_0_1/Redfish_Triggers_v1_0_1_CS.h" +// +// EFI structure of Redfish Triggers v1_0_1 +// +typedef struct _EFI_REDFISH_TRIGGERS_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TRIGGERS_V1_0_1_CS *Triggers; +} EFI_REDFISH_TRIGGERS_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_0_2/EfiTriggersV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_0_2/EfiTriggersV1_0_2.h new file mode 100644 index 00000000000..369820a378a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_0_2/EfiTriggersV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Triggers v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TRIGGERS_V1_0_2_H__ +#define EFI_REDFISH_INTERP_TRIGGERS_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Triggers/v1_0_2/Redfish_Triggers_v1_0_2_CS.h" +// +// EFI structure of Redfish Triggers v1_0_2 +// +typedef struct _EFI_REDFISH_TRIGGERS_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TRIGGERS_V1_0_2_CS *Triggers; +} EFI_REDFISH_TRIGGERS_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_0_3/EfiTriggersV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_0_3/EfiTriggersV1_0_3.h new file mode 100644 index 00000000000..946ddc22bea --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_0_3/EfiTriggersV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Triggers v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TRIGGERS_V1_0_3_H__ +#define EFI_REDFISH_INTERP_TRIGGERS_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Triggers/v1_0_3/Redfish_Triggers_v1_0_3_CS.h" +// +// EFI structure of Redfish Triggers v1_0_3 +// +typedef struct _EFI_REDFISH_TRIGGERS_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TRIGGERS_V1_0_3_CS *Triggers; +} EFI_REDFISH_TRIGGERS_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_0_4/EfiTriggersV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_0_4/EfiTriggersV1_0_4.h new file mode 100644 index 00000000000..35047f44129 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_0_4/EfiTriggersV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Triggers v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TRIGGERS_V1_0_4_H__ +#define EFI_REDFISH_INTERP_TRIGGERS_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Triggers/v1_0_4/Redfish_Triggers_v1_0_4_CS.h" +// +// EFI structure of Redfish Triggers v1_0_4 +// +typedef struct _EFI_REDFISH_TRIGGERS_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TRIGGERS_V1_0_4_CS *Triggers; +} EFI_REDFISH_TRIGGERS_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_0_5/EfiTriggersV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_0_5/EfiTriggersV1_0_5.h new file mode 100644 index 00000000000..fc500385ba3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_0_5/EfiTriggersV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Triggers v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TRIGGERS_V1_0_5_H__ +#define EFI_REDFISH_INTERP_TRIGGERS_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Triggers/v1_0_5/Redfish_Triggers_v1_0_5_CS.h" +// +// EFI structure of Redfish Triggers v1_0_5 +// +typedef struct _EFI_REDFISH_TRIGGERS_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TRIGGERS_V1_0_5_CS *Triggers; +} EFI_REDFISH_TRIGGERS_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_1_0/EfiTriggersV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_1_0/EfiTriggersV1_1_0.h new file mode 100644 index 00000000000..eb5ff8916bd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_1_0/EfiTriggersV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Triggers v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TRIGGERS_V1_1_0_H__ +#define EFI_REDFISH_INTERP_TRIGGERS_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Triggers/v1_1_0/Redfish_Triggers_v1_1_0_CS.h" +// +// EFI structure of Redfish Triggers v1_1_0 +// +typedef struct _EFI_REDFISH_TRIGGERS_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TRIGGERS_V1_1_0_CS *Triggers; +} EFI_REDFISH_TRIGGERS_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_1_1/EfiTriggersV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_1_1/EfiTriggersV1_1_1.h new file mode 100644 index 00000000000..501ce6393ca --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_1_1/EfiTriggersV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Triggers v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TRIGGERS_V1_1_1_H__ +#define EFI_REDFISH_INTERP_TRIGGERS_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Triggers/v1_1_1/Redfish_Triggers_v1_1_1_CS.h" +// +// EFI structure of Redfish Triggers v1_1_1 +// +typedef struct _EFI_REDFISH_TRIGGERS_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TRIGGERS_V1_1_1_CS *Triggers; +} EFI_REDFISH_TRIGGERS_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_1_2/EfiTriggersV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_1_2/EfiTriggersV1_1_2.h new file mode 100644 index 00000000000..a34d57ad47e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_1_2/EfiTriggersV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Triggers v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TRIGGERS_V1_1_2_H__ +#define EFI_REDFISH_INTERP_TRIGGERS_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Triggers/v1_1_2/Redfish_Triggers_v1_1_2_CS.h" +// +// EFI structure of Redfish Triggers v1_1_2 +// +typedef struct _EFI_REDFISH_TRIGGERS_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TRIGGERS_V1_1_2_CS *Triggers; +} EFI_REDFISH_TRIGGERS_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_1_3/EfiTriggersV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_1_3/EfiTriggersV1_1_3.h new file mode 100644 index 00000000000..0a63d6df3a3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Triggers/v1_1_3/EfiTriggersV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Triggers v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TRIGGERS_V1_1_3_H__ +#define EFI_REDFISH_INTERP_TRIGGERS_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Triggers/v1_1_3/Redfish_Triggers_v1_1_3_CS.h" +// +// EFI structure of Redfish Triggers v1_1_3 +// +typedef struct _EFI_REDFISH_TRIGGERS_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TRIGGERS_V1_1_3_CS *Triggers; +} EFI_REDFISH_TRIGGERS_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/TriggersCollection/EfiTriggersCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/TriggersCollection/EfiTriggersCollection.h new file mode 100644 index 00000000000..f82589b0281 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/TriggersCollection/EfiTriggersCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for TriggersCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_TRIGGERSCOLLECTION_H__ +#define EFI_REDFISH_INTERP_TRIGGERSCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/TriggersCollection/Redfish_TriggersCollection_CS.h" +// +// EFI structure of Redfish TriggersCollection +// +typedef struct _EFI_REDFISH_TRIGGERSCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_TRIGGERSCOLLECTION_CS *TriggersCollection; +} EFI_REDFISH_TRIGGERSCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_0/EfiUpdateServiceV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_0/EfiUpdateServiceV1_0_0.h new file mode 100644 index 00000000000..a3e136dc36a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_0/EfiUpdateServiceV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_0_0/Redfish_UpdateService_v1_0_0_CS.h" +// +// EFI structure of Redfish UpdateService v1_0_0 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_0_0_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_1/EfiUpdateServiceV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_1/EfiUpdateServiceV1_0_1.h new file mode 100644 index 00000000000..ca87fd61dd1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_1/EfiUpdateServiceV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_0_1_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_0_1/Redfish_UpdateService_v1_0_1_CS.h" +// +// EFI structure of Redfish UpdateService v1_0_1 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_0_1_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_10/EfiUpdateServiceV1_0_10.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_10/EfiUpdateServiceV1_0_10.h new file mode 100644 index 00000000000..4601d5656be --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_10/EfiUpdateServiceV1_0_10.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_0_10 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_0_10_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_0_10_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_0_10/Redfish_UpdateService_v1_0_10_CS.h" +// +// EFI structure of Redfish UpdateService v1_0_10 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_0_10 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_0_10_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_0_10; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_2/EfiUpdateServiceV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_2/EfiUpdateServiceV1_0_2.h new file mode 100644 index 00000000000..e0a7775a083 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_2/EfiUpdateServiceV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_0_2_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_0_2/Redfish_UpdateService_v1_0_2_CS.h" +// +// EFI structure of Redfish UpdateService v1_0_2 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_0_2_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_3/EfiUpdateServiceV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_3/EfiUpdateServiceV1_0_3.h new file mode 100644 index 00000000000..e515e59861b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_3/EfiUpdateServiceV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_0_3_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_0_3/Redfish_UpdateService_v1_0_3_CS.h" +// +// EFI structure of Redfish UpdateService v1_0_3 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_0_3_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_4/EfiUpdateServiceV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_4/EfiUpdateServiceV1_0_4.h new file mode 100644 index 00000000000..86c04945791 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_4/EfiUpdateServiceV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_0_4_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_0_4/Redfish_UpdateService_v1_0_4_CS.h" +// +// EFI structure of Redfish UpdateService v1_0_4 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_0_4_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_5/EfiUpdateServiceV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_5/EfiUpdateServiceV1_0_5.h new file mode 100644 index 00000000000..f67d48f13a4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_5/EfiUpdateServiceV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_0_5_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_0_5/Redfish_UpdateService_v1_0_5_CS.h" +// +// EFI structure of Redfish UpdateService v1_0_5 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_0_5_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_6/EfiUpdateServiceV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_6/EfiUpdateServiceV1_0_6.h new file mode 100644 index 00000000000..0705523b0bf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_6/EfiUpdateServiceV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_0_6_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_0_6/Redfish_UpdateService_v1_0_6_CS.h" +// +// EFI structure of Redfish UpdateService v1_0_6 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_0_6_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_7/EfiUpdateServiceV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_7/EfiUpdateServiceV1_0_7.h new file mode 100644 index 00000000000..b8ba5f0dde2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_7/EfiUpdateServiceV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_0_7_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_0_7/Redfish_UpdateService_v1_0_7_CS.h" +// +// EFI structure of Redfish UpdateService v1_0_7 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_0_7_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_8/EfiUpdateServiceV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_8/EfiUpdateServiceV1_0_8.h new file mode 100644 index 00000000000..3e2f8986c89 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_8/EfiUpdateServiceV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_0_8_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_0_8/Redfish_UpdateService_v1_0_8_CS.h" +// +// EFI structure of Redfish UpdateService v1_0_8 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_0_8_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_9/EfiUpdateServiceV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_9/EfiUpdateServiceV1_0_9.h new file mode 100644 index 00000000000..b8525569f67 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_0_9/EfiUpdateServiceV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_0_9_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_0_9/Redfish_UpdateService_v1_0_9_CS.h" +// +// EFI structure of Redfish UpdateService v1_0_9 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_0_9_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_0/EfiUpdateServiceV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_0/EfiUpdateServiceV1_1_0.h new file mode 100644 index 00000000000..0063b826787 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_0/EfiUpdateServiceV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_1_0_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_1_0/Redfish_UpdateService_v1_1_0_CS.h" +// +// EFI structure of Redfish UpdateService v1_1_0 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_1_0_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_1/EfiUpdateServiceV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_1/EfiUpdateServiceV1_1_1.h new file mode 100644 index 00000000000..f4f8927498f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_1/EfiUpdateServiceV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_1_1_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_1_1/Redfish_UpdateService_v1_1_1_CS.h" +// +// EFI structure of Redfish UpdateService v1_1_1 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_1_1_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_2/EfiUpdateServiceV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_2/EfiUpdateServiceV1_1_2.h new file mode 100644 index 00000000000..fb3075a9b83 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_2/EfiUpdateServiceV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_1_2_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_1_2/Redfish_UpdateService_v1_1_2_CS.h" +// +// EFI structure of Redfish UpdateService v1_1_2 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_1_2_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_3/EfiUpdateServiceV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_3/EfiUpdateServiceV1_1_3.h new file mode 100644 index 00000000000..f15f076c7a1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_3/EfiUpdateServiceV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_1_3_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_1_3/Redfish_UpdateService_v1_1_3_CS.h" +// +// EFI structure of Redfish UpdateService v1_1_3 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_1_3_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_4/EfiUpdateServiceV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_4/EfiUpdateServiceV1_1_4.h new file mode 100644 index 00000000000..c7eaad10276 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_4/EfiUpdateServiceV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_1_4_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_1_4/Redfish_UpdateService_v1_1_4_CS.h" +// +// EFI structure of Redfish UpdateService v1_1_4 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_1_4_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_5/EfiUpdateServiceV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_5/EfiUpdateServiceV1_1_5.h new file mode 100644 index 00000000000..12dfd774843 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_5/EfiUpdateServiceV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_1_5_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_1_5/Redfish_UpdateService_v1_1_5_CS.h" +// +// EFI structure of Redfish UpdateService v1_1_5 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_1_5_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_6/EfiUpdateServiceV1_1_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_6/EfiUpdateServiceV1_1_6.h new file mode 100644 index 00000000000..cc1a119b4a2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_6/EfiUpdateServiceV1_1_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_1_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_1_6_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_1_6_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_1_6/Redfish_UpdateService_v1_1_6_CS.h" +// +// EFI structure of Redfish UpdateService v1_1_6 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_1_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_1_6_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_1_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_7/EfiUpdateServiceV1_1_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_7/EfiUpdateServiceV1_1_7.h new file mode 100644 index 00000000000..cf583a8fe7f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_7/EfiUpdateServiceV1_1_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_1_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_1_7_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_1_7_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_1_7/Redfish_UpdateService_v1_1_7_CS.h" +// +// EFI structure of Redfish UpdateService v1_1_7 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_1_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_1_7_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_1_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_8/EfiUpdateServiceV1_1_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_8/EfiUpdateServiceV1_1_8.h new file mode 100644 index 00000000000..82abacbe855 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_8/EfiUpdateServiceV1_1_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_1_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_1_8_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_1_8_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_1_8/Redfish_UpdateService_v1_1_8_CS.h" +// +// EFI structure of Redfish UpdateService v1_1_8 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_1_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_1_8_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_1_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_9/EfiUpdateServiceV1_1_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_9/EfiUpdateServiceV1_1_9.h new file mode 100644 index 00000000000..f2d83250a3e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_1_9/EfiUpdateServiceV1_1_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_1_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_1_9_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_1_9_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_1_9/Redfish_UpdateService_v1_1_9_CS.h" +// +// EFI structure of Redfish UpdateService v1_1_9 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_1_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_1_9_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_1_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_0/EfiUpdateServiceV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_0/EfiUpdateServiceV1_2_0.h new file mode 100644 index 00000000000..9a4351d71ac --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_0/EfiUpdateServiceV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_2_0_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_2_0/Redfish_UpdateService_v1_2_0_CS.h" +// +// EFI structure of Redfish UpdateService v1_2_0 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_2_0_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_1/EfiUpdateServiceV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_1/EfiUpdateServiceV1_2_1.h new file mode 100644 index 00000000000..38bcd034531 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_1/EfiUpdateServiceV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_2_1_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_2_1/Redfish_UpdateService_v1_2_1_CS.h" +// +// EFI structure of Redfish UpdateService v1_2_1 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_2_1_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_2/EfiUpdateServiceV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_2/EfiUpdateServiceV1_2_2.h new file mode 100644 index 00000000000..aadeea9846d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_2/EfiUpdateServiceV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_2_2_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_2_2/Redfish_UpdateService_v1_2_2_CS.h" +// +// EFI structure of Redfish UpdateService v1_2_2 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_2_2_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_3/EfiUpdateServiceV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_3/EfiUpdateServiceV1_2_3.h new file mode 100644 index 00000000000..8ec049d91ae --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_3/EfiUpdateServiceV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_2_3_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_2_3/Redfish_UpdateService_v1_2_3_CS.h" +// +// EFI structure of Redfish UpdateService v1_2_3 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_2_3_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_4/EfiUpdateServiceV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_4/EfiUpdateServiceV1_2_4.h new file mode 100644 index 00000000000..70d285bb638 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_4/EfiUpdateServiceV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_2_4_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_2_4/Redfish_UpdateService_v1_2_4_CS.h" +// +// EFI structure of Redfish UpdateService v1_2_4 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_2_4_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_5/EfiUpdateServiceV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_5/EfiUpdateServiceV1_2_5.h new file mode 100644 index 00000000000..c4095c6bf91 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_5/EfiUpdateServiceV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_2_5_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_2_5/Redfish_UpdateService_v1_2_5_CS.h" +// +// EFI structure of Redfish UpdateService v1_2_5 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_2_5_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_6/EfiUpdateServiceV1_2_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_6/EfiUpdateServiceV1_2_6.h new file mode 100644 index 00000000000..d776e8c2c98 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_6/EfiUpdateServiceV1_2_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_2_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_2_6_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_2_6_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_2_6/Redfish_UpdateService_v1_2_6_CS.h" +// +// EFI structure of Redfish UpdateService v1_2_6 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_2_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_2_6_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_2_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_7/EfiUpdateServiceV1_2_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_7/EfiUpdateServiceV1_2_7.h new file mode 100644 index 00000000000..79da9bd5ac7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_7/EfiUpdateServiceV1_2_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_2_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_2_7_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_2_7_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_2_7/Redfish_UpdateService_v1_2_7_CS.h" +// +// EFI structure of Redfish UpdateService v1_2_7 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_2_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_2_7_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_2_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_8/EfiUpdateServiceV1_2_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_8/EfiUpdateServiceV1_2_8.h new file mode 100644 index 00000000000..521df2ee061 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_2_8/EfiUpdateServiceV1_2_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_2_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_2_8_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_2_8_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_2_8/Redfish_UpdateService_v1_2_8_CS.h" +// +// EFI structure of Redfish UpdateService v1_2_8 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_2_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_2_8_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_2_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_0/EfiUpdateServiceV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_0/EfiUpdateServiceV1_3_0.h new file mode 100644 index 00000000000..399b113afe8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_0/EfiUpdateServiceV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_3_0_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_3_0/Redfish_UpdateService_v1_3_0_CS.h" +// +// EFI structure of Redfish UpdateService v1_3_0 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_3_0_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_1/EfiUpdateServiceV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_1/EfiUpdateServiceV1_3_1.h new file mode 100644 index 00000000000..9ec3fdf8074 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_1/EfiUpdateServiceV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_3_1_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_3_1/Redfish_UpdateService_v1_3_1_CS.h" +// +// EFI structure of Redfish UpdateService v1_3_1 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_3_1_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_2/EfiUpdateServiceV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_2/EfiUpdateServiceV1_3_2.h new file mode 100644 index 00000000000..06524881da1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_2/EfiUpdateServiceV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_3_2_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_3_2/Redfish_UpdateService_v1_3_2_CS.h" +// +// EFI structure of Redfish UpdateService v1_3_2 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_3_2_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_3/EfiUpdateServiceV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_3/EfiUpdateServiceV1_3_3.h new file mode 100644 index 00000000000..3760724c826 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_3/EfiUpdateServiceV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_3_3_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_3_3/Redfish_UpdateService_v1_3_3_CS.h" +// +// EFI structure of Redfish UpdateService v1_3_3 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_3_3_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_4/EfiUpdateServiceV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_4/EfiUpdateServiceV1_3_4.h new file mode 100644 index 00000000000..5b13c34a831 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_4/EfiUpdateServiceV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_3_4_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_3_4/Redfish_UpdateService_v1_3_4_CS.h" +// +// EFI structure of Redfish UpdateService v1_3_4 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_3_4_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_5/EfiUpdateServiceV1_3_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_5/EfiUpdateServiceV1_3_5.h new file mode 100644 index 00000000000..d75294a2931 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_5/EfiUpdateServiceV1_3_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_3_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_3_5_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_3_5_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_3_5/Redfish_UpdateService_v1_3_5_CS.h" +// +// EFI structure of Redfish UpdateService v1_3_5 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_3_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_3_5_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_3_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_6/EfiUpdateServiceV1_3_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_6/EfiUpdateServiceV1_3_6.h new file mode 100644 index 00000000000..831830fe0f2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_3_6/EfiUpdateServiceV1_3_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_3_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_3_6_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_3_6_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_3_6/Redfish_UpdateService_v1_3_6_CS.h" +// +// EFI structure of Redfish UpdateService v1_3_6 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_3_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_3_6_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_3_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_4_0/EfiUpdateServiceV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_4_0/EfiUpdateServiceV1_4_0.h new file mode 100644 index 00000000000..f8b0a930749 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_4_0/EfiUpdateServiceV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_4_0_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_4_0/Redfish_UpdateService_v1_4_0_CS.h" +// +// EFI structure of Redfish UpdateService v1_4_0 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_4_0_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_4_1/EfiUpdateServiceV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_4_1/EfiUpdateServiceV1_4_1.h new file mode 100644 index 00000000000..ec031d96250 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_4_1/EfiUpdateServiceV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_4_1_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_4_1/Redfish_UpdateService_v1_4_1_CS.h" +// +// EFI structure of Redfish UpdateService v1_4_1 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_4_1_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_4_2/EfiUpdateServiceV1_4_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_4_2/EfiUpdateServiceV1_4_2.h new file mode 100644 index 00000000000..d53d464a15d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_4_2/EfiUpdateServiceV1_4_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_4_2_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_4_2_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_4_2/Redfish_UpdateService_v1_4_2_CS.h" +// +// EFI structure of Redfish UpdateService v1_4_2 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_4_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_4_2_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_4_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_4_3/EfiUpdateServiceV1_4_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_4_3/EfiUpdateServiceV1_4_3.h new file mode 100644 index 00000000000..d33fb63d6fa --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_4_3/EfiUpdateServiceV1_4_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_4_3_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_4_3_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_4_3/Redfish_UpdateService_v1_4_3_CS.h" +// +// EFI structure of Redfish UpdateService v1_4_3 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_4_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_4_3_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_4_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_4_4/EfiUpdateServiceV1_4_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_4_4/EfiUpdateServiceV1_4_4.h new file mode 100644 index 00000000000..f75bb8928b7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_4_4/EfiUpdateServiceV1_4_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_4_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_4_4_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_4_4_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_4_4/Redfish_UpdateService_v1_4_4_CS.h" +// +// EFI structure of Redfish UpdateService v1_4_4 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_4_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_4_4_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_4_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_4_5/EfiUpdateServiceV1_4_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_4_5/EfiUpdateServiceV1_4_5.h new file mode 100644 index 00000000000..47f3b9108e4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_4_5/EfiUpdateServiceV1_4_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_4_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_4_5_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_4_5_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_4_5/Redfish_UpdateService_v1_4_5_CS.h" +// +// EFI structure of Redfish UpdateService v1_4_5 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_4_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_4_5_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_4_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_5_0/EfiUpdateServiceV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_5_0/EfiUpdateServiceV1_5_0.h new file mode 100644 index 00000000000..93a55275c90 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_5_0/EfiUpdateServiceV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_5_0_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_5_0/Redfish_UpdateService_v1_5_0_CS.h" +// +// EFI structure of Redfish UpdateService v1_5_0 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_5_0_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_5_1/EfiUpdateServiceV1_5_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_5_1/EfiUpdateServiceV1_5_1.h new file mode 100644 index 00000000000..2b5a237c6cf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_5_1/EfiUpdateServiceV1_5_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_5_1_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_5_1_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_5_1/Redfish_UpdateService_v1_5_1_CS.h" +// +// EFI structure of Redfish UpdateService v1_5_1 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_5_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_5_1_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_5_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_5_2/EfiUpdateServiceV1_5_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_5_2/EfiUpdateServiceV1_5_2.h new file mode 100644 index 00000000000..32dec819705 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_5_2/EfiUpdateServiceV1_5_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_5_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_5_2_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_5_2_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_5_2/Redfish_UpdateService_v1_5_2_CS.h" +// +// EFI structure of Redfish UpdateService v1_5_2 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_5_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_5_2_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_5_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_5_3/EfiUpdateServiceV1_5_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_5_3/EfiUpdateServiceV1_5_3.h new file mode 100644 index 00000000000..45dadf72e22 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_5_3/EfiUpdateServiceV1_5_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_5_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_5_3_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_5_3_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_5_3/Redfish_UpdateService_v1_5_3_CS.h" +// +// EFI structure of Redfish UpdateService v1_5_3 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_5_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_5_3_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_5_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_5_4/EfiUpdateServiceV1_5_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_5_4/EfiUpdateServiceV1_5_4.h new file mode 100644 index 00000000000..fab64d11d0b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_5_4/EfiUpdateServiceV1_5_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_5_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_5_4_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_5_4_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_5_4/Redfish_UpdateService_v1_5_4_CS.h" +// +// EFI structure of Redfish UpdateService v1_5_4 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_5_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_5_4_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_5_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_6_0/EfiUpdateServiceV1_6_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_6_0/EfiUpdateServiceV1_6_0.h new file mode 100644 index 00000000000..b7b557d6a65 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_6_0/EfiUpdateServiceV1_6_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_6_0_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_6_0_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_6_0/Redfish_UpdateService_v1_6_0_CS.h" +// +// EFI structure of Redfish UpdateService v1_6_0 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_6_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_6_0_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_6_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_6_1/EfiUpdateServiceV1_6_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_6_1/EfiUpdateServiceV1_6_1.h new file mode 100644 index 00000000000..36e887bbf04 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_6_1/EfiUpdateServiceV1_6_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_6_1_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_6_1_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_6_1/Redfish_UpdateService_v1_6_1_CS.h" +// +// EFI structure of Redfish UpdateService v1_6_1 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_6_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_6_1_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_6_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_6_2/EfiUpdateServiceV1_6_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_6_2/EfiUpdateServiceV1_6_2.h new file mode 100644 index 00000000000..6c0025e36b6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_6_2/EfiUpdateServiceV1_6_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_6_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_6_2_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_6_2_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_6_2/Redfish_UpdateService_v1_6_2_CS.h" +// +// EFI structure of Redfish UpdateService v1_6_2 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_6_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_6_2_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_6_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_6_3/EfiUpdateServiceV1_6_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_6_3/EfiUpdateServiceV1_6_3.h new file mode 100644 index 00000000000..7e55c493c21 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_6_3/EfiUpdateServiceV1_6_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_6_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_6_3_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_6_3_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_6_3/Redfish_UpdateService_v1_6_3_CS.h" +// +// EFI structure of Redfish UpdateService v1_6_3 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_6_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_6_3_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_6_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_7_0/EfiUpdateServiceV1_7_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_7_0/EfiUpdateServiceV1_7_0.h new file mode 100644 index 00000000000..42a2dcf6a7a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_7_0/EfiUpdateServiceV1_7_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_7_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_7_0_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_7_0_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_7_0/Redfish_UpdateService_v1_7_0_CS.h" +// +// EFI structure of Redfish UpdateService v1_7_0 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_7_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_7_0_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_7_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_7_1/EfiUpdateServiceV1_7_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_7_1/EfiUpdateServiceV1_7_1.h new file mode 100644 index 00000000000..451291a1915 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_7_1/EfiUpdateServiceV1_7_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_7_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_7_1_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_7_1_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_7_1/Redfish_UpdateService_v1_7_1_CS.h" +// +// EFI structure of Redfish UpdateService v1_7_1 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_7_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_7_1_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_7_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_7_2/EfiUpdateServiceV1_7_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_7_2/EfiUpdateServiceV1_7_2.h new file mode 100644 index 00000000000..77319f3d25b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_7_2/EfiUpdateServiceV1_7_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_7_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_7_2_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_7_2_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_7_2/Redfish_UpdateService_v1_7_2_CS.h" +// +// EFI structure of Redfish UpdateService v1_7_2 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_7_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_7_2_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_7_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_7_3/EfiUpdateServiceV1_7_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_7_3/EfiUpdateServiceV1_7_3.h new file mode 100644 index 00000000000..ea453487f0d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_7_3/EfiUpdateServiceV1_7_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_7_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_7_3_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_7_3_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_7_3/Redfish_UpdateService_v1_7_3_CS.h" +// +// EFI structure of Redfish UpdateService v1_7_3 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_7_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_7_3_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_7_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_8_0/EfiUpdateServiceV1_8_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_8_0/EfiUpdateServiceV1_8_0.h new file mode 100644 index 00000000000..dc7e87a88ba --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_8_0/EfiUpdateServiceV1_8_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_8_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_8_0_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_8_0_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_8_0/Redfish_UpdateService_v1_8_0_CS.h" +// +// EFI structure of Redfish UpdateService v1_8_0 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_8_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_8_0_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_8_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_8_1/EfiUpdateServiceV1_8_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_8_1/EfiUpdateServiceV1_8_1.h new file mode 100644 index 00000000000..fdd5b16e5d6 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_8_1/EfiUpdateServiceV1_8_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_8_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_8_1_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_8_1_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_8_1/Redfish_UpdateService_v1_8_1_CS.h" +// +// EFI structure of Redfish UpdateService v1_8_1 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_8_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_8_1_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_8_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_8_2/EfiUpdateServiceV1_8_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_8_2/EfiUpdateServiceV1_8_2.h new file mode 100644 index 00000000000..226afbb0007 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_8_2/EfiUpdateServiceV1_8_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_8_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_8_2_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_8_2_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_8_2/Redfish_UpdateService_v1_8_2_CS.h" +// +// EFI structure of Redfish UpdateService v1_8_2 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_8_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_8_2_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_8_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_8_3/EfiUpdateServiceV1_8_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_8_3/EfiUpdateServiceV1_8_3.h new file mode 100644 index 00000000000..5a6ffe1d7ec --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/UpdateService/v1_8_3/EfiUpdateServiceV1_8_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for UpdateService v1_8_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_UPDATESERVICE_V1_8_3_H__ +#define EFI_REDFISH_INTERP_UPDATESERVICE_V1_8_3_H__ + +#include +#include +#include "ConverterLib/edk2library/UpdateService/v1_8_3/Redfish_UpdateService_v1_8_3_CS.h" +// +// EFI structure of Redfish UpdateService v1_8_3 +// +typedef struct _EFI_REDFISH_UPDATESERVICE_V1_8_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_UPDATESERVICE_V1_8_3_CS *UpdateService; +} EFI_REDFISH_UPDATESERVICE_V1_8_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VCATEntry/v1_0_0/EfiVCATEntryV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/VCATEntry/v1_0_0/EfiVCATEntryV1_0_0.h new file mode 100644 index 00000000000..5408960466f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VCATEntry/v1_0_0/EfiVCATEntryV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VCATEntry v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VCATENTRY_V1_0_0_H__ +#define EFI_REDFISH_INTERP_VCATENTRY_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/VCATEntry/v1_0_0/Redfish_VCATEntry_v1_0_0_CS.h" +// +// EFI structure of Redfish VCATEntry v1_0_0 +// +typedef struct _EFI_REDFISH_VCATENTRY_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VCATENTRY_V1_0_0_CS *VCATEntry; +} EFI_REDFISH_VCATENTRY_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VCATEntry/v1_0_1/EfiVCATEntryV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/VCATEntry/v1_0_1/EfiVCATEntryV1_0_1.h new file mode 100644 index 00000000000..6dfbe02da7d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VCATEntry/v1_0_1/EfiVCATEntryV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VCATEntry v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VCATENTRY_V1_0_1_H__ +#define EFI_REDFISH_INTERP_VCATENTRY_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/VCATEntry/v1_0_1/Redfish_VCATEntry_v1_0_1_CS.h" +// +// EFI structure of Redfish VCATEntry v1_0_1 +// +typedef struct _EFI_REDFISH_VCATENTRY_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VCATENTRY_V1_0_1_CS *VCATEntry; +} EFI_REDFISH_VCATENTRY_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VCATEntryCollection/EfiVCATEntryCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/VCATEntryCollection/EfiVCATEntryCollection.h new file mode 100644 index 00000000000..0aaac30b46d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VCATEntryCollection/EfiVCATEntryCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VCATEntryCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VCATENTRYCOLLECTION_H__ +#define EFI_REDFISH_INTERP_VCATENTRYCOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/VCATEntryCollection/Redfish_VCATEntryCollection_CS.h" +// +// EFI structure of Redfish VCATEntryCollection +// +typedef struct _EFI_REDFISH_VCATENTRYCOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VCATENTRYCOLLECTION_CS *VCATEntryCollection; +} EFI_REDFISH_VCATENTRYCOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_0/EfiVLanNetworkInterfaceV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_0/EfiVLanNetworkInterfaceV1_0_0.h new file mode 100644 index 00000000000..3ad8f06c4bf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_0/EfiVLanNetworkInterfaceV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VLanNetworkInterface v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/VLanNetworkInterface/v1_0_0/Redfish_VLanNetworkInterface_v1_0_0_CS.h" +// +// EFI structure of Redfish VLanNetworkInterface v1_0_0 +// +typedef struct _EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_0_CS *VLanNetworkInterface; +} EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_1/EfiVLanNetworkInterfaceV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_1/EfiVLanNetworkInterfaceV1_0_1.h new file mode 100644 index 00000000000..2e0ef043e9c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_1/EfiVLanNetworkInterfaceV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VLanNetworkInterface v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_0_1_H__ +#define EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/VLanNetworkInterface/v1_0_1/Redfish_VLanNetworkInterface_v1_0_1_CS.h" +// +// EFI structure of Redfish VLanNetworkInterface v1_0_1 +// +typedef struct _EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_1_CS *VLanNetworkInterface; +} EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_2/EfiVLanNetworkInterfaceV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_2/EfiVLanNetworkInterfaceV1_0_2.h new file mode 100644 index 00000000000..226b41feb4d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_2/EfiVLanNetworkInterfaceV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VLanNetworkInterface v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_0_2_H__ +#define EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/VLanNetworkInterface/v1_0_2/Redfish_VLanNetworkInterface_v1_0_2_CS.h" +// +// EFI structure of Redfish VLanNetworkInterface v1_0_2 +// +typedef struct _EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_2_CS *VLanNetworkInterface; +} EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_3/EfiVLanNetworkInterfaceV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_3/EfiVLanNetworkInterfaceV1_0_3.h new file mode 100644 index 00000000000..39c5c162c92 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_3/EfiVLanNetworkInterfaceV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VLanNetworkInterface v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_0_3_H__ +#define EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/VLanNetworkInterface/v1_0_3/Redfish_VLanNetworkInterface_v1_0_3_CS.h" +// +// EFI structure of Redfish VLanNetworkInterface v1_0_3 +// +typedef struct _EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_3_CS *VLanNetworkInterface; +} EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_4/EfiVLanNetworkInterfaceV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_4/EfiVLanNetworkInterfaceV1_0_4.h new file mode 100644 index 00000000000..c19b296efba --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_4/EfiVLanNetworkInterfaceV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VLanNetworkInterface v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_0_4_H__ +#define EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/VLanNetworkInterface/v1_0_4/Redfish_VLanNetworkInterface_v1_0_4_CS.h" +// +// EFI structure of Redfish VLanNetworkInterface v1_0_4 +// +typedef struct _EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_4_CS *VLanNetworkInterface; +} EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_5/EfiVLanNetworkInterfaceV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_5/EfiVLanNetworkInterfaceV1_0_5.h new file mode 100644 index 00000000000..4aff1120cb8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_5/EfiVLanNetworkInterfaceV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VLanNetworkInterface v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_0_5_H__ +#define EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/VLanNetworkInterface/v1_0_5/Redfish_VLanNetworkInterface_v1_0_5_CS.h" +// +// EFI structure of Redfish VLanNetworkInterface v1_0_5 +// +typedef struct _EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_5_CS *VLanNetworkInterface; +} EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_6/EfiVLanNetworkInterfaceV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_6/EfiVLanNetworkInterfaceV1_0_6.h new file mode 100644 index 00000000000..19cdf03d5a1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_6/EfiVLanNetworkInterfaceV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VLanNetworkInterface v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_0_6_H__ +#define EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/VLanNetworkInterface/v1_0_6/Redfish_VLanNetworkInterface_v1_0_6_CS.h" +// +// EFI structure of Redfish VLanNetworkInterface v1_0_6 +// +typedef struct _EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_6_CS *VLanNetworkInterface; +} EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_7/EfiVLanNetworkInterfaceV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_7/EfiVLanNetworkInterfaceV1_0_7.h new file mode 100644 index 00000000000..dacb37e7618 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_7/EfiVLanNetworkInterfaceV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VLanNetworkInterface v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_0_7_H__ +#define EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/VLanNetworkInterface/v1_0_7/Redfish_VLanNetworkInterface_v1_0_7_CS.h" +// +// EFI structure of Redfish VLanNetworkInterface v1_0_7 +// +typedef struct _EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_7_CS *VLanNetworkInterface; +} EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_8/EfiVLanNetworkInterfaceV1_0_8.h b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_8/EfiVLanNetworkInterfaceV1_0_8.h new file mode 100644 index 00000000000..e2305a7b088 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_8/EfiVLanNetworkInterfaceV1_0_8.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VLanNetworkInterface v1_0_8 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_0_8_H__ +#define EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_0_8_H__ + +#include +#include +#include "ConverterLib/edk2library/VLanNetworkInterface/v1_0_8/Redfish_VLanNetworkInterface_v1_0_8_CS.h" +// +// EFI structure of Redfish VLanNetworkInterface v1_0_8 +// +typedef struct _EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_8 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_8_CS *VLanNetworkInterface; +} EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_8; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_9/EfiVLanNetworkInterfaceV1_0_9.h b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_9/EfiVLanNetworkInterfaceV1_0_9.h new file mode 100644 index 00000000000..604237af121 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_0_9/EfiVLanNetworkInterfaceV1_0_9.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VLanNetworkInterface v1_0_9 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_0_9_H__ +#define EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_0_9_H__ + +#include +#include +#include "ConverterLib/edk2library/VLanNetworkInterface/v1_0_9/Redfish_VLanNetworkInterface_v1_0_9_CS.h" +// +// EFI structure of Redfish VLanNetworkInterface v1_0_9 +// +typedef struct _EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_9 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_9_CS *VLanNetworkInterface; +} EFI_REDFISH_VLANNETWORKINTERFACE_V1_0_9; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_1_0/EfiVLanNetworkInterfaceV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_1_0/EfiVLanNetworkInterfaceV1_1_0.h new file mode 100644 index 00000000000..6a85f03170d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_1_0/EfiVLanNetworkInterfaceV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VLanNetworkInterface v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_1_0_H__ +#define EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/VLanNetworkInterface/v1_1_0/Redfish_VLanNetworkInterface_v1_1_0_CS.h" +// +// EFI structure of Redfish VLanNetworkInterface v1_1_0 +// +typedef struct _EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_0_CS *VLanNetworkInterface; +} EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_1_1/EfiVLanNetworkInterfaceV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_1_1/EfiVLanNetworkInterfaceV1_1_1.h new file mode 100644 index 00000000000..b248d01ada7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_1_1/EfiVLanNetworkInterfaceV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VLanNetworkInterface v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_1_1_H__ +#define EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/VLanNetworkInterface/v1_1_1/Redfish_VLanNetworkInterface_v1_1_1_CS.h" +// +// EFI structure of Redfish VLanNetworkInterface v1_1_1 +// +typedef struct _EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_1_CS *VLanNetworkInterface; +} EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_1_2/EfiVLanNetworkInterfaceV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_1_2/EfiVLanNetworkInterfaceV1_1_2.h new file mode 100644 index 00000000000..797e6d921e4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_1_2/EfiVLanNetworkInterfaceV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VLanNetworkInterface v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_1_2_H__ +#define EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/VLanNetworkInterface/v1_1_2/Redfish_VLanNetworkInterface_v1_1_2_CS.h" +// +// EFI structure of Redfish VLanNetworkInterface v1_1_2 +// +typedef struct _EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_2_CS *VLanNetworkInterface; +} EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_1_3/EfiVLanNetworkInterfaceV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_1_3/EfiVLanNetworkInterfaceV1_1_3.h new file mode 100644 index 00000000000..ca6626f8309 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_1_3/EfiVLanNetworkInterfaceV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VLanNetworkInterface v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_1_3_H__ +#define EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/VLanNetworkInterface/v1_1_3/Redfish_VLanNetworkInterface_v1_1_3_CS.h" +// +// EFI structure of Redfish VLanNetworkInterface v1_1_3 +// +typedef struct _EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_3_CS *VLanNetworkInterface; +} EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_1_4/EfiVLanNetworkInterfaceV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_1_4/EfiVLanNetworkInterfaceV1_1_4.h new file mode 100644 index 00000000000..8d9daf60629 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_1_4/EfiVLanNetworkInterfaceV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VLanNetworkInterface v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_1_4_H__ +#define EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/VLanNetworkInterface/v1_1_4/Redfish_VLanNetworkInterface_v1_1_4_CS.h" +// +// EFI structure of Redfish VLanNetworkInterface v1_1_4 +// +typedef struct _EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_4_CS *VLanNetworkInterface; +} EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_1_5/EfiVLanNetworkInterfaceV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_1_5/EfiVLanNetworkInterfaceV1_1_5.h new file mode 100644 index 00000000000..005574656d5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_1_5/EfiVLanNetworkInterfaceV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VLanNetworkInterface v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_1_5_H__ +#define EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/VLanNetworkInterface/v1_1_5/Redfish_VLanNetworkInterface_v1_1_5_CS.h" +// +// EFI structure of Redfish VLanNetworkInterface v1_1_5 +// +typedef struct _EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_5_CS *VLanNetworkInterface; +} EFI_REDFISH_VLANNETWORKINTERFACE_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_2_0/EfiVLanNetworkInterfaceV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_2_0/EfiVLanNetworkInterfaceV1_2_0.h new file mode 100644 index 00000000000..950fc51081f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterface/v1_2_0/EfiVLanNetworkInterfaceV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VLanNetworkInterface v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_2_0_H__ +#define EFI_REDFISH_INTERP_VLANNETWORKINTERFACE_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/VLanNetworkInterface/v1_2_0/Redfish_VLanNetworkInterface_v1_2_0_CS.h" +// +// EFI structure of Redfish VLanNetworkInterface v1_2_0 +// +typedef struct _EFI_REDFISH_VLANNETWORKINTERFACE_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VLANNETWORKINTERFACE_V1_2_0_CS *VLanNetworkInterface; +} EFI_REDFISH_VLANNETWORKINTERFACE_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterfaceCollection/EfiVLanNetworkInterfaceCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterfaceCollection/EfiVLanNetworkInterfaceCollection.h new file mode 100644 index 00000000000..d1274366a02 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VLanNetworkInterfaceCollection/EfiVLanNetworkInterfaceCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VLanNetworkInterfaceCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VLANNETWORKINTERFACECOLLECTION_H__ +#define EFI_REDFISH_INTERP_VLANNETWORKINTERFACECOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/VLanNetworkInterfaceCollection/Redfish_VLanNetworkInterfaceCollection_CS.h" +// +// EFI structure of Redfish VLanNetworkInterfaceCollection +// +typedef struct _EFI_REDFISH_VLANNETWORKINTERFACECOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VLANNETWORKINTERFACECOLLECTION_CS *VLanNetworkInterfaceCollection; +} EFI_REDFISH_VLANNETWORKINTERFACECOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_0/EfiVirtualMediaV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_0/EfiVirtualMediaV1_0_0.h new file mode 100644 index 00000000000..3c3eacff5dc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_0/EfiVirtualMediaV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VirtualMedia v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_0_0_H__ +#define EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/VirtualMedia/v1_0_0/Redfish_VirtualMedia_v1_0_0_CS.h" +// +// EFI structure of Redfish VirtualMedia v1_0_0 +// +typedef struct _EFI_REDFISH_VIRTUALMEDIA_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VIRTUALMEDIA_V1_0_0_CS *VirtualMedia; +} EFI_REDFISH_VIRTUALMEDIA_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_2/EfiVirtualMediaV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_2/EfiVirtualMediaV1_0_2.h new file mode 100644 index 00000000000..acad795125e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_2/EfiVirtualMediaV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VirtualMedia v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_0_2_H__ +#define EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/VirtualMedia/v1_0_2/Redfish_VirtualMedia_v1_0_2_CS.h" +// +// EFI structure of Redfish VirtualMedia v1_0_2 +// +typedef struct _EFI_REDFISH_VIRTUALMEDIA_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VIRTUALMEDIA_V1_0_2_CS *VirtualMedia; +} EFI_REDFISH_VIRTUALMEDIA_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_3/EfiVirtualMediaV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_3/EfiVirtualMediaV1_0_3.h new file mode 100644 index 00000000000..06f1f6241e8 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_3/EfiVirtualMediaV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VirtualMedia v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_0_3_H__ +#define EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/VirtualMedia/v1_0_3/Redfish_VirtualMedia_v1_0_3_CS.h" +// +// EFI structure of Redfish VirtualMedia v1_0_3 +// +typedef struct _EFI_REDFISH_VIRTUALMEDIA_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VIRTUALMEDIA_V1_0_3_CS *VirtualMedia; +} EFI_REDFISH_VIRTUALMEDIA_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_4/EfiVirtualMediaV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_4/EfiVirtualMediaV1_0_4.h new file mode 100644 index 00000000000..25818636525 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_4/EfiVirtualMediaV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VirtualMedia v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_0_4_H__ +#define EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/VirtualMedia/v1_0_4/Redfish_VirtualMedia_v1_0_4_CS.h" +// +// EFI structure of Redfish VirtualMedia v1_0_4 +// +typedef struct _EFI_REDFISH_VIRTUALMEDIA_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VIRTUALMEDIA_V1_0_4_CS *VirtualMedia; +} EFI_REDFISH_VIRTUALMEDIA_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_5/EfiVirtualMediaV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_5/EfiVirtualMediaV1_0_5.h new file mode 100644 index 00000000000..e9f17e60c8d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_5/EfiVirtualMediaV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VirtualMedia v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_0_5_H__ +#define EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/VirtualMedia/v1_0_5/Redfish_VirtualMedia_v1_0_5_CS.h" +// +// EFI structure of Redfish VirtualMedia v1_0_5 +// +typedef struct _EFI_REDFISH_VIRTUALMEDIA_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VIRTUALMEDIA_V1_0_5_CS *VirtualMedia; +} EFI_REDFISH_VIRTUALMEDIA_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_6/EfiVirtualMediaV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_6/EfiVirtualMediaV1_0_6.h new file mode 100644 index 00000000000..57dff288a8f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_6/EfiVirtualMediaV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VirtualMedia v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_0_6_H__ +#define EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/VirtualMedia/v1_0_6/Redfish_VirtualMedia_v1_0_6_CS.h" +// +// EFI structure of Redfish VirtualMedia v1_0_6 +// +typedef struct _EFI_REDFISH_VIRTUALMEDIA_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VIRTUALMEDIA_V1_0_6_CS *VirtualMedia; +} EFI_REDFISH_VIRTUALMEDIA_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_7/EfiVirtualMediaV1_0_7.h b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_7/EfiVirtualMediaV1_0_7.h new file mode 100644 index 00000000000..50d17ea5ce7 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_0_7/EfiVirtualMediaV1_0_7.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VirtualMedia v1_0_7 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_0_7_H__ +#define EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_0_7_H__ + +#include +#include +#include "ConverterLib/edk2library/VirtualMedia/v1_0_7/Redfish_VirtualMedia_v1_0_7_CS.h" +// +// EFI structure of Redfish VirtualMedia v1_0_7 +// +typedef struct _EFI_REDFISH_VIRTUALMEDIA_V1_0_7 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VIRTUALMEDIA_V1_0_7_CS *VirtualMedia; +} EFI_REDFISH_VIRTUALMEDIA_V1_0_7; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_1_0/EfiVirtualMediaV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_1_0/EfiVirtualMediaV1_1_0.h new file mode 100644 index 00000000000..8717107390b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_1_0/EfiVirtualMediaV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VirtualMedia v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_1_0_H__ +#define EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/VirtualMedia/v1_1_0/Redfish_VirtualMedia_v1_1_0_CS.h" +// +// EFI structure of Redfish VirtualMedia v1_1_0 +// +typedef struct _EFI_REDFISH_VIRTUALMEDIA_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VIRTUALMEDIA_V1_1_0_CS *VirtualMedia; +} EFI_REDFISH_VIRTUALMEDIA_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_1_1/EfiVirtualMediaV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_1_1/EfiVirtualMediaV1_1_1.h new file mode 100644 index 00000000000..a1e5e54f62f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_1_1/EfiVirtualMediaV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VirtualMedia v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_1_1_H__ +#define EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/VirtualMedia/v1_1_1/Redfish_VirtualMedia_v1_1_1_CS.h" +// +// EFI structure of Redfish VirtualMedia v1_1_1 +// +typedef struct _EFI_REDFISH_VIRTUALMEDIA_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VIRTUALMEDIA_V1_1_1_CS *VirtualMedia; +} EFI_REDFISH_VIRTUALMEDIA_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_1_2/EfiVirtualMediaV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_1_2/EfiVirtualMediaV1_1_2.h new file mode 100644 index 00000000000..1e5407dffc5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_1_2/EfiVirtualMediaV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VirtualMedia v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_1_2_H__ +#define EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/VirtualMedia/v1_1_2/Redfish_VirtualMedia_v1_1_2_CS.h" +// +// EFI structure of Redfish VirtualMedia v1_1_2 +// +typedef struct _EFI_REDFISH_VIRTUALMEDIA_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VIRTUALMEDIA_V1_1_2_CS *VirtualMedia; +} EFI_REDFISH_VIRTUALMEDIA_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_1_3/EfiVirtualMediaV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_1_3/EfiVirtualMediaV1_1_3.h new file mode 100644 index 00000000000..006f0fee31f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_1_3/EfiVirtualMediaV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VirtualMedia v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_1_3_H__ +#define EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/VirtualMedia/v1_1_3/Redfish_VirtualMedia_v1_1_3_CS.h" +// +// EFI structure of Redfish VirtualMedia v1_1_3 +// +typedef struct _EFI_REDFISH_VIRTUALMEDIA_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VIRTUALMEDIA_V1_1_3_CS *VirtualMedia; +} EFI_REDFISH_VIRTUALMEDIA_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_1_4/EfiVirtualMediaV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_1_4/EfiVirtualMediaV1_1_4.h new file mode 100644 index 00000000000..2dd5d390194 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_1_4/EfiVirtualMediaV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VirtualMedia v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_1_4_H__ +#define EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/VirtualMedia/v1_1_4/Redfish_VirtualMedia_v1_1_4_CS.h" +// +// EFI structure of Redfish VirtualMedia v1_1_4 +// +typedef struct _EFI_REDFISH_VIRTUALMEDIA_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VIRTUALMEDIA_V1_1_4_CS *VirtualMedia; +} EFI_REDFISH_VIRTUALMEDIA_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_1_5/EfiVirtualMediaV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_1_5/EfiVirtualMediaV1_1_5.h new file mode 100644 index 00000000000..58c2b92b9e2 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_1_5/EfiVirtualMediaV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VirtualMedia v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_1_5_H__ +#define EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/VirtualMedia/v1_1_5/Redfish_VirtualMedia_v1_1_5_CS.h" +// +// EFI structure of Redfish VirtualMedia v1_1_5 +// +typedef struct _EFI_REDFISH_VIRTUALMEDIA_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VIRTUALMEDIA_V1_1_5_CS *VirtualMedia; +} EFI_REDFISH_VIRTUALMEDIA_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_2_0/EfiVirtualMediaV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_2_0/EfiVirtualMediaV1_2_0.h new file mode 100644 index 00000000000..f141c456ef3 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_2_0/EfiVirtualMediaV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VirtualMedia v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_2_0_H__ +#define EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/VirtualMedia/v1_2_0/Redfish_VirtualMedia_v1_2_0_CS.h" +// +// EFI structure of Redfish VirtualMedia v1_2_0 +// +typedef struct _EFI_REDFISH_VIRTUALMEDIA_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VIRTUALMEDIA_V1_2_0_CS *VirtualMedia; +} EFI_REDFISH_VIRTUALMEDIA_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_2_1/EfiVirtualMediaV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_2_1/EfiVirtualMediaV1_2_1.h new file mode 100644 index 00000000000..bfbb22e3dfb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_2_1/EfiVirtualMediaV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VirtualMedia v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_2_1_H__ +#define EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/VirtualMedia/v1_2_1/Redfish_VirtualMedia_v1_2_1_CS.h" +// +// EFI structure of Redfish VirtualMedia v1_2_1 +// +typedef struct _EFI_REDFISH_VIRTUALMEDIA_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VIRTUALMEDIA_V1_2_1_CS *VirtualMedia; +} EFI_REDFISH_VIRTUALMEDIA_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_2_2/EfiVirtualMediaV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_2_2/EfiVirtualMediaV1_2_2.h new file mode 100644 index 00000000000..cfb4cd13133 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_2_2/EfiVirtualMediaV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VirtualMedia v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_2_2_H__ +#define EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/VirtualMedia/v1_2_2/Redfish_VirtualMedia_v1_2_2_CS.h" +// +// EFI structure of Redfish VirtualMedia v1_2_2 +// +typedef struct _EFI_REDFISH_VIRTUALMEDIA_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VIRTUALMEDIA_V1_2_2_CS *VirtualMedia; +} EFI_REDFISH_VIRTUALMEDIA_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_2_3/EfiVirtualMediaV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_2_3/EfiVirtualMediaV1_2_3.h new file mode 100644 index 00000000000..143f8ba6d0e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_2_3/EfiVirtualMediaV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VirtualMedia v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_2_3_H__ +#define EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/VirtualMedia/v1_2_3/Redfish_VirtualMedia_v1_2_3_CS.h" +// +// EFI structure of Redfish VirtualMedia v1_2_3 +// +typedef struct _EFI_REDFISH_VIRTUALMEDIA_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VIRTUALMEDIA_V1_2_3_CS *VirtualMedia; +} EFI_REDFISH_VIRTUALMEDIA_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_2_4/EfiVirtualMediaV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_2_4/EfiVirtualMediaV1_2_4.h new file mode 100644 index 00000000000..5046728700b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_2_4/EfiVirtualMediaV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VirtualMedia v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_2_4_H__ +#define EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/VirtualMedia/v1_2_4/Redfish_VirtualMedia_v1_2_4_CS.h" +// +// EFI structure of Redfish VirtualMedia v1_2_4 +// +typedef struct _EFI_REDFISH_VIRTUALMEDIA_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VIRTUALMEDIA_V1_2_4_CS *VirtualMedia; +} EFI_REDFISH_VIRTUALMEDIA_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_3_0/EfiVirtualMediaV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_3_0/EfiVirtualMediaV1_3_0.h new file mode 100644 index 00000000000..e71fc5b802e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_3_0/EfiVirtualMediaV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VirtualMedia v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_3_0_H__ +#define EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/VirtualMedia/v1_3_0/Redfish_VirtualMedia_v1_3_0_CS.h" +// +// EFI structure of Redfish VirtualMedia v1_3_0 +// +typedef struct _EFI_REDFISH_VIRTUALMEDIA_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VIRTUALMEDIA_V1_3_0_CS *VirtualMedia; +} EFI_REDFISH_VIRTUALMEDIA_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_3_1/EfiVirtualMediaV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_3_1/EfiVirtualMediaV1_3_1.h new file mode 100644 index 00000000000..9920cc65caa --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_3_1/EfiVirtualMediaV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VirtualMedia v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_3_1_H__ +#define EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/VirtualMedia/v1_3_1/Redfish_VirtualMedia_v1_3_1_CS.h" +// +// EFI structure of Redfish VirtualMedia v1_3_1 +// +typedef struct _EFI_REDFISH_VIRTUALMEDIA_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VIRTUALMEDIA_V1_3_1_CS *VirtualMedia; +} EFI_REDFISH_VIRTUALMEDIA_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_3_2/EfiVirtualMediaV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_3_2/EfiVirtualMediaV1_3_2.h new file mode 100644 index 00000000000..111e923ede5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMedia/v1_3_2/EfiVirtualMediaV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VirtualMedia v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_3_2_H__ +#define EFI_REDFISH_INTERP_VIRTUALMEDIA_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/VirtualMedia/v1_3_2/Redfish_VirtualMedia_v1_3_2_CS.h" +// +// EFI structure of Redfish VirtualMedia v1_3_2 +// +typedef struct _EFI_REDFISH_VIRTUALMEDIA_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VIRTUALMEDIA_V1_3_2_CS *VirtualMedia; +} EFI_REDFISH_VIRTUALMEDIA_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMediaCollection/EfiVirtualMediaCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMediaCollection/EfiVirtualMediaCollection.h new file mode 100644 index 00000000000..a7a3c2740c0 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VirtualMediaCollection/EfiVirtualMediaCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VirtualMediaCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VIRTUALMEDIACOLLECTION_H__ +#define EFI_REDFISH_INTERP_VIRTUALMEDIACOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/VirtualMediaCollection/Redfish_VirtualMediaCollection_CS.h" +// +// EFI structure of Redfish VirtualMediaCollection +// +typedef struct _EFI_REDFISH_VIRTUALMEDIACOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VIRTUALMEDIACOLLECTION_CS *VirtualMediaCollection; +} EFI_REDFISH_VIRTUALMEDIACOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_0_0/EfiVolumeV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_0_0/EfiVolumeV1_0_0.h new file mode 100644 index 00000000000..b62ca0ab8df --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_0_0/EfiVolumeV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_0_0_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_0_0/Redfish_Volume_v1_0_0_CS.h" +// +// EFI structure of Redfish Volume v1_0_0 +// +typedef struct _EFI_REDFISH_VOLUME_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_0_0_CS *Volume; +} EFI_REDFISH_VOLUME_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_0_1/EfiVolumeV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_0_1/EfiVolumeV1_0_1.h new file mode 100644 index 00000000000..4d00f4d0ccf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_0_1/EfiVolumeV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_0_1_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_0_1/Redfish_Volume_v1_0_1_CS.h" +// +// EFI structure of Redfish Volume v1_0_1 +// +typedef struct _EFI_REDFISH_VOLUME_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_0_1_CS *Volume; +} EFI_REDFISH_VOLUME_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_0_2/EfiVolumeV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_0_2/EfiVolumeV1_0_2.h new file mode 100644 index 00000000000..523893b0f51 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_0_2/EfiVolumeV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_0_2_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_0_2/Redfish_Volume_v1_0_2_CS.h" +// +// EFI structure of Redfish Volume v1_0_2 +// +typedef struct _EFI_REDFISH_VOLUME_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_0_2_CS *Volume; +} EFI_REDFISH_VOLUME_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_0_3/EfiVolumeV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_0_3/EfiVolumeV1_0_3.h new file mode 100644 index 00000000000..dcf31b6f302 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_0_3/EfiVolumeV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_0_3_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_0_3/Redfish_Volume_v1_0_3_CS.h" +// +// EFI structure of Redfish Volume v1_0_3 +// +typedef struct _EFI_REDFISH_VOLUME_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_0_3_CS *Volume; +} EFI_REDFISH_VOLUME_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_0_4/EfiVolumeV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_0_4/EfiVolumeV1_0_4.h new file mode 100644 index 00000000000..6b6e6305028 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_0_4/EfiVolumeV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_0_4_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_0_4/Redfish_Volume_v1_0_4_CS.h" +// +// EFI structure of Redfish Volume v1_0_4 +// +typedef struct _EFI_REDFISH_VOLUME_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_0_4_CS *Volume; +} EFI_REDFISH_VOLUME_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_1_0/EfiVolumeV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_1_0/EfiVolumeV1_1_0.h new file mode 100644 index 00000000000..2e1aef60685 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_1_0/EfiVolumeV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_1_0_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_1_0/Redfish_Volume_v1_1_0_CS.h" +// +// EFI structure of Redfish Volume v1_1_0 +// +typedef struct _EFI_REDFISH_VOLUME_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_1_0_CS *Volume; +} EFI_REDFISH_VOLUME_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_1_1/EfiVolumeV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_1_1/EfiVolumeV1_1_1.h new file mode 100644 index 00000000000..9fbda48b9b5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_1_1/EfiVolumeV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_1_1_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_1_1/Redfish_Volume_v1_1_1_CS.h" +// +// EFI structure of Redfish Volume v1_1_1 +// +typedef struct _EFI_REDFISH_VOLUME_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_1_1_CS *Volume; +} EFI_REDFISH_VOLUME_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_1_2/EfiVolumeV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_1_2/EfiVolumeV1_1_2.h new file mode 100644 index 00000000000..7afebe8d776 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_1_2/EfiVolumeV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_1_2_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_1_2/Redfish_Volume_v1_1_2_CS.h" +// +// EFI structure of Redfish Volume v1_1_2 +// +typedef struct _EFI_REDFISH_VOLUME_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_1_2_CS *Volume; +} EFI_REDFISH_VOLUME_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_1_3/EfiVolumeV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_1_3/EfiVolumeV1_1_3.h new file mode 100644 index 00000000000..06e36789b8e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_1_3/EfiVolumeV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_1_3_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_1_3/Redfish_Volume_v1_1_3_CS.h" +// +// EFI structure of Redfish Volume v1_1_3 +// +typedef struct _EFI_REDFISH_VOLUME_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_1_3_CS *Volume; +} EFI_REDFISH_VOLUME_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_1_4/EfiVolumeV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_1_4/EfiVolumeV1_1_4.h new file mode 100644 index 00000000000..9aaf1b3af00 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_1_4/EfiVolumeV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_1_4_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_1_4/Redfish_Volume_v1_1_4_CS.h" +// +// EFI structure of Redfish Volume v1_1_4 +// +typedef struct _EFI_REDFISH_VOLUME_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_1_4_CS *Volume; +} EFI_REDFISH_VOLUME_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_1_5/EfiVolumeV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_1_5/EfiVolumeV1_1_5.h new file mode 100644 index 00000000000..14f456a7824 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_1_5/EfiVolumeV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_1_5_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_1_5/Redfish_Volume_v1_1_5_CS.h" +// +// EFI structure of Redfish Volume v1_1_5 +// +typedef struct _EFI_REDFISH_VOLUME_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_1_5_CS *Volume; +} EFI_REDFISH_VOLUME_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_2_0/EfiVolumeV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_2_0/EfiVolumeV1_2_0.h new file mode 100644 index 00000000000..703fe030e63 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_2_0/EfiVolumeV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_2_0_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_2_0/Redfish_Volume_v1_2_0_CS.h" +// +// EFI structure of Redfish Volume v1_2_0 +// +typedef struct _EFI_REDFISH_VOLUME_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_2_0_CS *Volume; +} EFI_REDFISH_VOLUME_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_2_1/EfiVolumeV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_2_1/EfiVolumeV1_2_1.h new file mode 100644 index 00000000000..aa0e1716026 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_2_1/EfiVolumeV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_2_1_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_2_1/Redfish_Volume_v1_2_1_CS.h" +// +// EFI structure of Redfish Volume v1_2_1 +// +typedef struct _EFI_REDFISH_VOLUME_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_2_1_CS *Volume; +} EFI_REDFISH_VOLUME_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_2_2/EfiVolumeV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_2_2/EfiVolumeV1_2_2.h new file mode 100644 index 00000000000..eba56c3c5c9 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_2_2/EfiVolumeV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_2_2_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_2_2/Redfish_Volume_v1_2_2_CS.h" +// +// EFI structure of Redfish Volume v1_2_2 +// +typedef struct _EFI_REDFISH_VOLUME_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_2_2_CS *Volume; +} EFI_REDFISH_VOLUME_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_2_3/EfiVolumeV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_2_3/EfiVolumeV1_2_3.h new file mode 100644 index 00000000000..e5cf09e25ff --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_2_3/EfiVolumeV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_2_3_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_2_3/Redfish_Volume_v1_2_3_CS.h" +// +// EFI structure of Redfish Volume v1_2_3 +// +typedef struct _EFI_REDFISH_VOLUME_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_2_3_CS *Volume; +} EFI_REDFISH_VOLUME_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_2_4/EfiVolumeV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_2_4/EfiVolumeV1_2_4.h new file mode 100644 index 00000000000..279e3aefd46 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_2_4/EfiVolumeV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_2_4_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_2_4/Redfish_Volume_v1_2_4_CS.h" +// +// EFI structure of Redfish Volume v1_2_4 +// +typedef struct _EFI_REDFISH_VOLUME_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_2_4_CS *Volume; +} EFI_REDFISH_VOLUME_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_2_5/EfiVolumeV1_2_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_2_5/EfiVolumeV1_2_5.h new file mode 100644 index 00000000000..24d141e9fdb --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_2_5/EfiVolumeV1_2_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_2_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_2_5_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_2_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_2_5/Redfish_Volume_v1_2_5_CS.h" +// +// EFI structure of Redfish Volume v1_2_5 +// +typedef struct _EFI_REDFISH_VOLUME_V1_2_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_2_5_CS *Volume; +} EFI_REDFISH_VOLUME_V1_2_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_3_0/EfiVolumeV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_3_0/EfiVolumeV1_3_0.h new file mode 100644 index 00000000000..e9f7a71a38f --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_3_0/EfiVolumeV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_3_0_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_3_0/Redfish_Volume_v1_3_0_CS.h" +// +// EFI structure of Redfish Volume v1_3_0 +// +typedef struct _EFI_REDFISH_VOLUME_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_3_0_CS *Volume; +} EFI_REDFISH_VOLUME_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_3_1/EfiVolumeV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_3_1/EfiVolumeV1_3_1.h new file mode 100644 index 00000000000..e397cbfc64a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_3_1/EfiVolumeV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_3_1_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_3_1/Redfish_Volume_v1_3_1_CS.h" +// +// EFI structure of Redfish Volume v1_3_1 +// +typedef struct _EFI_REDFISH_VOLUME_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_3_1_CS *Volume; +} EFI_REDFISH_VOLUME_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_3_2/EfiVolumeV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_3_2/EfiVolumeV1_3_2.h new file mode 100644 index 00000000000..161b441a8cf --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_3_2/EfiVolumeV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_3_2_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_3_2/Redfish_Volume_v1_3_2_CS.h" +// +// EFI structure of Redfish Volume v1_3_2 +// +typedef struct _EFI_REDFISH_VOLUME_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_3_2_CS *Volume; +} EFI_REDFISH_VOLUME_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_3_3/EfiVolumeV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_3_3/EfiVolumeV1_3_3.h new file mode 100644 index 00000000000..da619fb5548 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_3_3/EfiVolumeV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_3_3_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_3_3/Redfish_Volume_v1_3_3_CS.h" +// +// EFI structure of Redfish Volume v1_3_3 +// +typedef struct _EFI_REDFISH_VOLUME_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_3_3_CS *Volume; +} EFI_REDFISH_VOLUME_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_3_4/EfiVolumeV1_3_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_3_4/EfiVolumeV1_3_4.h new file mode 100644 index 00000000000..6af4d7add41 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_3_4/EfiVolumeV1_3_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_3_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_3_4_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_3_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_3_4/Redfish_Volume_v1_3_4_CS.h" +// +// EFI structure of Redfish Volume v1_3_4 +// +typedef struct _EFI_REDFISH_VOLUME_V1_3_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_3_4_CS *Volume; +} EFI_REDFISH_VOLUME_V1_3_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_4_0/EfiVolumeV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_4_0/EfiVolumeV1_4_0.h new file mode 100644 index 00000000000..62cea9af040 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_4_0/EfiVolumeV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_4_0_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_4_0/Redfish_Volume_v1_4_0_CS.h" +// +// EFI structure of Redfish Volume v1_4_0 +// +typedef struct _EFI_REDFISH_VOLUME_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_4_0_CS *Volume; +} EFI_REDFISH_VOLUME_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_4_1/EfiVolumeV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_4_1/EfiVolumeV1_4_1.h new file mode 100644 index 00000000000..121b5729065 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_4_1/EfiVolumeV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_4_1_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_4_1/Redfish_Volume_v1_4_1_CS.h" +// +// EFI structure of Redfish Volume v1_4_1 +// +typedef struct _EFI_REDFISH_VOLUME_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_4_1_CS *Volume; +} EFI_REDFISH_VOLUME_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_4_2/EfiVolumeV1_4_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_4_2/EfiVolumeV1_4_2.h new file mode 100644 index 00000000000..4c7fb6800bd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_4_2/EfiVolumeV1_4_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_4_2_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_4_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_4_2/Redfish_Volume_v1_4_2_CS.h" +// +// EFI structure of Redfish Volume v1_4_2 +// +typedef struct _EFI_REDFISH_VOLUME_V1_4_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_4_2_CS *Volume; +} EFI_REDFISH_VOLUME_V1_4_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_4_3/EfiVolumeV1_4_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_4_3/EfiVolumeV1_4_3.h new file mode 100644 index 00000000000..9a8ed63f1a1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_4_3/EfiVolumeV1_4_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_4_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_4_3_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_4_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_4_3/Redfish_Volume_v1_4_3_CS.h" +// +// EFI structure of Redfish Volume v1_4_3 +// +typedef struct _EFI_REDFISH_VOLUME_V1_4_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_4_3_CS *Volume; +} EFI_REDFISH_VOLUME_V1_4_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_5_0/EfiVolumeV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_5_0/EfiVolumeV1_5_0.h new file mode 100644 index 00000000000..b9602f053dd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_5_0/EfiVolumeV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_5_0_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_5_0/Redfish_Volume_v1_5_0_CS.h" +// +// EFI structure of Redfish Volume v1_5_0 +// +typedef struct _EFI_REDFISH_VOLUME_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_5_0_CS *Volume; +} EFI_REDFISH_VOLUME_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_5_1/EfiVolumeV1_5_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_5_1/EfiVolumeV1_5_1.h new file mode 100644 index 00000000000..83f167b4915 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_5_1/EfiVolumeV1_5_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_5_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_5_1_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_5_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_5_1/Redfish_Volume_v1_5_1_CS.h" +// +// EFI structure of Redfish Volume v1_5_1 +// +typedef struct _EFI_REDFISH_VOLUME_V1_5_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_5_1_CS *Volume; +} EFI_REDFISH_VOLUME_V1_5_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_6_0/EfiVolumeV1_6_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_6_0/EfiVolumeV1_6_0.h new file mode 100644 index 00000000000..27c5d69e77d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_6_0/EfiVolumeV1_6_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_6_0_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_6_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_6_0/Redfish_Volume_v1_6_0_CS.h" +// +// EFI structure of Redfish Volume v1_6_0 +// +typedef struct _EFI_REDFISH_VOLUME_V1_6_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_6_0_CS *Volume; +} EFI_REDFISH_VOLUME_V1_6_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_6_1/EfiVolumeV1_6_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_6_1/EfiVolumeV1_6_1.h new file mode 100644 index 00000000000..ccf32682dba --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Volume/v1_6_1/EfiVolumeV1_6_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Volume v1_6_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUME_V1_6_1_H__ +#define EFI_REDFISH_INTERP_VOLUME_V1_6_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Volume/v1_6_1/Redfish_Volume_v1_6_1_CS.h" +// +// EFI structure of Redfish Volume v1_6_1 +// +typedef struct _EFI_REDFISH_VOLUME_V1_6_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUME_V1_6_1_CS *Volume; +} EFI_REDFISH_VOLUME_V1_6_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/VolumeCollection/EfiVolumeCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/VolumeCollection/EfiVolumeCollection.h new file mode 100644 index 00000000000..00631a21d39 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/VolumeCollection/EfiVolumeCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for VolumeCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_VOLUMECOLLECTION_H__ +#define EFI_REDFISH_INTERP_VOLUMECOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/VolumeCollection/Redfish_VolumeCollection_CS.h" +// +// EFI structure of Redfish VolumeCollection +// +typedef struct _EFI_REDFISH_VOLUMECOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_VOLUMECOLLECTION_CS *VolumeCollection; +} EFI_REDFISH_VOLUMECOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_0/EfiZoneV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_0/EfiZoneV1_0_0.h new file mode 100644 index 00000000000..29dcf68427b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_0/EfiZoneV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_0_0_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_0_0/Redfish_Zone_v1_0_0_CS.h" +// +// EFI structure of Redfish Zone v1_0_0 +// +typedef struct _EFI_REDFISH_ZONE_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_0_0_CS *Zone; +} EFI_REDFISH_ZONE_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_1/EfiZoneV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_1/EfiZoneV1_0_1.h new file mode 100644 index 00000000000..2b0b33fb734 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_1/EfiZoneV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_0_1_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_0_1/Redfish_Zone_v1_0_1_CS.h" +// +// EFI structure of Redfish Zone v1_0_1 +// +typedef struct _EFI_REDFISH_ZONE_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_0_1_CS *Zone; +} EFI_REDFISH_ZONE_V1_0_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_2/EfiZoneV1_0_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_2/EfiZoneV1_0_2.h new file mode 100644 index 00000000000..7f95a36c8ad --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_2/EfiZoneV1_0_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_0_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_0_2_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_0_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_0_2/Redfish_Zone_v1_0_2_CS.h" +// +// EFI structure of Redfish Zone v1_0_2 +// +typedef struct _EFI_REDFISH_ZONE_V1_0_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_0_2_CS *Zone; +} EFI_REDFISH_ZONE_V1_0_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_3/EfiZoneV1_0_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_3/EfiZoneV1_0_3.h new file mode 100644 index 00000000000..b4e6fa667ce --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_3/EfiZoneV1_0_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_0_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_0_3_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_0_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_0_3/Redfish_Zone_v1_0_3_CS.h" +// +// EFI structure of Redfish Zone v1_0_3 +// +typedef struct _EFI_REDFISH_ZONE_V1_0_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_0_3_CS *Zone; +} EFI_REDFISH_ZONE_V1_0_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_4/EfiZoneV1_0_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_4/EfiZoneV1_0_4.h new file mode 100644 index 00000000000..05fc3e9d152 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_4/EfiZoneV1_0_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_0_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_0_4_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_0_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_0_4/Redfish_Zone_v1_0_4_CS.h" +// +// EFI structure of Redfish Zone v1_0_4 +// +typedef struct _EFI_REDFISH_ZONE_V1_0_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_0_4_CS *Zone; +} EFI_REDFISH_ZONE_V1_0_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_5/EfiZoneV1_0_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_5/EfiZoneV1_0_5.h new file mode 100644 index 00000000000..b2ba43a6c1e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_5/EfiZoneV1_0_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_0_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_0_5_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_0_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_0_5/Redfish_Zone_v1_0_5_CS.h" +// +// EFI structure of Redfish Zone v1_0_5 +// +typedef struct _EFI_REDFISH_ZONE_V1_0_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_0_5_CS *Zone; +} EFI_REDFISH_ZONE_V1_0_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_6/EfiZoneV1_0_6.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_6/EfiZoneV1_0_6.h new file mode 100644 index 00000000000..c66cec62596 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_0_6/EfiZoneV1_0_6.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_0_6 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_0_6_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_0_6_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_0_6/Redfish_Zone_v1_0_6_CS.h" +// +// EFI structure of Redfish Zone v1_0_6 +// +typedef struct _EFI_REDFISH_ZONE_V1_0_6 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_0_6_CS *Zone; +} EFI_REDFISH_ZONE_V1_0_6; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_1_0/EfiZoneV1_1_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_1_0/EfiZoneV1_1_0.h new file mode 100644 index 00000000000..d577f8f1273 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_1_0/EfiZoneV1_1_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_1_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_1_0_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_1_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_1_0/Redfish_Zone_v1_1_0_CS.h" +// +// EFI structure of Redfish Zone v1_1_0 +// +typedef struct _EFI_REDFISH_ZONE_V1_1_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_1_0_CS *Zone; +} EFI_REDFISH_ZONE_V1_1_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_1_1/EfiZoneV1_1_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_1_1/EfiZoneV1_1_1.h new file mode 100644 index 00000000000..367663024da --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_1_1/EfiZoneV1_1_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_1_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_1_1_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_1_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_1_1/Redfish_Zone_v1_1_1_CS.h" +// +// EFI structure of Redfish Zone v1_1_1 +// +typedef struct _EFI_REDFISH_ZONE_V1_1_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_1_1_CS *Zone; +} EFI_REDFISH_ZONE_V1_1_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_1_2/EfiZoneV1_1_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_1_2/EfiZoneV1_1_2.h new file mode 100644 index 00000000000..44345a4c7e1 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_1_2/EfiZoneV1_1_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_1_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_1_2_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_1_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_1_2/Redfish_Zone_v1_1_2_CS.h" +// +// EFI structure of Redfish Zone v1_1_2 +// +typedef struct _EFI_REDFISH_ZONE_V1_1_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_1_2_CS *Zone; +} EFI_REDFISH_ZONE_V1_1_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_1_3/EfiZoneV1_1_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_1_3/EfiZoneV1_1_3.h new file mode 100644 index 00000000000..e0ce4626a4a --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_1_3/EfiZoneV1_1_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_1_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_1_3_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_1_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_1_3/Redfish_Zone_v1_1_3_CS.h" +// +// EFI structure of Redfish Zone v1_1_3 +// +typedef struct _EFI_REDFISH_ZONE_V1_1_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_1_3_CS *Zone; +} EFI_REDFISH_ZONE_V1_1_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_1_4/EfiZoneV1_1_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_1_4/EfiZoneV1_1_4.h new file mode 100644 index 00000000000..7f07cc0df19 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_1_4/EfiZoneV1_1_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_1_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_1_4_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_1_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_1_4/Redfish_Zone_v1_1_4_CS.h" +// +// EFI structure of Redfish Zone v1_1_4 +// +typedef struct _EFI_REDFISH_ZONE_V1_1_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_1_4_CS *Zone; +} EFI_REDFISH_ZONE_V1_1_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_1_5/EfiZoneV1_1_5.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_1_5/EfiZoneV1_1_5.h new file mode 100644 index 00000000000..05cbe58cc8e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_1_5/EfiZoneV1_1_5.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_1_5 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_1_5_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_1_5_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_1_5/Redfish_Zone_v1_1_5_CS.h" +// +// EFI structure of Redfish Zone v1_1_5 +// +typedef struct _EFI_REDFISH_ZONE_V1_1_5 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_1_5_CS *Zone; +} EFI_REDFISH_ZONE_V1_1_5; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_2_0/EfiZoneV1_2_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_2_0/EfiZoneV1_2_0.h new file mode 100644 index 00000000000..3e7c5a93530 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_2_0/EfiZoneV1_2_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_2_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_2_0_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_2_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_2_0/Redfish_Zone_v1_2_0_CS.h" +// +// EFI structure of Redfish Zone v1_2_0 +// +typedef struct _EFI_REDFISH_ZONE_V1_2_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_2_0_CS *Zone; +} EFI_REDFISH_ZONE_V1_2_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_2_1/EfiZoneV1_2_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_2_1/EfiZoneV1_2_1.h new file mode 100644 index 00000000000..3142653a814 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_2_1/EfiZoneV1_2_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_2_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_2_1_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_2_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_2_1/Redfish_Zone_v1_2_1_CS.h" +// +// EFI structure of Redfish Zone v1_2_1 +// +typedef struct _EFI_REDFISH_ZONE_V1_2_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_2_1_CS *Zone; +} EFI_REDFISH_ZONE_V1_2_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_2_2/EfiZoneV1_2_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_2_2/EfiZoneV1_2_2.h new file mode 100644 index 00000000000..b212d7c6d13 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_2_2/EfiZoneV1_2_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_2_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_2_2_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_2_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_2_2/Redfish_Zone_v1_2_2_CS.h" +// +// EFI structure of Redfish Zone v1_2_2 +// +typedef struct _EFI_REDFISH_ZONE_V1_2_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_2_2_CS *Zone; +} EFI_REDFISH_ZONE_V1_2_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_2_3/EfiZoneV1_2_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_2_3/EfiZoneV1_2_3.h new file mode 100644 index 00000000000..06b658adacd --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_2_3/EfiZoneV1_2_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_2_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_2_3_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_2_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_2_3/Redfish_Zone_v1_2_3_CS.h" +// +// EFI structure of Redfish Zone v1_2_3 +// +typedef struct _EFI_REDFISH_ZONE_V1_2_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_2_3_CS *Zone; +} EFI_REDFISH_ZONE_V1_2_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_2_4/EfiZoneV1_2_4.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_2_4/EfiZoneV1_2_4.h new file mode 100644 index 00000000000..66cff15645e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_2_4/EfiZoneV1_2_4.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_2_4 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_2_4_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_2_4_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_2_4/Redfish_Zone_v1_2_4_CS.h" +// +// EFI structure of Redfish Zone v1_2_4 +// +typedef struct _EFI_REDFISH_ZONE_V1_2_4 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_2_4_CS *Zone; +} EFI_REDFISH_ZONE_V1_2_4; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_3_0/EfiZoneV1_3_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_3_0/EfiZoneV1_3_0.h new file mode 100644 index 00000000000..c850e2ad379 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_3_0/EfiZoneV1_3_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_3_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_3_0_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_3_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_3_0/Redfish_Zone_v1_3_0_CS.h" +// +// EFI structure of Redfish Zone v1_3_0 +// +typedef struct _EFI_REDFISH_ZONE_V1_3_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_3_0_CS *Zone; +} EFI_REDFISH_ZONE_V1_3_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_3_1/EfiZoneV1_3_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_3_1/EfiZoneV1_3_1.h new file mode 100644 index 00000000000..85aed2c336e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_3_1/EfiZoneV1_3_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_3_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_3_1_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_3_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_3_1/Redfish_Zone_v1_3_1_CS.h" +// +// EFI structure of Redfish Zone v1_3_1 +// +typedef struct _EFI_REDFISH_ZONE_V1_3_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_3_1_CS *Zone; +} EFI_REDFISH_ZONE_V1_3_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_3_2/EfiZoneV1_3_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_3_2/EfiZoneV1_3_2.h new file mode 100644 index 00000000000..677aba4f9f4 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_3_2/EfiZoneV1_3_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_3_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_3_2_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_3_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_3_2/Redfish_Zone_v1_3_2_CS.h" +// +// EFI structure of Redfish Zone v1_3_2 +// +typedef struct _EFI_REDFISH_ZONE_V1_3_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_3_2_CS *Zone; +} EFI_REDFISH_ZONE_V1_3_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_3_3/EfiZoneV1_3_3.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_3_3/EfiZoneV1_3_3.h new file mode 100644 index 00000000000..0f599704511 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_3_3/EfiZoneV1_3_3.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_3_3 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_3_3_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_3_3_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_3_3/Redfish_Zone_v1_3_3_CS.h" +// +// EFI structure of Redfish Zone v1_3_3 +// +typedef struct _EFI_REDFISH_ZONE_V1_3_3 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_3_3_CS *Zone; +} EFI_REDFISH_ZONE_V1_3_3; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_4_0/EfiZoneV1_4_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_4_0/EfiZoneV1_4_0.h new file mode 100644 index 00000000000..1ecfb8a2c4c --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_4_0/EfiZoneV1_4_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_4_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_4_0_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_4_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_4_0/Redfish_Zone_v1_4_0_CS.h" +// +// EFI structure of Redfish Zone v1_4_0 +// +typedef struct _EFI_REDFISH_ZONE_V1_4_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_4_0_CS *Zone; +} EFI_REDFISH_ZONE_V1_4_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_4_1/EfiZoneV1_4_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_4_1/EfiZoneV1_4_1.h new file mode 100644 index 00000000000..9709374011d --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_4_1/EfiZoneV1_4_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_4_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_4_1_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_4_1_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_4_1/Redfish_Zone_v1_4_1_CS.h" +// +// EFI structure of Redfish Zone v1_4_1 +// +typedef struct _EFI_REDFISH_ZONE_V1_4_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_4_1_CS *Zone; +} EFI_REDFISH_ZONE_V1_4_1; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_4_2/EfiZoneV1_4_2.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_4_2/EfiZoneV1_4_2.h new file mode 100644 index 00000000000..470c5b56fcc --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_4_2/EfiZoneV1_4_2.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_4_2 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_4_2_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_4_2_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_4_2/Redfish_Zone_v1_4_2_CS.h" +// +// EFI structure of Redfish Zone v1_4_2 +// +typedef struct _EFI_REDFISH_ZONE_V1_4_2 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_4_2_CS *Zone; +} EFI_REDFISH_ZONE_V1_4_2; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_5_0/EfiZoneV1_5_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_5_0/EfiZoneV1_5_0.h new file mode 100644 index 00000000000..9a6e451042e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_5_0/EfiZoneV1_5_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_5_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_5_0_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_5_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_5_0/Redfish_Zone_v1_5_0_CS.h" +// +// EFI structure of Redfish Zone v1_5_0 +// +typedef struct _EFI_REDFISH_ZONE_V1_5_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_5_0_CS *Zone; +} EFI_REDFISH_ZONE_V1_5_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_6_0/EfiZoneV1_6_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_6_0/EfiZoneV1_6_0.h new file mode 100644 index 00000000000..0ec35a11424 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/Zone/v1_6_0/EfiZoneV1_6_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for Zone v1_6_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONE_V1_6_0_H__ +#define EFI_REDFISH_INTERP_ZONE_V1_6_0_H__ + +#include +#include +#include "ConverterLib/edk2library/Zone/v1_6_0/Redfish_Zone_v1_6_0_CS.h" +// +// EFI structure of Redfish Zone v1_6_0 +// +typedef struct _EFI_REDFISH_ZONE_V1_6_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONE_V1_6_0_CS *Zone; +} EFI_REDFISH_ZONE_V1_6_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/ZoneCollection/EfiZoneCollection.h b/RedfishClientPkg/Include/RedfishJsonStructure/ZoneCollection/EfiZoneCollection.h new file mode 100644 index 00000000000..b9d991feb5b --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/ZoneCollection/EfiZoneCollection.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for ZoneCollection + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_ZONECOLLECTION_H__ +#define EFI_REDFISH_INTERP_ZONECOLLECTION_H__ + +#include +#include +#include "ConverterLib/edk2library/ZoneCollection/Redfish_ZoneCollection_CS.h" +// +// EFI structure of Redfish ZoneCollection +// +typedef struct _EFI_REDFISH_ZONECOLLECTION { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_ZONECOLLECTION_CS *ZoneCollection; +} EFI_REDFISH_ZONECOLLECTION; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/redfisherror/v1_0_0/EfiredfisherrorV1_0_0.h b/RedfishClientPkg/Include/RedfishJsonStructure/redfisherror/v1_0_0/EfiredfisherrorV1_0_0.h new file mode 100644 index 00000000000..e30cc5d04d5 --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/redfisherror/v1_0_0/EfiredfisherrorV1_0_0.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for redfisherror v1_0_0 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_REDFISHERROR_V1_0_0_H__ +#define EFI_REDFISH_INTERP_REDFISHERROR_V1_0_0_H__ + +#include +#include +#include "ConverterLib/edk2library/redfisherror/v1_0_0/Redfish_redfisherror_v1_0_0_CS.h" +// +// EFI structure of Redfish redfisherror v1_0_0 +// +typedef struct _EFI_REDFISH_REDFISHERROR_V1_0_0 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_REDFISHERROR_V1_0_0_CS *redfisherror; +} EFI_REDFISH_REDFISHERROR_V1_0_0; + +#endif diff --git a/RedfishClientPkg/Include/RedfishJsonStructure/redfisherror/v1_0_1/EfiredfisherrorV1_0_1.h b/RedfishClientPkg/Include/RedfishJsonStructure/redfisherror/v1_0_1/EfiredfisherrorV1_0_1.h new file mode 100644 index 00000000000..04e079ff87e --- /dev/null +++ b/RedfishClientPkg/Include/RedfishJsonStructure/redfisherror/v1_0_1/EfiredfisherrorV1_0_1.h @@ -0,0 +1,30 @@ +/** @file + This file defines the EFI Redfish C Structure Interpreter for redfisherror v1_0_1 + + (C) Copyright 2019-2021 Hewlett Packard Enterprise Development LP
+ SPDX-License-Identifier: BSD-2-Clause-Patent + + Auto-generated file by Redfish Schema C Structure Generator. + https://github.com/DMTF/Redfish-Schema-C-Struct-Generator + + Copyright Notice: + Copyright 2019-2021 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 + +**/ + +#ifndef EFI_REDFISH_INTERP_REDFISHERROR_V1_0_1_H__ +#define EFI_REDFISH_INTERP_REDFISHERROR_V1_0_1_H__ + +#include +#include +#include "ConverterLib/edk2library/redfisherror/v1_0_1/Redfish_redfisherror_v1_0_1_CS.h" +// +// EFI structure of Redfish redfisherror v1_0_1 +// +typedef struct _EFI_REDFISH_REDFISHERROR_V1_0_1 { + EFI_REST_JSON_STRUCTURE_HEADER Header; + EFI_REDFISH_REDFISHERROR_V1_0_1_CS *redfisherror; +} EFI_REDFISH_REDFISHERROR_V1_0_1; + +#endif